+ _tree.first_child = 0;
+ }
+}
+
+
+void OBBindings::grabKeys(bool grab)
+{
+ for (int i = 0; i < Openbox::instance->screenCount(); ++i) {
+ Window root = otk::OBDisplay::screenInfo(i)->rootWindow();
+
+ BindingTree *p = _curpos->first_child;
+ while (p) {
+ if (grab) {
+ otk::OBDisplay::grabKey(p->binding.key, p->binding.modifiers,
+ root, false, GrabModeAsync, GrabModeAsync,
+ false);
+ }
+ else
+ otk::OBDisplay::ungrabKey(p->binding.key, p->binding.modifiers,
+ root);
+ p = p->next_sibling;
+ }
+
+ if (grab)
+ otk::OBDisplay::grabKey(_resetkey.key, _resetkey.modifiers,
+ root, true, GrabModeAsync, GrabModeAsync,
+ false);
+ else
+ otk::OBDisplay::ungrabKey(_resetkey.key, _resetkey.modifiers,
+ root);
+ }
+}
+
+
+void OBBindings::fire(unsigned int modifiers, unsigned int key, Time time)
+{
+ if (key == _resetkey.key && modifiers == _resetkey.modifiers) {
+ reset(this);
+ } else {
+ BindingTree *p = _curpos->first_child;
+ while (p) {
+ if (p->binding.key == key && p->binding.modifiers == modifiers) {
+ if (p->chain) {
+ _timer.start(); // start/restart the timer
+ grabKeys(false);
+ _curpos = p;
+ grabKeys(true);
+ } else {
+ Window win = None;
+ OBClient *c = Openbox::instance->focusedClient();
+ if (c) win = c->window();
+ python_callback(p->callback, win, modifiers, key, time);
+ reset(this);
+ }
+ break;
+ }
+ p = p->next_sibling;
+ }
+ }
+}
+
+void OBBindings::reset(OBBindings *self)
+{
+ self->_timer.stop();
+ self->grabKeys(false);
+ self->_curpos = &self->_tree;
+ self->grabKeys(true);