all repos — openbox @ 711a7d8c5623814c374ed6f56476bc616cb9391f

openbox fork - make it a bit more like ryudo

supply python routines for next/prev workspace
Dana Jansens danakj@orodu.net
commit

711a7d8c5623814c374ed6f56476bc616cb9391f

parent

d7cc09cebd23e052f230414f0ad7fb385e3cd2ef

M otk/display.ccotk/display.cc

@@ -176,6 +176,16 @@ return &_screenInfoList[snum];

} +const ScreenInfo* OBDisplay::findScreen(Window root) +{ + ScreenInfoList::iterator it, end = _screenInfoList.end(); + for (it = _screenInfoList.begin(); it != end; ++it) + if (it->rootWindow() == root) + return &(*it); + return 0; +} + + void OBDisplay::grab() { if (_grab_count == 0)
M otk/display.hhotk/display.hh

@@ -96,6 +96,8 @@ @return Info on the requested screen, in a ScreenInfo class

*/ static const ScreenInfo* screenInfo(int snum); + static const ScreenInfo* findScreen(Window root); + //! Returns if the display has the shape extention available inline static bool shape() { return _shape; } //! Returns the shape extension's event base
M otk/otk_wrap.ccotk/otk_wrap.cc

@@ -5497,6 +5497,25 @@ return NULL;

} +static PyObject *_wrap_OBDisplay_findScreen(PyObject *self, PyObject *args) { + PyObject *resultobj; + Window arg1 ; + otk::ScreenInfo *result; + Window *argp1 ; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:OBDisplay_findScreen",&obj0)) goto fail; + if ((SWIG_ConvertPtr(obj0,(void **) &argp1, SWIGTYPE_p_Window,SWIG_POINTER_EXCEPTION) == -1)) SWIG_fail; + arg1 = *argp1; + result = (otk::ScreenInfo *)otk::OBDisplay::findScreen(arg1); + + resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_otk__ScreenInfo, 0); + return resultobj; + fail: + return NULL; +} + + static PyObject *_wrap_OBDisplay_shape(PyObject *self, PyObject *args) { PyObject *resultobj; bool result;

@@ -13066,6 +13085,7 @@ { (char *)"OBDisplay_initialize", _wrap_OBDisplay_initialize, METH_VARARGS },

{ (char *)"OBDisplay_destroy", _wrap_OBDisplay_destroy, METH_VARARGS }, { (char *)"OBDisplay_gcCache", _wrap_OBDisplay_gcCache, METH_VARARGS }, { (char *)"OBDisplay_screenInfo", _wrap_OBDisplay_screenInfo, METH_VARARGS }, + { (char *)"OBDisplay_findScreen", _wrap_OBDisplay_findScreen, METH_VARARGS }, { (char *)"OBDisplay_shape", _wrap_OBDisplay_shape, METH_VARARGS }, { (char *)"OBDisplay_shapeEventBase", _wrap_OBDisplay_shapeEventBase, METH_VARARGS }, { (char *)"OBDisplay_xinerama", _wrap_OBDisplay_xinerama, METH_VARARGS },
M scripts/builtins.pyscripts/builtins.py

@@ -104,6 +104,26 @@ """Unshades the window on which the event occured"""

client = Openbox_findClient(openbox, data.window()) if not client: return OBClient_shade(client, 0) + +def next_desktop(data): + screen = Openbox_screen(openbox, data.screen()) + d = OBScreen_desktop(screen) + n = OBScreen_numDesktops(screen) + if (d == (n-1)): + d = 0 + else: + d = d + 1 + OBScreen_changeDesktop(screen, d) + +def prev_desktop(data): + screen = Openbox_screen(openbox, data.screen()) + d = OBScreen_desktop(screen) + n = OBScreen_numDesktops(screen) + if (d > 0): + d = d - 1 + else: + d = n - 1 + OBScreen_changeDesktop(screen, d) ######################################### ### Convenience functions for scripts ###
M src/actions.ccsrc/actions.cc

@@ -74,8 +74,10 @@

// 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 @@ // run the CLICK python hook

// 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 @@ {

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 @@ {

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 @@

// 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 @@ // kill off the Button1Mask etc, only want the modifiers

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); }
M src/bindings.ccsrc/bindings.cc

@@ -359,7 +359,8 @@ }

} -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 @@ } else {

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);
M src/bindings.hhsrc/bindings.hh

@@ -111,7 +111,7 @@

//! 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);
M src/python.ccsrc/python.cc

@@ -27,6 +27,12 @@ {

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 @@

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 @@ {"action", (PyCFunction)MotionData_action, METH_VARARGS,

"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 @@ return PyLong_FromUnsignedLong(self->state);

} 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 @@

} 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 @@ (getattrfunc)KeyDataGetAttr,

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 @@ data->press_clientheight = initarea.height();

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 @@ data->action = action;

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;
M src/python.hhsrc/python.hh

@@ -61,6 +61,7 @@

// *** 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 @@

// *** 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 @@ } ButtonData;

typedef struct { PyObject_HEAD; + int screen; Window window; unsigned int state; EventAction action;

@@ -97,6 +100,7 @@ } EventData;

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);
M src/screen.ccsrc/screen.cc

@@ -532,7 +532,7 @@ client->focus();

} // 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 @@ {

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);