aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/main.c b/main.c
index 46e0b44..59b3a72 100644
--- a/main.c
+++ b/main.c
@@ -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
18typedef struct Item Item; 20typedef struct Item Item;
19struct Item { 21struct Item {
20 Item *next; /* traverses all items */ 22 Item *next; /* traverses all items */
@@ -31,6 +33,7 @@ static int ret = 0;
31static int nitem = 0; 33static int nitem = 0;
32static unsigned int cmdw = 0; 34static unsigned int cmdw = 0;
33static unsigned int promptw = 0; 35static unsigned int promptw = 0;
36static unsigned int numlockmask = 0;
34static Bool running = True; 37static Bool running = True;
35static Item *allitems = NULL; /* first of all items */ 38static Item *allitems = NULL; /* first of all items */
36static Item *item = NULL; /* first of pattern matching items */ 39static 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);