]> Dogcows Code - chaz/openbox/commitdiff
make the 'toggle all desktops' button work
authorDana Jansens <danakj@orodu.net>
Thu, 23 Jan 2003 04:49:42 +0000 (04:49 +0000)
committerDana Jansens <danakj@orodu.net>
Thu, 23 Jan 2003 04:49:42 +0000 (04:49 +0000)
scripts/builtins.py
scripts/config.py
src/buttonwidget.cc
src/buttonwidget.hh
src/client.cc
src/frame.cc
src/frame.hh
src/openbox.py
src/openbox_wrap.cc

index 9b759e7ba12b5efc69260e85a9bc6f900d589672..b783fd63f9b5c6f6eda49bf984d1b61325ba8bb2 100644 (file)
@@ -141,19 +141,26 @@ def prev_desktop(data, no_wrap=0):
         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 @@ def setup_window_clicks():
 
 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():
index 7ffe15196a4dffa5eeb5aa892ba4c77b047e2e91..1320c581b058aa2e384e76e5d69976b4ec58c4af 100644 (file)
@@ -17,7 +17,7 @@ theme = "/usr/local/share/openbox/styles/fieron2"
 #                   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.
index eb864ba23827208ec219cbfc6b93596acc4c604f..c66778610d7d88657eff3f89391f176fd68cecbe 100644 (file)
@@ -5,16 +5,19 @@
 #endif
 
 #include "buttonwidget.hh"
-#include "otk/gccache.hh" // otk::BPen
+#include "client.hh"
 
 namespace ob {
 
 ButtonWidget::ButtonWidget(otk::Widget *parent,
-                           WidgetBase::WidgetType type)
+                           WidgetBase::WidgetType type,
+                           Client *client)
   : otk::Widget(parent),
     WidgetBase(type),
+    _client(client),
     _pressed(false),
-    _button(0)
+    _button(0),
+    _state(false)
 {
 }
 
@@ -26,6 +29,21 @@ ButtonWidget::~ButtonWidget()
 
 void ButtonWidget::setTextures()
 {
+  bool p = _pressed;
+
+  switch (type()) {
+  case Type_StickyButton:
+    if (_client->desktop() == (signed)0xffffffff)
+      p = true;
+    break;
+  case Type_MaximizeButton:
+    if (_client->maxHorz() || _client->maxVert())
+      p = true;
+    break;
+  default:
+    break;
+  }
+  
   switch (type()) {
   case Type_LeftGrip:
   case Type_RightGrip:
@@ -35,10 +53,10 @@ void ButtonWidget::setTextures()
       setTexture(_style->gripUnfocusBackground());
     break;
   case Type_StickyButton:
-  case Type_CloseButton:
   case Type_MaximizeButton:
+  case Type_CloseButton:
   case Type_IconifyButton:
-    if (_pressed) {
+    if (p) {
       if (_focused)
         setTexture(_style->buttonPressFocusBackground());
       else
@@ -77,6 +95,29 @@ void ButtonWidget::setStyle(otk::RenderStyle *style)
 }
 
 
+void ButtonWidget::update()
+{
+  switch (type()) {
+  case Type_StickyButton:
+    if ((_client->desktop() == (signed)0xffffffff) != _state) {
+      _state = !_state;
+      setTextures();
+    }
+    break;
+  case Type_MaximizeButton:
+    if ((_client->maxHorz() || _client->maxVert()) != _state) {
+      _state = !_state;
+      setTextures();
+    }
+    break;
+  default:
+    break;
+  }
+  
+  otk::Widget::update();
+}
+
+
 void ButtonWidget::renderForeground()
 {
   otk::PixmapMask *pm;
index a888a3d5226a48edf39e166f7f5a0b2b39348fdb..0d546f73fc8fc67763fc690e9bf6b0b68a43dcb9 100644 (file)
@@ -7,21 +7,28 @@
 
 namespace ob {
 
+class Client;
+
 class ButtonWidget : public otk::Widget, public WidgetBase
 {
 private:
   void setTextures();
+  Client *_client;
   bool _pressed;
   unsigned int _button;
+  bool _state;
   
 public:
-  ButtonWidget(otk::Widget *parent, WidgetBase::WidgetType type);
+  ButtonWidget(otk::Widget *parent, WidgetBase::WidgetType type,
+               Client *client);
   virtual ~ButtonWidget();
 
   virtual void setStyle(otk::RenderStyle *style);
 
   virtual void adjust();
 
+  virtual void update();
+  
   virtual void renderForeground();
   
   virtual void focus();
index 4f6fe4a21e3006a115528b5e92a04e4761c315d3..54afbc9a6d4d0cecf96491c43ec8c701d78a6685 100644 (file)
@@ -655,6 +655,8 @@ void Client::setDesktop(long target)
     frame->show();
   else
     frame->hide();
+
+  frame->adjustState();
 }
 
 
@@ -1072,6 +1074,9 @@ void Client::changeState()
                      otk::Property::atoms.atom, netstate, num);
 
   calcLayer();
+
+  if (frame)
+    frame->adjustState();
 }
 
 
index cd73f29ad1addc9db3cefec49d0776d765691d92..531db48db6cb9db830228a9469b68e7fdee4f593 100644 (file)
@@ -30,14 +30,14 @@ Frame::Frame(Client *client, otk::RenderStyle *style)
     _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);
@@ -399,6 +399,13 @@ void Frame::adjustShape()
 }
 
 
+void Frame::adjustState()
+{
+  _button_stick.update();
+  _button_max.update();
+}
+
+
 void Frame::grabClient()
 {
   // reparent the client to the frame
index 35c884fae7c1b3e766ac5da279e14a7e2d8c8c51..40c08199d012620160c25048524fb944a620f85a 100644 (file)
@@ -102,6 +102,9 @@ public:
   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.
index 2a7a8c389f06b98441aba11e76ff6f07cb70991c..ac8b0c6c3ba6505d01adf1edcba32c239f8caea9 100644 (file)
@@ -860,6 +860,7 @@ class Frame(_object):
     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)
index 5143dd1e2c4763867874ed5817588c4859132ef0..523e8451e99978d7b3f25bdfc5fa16f63eef85b9 100644 (file)
@@ -9801,6 +9801,22 @@ static PyObject *_wrap_Frame_adjustShape(PyObject *self, PyObject *args) {
 }
 
 
+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 @@ static PyMethodDef SwigMethods[] = {
         { (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 },
This page took 0.03255 seconds and 4 git commands to generate.