X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fpython.cc;h=a89fa4677a33fe6c517175e26e9aca34d77f65ee;hb=91c7e5c378b1a639c6f5383915ed68b36b7735d4;hp=12e74eeea1b0d5f1c6effe5b8206602167b4c465;hpb=cdcc526a0274cace9f542960fe4eee4ddcc23d31;p=chaz%2Fopenbox diff --git a/src/python.cc b/src/python.cc index 12e74eee..a89fa467 100644 --- a/src/python.cc +++ b/src/python.cc @@ -34,6 +34,7 @@ void python_init(char *argv0) PyRun_SimpleString("from openbox import *;"); // set up convenience global variables PyRun_SimpleString("openbox = Openbox_instance()"); + PyRun_SimpleString("display = Display_instance()"); // set up access to the python global variables PyObject *obmodule = PyImport_AddModule("__main__"); @@ -122,6 +123,26 @@ PyObject *ebind(ob::EventAction action, PyObject *func) Py_INCREF(Py_None); return Py_None; } +PyObject *kgrab(PyObject *func) +{ + if (!PyCallable_Check(func)) { + PyErr_SetString(PyExc_TypeError, "Invalid callback function."); + return NULL; + } + + if (!ob::openbox->bindings()->grabKeyboard(func)) { + PyErr_SetString(PyExc_RuntimeError,"Unable to grab keybaord."); + return NULL; + } + Py_INCREF(Py_None); return Py_None; +} + +PyObject *kungrab() +{ + ob::openbox->bindings()->ungrabKeyboard(); + Py_INCREF(Py_None); return Py_None; +} + PyObject *kbind(PyObject *keylist, ob::KeyContext context, PyObject *func) { if (!PyCallable_Check(func)) { @@ -191,21 +212,14 @@ void set_reset_key(const std::string &key) ob::openbox->bindings()->setResetKey(key); } -PyObject *send_client_msg(Window target, int type, Window about, +PyObject *send_client_msg(Window target, Atom type, Window about, long data, long data1, long data2, long data3, long data4) { - if (type < 0 || type >= otk::Property::NUM_ATOMS) { - PyErr_SetString(PyExc_TypeError, - "Invalid atom type. Must be from otk::Property::Atoms"); - return NULL; - } - XEvent e; e.xclient.type = ClientMessage; e.xclient.format = 32; - e.xclient.message_type = - openbox->property()->atom((otk::Property::Atoms)type); + e.xclient.message_type = type; e.xclient.window = about; e.xclient.data.l[0] = data; e.xclient.data.l[1] = data1;