+void OBBindings::removeAllButtons()
+{
+ for (int i = i; i < NUM_MOUSE_CONTEXT; ++i) {
+ ButtonBindingList::iterator it, end = _buttons[i].end();
+ for (it = _buttons[i].begin(); it != end; ++it) {
+ for (int a = 0; a < NUM_MOUSE_ACTION; ++a) {
+ while (!(*it)->callbacks[a].empty()) {
+ Py_XDECREF((*it)->callbacks[a].front());
+ (*it)->callbacks[a].pop_front();
+ }
+ }
+ // ungrab the button on all clients
+ for (int sn = 0; sn < Openbox::instance->screenCount(); ++sn) {
+ OBScreen *s = Openbox::instance->screen(sn);
+ OBClient::List::iterator c_it, c_end = s->clients.end();
+ for (c_it = s->clients.begin(); c_it != c_end; ++c_it) {
+ grabButton(false, (*it)->binding, (MouseContext)i, *c_it);
+ }
+ }
+ }
+ }
+}
+
+void OBBindings::grabButton(bool grab, const Binding &b, MouseContext context,
+ OBClient *client)
+{
+ Window win;
+ int mode = GrabModeAsync;
+ switch(context) {
+ case MC_Frame:
+ win = client->frame->window();
+ break;
+ case MC_Window:
+ win = client->frame->plate();
+ mode = GrabModeSync; // this is handled in fireButton
+ break;
+ default:
+ // any other elements already get button events, don't grab on them
+ return;
+ }
+ if (grab)
+ otk::OBDisplay::grabButton(b.key, b.modifiers, win, false,
+ ButtonPressMask | ButtonMotionMask |
+ ButtonReleaseMask, mode, GrabModeAsync,
+ None, None, false);
+ else
+ otk::OBDisplay::ungrabButton(b.key, b.modifiers, win);
+}
+