]> Dogcows Code - chaz/openbox/blobdiff - util/epist/keytree.cc
make epist compile with the new code base
[chaz/openbox] / util / epist / keytree.cc
index e9fa2cab49c860bd65604996eb2539f8e008ba13..94b542b0e3c057a59826e2d27520fd276101e7c5 100644 (file)
 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 // DEALINGS IN THE SOFTWARE.
 
+#ifdef    HAVE_CONFIG_H
+#  include "../../config.h"
+#endif // HAVE_CONFIG_H
+
 #include "keytree.hh"
 #include "epist.hh"
 #include "config.hh"
 
 #include <string>
+#include <iostream>
 
 using std::string;
 
@@ -80,18 +85,26 @@ void keytree::grabDefaults(screen *scr)
 
 void keytree::ungrabDefaults(screen *scr)
 {
+  Action *act;
+
   ChildList::const_iterator it, end = _head->children.end();
-  for (it = _head->children.begin(); it != end; ++it)
-    if ( (*it)->action )
-      scr->ungrabKey( (*it)->action->keycode(), (*it)->action->modifierMask() );
+  for (it = _head->children.begin(); it != end; ++it) {
+    act = (*it)->action;
+    if (act && act->type() != Action::toggleGrabs)
+      scr->ungrabKey(act->keycode(), act->modifierMask());
+  }
 }
 
 void keytree::grabChildren(keynode *node, screen *scr)
 {
+  Action *act;
+
   ChildList::const_iterator it, end = node->children.end();
-  for (it = node->children.begin(); it != end; ++it)
-    if ( (*it)->action )
-      scr->grabKey( (*it)->action->keycode(), (*it)->action->modifierMask() );
+  for (it = node->children.begin(); it != end; ++it) {
+    act = (*it)->action;
+    if (act)
+      scr->grabKey(act->keycode(), act->modifierMask());
+  }
 }
 
 void keytree::ungrabChildren(keynode *node, screen *scr)
@@ -174,10 +187,18 @@ const Action * keytree::getAction(const XEvent &e, unsigned int state,
 void keytree::addAction(Action::ActionType action, unsigned int mask,
                         string key, string arg)
 {
+  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;
+  }
+
+  KeySym sym = XStringToKeysym(key.c_str());
   keynode *tmp = new keynode;
+
   tmp->action = new Action(action,
-                           XKeysymToKeycode(_display,
-                                            XStringToKeysym(key.c_str())),
+                           XKeysymToKeycode(_display, sym),
                            mask, arg);
   tmp->parent = _current;
   _current->children.push_back(tmp);
@@ -203,16 +224,18 @@ void keytree::setCurrentNodeProps(Action::ActionType action, unsigned int mask,
 {
   if (_current->action)
     delete _current->action;
-  
+
+  KeySym sym = XStringToKeysym(key.c_str());
   _current->action = new Action(action,
-                                XKeysymToKeycode(_display,
-                                                 XStringToKeysym(key.c_str())),
+                                XKeysymToKeycode(_display, sym),
                                 mask, arg);
 }
 
 void keytree::initialize(void)
 {
-  int tval = _epist->getConfig()->getNumberValue(Config::chainTimeout);
+  int tval = 0;
+
+  _epist->getConfig()->getValue(Config::chainTimeout, tval);
   _timer = new BTimer(_epist, this);
 
   if (tval <= 0)
This page took 0.021875 seconds and 4 git commands to generate.