diff options
| author | Dana Jansens <danakj@orodu.net> | 2003-01-03 06:55:04 +0000 |
|---|---|---|
| committer | Dana Jansens <danakj@orodu.net> | 2003-01-03 06:55:04 +0000 |
| commit | 7db3ffecc980821ada3e805e2471716896e2410a (patch) | |
| tree | f34e6b615325ac998351ffc574dde9dc3f4c92bf /src | |
| parent | 165601550c205d6159a41146c38c5a30884f75e7 (diff) | |
you can bind buttons already about, and itll replace them
Diffstat (limited to 'src')
| -rw-r--r-- | src/bindings.cc | 17 | ||||
| -rw-r--r-- | src/bindings.hh | 4 | ||||
| -rw-r--r-- | src/frame.cc | 29 | ||||
| -rw-r--r-- | src/frame.hh | 3 |
4 files changed, 8 insertions, 45 deletions
diff --git a/src/bindings.cc b/src/bindings.cc index 943a9acc..3e9358d5 100644 --- a/src/bindings.cc +++ b/src/bindings.cc @@ -386,11 +386,8 @@ bool OBBindings::addButton(const std::string &but, MouseContext context, for (it = _buttons[context].begin(); it != end; ++it) if ((*it)->binding.key == b.key && (*it)->binding.modifiers == b.modifiers) { - ButtonBinding::CallbackList::iterator c_it, - c_end = (*it)->callback[action].end(); - for (c_it = (*it)->callback[action].begin(); c_it != c_end; ++c_it) - if (*c_it == callback) - return true; // already bound + if ((*it)->callback[action] == callback) + return true; // already bound break; } @@ -402,11 +399,11 @@ bool OBBindings::addButton(const std::string &but, MouseContext context, bind->binding.key = b.key; bind->binding.modifiers = b.modifiers; _buttons[context].push_back(bind); - printf("adding %d.%d to %d\n", b.key, b.modifiers, context); // XXX GRAB the new button everywhere! } else bind = *it; - bind->callback[action].push_back(callback); + Py_XDECREF(bind->callback[action]); // if it was already bound, unbind it + bind->callback[action] = callback; Py_INCREF(callback); return true; } @@ -450,10 +447,8 @@ void OBBindings::fire(ButtonData *data) for (it = _buttons[data->context].begin(); it != end; ++it) if ((*it)->binding.key == data->button && (*it)->binding.modifiers == data->state) { - ButtonBinding::CallbackList::iterator c_it, - c_end = (*it)->callback[data->action].end(); - for (c_it = (*it)->callback[data->action].begin(); c_it != c_end; ++c_it) - python_callback(*c_it, (PyObject*)data); + if ((*it)->callback[data->action]) + python_callback((*it)->callback[data->action], (PyObject*)data); } } diff --git a/src/bindings.hh b/src/bindings.hh index 5d1df29b..1ca46df7 100644 --- a/src/bindings.hh +++ b/src/bindings.hh @@ -52,9 +52,9 @@ typedef struct KeyBindingTree { typedef struct ButtonBinding { Binding binding; - typedef std::list<PyObject*> CallbackList; - CallbackList callback[NUM_MOUSE_ACTION]; + PyObject *callback[NUM_MOUSE_ACTION]; ButtonBinding() : binding(0, 0) { + for(int i=0; i<NUM_MOUSE_ACTION; ++i) callback[i] = 0; } }; diff --git a/src/frame.cc b/src/frame.cc index e7f310a0..6f4bba00 100644 --- a/src/frame.cc +++ b/src/frame.cc @@ -58,44 +58,15 @@ OBFrame::OBFrame(OBClient *client, otk::Style *style) _plate.show(); // the other stuff is shown based on decor settings grabClient(); - - grabButtons(true); } OBFrame::~OBFrame() { - grabButtons(false); releaseClient(false); } -void OBFrame::grabButtons(bool grab) -{ -/* _plate.grabButtons(grab); - - // grab any requested buttons on the entire frame - std::vector<std::string> grabs; - if (python_get_stringlist("client_buttons", &grabs)) { - std::vector<std::string>::iterator grab_it, grab_end = grabs.end(); - for (grab_it = grabs.begin(); grab_it != grab_end; ++grab_it) { - Binding b; - if (!Openbox::instance->bindings()->translate(*grab_it, b, false)) - continue; - printf("grabbing %d %d\n", b.key, b.modifiers); - if (grab) { - otk::OBDisplay::grabButton(b.key, b.modifiers, _window, true, - ButtonPressMask | ButtonMotionMask | - ButtonReleaseMask, GrabModeAsync, - GrabModeAsync, _window, None, false); - } else { - otk::OBDisplay::ungrabButton(b.key, b.modifiers, _window); - } - } - }*/ -} - - void OBFrame::setTitle(const std::string &text) { _label.setText(text); diff --git a/src/frame.hh b/src/frame.hh index 7313c3a1..ab1e1b03 100644 --- a/src/frame.hh +++ b/src/frame.hh @@ -80,9 +80,6 @@ private: //! Shape the frame window to the client window void adjustShape(); - //! Grabs or ungrabs buttons on the frame - void grabButtons(bool grab); - public: //! Constructs an OBFrame object, and reparents the client to itself /*! |
