X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=src%2Fbindings.cc;h=7c13ca64f9eba8e3290817a14eb9b7f51e8a7726;hb=7a95b5a949e590745a5a9a878e1386e7bd7d1b72;hp=108a4ef08eb322f546d74049938bdcabc347d1f6;hpb=2a40cebfdc5b0f282b04855f6b5f7ecce07ba4d3;p=chaz%2Fopenbox diff --git a/src/bindings.cc b/src/bindings.cc index 108a4ef0..7c13ca64 100644 --- a/src/bindings.cc +++ b/src/bindings.cc @@ -387,14 +387,11 @@ void OBBindings::fireKey(int screen, unsigned int modifiers, unsigned int key, grabKeys(true); otk::OBDisplay::ungrab(); } else { - Window win = None; OBClient *c = Openbox::instance->focusedClient(); - if (c) win = c->window(); - KeyData *data = new_key_data(screen, win, time, modifiers, key); + KeyData data(screen, c, time, modifiers, key); CallbackList::iterator it, end = p->callbacks.end(); for (it = p->callbacks.begin(); it != end; ++it) - python_callback(*it, (PyObject*)data); - Py_XDECREF((PyObject*)data); + python_callback(*it, &data); resetChains(this); } break; @@ -485,23 +482,26 @@ void OBBindings::grabButton(bool grab, const Binding &b, MouseContext context, { Window win; int mode = GrabModeAsync; + unsigned int mask; switch(context) { case MC_Frame: win = client->frame->window(); + mask = ButtonPressMask | ButtonMotionMask | ButtonReleaseMask; break; case MC_Window: win = client->frame->plate(); mode = GrabModeSync; // this is handled in fireButton + mask = ButtonPressMask; // can't catch more than this with Sync mode + // the release event is manufactured by the + // master buttonPressHandler 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); + otk::OBDisplay::grabButton(b.key, b.modifiers, win, false, mask, mode, + GrabModeAsync, None, None, false); else otk::OBDisplay::ungrabButton(b.key, b.modifiers, win); } @@ -515,11 +515,10 @@ void OBBindings::grabButtons(bool grab, OBClient *client) } } -void OBBindings::fireButton(ButtonData *data) +void OBBindings::fireButton(MouseData *data) { if (data->context == MC_Window) { - // these are grabbed in Sync mode to allow the press to be normal to the - // client + // Replay the event, so it goes to the client, and ungrab the device. XAllowEvents(otk::OBDisplay::display, ReplayPointer, data->time); } @@ -530,7 +529,7 @@ void OBBindings::fireButton(ButtonData *data) CallbackList::iterator c_it,c_end = (*it)->callbacks[data->action].end(); for (c_it = (*it)->callbacks[data->action].begin(); c_it != c_end; ++c_it) - python_callback(*c_it, (PyObject*)data); + python_callback(*c_it, data); } } @@ -540,7 +539,11 @@ bool OBBindings::addEvent(EventAction action, PyObject *callback) if (action < 0 || action >= NUM_EVENTS) { return false; } - +#ifdef XKB + if (action == EventBell && _eventlist[action].empty()) + XkbSelectEvents(otk::OBDisplay::display, XkbUseCoreKbd, + XkbBellNotifyMask, XkbBellNotifyMask); +#endif // XKB _eventlist[action].push_back(callback); Py_INCREF(callback); return true; @@ -558,6 +561,11 @@ bool OBBindings::removeEvent(EventAction action, PyObject *callback) if (it != _eventlist[action].end()) { Py_XDECREF(*it); _eventlist[action].erase(it); +#ifdef XKB + if (action == EventBell && _eventlist[action].empty()) + XkbSelectEvents(otk::OBDisplay::display, XkbUseCoreKbd, + XkbBellNotifyMask, 0); +#endif // XKB return true; } return false; @@ -577,7 +585,7 @@ void OBBindings::fireEvent(EventData *data) { CallbackList::iterator c_it, c_end = _eventlist[data->action].end(); for (c_it = _eventlist[data->action].begin(); c_it != c_end; ++c_it) - python_callback(*c_it, (PyObject*)data); + python_callback(*c_it, data); } }