On Tue, Feb 02, 2010 at 09:10:56AM -0500, Okan Demirmen wrote:
> On Sun 2010.01.17 at 16:05 +0100, Thomas Pfaff wrote:
> > This diff disallows setting blank labels and pressing Esc while editing
> > the current one will leave it unchanged. I don't see the point in allowing
> > empty labels as the windows will just show up as blank entries in the menu.
> >
> > Also remove `current' variable and just use `cc->label'.
>
> hi,
>
> i believe due to the nature of menu_filter(), you'll still run into
> losing your label using just strlen(). below the least intrusive way
> until we potentially look back at the menu code.
>
> i don't use labels at all, so can you verify this fixes all your cases?
>
> cheers,
> okan
>
> Index: calmwm.h
> ===================================================================
> RCS file: /home/open/anoncvs/cvs/xenocara/app/cwm/calmwm.h,v
> retrieving revision 1.115
> diff -u -p -r1.115 calmwm.h
> --- calmwm.h 27 Jan 2010 03:04:50 -0000 1.115
> +++ calmwm.h 30 Jan 2010 20:14:49 -0000
> @@ -320,6 +320,7 @@ struct menu {
> char print[MENU_MAXENTRY + 1];
> void *ctx;
> short dummy;
> + short abort;
> };
>
> TAILQ_HEAD(menu_q, menu);
> Index: kbfunc.c
> ===================================================================
> RCS file: /home/open/anoncvs/cvs/xenocara/app/cwm/kbfunc.c,v
> retrieving revision 1.50
> diff -u -p -r1.50 kbfunc.c
> --- kbfunc.c 15 Dec 2009 04:10:42 -0000 1.50
> +++ kbfunc.c 30 Jan 2010 20:36:18 -0000
> @@ -400,19 +400,19 @@ kbfunc_client_label(struct client_ctx *c
> {
> struct menu *mi;
> struct menu_q menuq;
> - char *current;
>
> TAILQ_INIT(&menuq);
>
> - current = cc->label;
> + /* dummy is set, so this will always return */
> + mi = menu_filter(cc->sc, &menuq, "label", cc->label, 1,
> + search_match_text, NULL);
>
> - if ((mi = menu_filter(cc->sc, &menuq, "label", current, 1,
> - search_match_text, NULL)) != NULL) {
> + if (!mi->abort) {
> if (cc->label != NULL)
> xfree(cc->label);
> cc->label = xstrdup(mi->text);
> - xfree(mi);
> }
> + xfree(mi);
> }
>
> void
> Index: menu.c
> ===================================================================
> RCS file: /home/open/anoncvs/cvs/xenocara/app/cwm/menu.c,v
> retrieving revision 1.19
> diff -u -p -r1.19 menu.c
> --- menu.c 15 Dec 2009 04:10:42 -0000 1.19
> +++ menu.c 30 Jan 2010 20:35:01 -0000
> @@ -223,6 +223,7 @@ menu_handle_key(XEvent *e, struct menu_c
> mc->searchstr, sizeof(mi->text));
> mi->dummy = 1;
> }
> + mi->abort = 0;
> return (mi);
> case CTL_WIPE:
> mc->searchstr[0] = '\0';
> @@ -235,6 +236,7 @@ menu_handle_key(XEvent *e, struct menu_c
> mi = xmalloc(sizeof *mi);
> mi->text[0] = '\0';
> mi->dummy = 1;
> + mi->abort = 1;
> return (mi);
> default:
> break;
>
ok.
-0-
--
Get Revenge! Live long enough to be a problem for your children!