diff options
author | Vito Caputo <vcaputo@gnugeneration.com> | 2016-01-03 03:05:38 -0800 |
---|---|---|
committer | Vito Caputo <vcaputo@gnugeneration.com> | 2016-01-03 03:05:38 -0800 |
commit | 535b2abd8f665c648dbeea16f96dcb0cba55d5df (patch) | |
tree | 0b86cfff629317957a6dcdeec809e714c54849e4 | |
parent | a75ab8242bc4060245034f12e31904d6b95c8ae7 (diff) |
Fix missed keyboard ungrab when alt was released with others still pressed
-rw-r--r-- | vwm.c | 26 |
1 files changed, 20 insertions, 6 deletions
@@ -2413,6 +2413,19 @@ _fail: return 0; } +/* Poll the keyboard state to see if _any_ keys are pressed */ +static int vwm_keyspressed() { + int i; + char state[32]; + + XQueryKeymap(display, state); + + for(i = 0; i < sizeof(state); i++) { + if(state[i]) return 1; + } + + return 0; +} /* Called in response to KeyRelease events, for now only interesting for detecting when Mod1 is released termintaing * window cycling for application of MRU on the focused window */ @@ -2439,18 +2452,19 @@ static void vwm_keyreleased(Window win, XEvent *keyrelease) /* make the focused desktop the most recently used */ if(focused_context == VWM_CONTEXT_FOCUS_DESKTOP && focused_desktop) vwm_desktop_mru(focused_desktop); - if(key_is_grabbed) { - XUngrabKeyboard(display, CurrentTime); - XFlush(display); - key_is_grabbed = 0; - fence_mask = 0; /* reset the fence mask on release for VWM_FENCE_MASKED_VIOLATE */ - } break; default: VWM_TRACE("Unhandled keycode: %x", (unsigned int)sym); break; } + + if(key_is_grabbed && !vwm_keyspressed()) { + XUngrabKeyboard(display, CurrentTime); + XFlush(display); + key_is_grabbed = 0; + fence_mask = 0; /* reset the fence mask on release for VWM_FENCE_MASKED_VIOLATE */ + } } |