From 1e235e3f01733e3282a76e6be8862206d1504bdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=BCbking?= Date: Fri, 15 Jul 2016 17:16:54 +0200 Subject: Grab keyboard synchronouosly to allow replays This allows to catch if a grabbed key (combo) is actually w/o effect (because eg. the OnDesktop condition does not match) and then replay the event ungrabbed to pass it to the focused client. Just like mouse grabbing, this BEARS THE POTENTIAL TO LOCK INPUT, thus needs AS MUCH TESTING AS POSSIBLE BUG: 1137 --- src/FbTk/KeyUtil.cc | 2 +- src/Screen.cc | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/FbTk/KeyUtil.cc b/src/FbTk/KeyUtil.cc index 10bc118..46a712a 100644 --- a/src/FbTk/KeyUtil.cc +++ b/src/FbTk/KeyUtil.cc @@ -129,7 +129,7 @@ void KeyUtil::grabKey(unsigned int key, unsigned int mod, Window win) { for (int i = 0; i < 8; i++) { XGrabKey(display, key, mod | (i & 1 ? LockMask : 0) | (i & 2 ? nummod : 0) | (i & 4 ? scrollmod : 0), - win, True, GrabModeAsync, GrabModeAsync); + win, True, GrabModeAsync, GrabModeSync); } } diff --git a/src/Screen.cc b/src/Screen.cc index 013b6c6..277952b 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -658,11 +658,14 @@ void BScreen::propertyNotify(Atom atom) { void BScreen::keyPressEvent(XKeyEvent &ke) { if (Fluxbox::instance()->keys()->doAction(ke.type, ke.state, ke.keycode, - Keys::GLOBAL|Keys::ON_DESKTOP)) { + Keys::GLOBAL|(ke.subwindow ? 0 : Keys::ON_DESKTOP))) { // re-grab keyboard, so we don't pass KeyRelease to clients // also for catching invalid keys in the middle of keychains FbTk::EventManager::instance()->grabKeyboard(rootWindow().window()); + XAllowEvents(Fluxbox::instance()->display(), SyncKeyboard, CurrentTime); + } else { + XAllowEvents(Fluxbox::instance()->display(), ReplayKeyboard, CurrentTime); } } -- cgit v0.11.2