diff --git a/src/Keys.cc b/src/Keys.cc index 172d913a..31f17226 100644 --- a/src/Keys.cc +++ b/src/Keys.cc @@ -575,6 +575,12 @@ bool Keys::doAction(int type, unsigned int mods, unsigned int key, return false; } + // if focus changes, windows will get NotifyWhileGrabbed, + // which they tend to ignore + if (type == KeyPress) { + XUngrabKeyboard(Fluxbox::instance()->display(), CurrentTime); + } + WinClient *old = WindowCmd::client(); WindowCmd::setClient(current); temp_key->m_command->execute(); diff --git a/src/Screen.cc b/src/Screen.cc index 9c0182bd..1d811915 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -680,8 +680,13 @@ void BScreen::propertyNotify(Atom atom) { } void BScreen::keyPressEvent(XKeyEvent &ke) { - Fluxbox::instance()->keys()->doAction(ke.type, ke.state, ke.keycode, - Keys::GLOBAL|Keys::ON_DESKTOP); + if (Fluxbox::instance()->keys()->doAction(ke.type, ke.state, ke.keycode, + Keys::GLOBAL|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()); + } } void BScreen::keyReleaseEvent(XKeyEvent &ke) {