diff options
| author | Dana Jansens <danakj@orodu.net> | 2002-12-30 22:27:46 +0000 |
|---|---|---|
| committer | Dana Jansens <danakj@orodu.net> | 2002-12-30 22:27:46 +0000 |
| commit | d7a30f93b517ac76816d0acea92e9c56ad5d6594 (patch) | |
| tree | e6453231346cea176c4ea49c2f5edd408f0400a8 /src/python.cc | |
| parent | db1fb534b8f5a1f19710ac77ef2ce85c4c1270ec (diff) | |
so close to keybindings. wont link for now.
Diffstat (limited to 'src/python.cc')
| -rw-r--r-- | src/python.cc | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/src/python.cc b/src/python.cc index ed71463c..a9b94811 100644 --- a/src/python.cc +++ b/src/python.cc @@ -16,7 +16,8 @@ static FunctionList mousefuncs; bool python_register(int action, PyObject *callback) { - if (action < 0 || action >= OBActions::NUM_ACTIONS) { + if (action < 0 || action >= OBActions::NUM_ACTIONS || + action == OBActions::Action_KeyPress) { PyErr_SetString(PyExc_AssertionError, "Invalid action type."); return false; } @@ -37,7 +38,8 @@ bool python_register(int action, PyObject *callback) bool python_preregister(int action, PyObject *callback) { - if (action < 0 || action >= OBActions::NUM_ACTIONS) { + if (action < 0 || action >= OBActions::NUM_ACTIONS || + action == OBActions::Action_KeyPress) { PyErr_SetString(PyExc_AssertionError, "Invalid action type."); return false; } @@ -58,7 +60,8 @@ bool python_preregister(int action, PyObject *callback) bool python_unregister(int action, PyObject *callback) { - if (action < 0 || action >= OBActions::NUM_ACTIONS) { + if (action < 0 || action >= OBActions::NUM_ACTIONS || + action == OBActions::Action_KeyPress) { PyErr_SetString(PyExc_AssertionError, "Invalid action type."); return false; } @@ -243,4 +246,36 @@ bool python_unbind_all() } +void python_callback_binding(int id, OBActions::ActionType action, + Window window, unsigned int state, + unsigned int keybutton, Time time) +{ + PyObject *func; + + assert(action >= 0 && action < OBActions::NUM_ACTIONS); + + if (action == OBActions::Action_KeyPress) + func = keyfuncs[id]; + else + func = mousefuncs[id]; + + if (!func) return; + + PyObject *arglist; + PyObject *result; + + arglist = Py_BuildValue("iliil", action, window, state, keybutton, time); + + // call the callback + result = PyEval_CallObject(func, arglist); + if (result) { + Py_DECREF(result); + } else { + // an exception occured in the script, display it + PyErr_Print(); + } + + Py_DECREF(arglist); +} + } |
