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
This commit is contained in:
Thomas Lübking 2016-07-15 17:16:54 +02:00
parent 2c66471126
commit 1e235e3f01
2 changed files with 5 additions and 2 deletions

View file

@ -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);
}
}

View file

@ -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);
}
}