From bf57c4cf3009102b60c00e53349becc7f2ba6911 Mon Sep 17 00:00:00 2001 From: Alexey Yakovenko Date: Wed, 28 Apr 2010 20:08:46 +0200 Subject: handle all combinations of num/caps/scroll lock modifiers in hotkeys plugin --- plugins/hotkeys/hotkeys.c | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) (limited to 'plugins/hotkeys') diff --git a/plugins/hotkeys/hotkeys.c b/plugins/hotkeys/hotkeys.c index 67024669..3a27b237 100644 --- a/plugins/hotkeys/hotkeys.c +++ b/plugins/hotkeys/hotkeys.c @@ -264,11 +264,22 @@ read_config (Display *disp) // need to grab it here to prevent gdk_x_error from being called while we're // doing it on other thread for (i = 0; i < command_count; i++) { - XGrabKey (disp, commands[i].keycode, commands[i].modifier, DefaultRootWindow (disp), False, GrabModeAsync, GrabModeAsync); - XGrabKey (disp, commands[i].keycode, commands[i].modifier|LockMask, DefaultRootWindow (disp), False, GrabModeAsync, GrabModeAsync); - XGrabKey (disp, commands[i].keycode, commands[i].modifier|Mod2Mask, DefaultRootWindow (disp), False, GrabModeAsync, GrabModeAsync); - XGrabKey (disp, commands[i].keycode, commands[i].modifier|Mod3Mask, DefaultRootWindow (disp), False, GrabModeAsync, GrabModeAsync); - XGrabKey (disp, commands[i].keycode, commands[i].modifier|Mod5Mask, DefaultRootWindow (disp), False, GrabModeAsync, GrabModeAsync); + for (int f = 0; f < 16; f++) { + uint32_t flags = 0; + if (f & 1) { + flags |= LockMask; + } + if (f & 2) { + flags |= Mod2Mask; + } + if (f & 4) { + flags |= Mod3Mask; + } + if (f & 8) { + flags |= Mod5Mask; + } + XGrabKey (disp, commands[i].keycode, commands[i].modifier | flags, DefaultRootWindow (disp), False, GrabModeAsync, GrabModeAsync); + } } } @@ -300,11 +311,22 @@ hotkeys_event_loop (void *unused) { trace ("hotkeys: reinitializing\n"); XSetErrorHandler (x_err_handler); for (int i = 0; i < command_count; i++) { - XUngrabKey (disp, commands[i].keycode, commands[i].modifier, DefaultRootWindow (disp)); - XUngrabKey (disp, commands[i].keycode, commands[i].modifier|LockMask, DefaultRootWindow (disp)); - XUngrabKey (disp, commands[i].keycode, commands[i].modifier|Mod2Mask, DefaultRootWindow (disp)); - XUngrabKey (disp, commands[i].keycode, commands[i].modifier|Mod3Mask, DefaultRootWindow (disp)); - XUngrabKey (disp, commands[i].keycode, commands[i].modifier|Mod5Mask, DefaultRootWindow (disp)); + for (int f = 0; f < 16; f++) { + uint32_t flags = 0; + if (f & 1) { + flags |= LockMask; + } + if (f & 2) { + flags |= Mod2Mask; + } + if (f & 4) { + flags |= Mod3Mask; + } + if (f & 8) { + flags |= Mod5Mask; + } + XUngrabKey (disp, commands[i].keycode, commands[i].modifier | flags, DefaultRootWindow (disp)); + } } memset (commands, 0, sizeof (commands)); command_count = 0; -- cgit v1.2.3