From 7cac1f19acf894aaf4470460732574abc158fd78 Mon Sep 17 00:00:00 2001 From: Marius Nita Date: Thu, 22 Aug 2002 18:19:57 +0000 Subject: [PATCH] toggleGrabs action added --- util/epist/actions.hh | 1 + util/epist/keytree.cc | 10 +++++++++- util/epist/parser.cc | 1 + util/epist/screen.cc | 17 +++++++++++++++-- util/epist/screen.hh | 1 + 5 files changed, 27 insertions(+), 3 deletions(-) diff --git a/util/epist/actions.hh b/util/epist/actions.hh index 89b99eca..6fdd48f0 100644 --- a/util/epist/actions.hh +++ b/util/epist/actions.hh @@ -89,6 +89,7 @@ public: showWorkspaceMenu, toggleDecorations, + toggleGrabs, stringChain, keyChain, numberChain, diff --git a/util/epist/keytree.cc b/util/epist/keytree.cc index e9fa2cab..6dcba312 100644 --- a/util/epist/keytree.cc +++ b/util/epist/keytree.cc @@ -82,7 +82,7 @@ void keytree::ungrabDefaults(screen *scr) { ChildList::const_iterator it, end = _head->children.end(); for (it = _head->children.begin(); it != end; ++it) - if ( (*it)->action ) + if ( (*it)->action && (*it)->action->type() != Action::toggleGrabs) scr->ungrabKey( (*it)->action->keycode(), (*it)->action->modifierMask() ); } @@ -175,6 +175,14 @@ void keytree::addAction(Action::ActionType action, unsigned int mask, string key, string arg) { keynode *tmp = new keynode; + + if (action == Action::toggleGrabs && _current != _head) { + // the toggleGrabs key can only be set up as a root key, since if + // it was a chain key, we'd have to not ungrab the whole chain up + // to that key. which kinda defeats the purpose of this function. + return; + } + tmp->action = new Action(action, XKeysymToKeycode(_display, XStringToKeysym(key.c_str())), diff --git a/util/epist/parser.cc b/util/epist/parser.cc index 548212c4..d7ac2c13 100644 --- a/util/epist/parser.cc +++ b/util/epist/parser.cc @@ -102,6 +102,7 @@ void parser::setAction(string act) { "showrootmenu", Action::showRootMenu }, { "showworkspacemenu", Action::showWorkspaceMenu }, { "toggledecorations", Action::toggleDecorations }, + { "togglegrabs", Action::toggleGrabs }, { "stringchain", Action::stringChain }, { "keychain", Action::keyChain }, { "numberchain", Action::numberChain }, diff --git a/util/epist/screen.cc b/util/epist/screen.cc index 2862b870..0f8dfa56 100644 --- a/util/epist/screen.cc +++ b/util/epist/screen.cc @@ -59,6 +59,7 @@ screen::screen(epist *epist, int number) _number = number; _info = _epist->getScreenInfo(_number); _root = _info->getRootWindow(); + _grabbed = true; // find a window manager supporting NETWM, waiting for it to load if we must int count = 20; // try for 20 seconds @@ -151,8 +152,9 @@ void screen::handleKeypress(const XEvent &e) { // Mask out the lock modifiers. We want our keys to always work // This should be made an option unsigned int state = e.xkey.state & ~(LockMask|scrolllockMask|numlockMask); - const Action *it = _epist->getKeyTree().getAction(e, state, this); - + keytree &ktree = _epist->getKeyTree(); + const Action *it = ktree.getAction(e, state, this); + if (!it) return; @@ -252,6 +254,17 @@ void screen::handleKeypress(const XEvent &e) { None); return; + case Action::toggleGrabs: { + if (_grabbed) { + ktree.ungrabDefaults(this); + _grabbed = false; + } else { + ktree.grabDefaults(this); + _grabbed = true; + } + return; + } + default: break; } diff --git a/util/epist/screen.hh b/util/epist/screen.hh index 98f8a351..34e3c77f 100644 --- a/util/epist/screen.hh +++ b/util/epist/screen.hh @@ -53,6 +53,7 @@ class screen { unsigned int _num_desktops; bool _managed; + bool _grabbed; // used for keygrab toggle function XWindow *findWindow(const XEvent &e) const; void updateNumDesktops(); -- 2.39.2