you can bind buttons already about, and itll replace them

This commit is contained in:
Dana Jansens 2003-01-03 06:55:04 +00:00
parent 165601550c
commit 7db3ffecc9
5 changed files with 12 additions and 57 deletions

View file

@ -17,18 +17,10 @@ theme = "/usr/local/share/openbox/styles/nyz"
### behaviors. ###
#############################################################################
# click_focus - '1' if clicking in a client will cause it to focus in the
# default hook functions; else '0'.
click_focus = 0
# click_raise - '1' if clicking in a client will cause it to raise to the
# top of its stacking layer; else '0'.
click_raise = 0
# enter_focus - '1' if entering a client window will cause it to focus in the
# default hook functions; else '0'.
enter_focus = 1
# leave_unfocus - '1' if leaving a client window will cause it to unfocus in
# the default hook functions; else '0'.
leave_unfocus = 1
# resize_nearest - 1 to resize from the corner nearest where the mouse is, 0
# to resize always from the bottom right corner
resize_nearest = 1
print "Loaded config.py"

View file

@ -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);
}
}

View file

@ -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;
}
};

View file

@ -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);

View file

@ -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
/*!