summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2003-01-07 02:24:43 +0000
committerDana Jansens <danakj@orodu.net>2003-01-07 02:24:43 +0000
commit711a7d8c5623814c374ed6f56476bc616cb9391f (patch)
treed57e347fb2a2c53aee52c5a1f9aebb6719a260b6 /src
parentd7cc09cebd23e052f230414f0ad7fb385e3cd2ef (diff)
supply python routines for next/prev workspace
Diffstat (limited to 'src')
-rw-r--r--src/actions.cc33
-rw-r--r--src/bindings.cc5
-rw-r--r--src/bindings.hh2
-rw-r--r--src/python.cc39
-rw-r--r--src/python.hh24
-rw-r--r--src/screen.cc5
6 files changed, 72 insertions, 36 deletions
diff --git a/src/actions.cc b/src/actions.cc
index 1d4a5bb6..79b31a27 100644
--- a/src/actions.cc
+++ b/src/actions.cc
@@ -74,8 +74,10 @@ void OBActions::buttonPressHandler(const XButtonEvent &e)
// kill off the Button1Mask etc, only want the modifiers
unsigned int state = e.state & (ControlMask | ShiftMask | Mod1Mask |
Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask);
- ButtonData *data = new_button_data(e.window, e.time, state, e.button,
- w->mcontext(), MousePress);
+ ButtonData *data =
+ new_button_data(otk::OBDisplay::findScreen(e.root)->screen(),
+ e.window, e.time, state, e.button, w->mcontext(),
+ MousePress);
Openbox::instance->bindings()->fireButton(data);
Py_DECREF((PyObject*)data);
@@ -112,8 +114,10 @@ void OBActions::buttonReleaseHandler(const XButtonEvent &e)
// kill off the Button1Mask etc, only want the modifiers
unsigned int state = e.state & (ControlMask | ShiftMask | Mod1Mask |
Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask);
- ButtonData *data = new_button_data(e.window, e.time, state, e.button,
- w->mcontext(), MouseClick);
+ ButtonData *data =
+ new_button_data(otk::OBDisplay::findScreen(e.root)->screen(),
+ e.window, e.time, state, e.button, w->mcontext(),
+ MouseClick);
Openbox::instance->bindings()->fireButton(data);
@@ -149,7 +153,9 @@ void OBActions::enterHandler(const XCrossingEvent &e)
OtkEventHandler::enterHandler(e);
// run the ENTER python hook
- EventData *data = new_event_data(e.window, EventEnterWindow, e.state);
+ EventData *data =
+ new_event_data(otk::OBDisplay::findScreen(e.root)->screen(),
+ e.window, EventEnterWindow, e.state);
Openbox::instance->bindings()->fireEvent(data);
Py_DECREF((PyObject*)data);
}
@@ -160,7 +166,9 @@ void OBActions::leaveHandler(const XCrossingEvent &e)
OtkEventHandler::leaveHandler(e);
// run the LEAVE python hook
- EventData *data = new_event_data(e.window, EventLeaveWindow, e.state);
+ EventData *data =
+ new_event_data(otk::OBDisplay::findScreen(e.root)->screen(),
+ e.window, EventLeaveWindow, e.state);
Openbox::instance->bindings()->fireEvent(data);
Py_DECREF((PyObject*)data);
}
@@ -173,7 +181,9 @@ void OBActions::keyPressHandler(const XKeyEvent &e)
// kill off the Button1Mask etc, only want the modifiers
unsigned int state = e.state & (ControlMask | ShiftMask | Mod1Mask |
Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask);
- Openbox::instance->bindings()->fireKey(state, e.keycode, e.time);
+ Openbox::instance->bindings()->
+ fireKey(otk::OBDisplay::findScreen(e.root)->screen(),
+ state, e.keycode, e.time);
}
@@ -206,10 +216,11 @@ void OBActions::motionHandler(const XMotionEvent &e)
unsigned int state = e.state & (ControlMask | ShiftMask | Mod1Mask |
Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask);
unsigned int button = _posqueue[0]->button;
- MotionData *data = new_motion_data(e.window, e.time, state, button,
- w->mcontext(), MouseMotion,
- x_root, y_root, _posqueue[0]->pos,
- _posqueue[0]->clientarea);
+ MotionData *data =
+ new_motion_data(otk::OBDisplay::findScreen(e.root)->screen(),
+ e.window, e.time, state, button, w->mcontext(),
+ MouseMotion, x_root, y_root, _posqueue[0]->pos,
+ _posqueue[0]->clientarea);
Openbox::instance->bindings()->fireButton((ButtonData*)data);
Py_DECREF((PyObject*)data);
}
diff --git a/src/bindings.cc b/src/bindings.cc
index f68dc65a..6e5b147e 100644
--- a/src/bindings.cc
+++ b/src/bindings.cc
@@ -359,7 +359,8 @@ void OBBindings::grabKeys(bool grab)
}
-void OBBindings::fireKey(unsigned int modifiers, unsigned int key, Time time)
+void OBBindings::fireKey(int screen, unsigned int modifiers, unsigned int key,
+ Time time)
{
if (key == _resetkey.key && modifiers == _resetkey.modifiers) {
resetChains(this);
@@ -376,7 +377,7 @@ void OBBindings::fireKey(unsigned int modifiers, unsigned int key, Time time)
Window win = None;
OBClient *c = Openbox::instance->focusedClient();
if (c) win = c->window();
- KeyData *data = new_key_data(win, time, modifiers, key);
+ KeyData *data = new_key_data(screen, win, time, modifiers, key);
CallbackList::iterator it, end = p->callbacks.end();
for (it = p->callbacks.begin(); it != end; ++it)
python_callback(*it, (PyObject*)data);
diff --git a/src/bindings.hh b/src/bindings.hh
index 8a2f03e1..00439e1e 100644
--- a/src/bindings.hh
+++ b/src/bindings.hh
@@ -111,7 +111,7 @@ public:
//! Removes all key bindings
void removeAllKeys();
- void fireKey(unsigned int modifiers,unsigned int key, Time time);
+ void fireKey(int screen, unsigned int modifiers,unsigned int key, Time time);
void setResetKey(const std::string &key);
diff --git a/src/python.cc b/src/python.cc
index c463fdc8..c8cf7eb8 100644
--- a/src/python.cc
+++ b/src/python.cc
@@ -27,6 +27,12 @@ static void dealloc(PyObject *self)
PyObject_Del(self);
}
+PyObject *MotionData_screen(MotionData *self, PyObject *args)
+{
+ if(!PyArg_ParseTuple(args,":screen")) return NULL;
+ return PyLong_FromLong(self->screen);
+}
+
PyObject *MotionData_window(MotionData *self, PyObject *args)
{
if(!PyArg_ParseTuple(args,":window")) return NULL;
@@ -124,6 +130,8 @@ PyObject *MotionData_time(MotionData *self, PyObject *args)
static PyMethodDef MotionData_methods[] = {
{"action", (PyCFunction)MotionData_action, METH_VARARGS,
"Return the action being executed."},
+ {"screen", (PyCFunction)MotionData_screen, METH_VARARGS,
+ "Return the number of the screen the event is on."},
{"window", (PyCFunction)MotionData_window, METH_VARARGS,
"Return the client window id."},
{"context", (PyCFunction)MotionData_context, METH_VARARGS,
@@ -160,6 +168,8 @@ static PyMethodDef ButtonData_methods[] = {
"Return the action being executed."},
{"context", (PyCFunction)MotionData_context, METH_VARARGS,
"Return the context that the action is occuring in."},
+ {"screen", (PyCFunction)MotionData_screen, METH_VARARGS,
+ "Return the number of the screen the event is on."},
{"window", (PyCFunction)MotionData_window, METH_VARARGS,
"Return the client window id."},
{"modifiers", (PyCFunction)MotionData_modifiers, METH_VARARGS,
@@ -184,6 +194,8 @@ PyObject *EventData_modifiers(EventData *self, PyObject *args)
}
static PyMethodDef EventData_methods[] = {
+ {"screen", (PyCFunction)MotionData_screen, METH_VARARGS,
+ "Return the number of the screen the event is on."},
{"window", (PyCFunction)MotionData_window, METH_VARARGS,
"Return the client window id."},
{"action", (PyCFunction)EventData_action, METH_VARARGS,
@@ -202,6 +214,8 @@ PyObject *KeyData_key(KeyData *self, PyObject *args)
}
static PyMethodDef KeyData_methods[] = {
+ {"screen", (PyCFunction)MotionData_screen, METH_VARARGS,
+ "Return the number of the screen the event is on."},
{"window", (PyCFunction)MotionData_window, METH_VARARGS,
"Return the client window id."},
{"modifiers", (PyCFunction)MotionData_modifiers, METH_VARARGS,
@@ -281,12 +295,14 @@ static PyTypeObject KeyData_Type = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
};
-MotionData *new_motion_data(Window window, Time time, unsigned int state,
- unsigned int button, MouseContext context,
- MouseAction action, int xroot, int yroot,
- const otk::Point &initpos, const otk::Rect &initarea)
+MotionData *new_motion_data(int screen, Window window, Time time,
+ unsigned int state, unsigned int button,
+ MouseContext context, MouseAction action,
+ int xroot, int yroot, const otk::Point &initpos,
+ const otk::Rect &initarea)
{
MotionData *data = PyObject_New(MotionData, &MotionData_Type);
+ data->screen = screen;
data->window = window;
data->time = time;
data->state = state;
@@ -304,11 +320,12 @@ MotionData *new_motion_data(Window window, Time time, unsigned int state,
return data;
}
-ButtonData *new_button_data(Window window, Time time, unsigned int state,
- unsigned int button, MouseContext context,
- MouseAction action)
+ButtonData *new_button_data(int screen, Window window, Time time,
+ unsigned int state, unsigned int button,
+ MouseContext context, MouseAction action)
{
ButtonData *data = PyObject_New(ButtonData, &ButtonData_Type);
+ data->screen = screen;
data->window = window;
data->time = time;
data->state = state;
@@ -318,20 +335,22 @@ ButtonData *new_button_data(Window window, Time time, unsigned int state,
return data;
}
-EventData *new_event_data(Window window, EventAction action,
+EventData *new_event_data(int screen, Window window, EventAction action,
unsigned int state)
{
EventData *data = PyObject_New(EventData, &EventData_Type);
+ data->screen = screen;
data->window = window;
data->action = action;
data->state = state;
return data;
}
-KeyData *new_key_data(Window window, Time time, unsigned int state,
- unsigned int key)
+KeyData *new_key_data(int screen, Window window, Time time, unsigned int state,
+ unsigned int key)
{
KeyData *data = PyObject_New(KeyData, &KeyData_Type);
+ data->screen = screen;
data->window = window;
data->time = time;
data->state = state;
diff --git a/src/python.hh b/src/python.hh
index 2bf656d8..948e9a72 100644
--- a/src/python.hh
+++ b/src/python.hh
@@ -61,6 +61,7 @@ enum EventAction {
// *** MotionData can be (and is) cast ButtonData!! (in actions.cc) *** //
typedef struct {
PyObject_HEAD;
+ int screen;
Window window;
Time time;
unsigned int state;
@@ -80,6 +81,7 @@ typedef struct {
// *** MotionData can be (and is) cast ButtonData!! (in actions.cc) *** //
typedef struct {
PyObject_HEAD;
+ int screen;
Window window;
Time time;
unsigned int state;
@@ -90,6 +92,7 @@ typedef struct {
typedef struct {
PyObject_HEAD;
+ int screen;
Window window;
unsigned int state;
EventAction action;
@@ -97,6 +100,7 @@ typedef struct {
typedef struct {
PyObject_HEAD;
+ int screen;
Window window;
Time time;
unsigned int state;
@@ -107,17 +111,17 @@ void python_init(char *argv0);
void python_destroy();
bool python_exec(const std::string &path);
-MotionData *new_motion_data(Window window, Time time, unsigned int state,
- unsigned int button, MouseContext context,
- MouseAction action, int xroot, int yroot,
- const otk::Point &initpos,
+MotionData *new_motion_data(int screen, Window window, Time time,
+ unsigned int state, unsigned int button,
+ MouseContext context, MouseAction action,
+ int xroot, int yroot, const otk::Point &initpos,
const otk::Rect &initarea);
-ButtonData *new_button_data(Window window, Time time, unsigned int state,
- unsigned int button, MouseContext context,
- MouseAction action);
-EventData *new_event_data(Window window, EventAction action,
- unsigned int state);
-KeyData *new_key_data(Window window, Time time, unsigned int state,
+ButtonData *new_button_data(int screen, Window window, Time time,
+ unsigned int state, unsigned int button,
+ MouseContext context, MouseAction action);
+EventData *new_event_data(int screen, Window window, EventAction action,
+ unsigned int state);
+KeyData *new_key_data(int screen, Window window, Time time, unsigned int state,
unsigned int key);
void python_callback(PyObject *func, PyObject *data);
diff --git a/src/screen.cc b/src/screen.cc
index a7c72e2c..65770556 100644
--- a/src/screen.cc
+++ b/src/screen.cc
@@ -532,7 +532,7 @@ void OBScreen::manageWindow(Window window)
}
// call the python NEWWINDOW binding
- EventData *data = new_event_data(window, EventNewWindow, 0);
+ EventData *data = new_event_data(_number, window, EventNewWindow, 0);
Openbox::instance->bindings()->fireEvent(data);
Py_DECREF((PyObject*)data);
@@ -545,7 +545,8 @@ void OBScreen::unmanageWindow(OBClient *client)
OBFrame *frame = client->frame;
// call the python CLOSEWINDOW binding
- EventData *data = new_event_data(client->window(), EventCloseWindow, 0);
+ EventData *data = new_event_data(_number, client->window(),
+ EventCloseWindow, 0);
Openbox::instance->bindings()->fireEvent(data);
Py_DECREF((PyObject*)data);