make the 'toggle all desktops' button work
Dana Jansens danakj@orodu.net
9 files changed,
109 insertions(+),
20 deletions(-)
M
scripts/builtins.py
→
scripts/builtins.py
@@ -141,19 +141,26 @@ elif not no_wrap:
d = n - 1 change_desktop(data, d) -def send_to_all_desktops(data): - """Sends a client to all desktops""" - if not data.client: return - send_client_msg(display.screenInfo(data.screen).rootWindow(), - Property_atoms().net_wm_desktop, data.client.window(), - 0xffffffff) - def send_to_desktop(data, num): """Sends a client to a specified desktop""" if not data.client: return send_client_msg(display.screenInfo(data.screen).rootWindow(), Property_atoms().net_wm_desktop, data.client.window(), num) +def toggle_all_desktops(data): + """Toggles between sending a client to all desktops and to the current + desktop.""" + if not data.client: return + if not data.client.desktop() == 0xffffffff: + send_to_desktop(data, 0xffffffff) + else: + send_to_desktop(data, openbox.screen(data.screen).desktop()) + +def send_to_all_desktops(data): + """Sends a client to all desktops""" + if not data.client: return + send_to_desktop(data, 0xffffffff) + def send_to_next_desktop(data, no_wrap=0, follow=1): """Sends a window to the next desktop, optionally (by default) cycling around to the first when going past the last. Also optionally moving to@@ -255,6 +262,7 @@ mbind("Left", MC_Titlebar, MouseDoubleClick, toggle_shade)
def setup_window_buttons(): """Sets up the default behaviors for the buttons in the window titlebar.""" + mbind("Left", MC_StickyButton, MouseClick, toggle_all_desktops) mbind("Left", MC_CloseButton, MouseClick, close) def setup_scroll():
M
scripts/config.py
→
scripts/config.py
@@ -17,7 +17,7 @@ # I - iconify button, L - text label, M - maximize button,
# S - sticky button, C - close button # If no 'L' is included in the string, one will be added to # the end by Openbox. -titlebar_layout = "ILC" +titlebar_layout = "ILMC" # double_click_delay - the number of milliseconds in which 2 clicks are # perceived as a double-click.
M
src/client.cc
→
src/client.cc
@@ -655,6 +655,8 @@ _desktop == (signed)0xffffffff)
frame->show(); else frame->hide(); + + frame->adjustState(); }@@ -1072,6 +1074,9 @@ otk::Property::set(_window, otk::Property::atoms.net_wm_state,
otk::Property::atoms.atom, netstate, num); calcLayer(); + + if (frame) + frame->adjustState(); }
M
src/frame.cc
→
src/frame.cc
@@ -30,14 +30,14 @@ _client(client),
_screen(otk::display->screenInfo(client->screen())), _plate(this, WidgetBase::Type_Plate), _titlebar(this, WidgetBase::Type_Titlebar), - _button_close(&_titlebar, WidgetBase::Type_CloseButton), - _button_iconify(&_titlebar, WidgetBase::Type_IconifyButton), - _button_max(&_titlebar, WidgetBase::Type_MaximizeButton), - _button_stick(&_titlebar, WidgetBase::Type_StickyButton), + _button_close(&_titlebar, WidgetBase::Type_CloseButton, client), + _button_iconify(&_titlebar, WidgetBase::Type_IconifyButton, client), + _button_max(&_titlebar, WidgetBase::Type_MaximizeButton, client), + _button_stick(&_titlebar, WidgetBase::Type_StickyButton, client), _label(&_titlebar, WidgetBase::Type_Label), _handle(this, WidgetBase::Type_Handle), - _grip_left(&_handle, WidgetBase::Type_LeftGrip), - _grip_right(&_handle, WidgetBase::Type_RightGrip), + _grip_left(&_handle, WidgetBase::Type_LeftGrip, client), + _grip_right(&_handle, WidgetBase::Type_RightGrip, client), _decorations(client->decorations()) { assert(client);@@ -396,6 +396,13 @@ ShapeBounding, 0, 0, xrect, num,
ShapeUnion, Unsorted); } #endif // SHAPE +} + + +void Frame::adjustState() +{ + _button_stick.update(); + _button_max.update(); }
M
src/frame.hh
→
src/frame.hh
@@ -102,6 +102,9 @@ //! Update the frame's position to match the client
void adjustPosition(); //! Shape the frame window to the client window void adjustShape(); + //! Update the frame to match the client's new state (for things like toggle + //! buttons) + void adjustState(); //! Applies gravity to the client's position to find where the frame should //! be positioned.
M
src/openbox.py
→
src/openbox.py
@@ -860,6 +860,7 @@ def releaseClient(*args): return apply(_openbox.Frame_releaseClient,args)
def adjustSize(*args): return apply(_openbox.Frame_adjustSize,args) def adjustPosition(*args): return apply(_openbox.Frame_adjustPosition,args) def adjustShape(*args): return apply(_openbox.Frame_adjustShape,args) + def adjustState(*args): return apply(_openbox.Frame_adjustState,args) def clientGravity(*args): return apply(_openbox.Frame_clientGravity,args) def frameGravity(*args): return apply(_openbox.Frame_frameGravity,args) def plate(*args): return apply(_openbox.Frame_plate,args)
M
src/openbox_wrap.cc
→
src/openbox_wrap.cc
@@ -9801,6 +9801,22 @@ return NULL;
} +static PyObject *_wrap_Frame_adjustState(PyObject *self, PyObject *args) { + PyObject *resultobj; + ob::Frame *arg1 = (ob::Frame *) 0 ; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Frame_adjustState",&obj0)) goto fail; + if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_ob__Frame,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail; + (arg1)->adjustState(); + + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + static PyObject *_wrap_Frame_clientGravity(PyObject *self, PyObject *args) { PyObject *resultobj; ob::Frame *arg1 = (ob::Frame *) 0 ;@@ -11699,6 +11715,7 @@ { (char *)"Frame_releaseClient", _wrap_Frame_releaseClient, METH_VARARGS },
{ (char *)"Frame_adjustSize", _wrap_Frame_adjustSize, METH_VARARGS }, { (char *)"Frame_adjustPosition", _wrap_Frame_adjustPosition, METH_VARARGS }, { (char *)"Frame_adjustShape", _wrap_Frame_adjustShape, METH_VARARGS }, + { (char *)"Frame_adjustState", _wrap_Frame_adjustState, METH_VARARGS }, { (char *)"Frame_clientGravity", _wrap_Frame_clientGravity, METH_VARARGS }, { (char *)"Frame_frameGravity", _wrap_Frame_frameGravity, METH_VARARGS }, { (char *)"Frame_plate", _wrap_Frame_plate, METH_VARARGS },