all repos — openbox @ 7417e2b54e3a213cb47cf9454f5d4456bd03dedb

openbox fork - make it a bit more like ryudo

window shading
Dana Jansens danakj@orodu.net
commit

7417e2b54e3a213cb47cf9454f5d4456bd03dedb

parent

e6ae9e51f792e4eb3316e6b4b75bd864535d7665

5 files changed, 134 insertions(+), 4 deletions(-)

jump to
M scripts/builtins.pyscripts/builtins.py

@@ -79,4 +79,20 @@ if not client: return

screen = Openbox_screen(openbox, OBClient_screen(client)) OBScreen_restack(screen, 0, client) +def toggle_shade(data): + client = Openbox_findClient(openbox, data.window()) + if not client: return + print "toggle_shade" + OBClient_shade(client, not OBClient_shaded(client)) + +def shade(data): + client = Openbox_findClient(openbox, data.window()) + if not client: return + OBClient_shade(client, 1) + +def unshade(data): + client = Openbox_findClient(openbox, data.window()) + if not client: return + OBClient_shade(client, 0) + print "Loaded builtins.py"
M src/client.ccsrc/client.cc

@@ -249,7 +249,7 @@ {

const otk::OBProperty *property = Openbox::instance->property(); _modal = _shaded = _max_horz = _max_vert = _fullscreen = _above = _below = - false; + _skip_taskbar = _skip_pager = false; unsigned long *state; unsigned long num = (unsigned) -1;

@@ -262,6 +262,12 @@ _modal = true;

else if (state[i] == property->atom(otk::OBProperty::net_wm_state_shaded)) _shaded = true; + else if (state[i] == + property->atom(otk::OBProperty::net_wm_state_skip_taskbar)) + _skip_taskbar = true; + else if (state[i] == + property->atom(otk::OBProperty::net_wm_state_skip_pager)) + _skip_pager = true; else if (state[i] == property->atom(otk::OBProperty::net_wm_state_fullscreen)) _fullscreen = true;

@@ -565,6 +571,12 @@ action = _max_horz ? State_Remove : State_Add;

else if (state == property->atom(otk::OBProperty::net_wm_state_shaded)) action = _shaded ? State_Remove : State_Add; else if (state == + property->atom(otk::OBProperty::net_wm_state_skip_taskbar)) + action = _skip_taskbar ? State_Remove : State_Add; + else if (state == + property->atom(otk::OBProperty::net_wm_state_skip_pager)) + action = _skip_pager ? State_Remove : State_Add; + else if (state == property->atom(otk::OBProperty::net_wm_state_fullscreen)) action = _fullscreen ? State_Remove : State_Add; else if (state == property->atom(otk::OBProperty::net_wm_state_above))

@@ -593,6 +605,12 @@ property->atom(otk::OBProperty::net_wm_state_shaded)) {

if (_shaded) continue; _shaded = true; // XXX: hide the client window + } else if (state == + property->atom(otk::OBProperty::net_wm_state_skip_taskbar)) { + _skip_taskbar = true; + } else if (state == + property->atom(otk::OBProperty::net_wm_state_skip_pager)) { + _skip_pager = true; } else if (state == property->atom(otk::OBProperty::net_wm_state_fullscreen)) { if (_fullscreen) continue;

@@ -630,6 +648,12 @@ if (!_shaded) continue;

_shaded = false; // XXX: show the client window } else if (state == + property->atom(otk::OBProperty::net_wm_state_skip_taskbar)) { + _skip_taskbar = false; + } else if (state == + property->atom(otk::OBProperty::net_wm_state_skip_pager)) { + _skip_pager = false; + } else if (state == property->atom(otk::OBProperty::net_wm_state_fullscreen)) { if (!_fullscreen) continue; _fullscreen = false;

@@ -846,6 +870,57 @@ ce.xclient.data.l[2] = 0l;

ce.xclient.data.l[3] = 0l; ce.xclient.data.l[4] = 0l; XSendEvent(otk::OBDisplay::display, _window, False, NoEventMask, &ce); +} + + +void OBClient::changeState() +{ + const otk::OBProperty *property = Openbox::instance->property(); + + unsigned long state[2]; + state[0] = _wmstate; + state[1] = None; + property->set(_window, otk::OBProperty::wm_state, otk::OBProperty::wm_state, + state, 2); + + Atom netstate[10]; + int num = 0; + if (_modal) + netstate[num++] = property->atom(otk::OBProperty::net_wm_state_modal); + if (_shaded) + netstate[num++] = property->atom(otk::OBProperty::net_wm_state_shaded); + if (_iconic) + netstate[num++] = property->atom(otk::OBProperty::net_wm_state_hidden); + if (_skip_taskbar) + netstate[num++] = + property->atom(otk::OBProperty::net_wm_state_skip_taskbar); + if (_skip_pager) + netstate[num++] = property->atom(otk::OBProperty::net_wm_state_skip_pager); + if (_fullscreen) + netstate[num++] = property->atom(otk::OBProperty::net_wm_state_fullscreen); + if (_max_vert) + netstate[num++] = + property->atom(otk::OBProperty::net_wm_state_maximized_vert); + if (_max_horz) + netstate[num++] = + property->atom(otk::OBProperty::net_wm_state_maximized_horz); + if (_above) + netstate[num++] = property->atom(otk::OBProperty::net_wm_state_above); + if (_below) + netstate[num++] = property->atom(otk::OBProperty::net_wm_state_below); + property->set(_window, otk::OBProperty::net_wm_state, + otk::OBProperty::Atom_Atom, netstate, num); + +} + +void OBClient::shade(bool shade) +{ + if (shade == _shaded) return; // already done + + _wmstate = shade ? IconicState : NormalState; + _shaded = shade; + changeState(); + frame->adjustSize(); }
M src/client.hhsrc/client.hh

@@ -252,6 +252,10 @@ //! The window is maximized to fill the screen vertically

bool _max_vert; //! The window is maximized to fill the screen horizontally bool _max_horz; + //! The window should not be displayed by pagers + bool _skip_pager; + //! The window should not be displayed by taskbars + bool _skip_taskbar; //! The window is a 'fullscreen' window, and should be on top of all others bool _fullscreen; //! The window should be on top of other windows of the same type

@@ -316,6 +320,9 @@ //! Updates the window's application name and class

void updateClass(); // XXX: updateTransientFor(); + //! Change the client's state hints to match the class' data + void changeState(); + public: #ifndef SWIG //! Constructs a new OBClient object around a specified window id

@@ -433,12 +440,19 @@

//! Request the client to close its window. void close(); + //! Shades or unshades the client window + /*! + @param shade true if the window should be shaded; false if it should be + unshaded. + */ + void shade(bool shade); + //! Attempt to focus the client window bool focus(); //! Remove focus from the client window void unfocus(); - + virtual void focusHandler(const XFocusChangeEvent &e); virtual void unfocusHandler(const XFocusChangeEvent &e); virtual void propertyHandler(const XPropertyEvent &e);
M src/frame.ccsrc/frame.cc

@@ -296,8 +296,12 @@

// position/size all the windows - resize(_innersize.left + _innersize.right + _client->area().width(), - _innersize.top + _innersize.bottom + _client->area().height()); + if (_client->shaded()) + resize(_innersize.left + _innersize.right + _client->area().width(), + _titlebar.height()); + else + resize(_innersize.left + _innersize.right + _client->area().width(), + _innersize.top + _innersize.bottom + _client->area().height()); _plate.setGeometry(_innersize.left - cbwidth, _innersize.top - cbwidth, _client->area().width(), _client->area().height());
M src/openbox_wrap.ccsrc/openbox_wrap.cc

@@ -2312,6 +2312,26 @@ return NULL;

} +static PyObject *_wrap_OBClient_shade(PyObject *self, PyObject *args) { + PyObject *resultobj; + ob::OBClient *arg1 = (ob::OBClient *) 0 ; + bool arg2 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:OBClient_shade",&obj0,&obj1)) goto fail; + if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_ob__OBClient,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail; + arg2 = (bool) PyInt_AsLong(obj1); + if (PyErr_Occurred()) SWIG_fail; + (arg1)->shade(arg2); + + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + static PyObject *_wrap_OBClient_focus(PyObject *self, PyObject *args) { PyObject *resultobj; ob::OBClient *arg1 = (ob::OBClient *) 0 ;

@@ -2729,6 +2749,7 @@ { (char *)"OBClient_area", _wrap_OBClient_area, 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 }, + { (char *)"OBClient_shade", _wrap_OBClient_shade, METH_VARARGS }, { (char *)"OBClient_focus", _wrap_OBClient_focus, METH_VARARGS }, { (char *)"OBClient_unfocus", _wrap_OBClient_unfocus, METH_VARARGS }, { (char *)"OBClient_focusHandler", _wrap_OBClient_focusHandler, METH_VARARGS },