toggleGrabs action added
This commit is contained in:
parent
22e8615f61
commit
7cac1f19ac
5 changed files with 27 additions and 3 deletions
|
@ -89,6 +89,7 @@ public:
|
||||||
showWorkspaceMenu,
|
showWorkspaceMenu,
|
||||||
toggleDecorations,
|
toggleDecorations,
|
||||||
|
|
||||||
|
toggleGrabs,
|
||||||
stringChain,
|
stringChain,
|
||||||
keyChain,
|
keyChain,
|
||||||
numberChain,
|
numberChain,
|
||||||
|
|
|
@ -82,7 +82,7 @@ void keytree::ungrabDefaults(screen *scr)
|
||||||
{
|
{
|
||||||
ChildList::const_iterator it, end = _head->children.end();
|
ChildList::const_iterator it, end = _head->children.end();
|
||||||
for (it = _head->children.begin(); it != end; ++it)
|
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() );
|
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)
|
string key, string arg)
|
||||||
{
|
{
|
||||||
keynode *tmp = new keynode;
|
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,
|
tmp->action = new Action(action,
|
||||||
XKeysymToKeycode(_display,
|
XKeysymToKeycode(_display,
|
||||||
XStringToKeysym(key.c_str())),
|
XStringToKeysym(key.c_str())),
|
||||||
|
|
|
@ -102,6 +102,7 @@ void parser::setAction(string act)
|
||||||
{ "showrootmenu", Action::showRootMenu },
|
{ "showrootmenu", Action::showRootMenu },
|
||||||
{ "showworkspacemenu", Action::showWorkspaceMenu },
|
{ "showworkspacemenu", Action::showWorkspaceMenu },
|
||||||
{ "toggledecorations", Action::toggleDecorations },
|
{ "toggledecorations", Action::toggleDecorations },
|
||||||
|
{ "togglegrabs", Action::toggleGrabs },
|
||||||
{ "stringchain", Action::stringChain },
|
{ "stringchain", Action::stringChain },
|
||||||
{ "keychain", Action::keyChain },
|
{ "keychain", Action::keyChain },
|
||||||
{ "numberchain", Action::numberChain },
|
{ "numberchain", Action::numberChain },
|
||||||
|
|
|
@ -59,6 +59,7 @@ screen::screen(epist *epist, int number)
|
||||||
_number = number;
|
_number = number;
|
||||||
_info = _epist->getScreenInfo(_number);
|
_info = _epist->getScreenInfo(_number);
|
||||||
_root = _info->getRootWindow();
|
_root = _info->getRootWindow();
|
||||||
|
_grabbed = true;
|
||||||
|
|
||||||
// find a window manager supporting NETWM, waiting for it to load if we must
|
// find a window manager supporting NETWM, waiting for it to load if we must
|
||||||
int count = 20; // try for 20 seconds
|
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
|
// Mask out the lock modifiers. We want our keys to always work
|
||||||
// This should be made an option
|
// This should be made an option
|
||||||
unsigned int state = e.xkey.state & ~(LockMask|scrolllockMask|numlockMask);
|
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)
|
if (!it)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -252,6 +254,17 @@ void screen::handleKeypress(const XEvent &e) {
|
||||||
None);
|
None);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
case Action::toggleGrabs: {
|
||||||
|
if (_grabbed) {
|
||||||
|
ktree.ungrabDefaults(this);
|
||||||
|
_grabbed = false;
|
||||||
|
} else {
|
||||||
|
ktree.grabDefaults(this);
|
||||||
|
_grabbed = true;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,7 @@ class screen {
|
||||||
unsigned int _num_desktops;
|
unsigned int _num_desktops;
|
||||||
|
|
||||||
bool _managed;
|
bool _managed;
|
||||||
|
bool _grabbed; // used for keygrab toggle function
|
||||||
|
|
||||||
XWindow *findWindow(const XEvent &e) const;
|
XWindow *findWindow(const XEvent &e) const;
|
||||||
void updateNumDesktops();
|
void updateNumDesktops();
|
||||||
|
|
Loading…
Reference in a new issue