+
+void OBBindings::grabMouse(bool grab, const OBClient *client)
+{
+ BindingTree *p = _mousetree;
+ while (p) {
+ if (grab)
+ otk::OBDisplay::grabButton(p->binding.key, p->binding.modifiers,
+ client->frame->window(), false,
+ ButtonMotionMask | ButtonPressMask |
+ ButtonReleaseMask, GrabModeAsync,
+ GrabModeAsync, None, None, false);
+ else
+ otk::OBDisplay::ungrabButton(p->binding.key, p->binding.modifiers,
+ client->frame->window());
+ p = p->next_sibling;
+ }
+}
+
+
+void OBBindings::grabMouseOnAll(bool grab)
+{
+ for (int i = 0; i < Openbox::instance->screenCount(); ++i) {
+ OBScreen *s = Openbox::instance->screen(i);
+ assert(s);
+ OBScreen::ClientList::iterator it, end = s->clients.end();
+ for (it = s->clients.begin(); it != end; ++it)
+ grabMouse(grab, *it);
+ }
+}
+
+
+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;
+ }
+ }
+}
+
+
+void OBBindings::fire(OBActions::ActionType type, Window window,
+ unsigned int modifiers, unsigned int key, Time time)
+{
+ if (type == OBActions::Action_KeyPress) {
+ BindingTree *p = _curpos->first_child;
+ while (p) {
+ if (p->binding.key == key && p->binding.modifiers == modifiers) {
+ if (p->chain) {
+ grabKeys(false);
+ _curpos = p;
+ grabKeys(true);
+ } else {
+ python_callback_binding(p->id, type, window, modifiers, key, time);
+ _curpos = &_keytree;
+ }
+ break;
+ }
+ p = p->next_sibling;
+ }
+
+ assert(false);
+ } else {
+ BindingTree *p = _mousetree;
+ while (p) {
+ if (p->binding.key == key && p->binding.modifiers == modifiers) {
+ python_callback_binding(p->id, type, window, modifiers, key, time);
+ break;
+ }
+ p = p->next_sibling;
+ }
+ }
+}
+
+