changed grabkeys, removed initmodmap

pull/1/head
Anselm R Garbe 17 years ago
parent 2b4157eccd
commit 85da537856
  1. 31
      dwm.c

31
dwm.c

@ -158,7 +158,6 @@ static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size);
static void grabbuttons(Client *c, Bool focused);
static void grabkeys(void);
static void initfont(const char *fontstr);
static void initmodmap(void);
static Bool isprotodel(Client *c);
static void keypress(XEvent *e);
static void killclient(const Arg *arg);
@ -752,6 +751,17 @@ grabbuttons(Client *c, Bool focused) {
void
grabkeys(void) {
unsigned int i, j;
XModifierKeymap *modmap;
/* update 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);
{ /* grab keys */
unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask };
KeyCode code;
@ -763,6 +773,7 @@ grabkeys(void) {
GrabModeAsync, GrabModeAsync);
}
}
}
void
initfont(const char *fontstr) {
@ -804,19 +815,6 @@ initfont(const char *fontstr) {
dc.font.height = dc.font.ascent + dc.font.descent;
}
void
initmodmap(void) {
unsigned int i, j;
XModifierKeymap *modmap;
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);
}
Bool
isprotodel(Client *c) {
int i, n;
@ -929,11 +927,9 @@ mappingnotify(XEvent *e) {
XMappingEvent *ev = &e->xmapping;
XRefreshKeyboardMapping(ev);
if(ev->request == MappingKeyboard) {
initmodmap();
if(ev->request == MappingKeyboard)
grabkeys();
}
}
void
maprequest(XEvent *e) {
@ -1379,7 +1375,6 @@ setup(void) {
XChangeWindowAttributes(dpy, root, CWEventMask|CWCursor, &wa);
XSelectInput(dpy, root, wa.event_mask);
initmodmap();
grabkeys();
}

Loading…
Cancel
Save