Fixing the stupid case when an invalid key is given and epist would hog the keyboard
This commit is contained in:
parent
5bb8616d44
commit
2037631f75
1 changed files with 24 additions and 10 deletions
|
@ -29,6 +29,7 @@
|
||||||
#include "config.hh"
|
#include "config.hh"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
|
@ -84,18 +85,26 @@ void keytree::grabDefaults(screen *scr)
|
||||||
|
|
||||||
void keytree::ungrabDefaults(screen *scr)
|
void keytree::ungrabDefaults(screen *scr)
|
||||||
{
|
{
|
||||||
|
Action *act;
|
||||||
|
|
||||||
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 && (*it)->action->type() != Action::toggleGrabs)
|
act = (*it)->action;
|
||||||
scr->ungrabKey( (*it)->action->keycode(), (*it)->action->modifierMask() );
|
if (act && act->type() != Action::toggleGrabs)
|
||||||
|
scr->ungrabKey(act->keycode(), act->modifierMask());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void keytree::grabChildren(keynode *node, screen *scr)
|
void keytree::grabChildren(keynode *node, screen *scr)
|
||||||
{
|
{
|
||||||
|
Action *act;
|
||||||
|
|
||||||
ChildList::const_iterator it, end = node->children.end();
|
ChildList::const_iterator it, end = node->children.end();
|
||||||
for (it = node->children.begin(); it != end; ++it)
|
for (it = node->children.begin(); it != end; ++it) {
|
||||||
if ( (*it)->action )
|
act = (*it)->action;
|
||||||
scr->grabKey( (*it)->action->keycode(), (*it)->action->modifierMask() );
|
if (act)
|
||||||
|
scr->grabKey(act->keycode(), act->modifierMask());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void keytree::ungrabChildren(keynode *node, screen *scr)
|
void keytree::ungrabChildren(keynode *node, screen *scr)
|
||||||
|
@ -178,8 +187,6 @@ const Action * keytree::getAction(const XEvent &e, unsigned int state,
|
||||||
void keytree::addAction(Action::ActionType action, unsigned int mask,
|
void keytree::addAction(Action::ActionType action, unsigned int mask,
|
||||||
string key, string arg)
|
string key, string arg)
|
||||||
{
|
{
|
||||||
keynode *tmp = new keynode;
|
|
||||||
|
|
||||||
if (action == Action::toggleGrabs && _current != _head) {
|
if (action == Action::toggleGrabs && _current != _head) {
|
||||||
// the toggleGrabs key can only be set up as a root key, since if
|
// 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
|
// it was a chain key, we'd have to not ungrab the whole chain up
|
||||||
|
@ -187,9 +194,16 @@ void keytree::addAction(Action::ActionType action, unsigned int mask,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KeySym sym = XStringToKeysym(key.c_str());
|
||||||
|
|
||||||
|
if (sym == 0) {
|
||||||
|
std::cerr << "Key " << key << " is invalid! (Action ignored)\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
keynode *tmp = new keynode;
|
||||||
tmp->action = new Action(action,
|
tmp->action = new Action(action,
|
||||||
XKeysymToKeycode(_display,
|
XKeysymToKeycode(_display, sym),
|
||||||
XStringToKeysym(key.c_str())),
|
|
||||||
mask, arg);
|
mask, arg);
|
||||||
tmp->parent = _current;
|
tmp->parent = _current;
|
||||||
_current->children.push_back(tmp);
|
_current->children.push_back(tmp);
|
||||||
|
|
Loading…
Reference in a new issue