X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;ds=sidebyside;f=event.c;h=85205d9b76a218b29c27174e1992eaed986e8711;hb=d26ffc7fa30402fa9f35107224966bdc883e40ce;hp=881d41a84437facf05f97dc439937ef00779a372;hpb=2ffdc1936cf13af5df0cc6d9415961dbe13b9cf8;p=dwm.git diff --git a/event.c b/event.c index 881d41a..85205d9 100644 --- a/event.c +++ b/event.c @@ -276,6 +276,16 @@ leavenotify(XEvent *e) } } +static void +mappingnotify(XEvent *e) +{ + XMappingEvent *ev = &e->xmapping; + + XRefreshKeyboardMapping(ev); + if(ev->request == MappingKeyboard) + grabkeys(); +} + static void maprequest(XEvent *e) { @@ -348,6 +358,7 @@ void (*handler[LASTEvent]) (XEvent *) = { [LeaveNotify] = leavenotify, [Expose] = expose, [KeyPress] = keypress, + [MappingNotify] = mappingnotify, [MapRequest] = maprequest, [PropertyNotify] = propertynotify, [UnmapNotify] = unmapnotify @@ -360,6 +371,7 @@ grabkeys() unsigned int i; KeyCode code; + XUngrabKey(dpy, AnyKey, AnyModifier, root); for(i = 0; i < len; i++) { code = XKeysymToKeycode(dpy, key[i].keysym); XGrabKey(dpy, code, key[i].mod, root, True, @@ -370,5 +382,6 @@ grabkeys() GrabModeAsync, GrabModeAsync); XGrabKey(dpy, code, key[i].mod | NUMLOCKMASK | LockMask, root, True, GrabModeAsync, GrabModeAsync); + XSync(dpy, False); } }