diff options
author | Anselm R. Garbe <arg@suckless.org> | 2007-01-11 15:52:37 +0100 |
---|---|---|
committer | Anselm R. Garbe <arg@suckless.org> | 2007-01-11 15:52:37 +0100 |
commit | b6cd6ed2661693c90c1c6e7119a8ac4a0b09e7e1 (patch) | |
tree | 717a9c06f569ab344b7323ad4fd80568521bd9bb | |
parent | 09813fcf2c7929fbfe5bc2f9d877c4e2e83e14b8 (diff) |
added evil key support to dmenu
-rw-r--r-- | main.c | 17 |
1 files changed, 15 insertions, 2 deletions
@@ -15,6 +15,8 @@ | |||
15 | #include <X11/Xutil.h> | 15 | #include <X11/Xutil.h> |
16 | #include <X11/keysym.h> | 16 | #include <X11/keysym.h> |
17 | 17 | ||
18 | #define CLEANMASK(mask) (mask & ~(numlockmask | LockMask)) | ||
19 | |||
18 | typedef struct Item Item; | 20 | typedef struct Item Item; |
19 | struct Item { | 21 | struct Item { |
20 | Item *next; /* traverses all items */ | 22 | Item *next; /* traverses all items */ |
@@ -31,6 +33,7 @@ static int ret = 0; | |||
31 | static int nitem = 0; | 33 | static int nitem = 0; |
32 | static unsigned int cmdw = 0; | 34 | static unsigned int cmdw = 0; |
33 | static unsigned int promptw = 0; | 35 | static unsigned int promptw = 0; |
36 | static unsigned int numlockmask = 0; | ||
34 | static Bool running = True; | 37 | static Bool running = True; |
35 | static Item *allitems = NULL; /* first of all items */ | 38 | static Item *allitems = NULL; /* first of all items */ |
36 | static Item *item = NULL; /* first of pattern matching items */ | 39 | static Item *item = NULL; /* first of pattern matching items */ |
@@ -187,7 +190,7 @@ kpress(XKeyEvent * e) { | |||
187 | return; | 190 | return; |
188 | } | 191 | } |
189 | } | 192 | } |
190 | if(e->state & Mod1Mask) { | 193 | if(CLEANMASK(e->state) & Mod1Mask) { |
191 | switch(ksym) { | 194 | switch(ksym) { |
192 | default: return; | 195 | default: return; |
193 | case XK_h: | 196 | case XK_h: |
@@ -347,10 +350,11 @@ main(int argc, char *argv[]) { | |||
347 | char *selbg = SELBGCOLOR; | 350 | char *selbg = SELBGCOLOR; |
348 | char *selfg = SELFGCOLOR; | 351 | char *selfg = SELFGCOLOR; |
349 | fd_set rd; | 352 | fd_set rd; |
350 | int i; | 353 | int i, j; |
351 | struct timeval timeout; | 354 | struct timeval timeout; |
352 | Item *itm; | 355 | Item *itm; |
353 | XEvent ev; | 356 | XEvent ev; |
357 | XModifierKeymap *modmap; | ||
354 | XSetWindowAttributes wa; | 358 | XSetWindowAttributes wa; |
355 | 359 | ||
356 | timeout.tv_usec = 0; | 360 | timeout.tv_usec = 0; |
@@ -408,6 +412,15 @@ main(int argc, char *argv[]) { | |||
408 | if(select(ConnectionNumber(dpy) + 1, &rd, NULL, NULL, &timeout) < 1) | 412 | if(select(ConnectionNumber(dpy) + 1, &rd, NULL, NULL, &timeout) < 1) |
409 | goto UninitializedEnd; | 413 | goto UninitializedEnd; |
410 | maxname = readstdin(); | 414 | maxname = readstdin(); |
415 | /* init modifier map */ | ||
416 | modmap = XGetModifierMapping(dpy); | ||
417 | for (i = 0; i < 8; i++) { | ||
418 | for (j = 0; j < modmap->max_keypermod; j++) { | ||
419 | if(modmap->modifiermap[i * modmap->max_keypermod + j] == XKeysymToKeycode(dpy, XK_Num_Lock)) | ||
420 | numlockmask = (1 << i); | ||
421 | } | ||
422 | } | ||
423 | XFreeModifiermap(modmap); | ||
411 | /* style */ | 424 | /* style */ |
412 | dc.norm[ColBG] = getcolor(normbg); | 425 | dc.norm[ColBG] = getcolor(normbg); |
413 | dc.norm[ColFG] = getcolor(normfg); | 426 | dc.norm[ColFG] = getcolor(normfg); |