From: Dana Jansens Date: Tue, 31 Dec 2002 09:17:16 +0000 (+0000) Subject: add click_raise global var X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=1161a90a70b21d3064a9dee62c72dd4be3025ada;p=chaz%2Fopenbox add click_raise global var --- diff --git a/scripts/clicks.py b/scripts/clicks.py index 91429d1f..c6f47d58 100644 --- a/scripts/clicks.py +++ b/scripts/clicks.py @@ -28,7 +28,8 @@ def def_press_model(action, win, type, modifiers, button, xroot, yroot, time): return if click_focus != 0: OBClient_focus(client) - print "OBClient_raise(client)" + if click_raise != 0: + print "OBClient_raise(client)" def def_click_root(action, win, type, modifiers, button, time): if type == Type_Root: diff --git a/scripts/globals.py b/scripts/globals.py index 025ba5b5..0a3389ec 100644 --- a/scripts/globals.py +++ b/scripts/globals.py @@ -18,6 +18,9 @@ client_buttons = ["A-1", "A-2", "A-3"] # click_focus - true if clicking in a client will cause it to focus in the # default hook functions click_focus = 0 +# click_raise - true if clicking in a client will cause it to raise to the +# top of its stacking layer +click_raise = 0 # enter_focus - true if entering a client window will cause it to focus in the # default hook functions enter_focus = 1 diff --git a/src/actions.cc b/src/actions.cc index cbce4f12..50259c89 100644 --- a/src/actions.cc +++ b/src/actions.cc @@ -35,16 +35,13 @@ void OBActions::buttonPressHandler(const XButtonEvent &e) { OtkEventHandler::buttonPressHandler(e); - // run the PRESS guile hook + // run the PRESS python hook OBWidget *w = dynamic_cast (Openbox::instance->findHandler(e.window)); python_callback(Action_ButtonPress, e.window, (OBWidget::WidgetType)(w ? w->type():-1), e.state, e.button, e.x_root, e.y_root, e.time); - if (w && w->type() == OBWidget::Type_Frame) // a binding - Openbox::instance->bindings()->fire(Action_ButtonPress, e.window, - e.state, e.button, e.time); if (_button) return; // won't count toward CLICK events @@ -59,13 +56,10 @@ void OBActions::buttonReleaseHandler(const XButtonEvent &e) OBWidget *w = dynamic_cast (Openbox::instance->findHandler(e.window)); - // run the RELEASE guile hook + // run the RELEASE python hook python_callback(Action_ButtonRelease, e.window, (OBWidget::WidgetType)(w ? w->type():-1), e.state, e.button, e.x_root, e.y_root, e.time); - if (w && w->type() == OBWidget::Type_Frame) // a binding - Openbox::instance->bindings()->fire(Action_ButtonRelease, e.window, - e.state, e.button, e.time); // not for the button we're watching? if (_button != e.button) return; @@ -81,24 +75,18 @@ void OBActions::buttonReleaseHandler(const XButtonEvent &e) e.x < attr.width && e.y < attr.height)) return; - // run the CLICK guile hook + // run the CLICK python hook python_callback(Action_Click, e.window, (OBWidget::WidgetType)(w ? w->type():-1), e.state, e.button, e.time); - if (w && w->type() == OBWidget::Type_Frame) // a binding - Openbox::instance->bindings()->fire(Action_Click, e.window, - e.state, e.button, e.time); if (e.time - _release.time < DOUBLECLICKDELAY && _release.win == e.window && _release.button == e.button) { - // run the DOUBLECLICK guile hook + // run the DOUBLECLICK python hook python_callback(Action_DoubleClick, e.window, (OBWidget::WidgetType)(w ? w->type():-1), e.state, e.button, e.time); - if (w && w->type() == OBWidget::Type_Frame) // a binding - Openbox::instance->bindings()->fire(Action_DoubleClick, e.window, - e.state, e.button, e.time); // reset so you cant triple click for 2 doubleclicks _release.win = 0; @@ -120,7 +108,7 @@ void OBActions::enterHandler(const XCrossingEvent &e) OBWidget *w = dynamic_cast (Openbox::instance->findHandler(e.window)); - // run the ENTER guile hook + // run the ENTER python hook python_callback(Action_EnterWindow, e.window, (OBWidget::WidgetType)(w ? w->type():-1), e.state); } @@ -133,7 +121,7 @@ void OBActions::leaveHandler(const XCrossingEvent &e) OBWidget *w = dynamic_cast (Openbox::instance->findHandler(e.window)); - // run the LEAVE guile hook + // run the LEAVE python hook python_callback(Action_LeaveWindow, e.window, (OBWidget::WidgetType)(w ? w->type():-1), e.state); } @@ -144,8 +132,7 @@ void OBActions::keyPressHandler(const XKeyEvent &e) // OBWidget *w = dynamic_cast // (Openbox::instance->findHandler(e.window)); - Openbox::instance->bindings()->fire(Action_KeyPress, e.window, - e.state, e.keycode, e.time); + Openbox::instance->bindings()->fire(e.window, e.state, e.keycode, e.time); } @@ -172,12 +159,23 @@ void OBActions::motionHandler(const XMotionEvent &e) (Openbox::instance->findHandler(e.window)); // XXX: i can envision all sorts of crazy shit with this.. gestures, etc - // maybe that should all be done via python tho.. - // run the simple MOTION guile hook for now... + // maybe that should all be done via python tho.. (or radial menus!) + // run the simple MOTION python hook for now... python_callback(Action_MouseMotion, e.window, (OBWidget::WidgetType)(w ? w->type():-1), e.state, e.x_root, e.y_root, e.time); } +void OBActions::mapRequestHandler(const XMapRequestEvent &e) +{ +} + +void OBActions::unmapHandler(const XUnmapEvent &e) +{ +} + +void OBActions::destroyHandler(const XDestroyWindowEvent &e) +{ +} } diff --git a/src/actions.hh b/src/actions.hh index f210f6ce..8b6633be 100644 --- a/src/actions.hh +++ b/src/actions.hh @@ -33,6 +33,8 @@ public: Action_LeaveWindow, Action_KeyPress, Action_MouseMotion, + Action_NewWindow, + Action_CloseWindow, NUM_ACTIONS }; @@ -67,6 +69,10 @@ public: virtual void keyPressHandler(const XKeyEvent &e); virtual void motionHandler(const XMotionEvent &e); + + virtual void mapRequestHandler(const XMapRequestEvent &e); + virtual void unmapHandler(const XUnmapEvent &e); + virtual void destroyHandler(const XDestroyWindowEvent &e); }; } diff --git a/src/bindings.cc b/src/bindings.cc index a6b91dc4..ef14d585 100644 --- a/src/bindings.cc +++ b/src/bindings.cc @@ -123,7 +123,7 @@ BindingTree *OBBindings::buildtree(const StringVect &keylist, int id) const ret = new BindingTree(id); if (!p) ret->chain = false; // only the first built node ret->first_child = p; - if (!translate(*it, ret->binding, true)) { + if (!translate(*it, ret->binding)) { destroytree(ret); ret = 0; break; @@ -134,7 +134,7 @@ BindingTree *OBBindings::buildtree(const StringVect &keylist, int id) const OBBindings::OBBindings() - : _curpos(&_keytree), _resetkey(0,0) + : _curpos(&_tree), _resetkey(0,0) { setResetKey("C-g"); // set the default reset key } @@ -151,11 +151,11 @@ void OBBindings::assimilate(BindingTree *node) { BindingTree *a, *b, *tmp, *last; - if (!_keytree.first_child) { + if (!_tree.first_child) { // there are no nodes at this level yet - _keytree.first_child = node; + _tree.first_child = node; } else { - a = _keytree.first_child; + a = _tree.first_child; last = a; b = node; while (a) { @@ -179,9 +179,9 @@ void OBBindings::assimilate(BindingTree *node) } -int OBBindings::find_key(BindingTree *search) const { +int OBBindings::find(BindingTree *search) const { BindingTree *a, *b; - a = _keytree.first_child; + a = _tree.first_child; b = search; while (a && b) { if (a->binding != b->binding) { @@ -202,14 +202,14 @@ int OBBindings::find_key(BindingTree *search) const { } -bool OBBindings::add_key(const StringVect &keylist, int id) +bool OBBindings::add(const StringVect &keylist, int id) { BindingTree *tree; if (!(tree = buildtree(keylist, id))) return false; // invalid binding requested - if (find_key(tree) != -1) { + if (find(tree) != -1) { // conflicts with another binding destroytree(tree); return false; @@ -226,7 +226,7 @@ bool OBBindings::add_key(const StringVect &keylist, int id) } -int OBBindings::find_key(const StringVect &keylist) +int OBBindings::find(const StringVect &keylist) { BindingTree *tree; bool ret; @@ -234,7 +234,7 @@ int OBBindings::find_key(const StringVect &keylist) if (!(tree = buildtree(keylist, 0))) return false; // invalid binding requested - ret = find_key(tree) >= 0; + ret = find(tree) >= 0; destroytree(tree); @@ -242,13 +242,13 @@ int OBBindings::find_key(const StringVect &keylist) } -int OBBindings::remove_key(const StringVect &keylist) +int OBBindings::remove(const StringVect &keylist) { (void)keylist; assert(false); // XXX: function not implemented yet grabKeys(false); - _curpos = &_keytree; + _curpos = &_tree; // do shit here... @@ -260,7 +260,7 @@ int OBBindings::remove_key(const StringVect &keylist) void OBBindings::setResetKey(const std::string &key) { Binding b(0, 0); - if (translate(key, b, true)) { + if (translate(key, b)) { grabKeys(false); _resetkey.key = b.key; _resetkey.modifiers = b.modifiers; @@ -285,9 +285,9 @@ static void remove_branch(BindingTree *first) void OBBindings::remove_all() { - if (_keytree.first_child) { - remove_branch(_keytree.first_child); - _keytree.first_child = 0; + if (_tree.first_child) { + remove_branch(_tree.first_child); + _tree.first_child = 0; } } @@ -325,7 +325,7 @@ void OBBindings::fire(Window window, unsigned int modifiers, unsigned int key, { if (key == _resetkey.key && modifiers == _resetkey.modifiers) { grabKeys(false); - _curpos = &_keytree; + _curpos = &_tree; grabKeys(true); } else { BindingTree *p = _curpos->first_child; @@ -336,9 +336,9 @@ void OBBindings::fire(Window window, unsigned int modifiers, unsigned int key, _curpos = p; grabKeys(true); } else { - python_callback_binding(p->id, type, window, modifiers, key, time); + python_callback_binding(p->id, window, modifiers, key, time); grabKeys(false); - _curpos = &_keytree; + _curpos = &_tree; grabKeys(true); } break; diff --git a/src/openbox.i b/src/openbox.i index 719909e2..0bfad27f 100644 --- a/src/openbox.i +++ b/src/openbox.i @@ -56,12 +56,10 @@ %rename(preregister) ob::python_preregister; %rename(unregister) ob::python_unregister; %rename(unregister_all) ob::python_unregister_all; -%rename(bind_key) ob::python_bind_key; -%rename(unbind_key) ob::python_unbind_key; -%rename(set_reset_key) ob::python_set_reset_key; -%rename(bind_mouse) ob::python_bind_mouse; -%rename(unbind_mouse) ob::python_unbind_mouse; +%rename(bind) ob::python_bind; +%rename(unbind) ob::python_unbind; %rename(unbind_all) ob::python_unbind_all; +%rename(set_reset_key) ob::python_set_reset_key; %ignore ob::OBScreen::clients; %{ diff --git a/src/openbox_wrap.cc b/src/openbox_wrap.cc index f73fb270..8539963c 100644 --- a/src/openbox_wrap.cc +++ b/src/openbox_wrap.cc @@ -645,34 +645,33 @@ SWIG_InstallConstants(PyObject *d, swig_const_info constants[]) { /* -------- TYPES TABLE (BEGIN) -------- */ -#define SWIGTYPE_p_ob__OBActions__ActionType swig_types[0] -#define SWIGTYPE_p_otk__OBTimerQueueManager swig_types[1] -#define SWIGTYPE_p_ob__Cursors swig_types[2] -#define SWIGTYPE_p_ob__OBScreen swig_types[3] -#define SWIGTYPE_p_otk__Style swig_types[4] -#define SWIGTYPE_p_ob__OBFrame swig_types[5] -#define SWIGTYPE_p_XReparentEvent swig_types[6] -#define SWIGTYPE_p_ob__OBClient swig_types[7] -#define SWIGTYPE_p_ob__Openbox swig_types[8] -#define SWIGTYPE_p_otk__Strut swig_types[9] -#define SWIGTYPE_p_XShapeEvent swig_types[10] -#define SWIGTYPE_p_XConfigureRequestEvent swig_types[11] -#define SWIGTYPE_p_otk__OtkEventHandler swig_types[12] -#define SWIGTYPE_p_otk__Rect swig_types[13] -#define SWIGTYPE_p_ob__OBWidget swig_types[14] -#define SWIGTYPE_p_XFocusChangeEvent swig_types[15] -#define SWIGTYPE_p_XClientMessageEvent swig_types[16] -#define SWIGTYPE_p_otk__OBProperty swig_types[17] -#define SWIGTYPE_p_otk__OtkEventDispatcher swig_types[18] -#define SWIGTYPE_p_XPropertyEvent swig_types[19] -#define SWIGTYPE_p_XDestroyWindowEvent swig_types[20] -#define SWIGTYPE_p_otk__BImageControl swig_types[21] -#define SWIGTYPE_p_PyObject swig_types[22] -#define SWIGTYPE_p_ob__OBBindings swig_types[23] -#define SWIGTYPE_p_ob__MwmHints swig_types[24] -#define SWIGTYPE_p_otk__Configuration swig_types[25] -#define SWIGTYPE_p_XUnmapEvent swig_types[26] -static swig_type_info *swig_types[28]; +#define SWIGTYPE_p_otk__OBTimerQueueManager swig_types[0] +#define SWIGTYPE_p_ob__Cursors swig_types[1] +#define SWIGTYPE_p_ob__OBScreen swig_types[2] +#define SWIGTYPE_p_otk__Style swig_types[3] +#define SWIGTYPE_p_ob__OBFrame swig_types[4] +#define SWIGTYPE_p_XReparentEvent swig_types[5] +#define SWIGTYPE_p_ob__OBClient swig_types[6] +#define SWIGTYPE_p_ob__Openbox swig_types[7] +#define SWIGTYPE_p_otk__Strut swig_types[8] +#define SWIGTYPE_p_XShapeEvent swig_types[9] +#define SWIGTYPE_p_XConfigureRequestEvent swig_types[10] +#define SWIGTYPE_p_otk__OtkEventHandler swig_types[11] +#define SWIGTYPE_p_otk__Rect swig_types[12] +#define SWIGTYPE_p_ob__OBWidget swig_types[13] +#define SWIGTYPE_p_XFocusChangeEvent swig_types[14] +#define SWIGTYPE_p_XClientMessageEvent swig_types[15] +#define SWIGTYPE_p_otk__OBProperty swig_types[16] +#define SWIGTYPE_p_otk__OtkEventDispatcher swig_types[17] +#define SWIGTYPE_p_XPropertyEvent swig_types[18] +#define SWIGTYPE_p_XDestroyWindowEvent swig_types[19] +#define SWIGTYPE_p_otk__BImageControl swig_types[20] +#define SWIGTYPE_p_PyObject swig_types[21] +#define SWIGTYPE_p_ob__OBBindings swig_types[22] +#define SWIGTYPE_p_ob__MwmHints swig_types[23] +#define SWIGTYPE_p_otk__Configuration swig_types[24] +#define SWIGTYPE_p_XUnmapEvent swig_types[25] +static swig_type_info *swig_types[27]; /* -------- TYPES TABLE (END) -------- */ @@ -2571,7 +2570,7 @@ static PyObject *_wrap_unregister_all(PyObject *self, PyObject *args) { } -static PyObject *_wrap_bind_key(PyObject *self, PyObject *args) { +static PyObject *_wrap_bind(PyObject *self, PyObject *args) { PyObject *resultobj; PyObject *arg1 = (PyObject *) 0 ; PyObject *arg2 = (PyObject *) 0 ; @@ -2579,10 +2578,10 @@ static PyObject *_wrap_bind_key(PyObject *self, PyObject *args) { PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; - if(!PyArg_ParseTuple(args,(char *)"OO:bind_key",&obj0,&obj1)) goto fail; + if(!PyArg_ParseTuple(args,(char *)"OO:bind",&obj0,&obj1)) goto fail; arg1 = obj0; arg2 = obj1; - result = (bool)ob::python_bind_key(arg1,arg2); + result = (bool)ob::python_bind(arg1,arg2); resultobj = PyInt_FromLong((long)result); return resultobj; @@ -2591,15 +2590,15 @@ static PyObject *_wrap_bind_key(PyObject *self, PyObject *args) { } -static PyObject *_wrap_unbind_key(PyObject *self, PyObject *args) { +static PyObject *_wrap_unbind(PyObject *self, PyObject *args) { PyObject *resultobj; PyObject *arg1 = (PyObject *) 0 ; bool result; PyObject * obj0 = 0 ; - if(!PyArg_ParseTuple(args,(char *)"O:unbind_key",&obj0)) goto fail; + if(!PyArg_ParseTuple(args,(char *)"O:unbind",&obj0)) goto fail; arg1 = obj0; - result = (bool)ob::python_unbind_key(arg1); + result = (bool)ob::python_unbind(arg1); resultobj = PyInt_FromLong((long)result); return resultobj; @@ -2632,59 +2631,6 @@ static PyObject *_wrap_set_reset_key(PyObject *self, PyObject *args) { } -static PyObject *_wrap_bind_mouse(PyObject *self, PyObject *args) { - PyObject *resultobj; - std::string *arg1 = 0 ; - PyObject *arg2 = (PyObject *) 0 ; - bool result; - std::string temp1 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - - if(!PyArg_ParseTuple(args,(char *)"OO:bind_mouse",&obj0,&obj1)) goto fail; - { - if (PyString_Check(obj0)) { - temp1 = std::string(PyString_AsString(obj0)); - arg1 = &temp1; - }else { - SWIG_exception(SWIG_TypeError, "string expected"); - } - } - arg2 = obj1; - result = (bool)ob::python_bind_mouse((std::string const &)*arg1,arg2); - - resultobj = PyInt_FromLong((long)result); - return resultobj; - fail: - return NULL; -} - - -static PyObject *_wrap_unbind_mouse(PyObject *self, PyObject *args) { - PyObject *resultobj; - std::string *arg1 = 0 ; - bool result; - std::string temp1 ; - PyObject * obj0 = 0 ; - - if(!PyArg_ParseTuple(args,(char *)"O:unbind_mouse",&obj0)) goto fail; - { - if (PyString_Check(obj0)) { - temp1 = std::string(PyString_AsString(obj0)); - arg1 = &temp1; - }else { - SWIG_exception(SWIG_TypeError, "string expected"); - } - } - result = (bool)ob::python_unbind_mouse((std::string const &)*arg1); - - resultobj = PyInt_FromLong((long)result); - return resultobj; - fail: - return NULL; -} - - static PyObject *_wrap_unbind_all(PyObject *self, PyObject *args) { PyObject *resultobj; @@ -2701,30 +2647,25 @@ static PyObject *_wrap_unbind_all(PyObject *self, PyObject *args) { static PyObject *_wrap_python_callback_binding(PyObject *self, PyObject *args) { PyObject *resultobj; int arg1 ; - ob::OBActions::ActionType arg2 ; - Window arg3 ; + Window arg2 ; + unsigned int arg3 ; unsigned int arg4 ; - unsigned int arg5 ; - Time arg6 ; - ob::OBActions::ActionType *argp2 ; + Time arg5 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; - PyObject * obj5 = 0 ; - if(!PyArg_ParseTuple(args,(char *)"iOOOOO:python_callback_binding",&arg1,&obj1,&obj2,&obj3,&obj4,&obj5)) goto fail; - if ((SWIG_ConvertPtr(obj1,(void **) &argp2, SWIGTYPE_p_ob__OBActions__ActionType,SWIG_POINTER_EXCEPTION) == -1)) SWIG_fail; - arg2 = *argp2; - arg3 = (Window) PyInt_AsLong(obj2); + if(!PyArg_ParseTuple(args,(char *)"iOOOO:python_callback_binding",&arg1,&obj1,&obj2,&obj3,&obj4)) goto fail; + arg2 = (Window) PyInt_AsLong(obj1); if (PyErr_Occurred()) SWIG_fail; - arg4 = (unsigned int) PyInt_AsLong(obj3); + arg3 = (unsigned int) PyInt_AsLong(obj2); if (PyErr_Occurred()) SWIG_fail; - arg5 = (unsigned int) PyInt_AsLong(obj4); + arg4 = (unsigned int) PyInt_AsLong(obj3); if (PyErr_Occurred()) SWIG_fail; - arg6 = (Time) PyInt_AsLong(obj5); + arg5 = (Time) PyInt_AsLong(obj4); if (PyErr_Occurred()) SWIG_fail; - ob::python_callback_binding(arg1,arg2,arg3,arg4,arg5,arg6); + ob::python_callback_binding(arg1,arg2,arg3,arg4,arg5); Py_INCREF(Py_None); resultobj = Py_None; return resultobj; @@ -2832,11 +2773,9 @@ static PyMethodDef SwigMethods[] = { { (char *)"preregister", _wrap_preregister, METH_VARARGS }, { (char *)"unregister", _wrap_unregister, METH_VARARGS }, { (char *)"unregister_all", _wrap_unregister_all, METH_VARARGS }, - { (char *)"bind_key", _wrap_bind_key, METH_VARARGS }, - { (char *)"unbind_key", _wrap_unbind_key, METH_VARARGS }, + { (char *)"bind", _wrap_bind, METH_VARARGS }, + { (char *)"unbind", _wrap_unbind, METH_VARARGS }, { (char *)"set_reset_key", _wrap_set_reset_key, METH_VARARGS }, - { (char *)"bind_mouse", _wrap_bind_mouse, METH_VARARGS }, - { (char *)"unbind_mouse", _wrap_unbind_mouse, METH_VARARGS }, { (char *)"unbind_all", _wrap_unbind_all, METH_VARARGS }, { (char *)"python_callback_binding", _wrap_python_callback_binding, METH_VARARGS }, { NULL, NULL } @@ -2857,7 +2796,6 @@ static void *_p_ob__OBClientTo_p_ob__OBWidget(void *x) { static void *_p_ob__OpenboxTo_p_otk__OtkEventDispatcher(void *x) { return (void *)((otk::OtkEventDispatcher *) ((ob::Openbox *) x)); } -static swig_type_info _swigt__p_ob__OBActions__ActionType[] = {{"_p_ob__OBActions__ActionType", 0, "ob::OBActions::ActionType *", 0},{"_p_ob__OBActions__ActionType"},{0}}; static swig_type_info _swigt__p_otk__OBTimerQueueManager[] = {{"_p_otk__OBTimerQueueManager", 0, "otk::OBTimerQueueManager *", 0},{"_p_otk__OBTimerQueueManager"},{0}}; static swig_type_info _swigt__p_ob__Cursors[] = {{"_p_ob__Cursors", 0, "ob::Cursors *", 0},{"_p_ob__Cursors"},{0}}; static swig_type_info _swigt__p_ob__OBScreen[] = {{"_p_ob__OBScreen", 0, "ob::OBScreen *", 0},{"_p_ob__OBScreen"},{0}}; @@ -2886,7 +2824,6 @@ static swig_type_info _swigt__p_otk__Configuration[] = {{"_p_otk__Configuration" static swig_type_info _swigt__p_XUnmapEvent[] = {{"_p_XUnmapEvent", 0, "XUnmapEvent *", 0},{"_p_XUnmapEvent"},{0}}; static swig_type_info *swig_types_initial[] = { -_swigt__p_ob__OBActions__ActionType, _swigt__p_otk__OBTimerQueueManager, _swigt__p_ob__Cursors, _swigt__p_ob__OBScreen, diff --git a/src/python.cc b/src/python.cc index 21158dbe..dbe35f5d 100644 --- a/src/python.cc +++ b/src/python.cc @@ -136,7 +136,7 @@ void python_callback(OBActions::ActionType action, Window window, -bool python_bind_key(PyObject *keylist, PyObject *callback) +bool python_bind(PyObject *keylist, PyObject *callback) { if (!PyList_Check(keylist)) { PyErr_SetString(PyExc_AssertionError, "Invalid keylist. Not a list."); @@ -161,7 +161,7 @@ bool python_bind_key(PyObject *keylist, PyObject *callback) // the id is what the binding class can call back with so it doesnt have to // worry about the python function pointer int id = bindfuncs.size(); - if (Openbox::instance->bindings()->add_key(vectkeylist, id)) { + if (Openbox::instance->bindings()->add(vectkeylist, id)) { Py_XINCREF(callback); // Add a reference to new callback bindfuncs.push_back(callback); return true; @@ -171,7 +171,7 @@ bool python_bind_key(PyObject *keylist, PyObject *callback) } } -bool python_unbind_key(PyObject *keylist) +bool python_unbind(PyObject *keylist) { if (!PyList_Check(keylist)) { PyErr_SetString(PyExc_AssertionError, "Invalid keylist. Not a list."); @@ -191,7 +191,7 @@ bool python_unbind_key(PyObject *keylist) int id; if ((id = - Openbox::instance->bindings()->remove_key(vectkeylist)) >= 0) { + Openbox::instance->bindings()->remove(vectkeylist)) >= 0) { assert(bindfuncs[id]); // shouldn't be able to remove it twice Py_XDECREF(bindfuncs[id]); // Dispose of previous callback // important note: we don't erase the item from the list cuz that would @@ -208,60 +208,21 @@ void python_set_reset_key(const std::string &key) Openbox::instance->bindings()->setResetKey(key); } -bool python_bind_mouse(const std::string &button, PyObject *callback) -{ - if (!PyCallable_Check(callback)) { - PyErr_SetString(PyExc_AssertionError, "Invalid callback function."); - return false; - } - - // the id is what the binding class can call back with so it doesnt have to - // worry about the python function pointer - int id = bindfuncs.size(); - if (Openbox::instance->bindings()->add_mouse(button, id)) { - Py_XINCREF(callback); // Add a reference to new callback - bindfuncs.push_back(callback); - return true; - } else { - PyErr_SetString(PyExc_AssertionError,"Unable to create binding. Invalid."); - return false; - } -} - -bool python_unbind_mouse(const std::string &button) -{ - int id; - if ((id = - Openbox::instance->bindings()->remove_mouse(button)) >= 0) { - assert(bindfuncs[id]); // shouldn't be able to remove it twice - Py_XDECREF(bindfuncs[id]); // Dispose of previous callback - // important note: we don't erase the item from the list cuz that would - // ruin all the id's that are in use. simply nullify it. - bindfuncs[id] = 0; - return true; - } - - return false; -} - void python_unbind_all() { Openbox::instance->bindings()->remove_all(); } -void python_callback_binding(int id, OBActions::ActionType action, - Window window, unsigned int state, +void python_callback_binding(int id, Window window, unsigned int state, unsigned int keybutton, Time time) { - assert(action >= 0 && action < OBActions::NUM_ACTIONS); - if (!bindfuncs[id]) return; // the key was unbound PyObject *arglist; PyObject *result; - arglist = Py_BuildValue("ilisl", action, window, state, + arglist = Py_BuildValue("lisl", window, state, XKeysymToString( XKeycodeToKeysym(otk::OBDisplay::display, keybutton, 0)), diff --git a/src/python.hh b/src/python.hh index 9279caef..a654152b 100644 --- a/src/python.hh +++ b/src/python.hh @@ -18,13 +18,13 @@ namespace ob { //! Add a python callback funtion to the back of the hook list /*! - Registering functions for KeyPress events is pointless. Use python_bind_key + Registering functions for KeyPress events is pointless. Use python_bind instead to do this. */ bool python_register(int action, PyObject *callback); //! Add a python callback funtion to the front of the hook list /*! - Registering functions for KeyPress events is pointless. Use python_bind_key + Registering functions for KeyPress events is pointless. Use python_bind instead to do this. */ bool python_preregister(int action, PyObject *callback); @@ -40,22 +40,12 @@ bool python_unregister_all(int action); "C-A-space" or "A-Button1" etc. @param callback A python function to call when the binding is used. */ -bool python_bind_key(PyObject *keylist, PyObject *callback); +bool python_bind(PyObject *keylist, PyObject *callback); -bool python_unbind_key(PyObject *keylist); +bool python_unbind(PyObject *keylist); void python_set_reset_key(const std::string &key); -//! Adds a mouse binding -/*! - Bindings do not generate motion events. You can only handle motion events by - using register to set a function for all motion events. Bindings do generate - ButtonPress, ButtonRelease, Click, and DoubleClick events. -*/ -bool python_bind_mouse(const std::string &button, PyObject *callback); - -bool python_unbind_mouse(const std::string &button); - void python_unbind_all(); //! Fire a python callback function @@ -64,8 +54,8 @@ void python_callback(OBActions::ActionType action, Window window, long d1 = LONG_MIN, long d2 = LONG_MIN, long d3 = LONG_MIN, long d4 = LONG_MIN); -void python_callback_binding(int id, OBActions::ActionType action, - Window window, unsigned int state, +//! Fire a python callback function for a key binding +void python_callback_binding(int id, Window window, unsigned int state, unsigned int keybutton, Time time); } diff --git a/src/screen.cc b/src/screen.cc index 7e9d0ea0..61869a17 100644 --- a/src/screen.cc +++ b/src/screen.cc @@ -401,9 +401,6 @@ void OBScreen::manageWindow(Window window) clients.push_back(client); // update the root properties setClientList(); - - // grab buttons on the window - Openbox::instance->bindings()->grabMouse(true, client); } @@ -411,9 +408,6 @@ void OBScreen::unmanageWindow(OBClient *client) { OBFrame *frame = client->frame; - // ungrab buttons on the window - Openbox::instance->bindings()->grabMouse(false, client); - // XXX: pass around focus if this window was focused // remove from the wm's map