diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2016-02-11 01:46:53 +0100 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2016-02-11 01:46:53 +0100 |
commit | 945f620a3ce6a3d990182cd232664138b648cae2 (patch) | |
tree | 5faa4508f752a4f3e038a5fab2aefb5e80421fba | |
parent | 694f9f29a693500b4d29966378d51e876a70682b (diff) | |
download | desktop-tools-945f620a3ce6a3d990182cd232664138b648cae2.tar.gz desktop-tools-945f620a3ce6a3d990182cd232664138b648cae2.tar.xz desktop-tools-945f620a3ce6a3d990182cd232664138b648cae2.zip |
dwmstatus: make use of XkbKeysymToModifiers
-rw-r--r-- | dwmstatus.c | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/dwmstatus.c b/dwmstatus.c index 1009126..6d66e5e 100644 --- a/dwmstatus.c +++ b/dwmstatus.c @@ -2709,27 +2709,12 @@ g_keys[] = // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -static unsigned -get_numlock_mask (struct app_context *ctx) -{ - // XXX: can XKB virtual mods help this? Chapter 8. Virtual Modifiers - unsigned result = 0; - XModifierKeymap *modmap = XGetModifierMapping (ctx->dpy); - for (unsigned i = 0; i < 8; i++) - for (int j = 0; j < modmap->max_keypermod; j++) - if (modmap->modifiermap[i * modmap->max_keypermod + j] == - XKeysymToKeycode (ctx->dpy, XK_Num_Lock)) - result = (1 << i); - XFreeModifiermap(modmap); - return result; -} - static void on_x_keypress (struct app_context *ctx, XEvent *e) { XKeyEvent *ev = &e->xkey; KeySym keysym = XkbKeycodeToKeysym (ctx->dpy, (KeyCode) ev->keycode, - 0, !!(ev->state & ShiftMask)); + 0 /* XXX: current group? */, !!(ev->state & ShiftMask)); for (size_t i = 0; i < N_ELEMENTS (g_keys); i++) if (keysym == g_keys[i].keysym && g_keys[i].mod == ev->state @@ -2756,7 +2741,8 @@ on_x_ready (const struct pollfd *pfd, void *user_data) static void grab_keys (struct app_context *ctx) { - unsigned ignored_locks = LockMask | get_numlock_mask (ctx); + unsigned ignored_locks = + LockMask | XkbKeysymToModifiers (ctx->dpy, XK_Num_Lock); hard_assert (XkbSetIgnoreLockMods (ctx->dpy, XkbUseCoreKbd, ignored_locks, ignored_locks, 0, 0)); |