]> Dogcows Code - chaz/openbox/commitdiff
supply python routines for next/prev workspace
authorDana Jansens <danakj@orodu.net>
Tue, 7 Jan 2003 02:24:43 +0000 (02:24 +0000)
committerDana Jansens <danakj@orodu.net>
Tue, 7 Jan 2003 02:24:43 +0000 (02:24 +0000)
otk/display.cc
otk/display.hh
otk/otk_wrap.cc
scripts/builtins.py
src/actions.cc
src/bindings.cc
src/bindings.hh
src/python.cc
src/python.hh
src/screen.cc

index 3a15ff22ecb16b05a30fee590047b359ce108759..21ffcd5d85442992ec19c8bb7d987631519ffecf 100644 (file)
@@ -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)
index 0fbf2b34bf3dfe80aaf90751c0cbe2c4b5a2f460..ee8fecbd55e7ffcd68aa2172fca5e8880fe2c482 100644 (file)
@@ -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
index dc49a85b4a7cbea92169ced8fe27c41cbc7b6dc3..c8d4b60f8c9fe819896f69009764e782ad2f20c9 100644 (file)
@@ -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 },
index 64a1bc6c9641ac1f22208308bb15ea7fe5edf6e1..5d31054e556771d39e7d0be238e0b7807900b184 100644 (file)
@@ -104,6 +104,26 @@ def unshade(data):
     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 ###
index 1d4a5bb691a3ce4cbe4fbaef8dd62da6277a04fa..79b31a27630630d99adccdaccafde555c34fdf8e 100644 (file)
@@ -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);
 }
index f68dc65a2383faf3d9a00097aa573d129a243144..6e5b147e612191eb053045c12020c7b2db8da268 100644 (file)
@@ -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);
index 8a2f03e1df2371550bcd7084fbf4ed958f4bbe7d..00439e1e2713c69648ed88a209628e94fcd4b2b8 100644 (file)
@@ -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);
 
index c463fdc824d0edca37e2465a09f9cdc31757fa64..c8cf7eb86eced3ccdd497c2b948e8d947c13e8b1 100644 (file)
@@ -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;
index 2bf656d8620a4696f27c54350d1c74772636dba9..948e9a72af9b3bede62c58a802e7e645ab9819ae 100644 (file)
@@ -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);
index a7c72e2c4fff2fd956bb982fd8570d7d6e43d5a1..657705565893fa6c0e89bdb3dcb524ef2e405993 100644 (file)
@@ -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);
 
This page took 0.050043 seconds and 4 git commands to generate.