cleanup naming in OBBindings

This commit is contained in:
Dana Jansens 2003-01-03 07:03:59 +00:00
parent 7db3ffecc9
commit 31e37b3e88
4 changed files with 38 additions and 19 deletions

View file

@ -76,7 +76,7 @@ void OBActions::buttonPressHandler(const XButtonEvent &e)
Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask); Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask);
ButtonData *data = new_button_data(e.window, e.time, state, e.button, ButtonData *data = new_button_data(e.window, e.time, state, e.button,
w->mcontext(), MousePress); w->mcontext(), MousePress);
Openbox::instance->bindings()->fire(data); Openbox::instance->bindings()->fireButton(data);
Py_DECREF((PyObject*)data); Py_DECREF((PyObject*)data);
if (_button) return; // won't count toward CLICK events if (_button) return; // won't count toward CLICK events
@ -113,7 +113,7 @@ void OBActions::buttonReleaseHandler(const XButtonEvent &e)
Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask); Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask);
ButtonData *data = new_button_data(e.window, e.time, state, e.button, ButtonData *data = new_button_data(e.window, e.time, state, e.button,
w->mcontext(), MouseClick); w->mcontext(), MouseClick);
Openbox::instance->bindings()->fire(data); Openbox::instance->bindings()->fireButton(data);
if (e.time - _release.time < DOUBLECLICKDELAY && if (e.time - _release.time < DOUBLECLICKDELAY &&
@ -121,7 +121,7 @@ void OBActions::buttonReleaseHandler(const XButtonEvent &e)
// run the DOUBLECLICK python hook // run the DOUBLECLICK python hook
data->action = MouseDoubleClick; data->action = MouseDoubleClick;
Openbox::instance->bindings()->fire(data); Openbox::instance->bindings()->fireButton(data);
// reset so you cant triple click for 2 doubleclicks // reset so you cant triple click for 2 doubleclicks
_release.win = 0; _release.win = 0;
@ -171,7 +171,7 @@ void OBActions::keyPressHandler(const XKeyEvent &e)
unsigned int state = e.state & (ControlMask | ShiftMask | Mod1Mask | unsigned int state = e.state & (ControlMask | ShiftMask | Mod1Mask |
Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask); 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, w->mcontext(), MouseMotion,
x_root, y_root, _posqueue[0]->pos, x_root, y_root, _posqueue[0]->pos,
_posqueue[0]->clientarea); _posqueue[0]->clientarea);
Openbox::instance->bindings()->fire((ButtonData*)data); Openbox::instance->bindings()->fireButton((ButtonData*)data);
Py_DECREF((PyObject*)data); Py_DECREF((PyObject*)data);
} }

View file

@ -153,7 +153,8 @@ OBBindings::OBBindings()
OBBindings::~OBBindings() OBBindings::~OBBindings()
{ {
grabKeys(false); 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; KeyBindingTree *tree;
bool conflict; 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 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) { if (_keytree.first_child) {
remove_branch(_keytree.first_child); remove_branch(_keytree.first_child);
_keytree.first_child = 0; _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) { if (key == _resetkey.key && modifiers == _resetkey.modifiers) {
reset(this); reset(this);
@ -408,6 +411,19 @@ bool OBBindings::addButton(const std::string &but, MouseContext context,
return true; 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) void OBBindings::grabButtons(bool grab, OBClient *client)
{ {
for (int i = 0; i < NUM_MOUSE_CONTEXT; ++i) { 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); printf("but.mods %d.%d\n", data->button, data->state);

View file

@ -97,19 +97,19 @@ public:
a chain or not), or if any of the strings in the keylist are invalid. 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. @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 //! Removes a key binding
/*! /*!
@return The callbackid of the binding, or '< 0' if there was no binding to @return The callbackid of the binding, or '< 0' if there was no binding to
be removed. be removed.
*/ */
bool remove(const StringVect &keylist); bool removeKey(const StringVect &keylist);
//! Removes all key bindings //! 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); void setResetKey(const std::string &key);
@ -120,7 +120,10 @@ public:
void grabButtons(bool grab, OBClient *client); void grabButtons(bool grab, OBClient *client);
void fire(ButtonData *data); //! Removes all button bindings
void removeAllButtons();
void fireButton(ButtonData *data);
}; };
} }

View file

@ -454,7 +454,7 @@ PyObject * kbind(PyObject *keylist, ob::KeyContext context, PyObject *func)
vectkeylist.push_back(PyString_AsString(str)); 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."); PyErr_SetString(PyExc_RuntimeError,"Unable to add binding.");
return NULL; return NULL;
} }
@ -479,13 +479,13 @@ PyObject * kunbind(PyObject *keylist)
vectkeylist.push_back(PyString_AsString(str)); 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; Py_INCREF(Py_None); return Py_None;
} }
void kunbind_all() void kunbind_all()
{ {
ob::Openbox::instance->bindings()->removeAll(); ob::Openbox::instance->bindings()->removeAllKeys();
} }
void set_reset_key(const std::string &key) void set_reset_key(const std::string &key)