#include <X11/Xutil.h>
#include <X11/keysym.h>
+#define CLEANMASK(mask) (mask & ~(numlockmask | LockMask))
+
typedef struct Item Item;
struct Item {
Item *next; /* traverses all items */
static char text[4096];
static char *prompt = NULL;
-static int mx, my, mw, mh;
+static int mw, mh;
static int ret = 0;
static int nitem = 0;
static unsigned int cmdw = 0;
static unsigned int promptw = 0;
+static unsigned int numlockmask = 0;
static Bool running = True;
static Item *allitems = NULL; /* first of all items */
static Item *item = NULL; /* first of pattern matching items */
switch (ksym) {
default: /* ignore other control sequences */
return;
+ case XK_bracketleft:
+ ksym = XK_Escape;
break;
case XK_h:
case XK_H:
ksym = XK_BackSpace;
break;
+ case XK_i:
+ case XK_I:
+ ksym = XK_Tab;
+ break;
+ case XK_j:
+ case XK_J:
+ ksym = XK_Return;
+ break;
case XK_u:
case XK_U:
text[0] = 0;
match(text);
drawmenu();
return;
- break;
}
}
- if(e->state & Mod1Mask) {
+ if(CLEANMASK(e->state) & Mod1Mask) {
switch(ksym) {
default: return;
case XK_h:
char *selbg = SELBGCOLOR;
char *selfg = SELFGCOLOR;
fd_set rd;
- int i;
+ int i, j;
struct timeval timeout;
Item *itm;
XEvent ev;
+ XModifierKeymap *modmap;
XSetWindowAttributes wa;
timeout.tv_usec = 0;
if(++i < argc) timeout.tv_sec = atoi(argv[i]);
}
else if(!strncmp(argv[i], "-v", 3)) {
- fputs("dmenu-"VERSION", (C)opyright MMVII Anselm R. Garbe\n", stdout);
+ fputs("dmenu-"VERSION", (C)opyright MMVI-MMVII Anselm R. Garbe\n", stdout);
exit(EXIT_SUCCESS);
}
else
if(select(ConnectionNumber(dpy) + 1, &rd, NULL, NULL, &timeout) < 1)
goto UninitializedEnd;
maxname = readstdin();
+ /* init modifier map */
+ modmap = XGetModifierMapping(dpy);
+ for (i = 0; i < 8; i++) {
+ for (j = 0; j < modmap->max_keypermod; j++) {
+ if(modmap->modifiermap[i * modmap->max_keypermod + j] == XKeysymToKeycode(dpy, XK_Num_Lock))
+ numlockmask = (1 << i);
+ }
+ }
+ XFreeModifiermap(modmap);
/* style */
dc.norm[ColBG] = getcolor(normbg);
dc.norm[ColFG] = getcolor(normfg);
wa.override_redirect = 1;
wa.background_pixmap = ParentRelative;
wa.event_mask = ExposureMask | ButtonPressMask | KeyPressMask;
- mx = my = 0;
mw = DisplayWidth(dpy, screen);
mh = dc.font.height + 2;
if(bottom)
my += DisplayHeight(dpy, screen) - mh;
- win = XCreateWindow(dpy, root, mx, my, mw, mh, 0,
+ win = XCreateWindow(dpy, root, 0, 0, mw, mh, 0,
DefaultDepth(dpy, screen), CopyFromParent,
DefaultVisual(dpy, screen),
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);