cleanup naming in OBBindings
@@ -76,7 +76,7 @@ unsigned int state = e.state & (ControlMask | ShiftMask | Mod1Mask |
Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask); ButtonData *data = new_button_data(e.window, e.time, state, e.button, w->mcontext(), MousePress); - Openbox::instance->bindings()->fire(data); + Openbox::instance->bindings()->fireButton(data); Py_DECREF((PyObject*)data); if (_button) return; // won't count toward CLICK events@@ -113,7 +113,7 @@ unsigned int state = e.state & (ControlMask | ShiftMask | Mod1Mask |
Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask); ButtonData *data = new_button_data(e.window, e.time, state, e.button, w->mcontext(), MouseClick); - Openbox::instance->bindings()->fire(data); + Openbox::instance->bindings()->fireButton(data); if (e.time - _release.time < DOUBLECLICKDELAY &&@@ -121,7 +121,7 @@ _release.win == e.window && _release.button == e.button) {
// run the DOUBLECLICK python hook data->action = MouseDoubleClick; - Openbox::instance->bindings()->fire(data); + Openbox::instance->bindings()->fireButton(data); // reset so you cant triple click for 2 doubleclicks _release.win = 0;@@ -171,7 +171,7 @@ // (Openbox::instance->findHandler(e.window));
unsigned int state = e.state & (ControlMask | ShiftMask | Mod1Mask | Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask); - Openbox::instance->bindings()->fire(state, e.keycode, e.time); + Openbox::instance->bindings()->fireKey(state, e.keycode, e.time); }@@ -205,7 +205,7 @@ MotionData *data = new_motion_data(e.window, e.time, state, button,
w->mcontext(), MouseMotion, x_root, y_root, _posqueue[0]->pos, _posqueue[0]->clientarea); - Openbox::instance->bindings()->fire((ButtonData*)data); + Openbox::instance->bindings()->fireButton((ButtonData*)data); Py_DECREF((PyObject*)data); }
@@ -153,7 +153,8 @@
OBBindings::~OBBindings() { grabKeys(false); - removeAll(); + removeAllKeys(); + removeAllButtons(); }@@ -215,7 +216,7 @@ return 0; // it just isn't in here
} -bool OBBindings::add(const StringVect &keylist, PyObject *callback) +bool OBBindings::addKey(const StringVect &keylist, PyObject *callback) { KeyBindingTree *tree; bool conflict;@@ -242,7 +243,7 @@ return true;
} -bool OBBindings::remove(const StringVect &keylist) +bool OBBindings::removeKey(const StringVect &keylist) { assert(false); // XXX: function not implemented yet@@ -295,12 +296,14 @@ }
} -void OBBindings::removeAll() +void OBBindings::removeAllKeys() { + grabKeys(false); if (_keytree.first_child) { remove_branch(_keytree.first_child); _keytree.first_child = 0; } + grabKeys(true); }@@ -333,7 +336,7 @@ }
} -void OBBindings::fire(unsigned int modifiers, unsigned int key, Time time) +void OBBindings::fireKey(unsigned int modifiers, unsigned int key, Time time) { if (key == _resetkey.key && modifiers == _resetkey.modifiers) { reset(this);@@ -408,6 +411,19 @@ Py_INCREF(callback);
return true; } +void OBBindings::removeAllButtons() +{ + // XXX: UNGRAB shits + 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) { + Py_XDECREF((*it)->callback[a]); + (*it)->callback[a] = 0; + } + } +} + void OBBindings::grabButtons(bool grab, OBClient *client) { for (int i = 0; i < NUM_MOUSE_CONTEXT; ++i) {@@ -439,7 +455,7 @@ (*it)->binding.modifiers, win);
} } -void OBBindings::fire(ButtonData *data) +void OBBindings::fireButton(ButtonData *data) { printf("but.mods %d.%d\n", data->button, data->state);
@@ -97,19 +97,19 @@ A binding will fail to be added if the binding already exists (as part of
a chain or not), or if any of the strings in the keylist are invalid. @return true if the binding could be added; false if it could not. */ - bool add(const StringVect &keylist, PyObject *callback); + bool addKey(const StringVect &keylist, PyObject *callback); //! Removes a key binding /*! @return The callbackid of the binding, or '< 0' if there was no binding to be removed. */ - bool remove(const StringVect &keylist); + bool removeKey(const StringVect &keylist); //! Removes all key bindings - void removeAll(); + void removeAllKeys(); - void fire(unsigned int modifiers,unsigned int key, Time time); + void fireKey(unsigned int modifiers,unsigned int key, Time time); void setResetKey(const std::string &key);@@ -120,7 +120,10 @@ MouseAction action, PyObject *callback);
void grabButtons(bool grab, OBClient *client); - void fire(ButtonData *data); + //! Removes all button bindings + void removeAllButtons(); + + void fireButton(ButtonData *data); }; }
@@ -454,7 +454,7 @@ }
vectkeylist.push_back(PyString_AsString(str)); } - if (!ob::Openbox::instance->bindings()->add(vectkeylist, func)) { + if (!ob::Openbox::instance->bindings()->addKey(vectkeylist, func)) { PyErr_SetString(PyExc_RuntimeError,"Unable to add binding."); return NULL; }@@ -479,13 +479,13 @@ }
vectkeylist.push_back(PyString_AsString(str)); } - ob::Openbox::instance->bindings()->remove(vectkeylist); + ob::Openbox::instance->bindings()->removeKey(vectkeylist); Py_INCREF(Py_None); return Py_None; } void kunbind_all() { - ob::Openbox::instance->bindings()->removeAll(); + ob::Openbox::instance->bindings()->removeAllKeys(); } void set_reset_key(const std::string &key)