all repos — fluxbox @ 6ca6422344f0046ef1794c5fbaea90d28692fd5f

custom fork of the fluxbox windowmanager

introduce a 5s timeout for emacs shortcuts

The user needs to enter his chain within 5 seconds
Otherwise the chain is reset.

REQUEST: 291
Thomas Lübking thomas.luebking@gmail.com
commit

6ca6422344f0046ef1794c5fbaea90d28692fd5f

parent

6c4d1123c07f8fe265bbb38920b0ae3d90879d56

2 files changed, 18 insertions(+), 7 deletions(-)

jump to
M src/Keys.ccsrc/Keys.cc

@@ -522,6 +522,8 @@

if (!m_keylist) return false; + static Time first_key_time = 0; + static Time last_button_time = 0; static unsigned int last_button = 0;

@@ -544,6 +546,17 @@ last_button = key;

isdouble = double_click; } + auto resetKeyChain = [&]() { + first_key_time = 0; + next_key.reset(); + if (saved_keymode) { + setKeyMode(saved_keymode); + saved_keymode.reset(); + } + }; + if (type == KeyPress && first_key_time && time - first_key_time > 5000) + resetKeyChain(); + if (!next_key) next_key = m_keylist;

@@ -560,8 +573,10 @@ next_key->find(MotionNotify, mods, key, context, false))

return true; // if there's a motion action, prevent replay to the client (but do nothing) if (temp_key && !temp_key->keylist.empty()) { // emacs-style - if (!saved_keymode) + if (!saved_keymode) { + first_key_time = time; saved_keymode = m_keylist; + } next_key = temp_key; setKeyMode(next_key); return true;

@@ -570,11 +585,7 @@ if (!temp_key || temp_key->m_command == 0) {

if (type == KeyPress && !FbTk::KeyUtil::instance().keycodeToModmask(key)) { // if we're in the middle of an emacs-style keychain, exit it - next_key.reset(); - if (saved_keymode) { - setKeyMode(saved_keymode); - saved_keymode.reset(); - } + resetKeyChain(); } return false; }
M src/Screen.ccsrc/Screen.cc

@@ -656,7 +656,7 @@ }

void BScreen::keyPressEvent(XKeyEvent &ke) { if (Fluxbox::instance()->keys()->doAction(ke.type, ke.state, ke.keycode, - Keys::GLOBAL|(ke.subwindow ? 0 : Keys::ON_DESKTOP))) { + Keys::GLOBAL|(ke.subwindow ? 0 : Keys::ON_DESKTOP), 0, ke.time)) { // re-grab keyboard, so we don't pass KeyRelease to clients // also for catching invalid keys in the middle of keychains