From 3c9ef4366fd228c7272aa4f467ee4f7ecadf2049 Mon Sep 17 00:00:00 2001 From: okan Date: Fri, 30 Sep 2016 18:28:06 +0000 Subject: Use instinsic X11 functions for key/btn/ptr grab/ungrab/regrab requests; the one line wrappers provided no value and limited altering calls where needed; additionally, most of them had but one caller. --- conf.c | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'conf.c') diff --git a/conf.c b/conf.c index 5791db4..3745326 100644 --- a/conf.c +++ b/conf.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: conf.c,v 1.207 2016/09/29 00:21:55 okan Exp $ + * $OpenBSD: conf.c,v 1.208 2016/09/30 18:28:06 okan Exp $ */ #include @@ -655,28 +655,48 @@ conf_cursor(struct conf *c) c->cursor[i] = XCreateFontCursor(X_Dpy, cursor_binds[i]); } +static unsigned int ign_mods[] = { 0, LockMask, Mod2Mask, Mod2Mask | LockMask }; + void conf_grab_mouse(Window win) { struct binding *mb; + unsigned int i; - xu_btn_ungrab(win); + XUngrabButton(X_Dpy, AnyButton, AnyModifier, win); TAILQ_FOREACH(mb, &Conf.mousebindingq, entry) { - if (mb->context == CWM_CONTEXT_CLIENT) - xu_btn_grab(win, mb->modmask, mb->press.button); + if (mb->context != CWM_CONTEXT_CLIENT) + continue; + for (i = 0; i < nitems(ign_mods); i++) { + XGrabButton(X_Dpy, mb->press.button, + (mb->modmask | ign_mods[i]), win, False, + BUTTONMASK, GrabModeAsync, GrabModeSync, + None, None); + } } + } void conf_grab_kbd(Window win) { struct binding *kb; + KeyCode kc; + unsigned int i; - xu_key_ungrab(win); + XUngrabKey(X_Dpy, AnyKey, AnyModifier, win); - TAILQ_FOREACH(kb, &Conf.keybindingq, entry) - xu_key_grab(win, kb->modmask, kb->press.keysym); + TAILQ_FOREACH(kb, &Conf.keybindingq, entry) { + kc = XKeysymToKeycode(X_Dpy, kb->press.keysym); + if ((XkbKeycodeToKeysym(X_Dpy, kc, 0, 0) != kb->press.keysym) && + (XkbKeycodeToKeysym(X_Dpy, kc, 0, 1) == kb->press.keysym)) + kb->modmask |= ShiftMask; + + for (i = 0; i < nitems(ign_mods); i++) + XGrabKey(X_Dpy, kc, (kb->modmask | ign_mods[i]), win, + True, GrabModeAsync, GrabModeAsync); + } } static char *cwmhints[] = { -- cgit v1.2.3-2-gb3c3