X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fpython.cc;h=28369e9a2e1e1d5d8b62d89f926b192369cb4ba1;hb=8a7bff7a05b20b2f330c4d4e5f768a9bacb44ff9;hp=a7e2eada9e086a63aab4408b7bb172dfa2b6176c;hpb=5face4c6f35172761367f63ac0b6eaf62d84e532;p=chaz%2Fopenbox diff --git a/src/python.cc b/src/python.cc index a7e2eada..28369e9a 100644 --- a/src/python.cc +++ b/src/python.cc @@ -26,13 +26,13 @@ void python_init(char *argv0) // initialize the C python module init_otk(); init_ob(); - // include the openbox directories for python scripts in the sys path + // prepend the openbox directories for python scripts to the sys path PyRun_SimpleString("import sys"); - PyRun_SimpleString(const_cast(("sys.path.append('" + + PyRun_SimpleString("sys.path.insert(0, '" SCRIPTDIR "')"); + PyRun_SimpleString(const_cast(("sys.path.insert(0, '" + otk::expandTilde("~/.openbox/python") + "')").c_str())); - PyRun_SimpleString("sys.path.append('" SCRIPTDIR "')"); - PyRun_SimpleString("import ob; import otk;"); + PyRun_SimpleString("import ob; import otk; import config;"); // set up convenience global variables PyRun_SimpleString("ob.openbox = ob.Openbox_instance()"); PyRun_SimpleString("otk.display = otk.Display_instance()"); @@ -144,6 +144,21 @@ PyObject *kungrab() Py_INCREF(Py_None); return Py_None; } +PyObject *mgrab(int screen) +{ + if (!ob::openbox->bindings()->grabPointer(screen)) { + PyErr_SetString(PyExc_RuntimeError,"Unable to grab pointer."); + return NULL; + } + Py_INCREF(Py_None); return Py_None; +} + +PyObject *mungrab() +{ + ob::openbox->bindings()->ungrabPointer(); + Py_INCREF(Py_None); return Py_None; +} + PyObject *kbind(PyObject *keylist, ob::KeyContext::KC context, PyObject *func) { if (!PyCallable_Check(func)) {