[Superkb-devel] [PATCH] Make sure KeyReleased keys are actually not pressed (Bug #432887).
Status: Alpha
Brought to you by:
alvarezp
From: Eduardo A. B. L. <ebu...@du...> - 2010-12-05 10:25:21
|
Some KeyRelease events were generated by X's AutoRepeat, even if the key wasn't actually released. Using XQueryKeymap we check the state of the key. If it isn't a true KeyRelease the event is removed from the stack, else it executes the action associated. This solves bug described in https://bugs.launchpad.net/superkb/+bug/432887/ by Octavio Álvarez as: > When the bound key is held down before the Super key, Superkb will perform the associated action multiple times. > Apparently, this is because autorepeat is not getting disabled for the pressed down key. --- superkb.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/superkb.c b/superkb.c index 6c71b7b..bd058a6 100755 --- a/superkb.c +++ b/superkb.c @@ -200,6 +200,13 @@ void one_superkey_used_friendly_warning(int number, const char *keyname) { ); } +int key_is_pressed (Display *dpy, KeyCode keycode) +{ + char key_buffer [32]; + XQueryKeymap(dpy, key_buffer); + return ( (key_buffer[keycode >> 3] >> (keycode & 0x07)) & 0x01 ); +} + void superkb_start(superkb_p this) { @@ -514,6 +521,13 @@ void superkb_start(superkb_p this) int squashed_state = ev.xkey.state & this->state_mask; + if ( key_is_pressed (this->dpy, ev.xkey.keycode) ) { + /* Verifies that the key is indeed pressed and not just a + * KeyRelease generated X's AutoRepeat. + */ + remove_from_pressed_key_stack(ev.xkey.keycode, squashed_state); + continue; + } __Action(ev.xkey.keycode, squashed_state); debug(1, "[ac] Due to bound key release, executed action for key code = %d, name: %s\n", ev.xkey.keycode, -- 1.7.2.3 |