diff options
author | Alexey Yakovenko <wakeroid@gmail.com> | 2010-04-27 08:39:56 +0200 |
---|---|---|
committer | Alexey Yakovenko <wakeroid@gmail.com> | 2010-04-27 08:39:56 +0200 |
commit | cb7f7437433ce64a2fb030e520e9cbda717c99e5 (patch) | |
tree | 21777cad02f12a7eb255a111844e696089233d89 /plugins/hotkeys | |
parent | 6a36c949132512814ef28bdb0986f15b4679a3bc (diff) |
fixed hotkeys plugin to ignore unused modifiers;
fixed hotkeys init when no hotkeys were bound yet
Diffstat (limited to 'plugins/hotkeys')
-rw-r--r-- | plugins/hotkeys/hotkeys.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/plugins/hotkeys/hotkeys.c b/plugins/hotkeys/hotkeys.c index f52747d6..e744926d 100644 --- a/plugins/hotkeys/hotkeys.c +++ b/plugins/hotkeys/hotkeys.c @@ -25,6 +25,9 @@ #include "hotkeys.h" #include "../../deadbeef.h" +//#define trace(...) { fprintf(stderr, __VA_ARGS__); } +#define trace(fmt,...) + static DB_hotkeys_plugin_t plugin; static DB_functions_t *deadbeef; static int finished; @@ -290,6 +293,7 @@ hotkeys_event_loop (void *unused) { while (!finished) { if (need_reset) { + 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)); @@ -307,13 +311,23 @@ hotkeys_event_loop (void *unused) { if (event.xkey.type == KeyPress) { - for (i = 0; i < command_count; i++) + int state = event.xkey.state; + trace ("hotkeys: keypress, state=%X\n", state); + // ignore caps/scroll/numlock + state &= (ShiftMask|ControlMask|Mod1Mask|Mod4Mask); + trace ("filtered state=%X\n", state); + for (i = 0; i < command_count; i++) { if ( (event.xkey.keycode == commands[ i ].keycode) && - ( (event.xkey.state & commands[ i ].modifier) == commands[ i ].modifier)) + (state == commands[ i ].modifier)) { + trace ("matches to commands[%d]!\n", i); commands[i].func (); break; } + } + if (i == command_count) { + trace ("keypress doesn't match to any global hotkey\n"); + } } } usleep (200 * 1000); @@ -334,12 +348,7 @@ hotkeys_start (void) { read_config (disp); XSync (disp, 0); - if (command_count > 0) { - loop_tid = deadbeef->thread_start (hotkeys_event_loop, 0); - } - else { - cleanup (); - } + loop_tid = deadbeef->thread_start (hotkeys_event_loop, 0); } static int @@ -364,6 +373,7 @@ hotkeys_get_name_for_keycode (int keycode) { void hotkeys_reset (void) { need_reset = 1; + trace ("hotkeys: reset flagged\n"); } // define plugin interface |