supply python routines for next/prev workspace
This commit is contained in:
parent
d7cc09cebd
commit
711a7d8c56
10 changed files with 124 additions and 36 deletions
|
@ -176,6 +176,16 @@ const ScreenInfo* OBDisplay::screenInfo(int 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)
|
||||
|
|
|
@ -96,6 +96,8 @@ public:
|
|||
*/
|
||||
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
|
||||
|
|
|
@ -5497,6 +5497,25 @@ static PyObject *_wrap_OBDisplay_screenInfo(PyObject *self, PyObject *args) {
|
|||
}
|
||||
|
||||
|
||||
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 @@ static PyMethodDef SwigMethods[] = {
|
|||
{ (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 },
|
||||
|
|
|
@ -105,6 +105,26 @@ def unshade(data):
|
|||
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 ###
|
||||
#########################################
|
||||
|
|
|
@ -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,9 +216,10 @@ 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,
|
||||
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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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,
|
||||
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;
|
||||
|
|
|
@ -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,
|
||||
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(Window window, Time time, 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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue