if(!sub)
return (char *)s;
- if((c = *sub++) != 0) {
+ if((c = *sub++) != '\0') {
c = tolower(c);
len = strlen(sub);
do {
do {
- if((csub = *s++) == 0)
+ if((csub = *s++) == '\0')
return NULL;
}
while(tolower(csub) != c);
dc.x += promptw;
dc.w = mw - promptw;
/* print command */
- if(cmdw && item)
+ if(cmdw && item && !vlist)
dc.w = cmdw;
drawtext(text[0] ? text : NULL, dc.norm);
drawcursor();
KeySym ksym;
len = strlen(text);
- buf[0] = 0;
+ buf[0] = '\0';
num = XLookupString(e, buf, sizeof buf, &ksym, NULL);
if(IsKeypadKey(ksym)) {
if(ksym == XK_KP_Enter)
break;
case XK_u:
case XK_U:
- text[0] = 0;
+ memmove(text, text + cursor, sizeof text - cursor + 1);
+ cursor = 0;
match(text);
break;
case XK_w:
buf[--len] = '\0';
if(!(p = strdup(buf)))
eprint("fatal: could not strdup() %u bytes\n", len);
- if(max < len) {
+ if(max < len || !maxname) {
maxname = p;
max = len;
}
if(ev.xexpose.count == 0)
drawmenu();
break;
+ case VisibilityNotify:
+ if (ev.xvisibility.state != VisibilityUnobscured)
+ XRaiseWindow(dpy, win);
+ break;
}
}
/* menu window */
wa.override_redirect = True;
wa.background_pixmap = ParentRelative;
- wa.event_mask = ExposureMask | ButtonPressMask | KeyPressMask;
+ wa.event_mask = ExposureMask | ButtonPressMask | KeyPressMask | VisibilityChangeMask;
/* menu window geometry */
mh = dc.font.height + 2;
cmdw = MIN(textw(maxname), mw / 3);
if(prompt)
promptw = MIN(textw(prompt), mw / 5);
- text[0] = 0;
+ text[0] = '\0';
match(text);
XMapRaised(dpy, win);
}