]> Dogcows Code - chaz/openbox/commitdiff
support net_wm_strut's! nothing to do with them yet however
authorDana Jansens <danakj@orodu.net>
Sat, 4 Jan 2003 08:02:08 +0000 (08:02 +0000)
committerDana Jansens <danakj@orodu.net>
Sat, 4 Jan 2003 08:02:08 +0000 (08:02 +0000)
src/client.cc
src/client.hh
src/openbox_wrap.cc
src/screen.cc
src/screen.hh

index ddc083fa075392e93ce7e5b56b9d0e4994abe337..a2106d867749f901fa0d78d85b3cea03af65b64c 100644 (file)
@@ -89,6 +89,7 @@ OBClient::OBClient(int screen, Window window)
   updateTitle();
   updateIconTitle();
   updateClass();
+  updateStrut();
 
   calcLayer();
   changeState();
@@ -487,6 +488,29 @@ void OBClient::updateClass()
 }
 
 
+void OBClient::updateStrut()
+{
+  unsigned long num = 4;
+  unsigned long *data;
+  if (!Openbox::instance->property()->get(_window,
+                                          otk::OBProperty::net_wm_strut,
+                                          otk::OBProperty::Atom_Cardinal,
+                                          &num, &data))
+    return;
+
+  if (num == 4) {
+    _strut.left = data[0];
+    _strut.right = data[1];
+    _strut.top = data[2];
+    _strut.bottom = data[3];
+    
+    Openbox::instance->screen(_screen)->updateStrut();
+  }
+
+  delete [] data;
+}
+
+
 void OBClient::propertyHandler(const XPropertyEvent &e)
 {
   otk::OtkEventHandler::propertyHandler(e);
@@ -519,6 +543,8 @@ void OBClient::propertyHandler(const XPropertyEvent &e)
   else if (e.atom == property->atom(otk::OBProperty::wm_protocols))
     updateProtocols();
   // XXX: transient for hint
+  else if (e.atom == property->atom(otk::OBProperty::net_wm_strut))
+    updateStrut();
   // XXX: strut hint
 }
 
index 80c6e4ee159530a5bbd7ade87663491f16ad6156..f782a3559ef4dac5984a332b8ea222c754c482a3 100644 (file)
@@ -183,6 +183,13 @@ private:
   */
   otk::Rect    _area;
 
+  //! The window's strut
+  /*!
+    The strut defines areas of the screen that are marked off-bounds for window
+    placement. In theory, where this window exists.
+  */
+  otk::Strut   _strut;
+
   //! The logical size of the window
   /*!
     The "logical" size of the window is refers to the user's perception of the
@@ -319,6 +326,8 @@ private:
   //! Updates the window's application name and class
   void updateClass();
   // XXX: updateTransientFor();
+  //! Updates the strut for the client
+  void updateStrut();
 
   //! Change the client's state hints to match the class' data
   void changeState();
@@ -425,6 +434,9 @@ public:
   //! Returns the position and size of the client relative to the root window
   inline const otk::Rect &area() const { return _area; }
 
+  //! Returns the client's strut definition
+  inline const otk::Strut &strut() const { return _strut; }
+
   //! Move the client window
   void move(int x, int y);
   
index f4212c82d30b9f7a5a42acc9f9a96182b1ba9aa9..c3d014d6e661b1eab9f380ed235de9d052865895 100644 (file)
@@ -1513,36 +1513,14 @@ static PyObject *_wrap_OBScreen_focuswindow(PyObject *self, PyObject *args) {
 }
 
 
-static PyObject *_wrap_OBScreen_addStrut(PyObject *self, PyObject *args) {
+static PyObject *_wrap_OBScreen_updateStrut(PyObject *self, PyObject *args) {
     PyObject *resultobj;
     ob::OBScreen *arg1 = (ob::OBScreen *) 0 ;
-    otk::Strut *arg2 = (otk::Strut *) 0 ;
     PyObject * obj0  = 0 ;
-    PyObject * obj1  = 0 ;
-    
-    if(!PyArg_ParseTuple(args,(char *)"OO:OBScreen_addStrut",&obj0,&obj1)) goto fail;
-    if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_ob__OBScreen,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
-    if ((SWIG_ConvertPtr(obj1,(void **) &arg2, SWIGTYPE_p_otk__Strut,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
-    (arg1)->addStrut(arg2);
-    
-    Py_INCREF(Py_None); resultobj = Py_None;
-    return resultobj;
-    fail:
-    return NULL;
-}
-
-
-static PyObject *_wrap_OBScreen_removeStrut(PyObject *self, PyObject *args) {
-    PyObject *resultobj;
-    ob::OBScreen *arg1 = (ob::OBScreen *) 0 ;
-    otk::Strut *arg2 = (otk::Strut *) 0 ;
-    PyObject * obj0  = 0 ;
-    PyObject * obj1  = 0 ;
     
-    if(!PyArg_ParseTuple(args,(char *)"OO:OBScreen_removeStrut",&obj0,&obj1)) goto fail;
+    if(!PyArg_ParseTuple(args,(char *)"O:OBScreen_updateStrut",&obj0)) goto fail;
     if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_ob__OBScreen,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
-    if ((SWIG_ConvertPtr(obj1,(void **) &arg2, SWIGTYPE_p_otk__Strut,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
-    (arg1)->removeStrut(arg2);
+    (arg1)->updateStrut();
     
     Py_INCREF(Py_None); resultobj = Py_None;
     return resultobj;
@@ -2258,6 +2236,26 @@ static PyObject *_wrap_OBClient_area(PyObject *self, PyObject *args) {
 }
 
 
+static PyObject *_wrap_OBClient_strut(PyObject *self, PyObject *args) {
+    PyObject *resultobj;
+    ob::OBClient *arg1 = (ob::OBClient *) 0 ;
+    otk::Strut *result;
+    PyObject * obj0  = 0 ;
+    
+    if(!PyArg_ParseTuple(args,(char *)"O:OBClient_strut",&obj0)) goto fail;
+    if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_ob__OBClient,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
+    {
+        otk::Strut const &_result_ref = ((ob::OBClient const *)arg1)->strut();
+        result = (otk::Strut *) &_result_ref;
+    }
+    
+    resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_otk__Strut, 0);
+    return resultobj;
+    fail:
+    return NULL;
+}
+
+
 static PyObject *_wrap_OBClient_move(PyObject *self, PyObject *args) {
     PyObject *resultobj;
     ob::OBClient *arg1 = (ob::OBClient *) 0 ;
@@ -2683,8 +2681,7 @@ static PyMethodDef SwigMethods[] = {
         { (char *)"OBScreen_area", _wrap_OBScreen_area, METH_VARARGS },
         { (char *)"OBScreen_style", _wrap_OBScreen_style, METH_VARARGS },
         { (char *)"OBScreen_focuswindow", _wrap_OBScreen_focuswindow, METH_VARARGS },
-        { (char *)"OBScreen_addStrut", _wrap_OBScreen_addStrut, METH_VARARGS },
-        { (char *)"OBScreen_removeStrut", _wrap_OBScreen_removeStrut, METH_VARARGS },
+        { (char *)"OBScreen_updateStrut", _wrap_OBScreen_updateStrut, METH_VARARGS },
         { (char *)"OBScreen_manageExisting", _wrap_OBScreen_manageExisting, METH_VARARGS },
         { (char *)"OBScreen_manageWindow", _wrap_OBScreen_manageWindow, METH_VARARGS },
         { (char *)"OBScreen_unmanageWindow", _wrap_OBScreen_unmanageWindow, METH_VARARGS },
@@ -2725,6 +2722,7 @@ static PyMethodDef SwigMethods[] = {
         { (char *)"OBClient_layer", _wrap_OBClient_layer, METH_VARARGS },
         { (char *)"OBClient_toggleClientBorder", _wrap_OBClient_toggleClientBorder, METH_VARARGS },
         { (char *)"OBClient_area", _wrap_OBClient_area, METH_VARARGS },
+        { (char *)"OBClient_strut", _wrap_OBClient_strut, METH_VARARGS },
         { (char *)"OBClient_move", _wrap_OBClient_move, METH_VARARGS },
         { (char *)"OBClient_resize", _wrap_OBClient_resize, METH_VARARGS },
         { (char *)"OBClient_close", _wrap_OBClient_close, METH_VARARGS },
index d50ef6a32a40178db2a3fc3eee4d02f9e6fc5885..bebc82d17705d59763ed827038b478b4e4e3d9b4 100644 (file)
@@ -27,6 +27,7 @@ extern "C" {
 #include "otk/display.hh"
 
 #include <vector>
+#include <algorithm>
 
 static bool running;
 static int anotherWMRunning(Display *display, XErrorEvent *) {
@@ -191,17 +192,19 @@ void OBScreen::manageExisting()
 }
 
 
-//! Adds a window's strut to the screen's list of reserved spaces
-void OBScreen::addStrut(otk::Strut *strut)
+void OBScreen::updateStrut()
 {
-  _struts.push_back(strut);
-}
-
-
-//! Removes a window's strut from the screen's list of reserved spaces
-void OBScreen::removeStrut(otk::Strut *strut)
-{
-  _struts.remove(strut);
+  _strut.left = _strut.right = _strut.top = _strut.bottom = 0;
+
+  ClientList::iterator it, end = clients.end();
+  for (it = clients.begin(); it != end; ++it) {
+    const otk::Strut &s = (*it)->strut();
+    _strut.left = std::max(_strut.left, s.left);
+    _strut.right = std::max(_strut.right, s.right);
+    _strut.top = std::max(_strut.top, s.top);
+    _strut.bottom = std::max(_strut.bottom, s.bottom);
+  }
+  calcArea();
 }
 
 
@@ -217,31 +220,9 @@ void OBScreen::calcArea()
 #endif // XINERAMA
 */
   
-  /* these values represent offsets from the screen edge
-   * we look for the biggest offset on each edge and then apply them
-   * all at once
-   * do not be confused by the similarity to the names of Rect's members
-   */
-  unsigned int current_left = 0, current_right = 0, current_top = 0,
-    current_bottom = 0;
-
-  StrutList::const_iterator it = _struts.begin(), end = _struts.end();
-
-  for(; it != end; ++it) {
-    otk::Strut *strut = *it;
-    if (strut->left > current_left)
-      current_left = strut->left;
-    if (strut->top > current_top)
-      current_top = strut->top;
-    if (strut->right > current_right)
-      current_right = strut->right;
-    if (strut->bottom > current_bottom)
-      current_bottom = strut->bottom;
-  }
-
-  _area.setRect(current_left, current_top,
-                _info->width() - (current_left + current_right),
-                _info->height() - (current_top + current_bottom));
+  _area.setRect(_strut.left, _strut.top,
+                _info->width() - (_strut.left + _strut.right),
+                _info->height() - (_strut.top + _strut.bottom));
 
 /*
 #ifdef    XINERAMA
@@ -318,9 +299,7 @@ void OBScreen::setSupportedAtoms()
 /*
       otk::OBProperty::net_wm_desktop,
 */
-/*
       otk::OBProperty::net_wm_strut,
-*/
       otk::OBProperty::net_wm_window_type,
       otk::OBProperty::net_wm_window_type_desktop,
       otk::OBProperty::net_wm_window_type_dock,
index 91cf65c3b949784d2f4d40a5e1b2f65ce703cb63..cb078082a28be8ef906389efa9700c278ecaf0ba 100644 (file)
@@ -83,8 +83,8 @@ private:
   //! Area usable for placement etc (total - struts)
   otk::Rect _area;
 
-  //! Areas of the screen reserved by applications
-  StrutList _struts;
+  //! Combined strut from all of the clients' struts
+  otk::Strut _strut;
 
   //!  An offscreen window which gets focus when nothing else has it
   Window _focuswindow;
@@ -142,10 +142,11 @@ public:
   //!  An offscreen window which gets focus when nothing else has it
   inline Window focuswindow() const { return _focuswindow; }
 
-  //! Adds a window's strut to the screen's list of reserved spaces
-  void addStrut(otk::Strut *strut);
-  //! Removes a window's strut from the screen's list of reserved spaces
-  void removeStrut(otk::Strut *strut);
+  //! Update's the screen's combined strut of all the clients.
+  /*!
+    Clients should call this whenever they change their strut.
+  */
+  void updateStrut();
 
   //! Manage any pre-existing windows on the screen
   void manageExisting();
This page took 0.035655 seconds and 4 git commands to generate.