aewl

changeset 291:8e6e0aa5e2ae

removed NUMLOCKMASK, added dynamically calculated numlockmask instead
author Anselm R.Garbe <arg@10ksloc.org>
date Mon, 14 Aug 2006 19:18:02 +0200
parents 5c3b8c5286f5
children 4aa632b6ba66
files client.c config.arg.h config.default.h dwm.h event.c main.c
diffstat 6 files changed, 29 insertions(+), 19 deletions(-) [+]
line diff
     1.1 --- a/client.c	Mon Aug 14 18:47:13 2006 +0200
     1.2 +++ b/client.c	Mon Aug 14 19:18:02 2006 +0200
     1.3 @@ -228,27 +228,27 @@
     1.4  			GrabModeAsync, GrabModeSync, None, None);
     1.5  	XGrabButton(dpy, Button1, MODKEY | LockMask, c->win, False, BUTTONMASK,
     1.6  			GrabModeAsync, GrabModeSync, None, None);
     1.7 -	XGrabButton(dpy, Button1, MODKEY | NUMLOCKMASK, c->win, False, BUTTONMASK,
     1.8 +	XGrabButton(dpy, Button1, MODKEY | numlockmask, c->win, False, BUTTONMASK,
     1.9  			GrabModeAsync, GrabModeSync, None, None);
    1.10 -	XGrabButton(dpy, Button1, MODKEY | NUMLOCKMASK | LockMask, c->win, False, BUTTONMASK,
    1.11 +	XGrabButton(dpy, Button1, MODKEY | numlockmask | LockMask, c->win, False, BUTTONMASK,
    1.12  			GrabModeAsync, GrabModeSync, None, None);
    1.13  
    1.14  	XGrabButton(dpy, Button2, MODKEY, c->win, False, BUTTONMASK,
    1.15  			GrabModeAsync, GrabModeSync, None, None);
    1.16  	XGrabButton(dpy, Button2, MODKEY | LockMask, c->win, False, BUTTONMASK,
    1.17  			GrabModeAsync, GrabModeSync, None, None);
    1.18 -	XGrabButton(dpy, Button2, MODKEY | NUMLOCKMASK, c->win, False, BUTTONMASK,
    1.19 +	XGrabButton(dpy, Button2, MODKEY | numlockmask, c->win, False, BUTTONMASK,
    1.20  			GrabModeAsync, GrabModeSync, None, None);
    1.21 -	XGrabButton(dpy, Button2, MODKEY | NUMLOCKMASK | LockMask, c->win, False, BUTTONMASK,
    1.22 +	XGrabButton(dpy, Button2, MODKEY | numlockmask | LockMask, c->win, False, BUTTONMASK,
    1.23  			GrabModeAsync, GrabModeSync, None, None);
    1.24  
    1.25  	XGrabButton(dpy, Button3, MODKEY, c->win, False, BUTTONMASK,
    1.26  			GrabModeAsync, GrabModeSync, None, None);
    1.27  	XGrabButton(dpy, Button3, MODKEY | LockMask, c->win, False, BUTTONMASK,
    1.28  			GrabModeAsync, GrabModeSync, None, None);
    1.29 -	XGrabButton(dpy, Button3, MODKEY | NUMLOCKMASK, c->win, False, BUTTONMASK,
    1.30 +	XGrabButton(dpy, Button3, MODKEY | numlockmask, c->win, False, BUTTONMASK,
    1.31  			GrabModeAsync, GrabModeSync, None, None);
    1.32 -	XGrabButton(dpy, Button3, MODKEY | NUMLOCKMASK | LockMask, c->win, False, BUTTONMASK,
    1.33 +	XGrabButton(dpy, Button3, MODKEY | numlockmask | LockMask, c->win, False, BUTTONMASK,
    1.34  			GrabModeAsync, GrabModeSync, None, None);
    1.35  
    1.36  	settags(c);
     2.1 --- a/config.arg.h	Mon Aug 14 18:47:13 2006 +0200
     2.2 +++ b/config.arg.h	Mon Aug 14 19:18:02 2006 +0200
     2.3 @@ -13,7 +13,6 @@
     2.4  #define FGCOLOR			"#eeeeee"
     2.5  #define BORDERCOLOR		"#3f484d"
     2.6  #define MODKEY			Mod1Mask
     2.7 -#define NUMLOCKMASK		Mod2Mask
     2.8  #define MASTERW			60 /* percent */
     2.9  
    2.10  #define KEYS \
     3.1 --- a/config.default.h	Mon Aug 14 18:47:13 2006 +0200
     3.2 +++ b/config.default.h	Mon Aug 14 19:18:02 2006 +0200
     3.3 @@ -13,7 +13,6 @@
     3.4  #define FGCOLOR			"#eeeeee"
     3.5  #define BORDERCOLOR		"#9999CC"
     3.6  #define MODKEY			Mod1Mask
     3.7 -#define NUMLOCKMASK		Mod2Mask
     3.8  #define MASTERW			60 /* percent */
     3.9  
    3.10  #define KEYS \
     4.1 --- a/dwm.h	Mon Aug 14 18:47:13 2006 +0200
     4.2 +++ b/dwm.h	Mon Aug 14 19:18:02 2006 +0200
     4.3 @@ -70,7 +70,7 @@
     4.4  extern const char *tags[];
     4.5  extern char stext[1024];
     4.6  extern int screen, sx, sy, sw, sh, bx, by, bw, bh, mw;
     4.7 -extern unsigned int ntags;
     4.8 +extern unsigned int ntags, numlockmask;
     4.9  extern void (*handler[LASTEvent])(XEvent *);
    4.10  extern void (*arrange)(Arg *);
    4.11  extern Atom wmatom[WMLast], netatom[NetLast];
     5.1 --- a/event.c	Mon Aug 14 18:47:13 2006 +0200
     5.2 +++ b/event.c	Mon Aug 14 19:18:02 2006 +0200
     5.3 @@ -18,7 +18,7 @@
     5.4  
     5.5  KEYS
     5.6  
     5.7 -#define CLEANMASK(mask) (mask & ~(NUMLOCKMASK | LockMask))
     5.8 +#define CLEANMASK(mask) (mask & ~(numlockmask | LockMask))
     5.9  
    5.10  static void
    5.11  movemouse(Client *c)
    5.12 @@ -378,9 +378,9 @@
    5.13  				GrabModeAsync, GrabModeAsync);
    5.14  		XGrabKey(dpy, code, key[i].mod | LockMask, root, True,
    5.15  				GrabModeAsync, GrabModeAsync);
    5.16 -		XGrabKey(dpy, code, key[i].mod | NUMLOCKMASK, root, True,
    5.17 +		XGrabKey(dpy, code, key[i].mod | numlockmask, root, True,
    5.18  				GrabModeAsync, GrabModeAsync);
    5.19 -		XGrabKey(dpy, code, key[i].mod | NUMLOCKMASK | LockMask, root, True,
    5.20 +		XGrabKey(dpy, code, key[i].mod | numlockmask | LockMask, root, True,
    5.21  				GrabModeAsync, GrabModeAsync);
    5.22  	}
    5.23  }
     6.1 --- a/main.c	Mon Aug 14 18:47:13 2006 +0200
     6.2 +++ b/main.c	Mon Aug 14 19:18:02 2006 +0200
     6.3 @@ -11,6 +11,7 @@
     6.4  #include <unistd.h>
     6.5  #include <sys/select.h>
     6.6  #include <X11/cursorfont.h>
     6.7 +#include <X11/keysym.h>
     6.8  #include <X11/Xatom.h>
     6.9  #include <X11/Xproto.h>
    6.10  
    6.11 @@ -85,7 +86,7 @@
    6.12  char stext[1024];
    6.13  Bool *seltag;
    6.14  int screen, sx, sy, sw, sh, bx, by, bw, bh, mw;
    6.15 -unsigned int ntags;
    6.16 +unsigned int ntags, numlockmask;
    6.17  Atom wmatom[WMLast], netatom[NetLast];
    6.18  Bool running = True;
    6.19  Bool issel = True;
    6.20 @@ -162,12 +163,13 @@
    6.21  int
    6.22  main(int argc, char *argv[])
    6.23  {
    6.24 -	int i, xfd;
    6.25 +	int i, j, xfd;
    6.26  	unsigned int mask;
    6.27  	fd_set rd;
    6.28  	Bool readin = True;
    6.29  	Window w;
    6.30  	XEvent ev;
    6.31 +	XModifierKeymap *modmap;
    6.32  	XSetWindowAttributes wa;
    6.33  
    6.34  	if(argc == 2 && !strncmp("-v", argv[1], 3)) {
    6.35 @@ -211,7 +213,16 @@
    6.36  	cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
    6.37  	cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
    6.38  
    6.39 -	wa.event_mask = SubstructureRedirectMask | EnterWindowMask | LeaveWindowMask;
    6.40 +	modmap = XGetModifierMapping(dpy);
    6.41 +	for (i = 0; i < 8; i++) {
    6.42 +		for (j = 0; j < modmap->max_keypermod; j++) {
    6.43 +			if(modmap->modifiermap[i * modmap->max_keypermod + j] == XKeysymToKeycode(dpy, XK_Num_Lock))
    6.44 +				numlockmask = (1 << i);
    6.45 +		}
    6.46 +	}
    6.47 +	XFree(modmap);
    6.48 +
    6.49 +	wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask | EnterWindowMask | LeaveWindowMask;
    6.50  	wa.cursor = cursor[CurNormal];
    6.51  	XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa);
    6.52  
    6.53 @@ -233,13 +244,12 @@
    6.54  	sh = DisplayHeight(dpy, screen);
    6.55  	mw = (sw * MASTERW) / 100;
    6.56  
    6.57 +	bx = by = 0;
    6.58 +	bw = sw;
    6.59 +	dc.h = bh = dc.font.height + 4;
    6.60  	wa.override_redirect = 1;
    6.61  	wa.background_pixmap = ParentRelative;
    6.62  	wa.event_mask = ButtonPressMask | ExposureMask;
    6.63 -
    6.64 -	bx = by = 0;
    6.65 -	bw = sw;
    6.66 -	dc.h = bh = dc.font.height + 4;
    6.67  	barwin = XCreateWindow(dpy, root, bx, by, bw, bh, 0, DefaultDepth(dpy, screen),
    6.68  			CopyFromParent, DefaultVisual(dpy, screen),
    6.69  			CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
    6.70 @@ -258,6 +268,7 @@
    6.71  
    6.72  	/* main event loop, also reads status text from stdin */
    6.73  	XSync(dpy, False);
    6.74 +	goto XLoop;
    6.75  	while(running) {
    6.76  		FD_ZERO(&rd);
    6.77  		if(readin)
    6.78 @@ -278,6 +289,7 @@
    6.79  				drawstatus();
    6.80  			}
    6.81  			if(FD_ISSET(xfd, &rd)) {
    6.82 +XLoop:
    6.83  				while(XPending(dpy)) {
    6.84  					XNextEvent(dpy, &ev);
    6.85  					if(handler[ev.type])