all repos — openbox @ 8cc271604190c5200f34ffc8fee6100759c2fc60

openbox fork - make it a bit more like ryudo

supply the same interface with optional arguments as before. increment callback functions when they are registered.
Dana Jansens danakj@orodu.net
commit

8cc271604190c5200f34ffc8fee6100759c2fc60

parent

3ca451fc00eccb2ded41cc4b02e51fd4ad0c3265

2 files changed, 13 insertions(+), 21 deletions(-)

jump to
M wrap/callback.iwrap/callback.i

@@ -6,18 +6,14 @@ Calls a python callback for the MouseCallback function type

*/ static void PythonMouseCallback(ob::MouseData *data, void *pyfunc) { - PyObject *func, *arglist, *pdata; - PyObject *result; - double dres = 0; - - func = (PyObject*) pyfunc; + PyObject *arglist, *pdata, *result; pdata = SWIG_NewPointerObj((void *) data, SWIGTYPE_p_ob__MouseData, 0); arglist = Py_BuildValue("(O)", pdata); Py_DECREF(pdata); // call the callback - result = PyEval_CallObject(func, arglist); + result = PyEval_CallObject((PyObject*)pyfunc, arglist); if (!result || PyErr_Occurred()) { // an exception occured in the script, display it PyErr_Print();

@@ -32,18 +28,14 @@ Calls a python callback for the KeyCallback function type

*/ static void PythonKeyCallback(ob::KeyData *data, void *pyfunc) { - PyObject *func, *arglist, *pdata; - PyObject *result; - double dres = 0; - - func = (PyObject*) pyfunc; + PyObject *arglist, *pdata, *result; pdata = SWIG_NewPointerObj((void *) data, SWIGTYPE_p_ob__KeyData, 0); arglist = Py_BuildValue("(O)", pdata); Py_DECREF(pdata); // call the callback - result = PyEval_CallObject(func, arglist); + result = PyEval_CallObject((PyObject*)pyfunc, arglist); if (!result || PyErr_Occurred()) { // an exception occured in the script, display it PyErr_Print();

@@ -58,18 +50,14 @@ Calls a python callback for the EventCallback function type

*/ static void PythonEventCallback(ob::EventData *data, void *pyfunc) { - PyObject *func, *arglist, *pdata; - PyObject *result; - double dres = 0; - - func = (PyObject*) pyfunc; + PyObject *arglist, *pdata, *result; pdata = SWIG_NewPointerObj((void *) data, SWIGTYPE_p_ob__EventData, 0); arglist = Py_BuildValue("(O)", pdata); Py_DECREF(pdata); // call the callback - result = PyEval_CallObject(func, arglist); + result = PyEval_CallObject((PyObject*)pyfunc, arglist); if (!result || PyErr_Occurred()) { // an exception occured in the script, display it PyErr_Print();

@@ -129,6 +117,7 @@ action, PythonMouseCallback, func)) {

PyErr_SetString(PyExc_RuntimeError,"Unable to add binding."); return false; } + Py_INCREF(func); return true; }

@@ -143,6 +132,7 @@ if (!ob::openbox->bindings()->addEvent(action, PythonEventCallback, func)) {

PyErr_SetString(PyExc_RuntimeError,"Unable to add binding."); return false; } + Py_INCREF(func); return true; }

@@ -153,6 +143,7 @@ PythonKeyCallback, func)) {

PyErr_SetString(PyExc_RuntimeError,"Unable to grab keybaord."); return false; } + Py_INCREF(func); return true; }

@@ -202,6 +193,7 @@ if (!ob::openbox->bindings()->addKey(vectkeylist, PythonKeyCallback, func)) {

PyErr_SetString(PyExc_RuntimeError,"Unable to add binding."); return false; } + Py_INCREF(func); return true; }
M wrap/ob.iwrap/ob.i

@@ -68,8 +68,8 @@ ob::openbox->bindings()->setResetKey(key);

} void send_client_msg(Window target, Atom type, Window about, - long data, long data1, long data2, - long data3, long data4) + long data=0, long data1=0, long data2=0, + long data3=0, long data4=0) { XEvent e; e.xclient.type = ClientMessage;

@@ -87,7 +87,7 @@ SubstructureRedirectMask | SubstructureNotifyMask,

&e); } -void execute(const std::string &bin, int screen) +void execute(const std::string &bin, int screen=0) { if (screen >= ScreenCount(**otk::display)) screen = 0;