From: Dana Jansens Date: Fri, 3 Jan 2003 07:03:59 +0000 (+0000) Subject: cleanup naming in OBBindings X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=31e37b3e889daec26784399f6737ec9d8830e366;p=chaz%2Fopenbox cleanup naming in OBBindings --- diff --git a/src/actions.cc b/src/actions.cc index 79b9fc41..ffa0a8f0 100644 --- a/src/actions.cc +++ b/src/actions.cc @@ -76,7 +76,7 @@ void OBActions::buttonPressHandler(const XButtonEvent &e) 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 @@ void OBActions::buttonReleaseHandler(const XButtonEvent &e) 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 @@ void OBActions::buttonReleaseHandler(const XButtonEvent &e) // 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 @@ void OBActions::keyPressHandler(const XKeyEvent &e) 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 @@ void OBActions::motionHandler(const XMotionEvent &e) 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); } diff --git a/src/bindings.cc b/src/bindings.cc index 3e9358d5..d0a06fb0 100644 --- a/src/bindings.cc +++ b/src/bindings.cc @@ -153,7 +153,8 @@ OBBindings::OBBindings() OBBindings::~OBBindings() { grabKeys(false); - removeAll(); + removeAllKeys(); + removeAllButtons(); } @@ -215,7 +216,7 @@ PyObject *OBBindings::find(KeyBindingTree *search, bool *conflict) const { } -bool OBBindings::add(const StringVect &keylist, PyObject *callback) +bool OBBindings::addKey(const StringVect &keylist, PyObject *callback) { KeyBindingTree *tree; bool conflict; @@ -242,7 +243,7 @@ bool OBBindings::add(const StringVect &keylist, PyObject *callback) } -bool OBBindings::remove(const StringVect &keylist) +bool OBBindings::removeKey(const StringVect &keylist) { assert(false); // XXX: function not implemented yet @@ -295,12 +296,14 @@ static void remove_branch(KeyBindingTree *first) } -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::grabKeys(bool grab) } -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 @@ bool OBBindings::addButton(const std::string &but, MouseContext context, 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 @@ void OBBindings::grabButtons(bool grab, OBClient *client) } } -void OBBindings::fire(ButtonData *data) +void OBBindings::fireButton(ButtonData *data) { printf("but.mods %d.%d\n", data->button, data->state); diff --git a/src/bindings.hh b/src/bindings.hh index 1ca46df7..4da05836 100644 --- a/src/bindings.hh +++ b/src/bindings.hh @@ -97,19 +97,19 @@ public: 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 @@ public: void grabButtons(bool grab, OBClient *client); - void fire(ButtonData *data); + //! Removes all button bindings + void removeAllButtons(); + + void fireButton(ButtonData *data); }; } diff --git a/src/python.cc b/src/python.cc index 7ff12452..818115ca 100644 --- a/src/python.cc +++ b/src/python.cc @@ -454,7 +454,7 @@ PyObject * kbind(PyObject *keylist, ob::KeyContext context, PyObject *func) 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 @@ PyObject * kunbind(PyObject *keylist) 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)