more fixes, better sanity detection and error messages. it shouldn't hog the keyboard in any case now. it won't grab when modifiers or keys are borked.

This commit is contained in:
Marius Nita 2002-10-14 05:03:15 +00:00
parent 2037631f75
commit 8ea3db574a
3 changed files with 21 additions and 19 deletions

View file

@ -195,13 +195,8 @@ void keytree::addAction(Action::ActionType action, unsigned int mask,
} }
KeySym sym = XStringToKeysym(key.c_str()); KeySym sym = XStringToKeysym(key.c_str());
if (sym == 0) {
std::cerr << "Key " << key << " is invalid! (Action ignored)\n";
return;
}
keynode *tmp = new keynode; keynode *tmp = new keynode;
tmp->action = new Action(action, tmp->action = new Action(action,
XKeysymToKeycode(_display, sym), XKeysymToKeycode(_display, sym),
mask, arg); mask, arg);
@ -230,9 +225,9 @@ void keytree::setCurrentNodeProps(Action::ActionType action, unsigned int mask,
if (_current->action) if (_current->action)
delete _current->action; delete _current->action;
KeySym sym = XStringToKeysym(key.c_str());
_current->action = new Action(action, _current->action = new Action(action,
XKeysymToKeycode(_display, XKeysymToKeycode(_display, sym),
XStringToKeysym(key.c_str())),
mask, arg); mask, arg);
} }

View file

@ -61,6 +61,18 @@ void parser::parse(string rc_file)
_kt->initialize(); _kt->initialize();
} }
void parser::setKey(string key)
{
KeySym sym = XStringToKeysym(key.c_str());
if (sym == 0) {
std::cerr << "ERROR: Invalid key (" << key << ")! This may cause odd behavior.\n";
_add = false;
} else {
_key = key;
}
}
void parser::setAction(string act) void parser::setAction(string act)
{ {
struct { struct {
@ -189,14 +201,11 @@ void parser::endChain()
void parser::setChainBinding() void parser::setChainBinding()
{ {
if (_mask != 0 && _key != "") { if (_add)
if (!_add) {
cout << "Error: Bad modifier detected on chain's root key.\n";
_add = true;
}
_kt->setCurrentNodeProps(Action::noaction, _mask, _key, ""); _kt->setCurrentNodeProps(Action::noaction, _mask, _key, "");
_add = true;
reset(); reset();
}
} }
void parser::reset() void parser::reset()

View file

@ -36,9 +36,6 @@ public:
void parse(std::string); void parse(std::string);
void setKey(std::string key)
{ _key = key; }
void setArgumentNum(std::string arg) void setArgumentNum(std::string arg)
{ _arg = arg; } { _arg = arg; }
@ -57,6 +54,7 @@ public:
void setOption(std::string opt) void setOption(std::string opt)
{ _config->addOption(opt, _arg); } { _config->addOption(opt, _arg); }
void setKey(std::string);
void setAction(std::string); void setAction(std::string);
void addModifier(std::string); void addModifier(std::string);
void endAction(); void endAction();