updateTitle();
updateIconTitle();
updateClass();
+ updateStrut();
calcLayer();
changeState();
}
+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);
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
}
*/
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
//! 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();
//! 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);
}
-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;
}
+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 ;
{ (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 },
{ (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 },
#include "otk/display.hh"
#include <vector>
+#include <algorithm>
static bool running;
static int anotherWMRunning(Display *display, XErrorEvent *) {
}
-//! 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();
}
#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
/*
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,
//! 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;
//! 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();