all repos — openbox @ 7cac1f19acf894aaf4470460732574abc158fd78

openbox fork - make it a bit more like ryudo

toggleGrabs action added
Marius Nita marius@cs.pdx.edu
commit

7cac1f19acf894aaf4470460732574abc158fd78

parent

22e8615f6125cc117af9e01124b9bcc2b19c59ab

M util/epist/actions.hhutil/epist/actions.hh

@@ -89,6 +89,7 @@ showRootMenu,

showWorkspaceMenu, toggleDecorations, + toggleGrabs, stringChain, keyChain, numberChain,
M util/epist/keytree.ccutil/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())),
M util/epist/parser.ccutil/epist/parser.cc

@@ -102,6 +102,7 @@ { "prevscreen", Action::prevScreen },

{ "showrootmenu", Action::showRootMenu }, { "showworkspacemenu", Action::showWorkspaceMenu }, { "toggledecorations", Action::toggleDecorations }, + { "togglegrabs", Action::toggleGrabs }, { "stringchain", Action::stringChain }, { "keychain", Action::keyChain }, { "numberchain", Action::numberChain },
M util/epist/screen.ccutil/epist/screen.cc

@@ -59,6 +59,7 @@ _last_active = _clients.end();

_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 @@

// 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;

@@ -251,6 +253,17 @@ case Action::showWorkspaceMenu:

_xatom->sendClientMessage(rootWindow(), XAtom::openbox_show_workspace_menu, None); return; + + case Action::toggleGrabs: { + if (_grabbed) { + ktree.ungrabDefaults(this); + _grabbed = false; + } else { + ktree.grabDefaults(this); + _grabbed = true; + } + return; + } default: break;
M util/epist/screen.hhutil/epist/screen.hh

@@ -53,6 +53,7 @@ unsigned int _active_desktop;

unsigned int _num_desktops; bool _managed; + bool _grabbed; // used for keygrab toggle function XWindow *findWindow(const XEvent &e) const; void updateNumDesktops();