make sure windows aren't doing things they aren't allowed when their allowed actions...
authorDana Jansens <danakj@orodu.net>
Wed, 5 Feb 2003 06:44:39 +0000 (06:44 +0000)
committerDana Jansens <danakj@orodu.net>
Wed, 5 Feb 2003 06:44:39 +0000 (06:44 +0000)
remaximize windows when their decorations are changed

src/client.cc
src/client.hh

index d42a962..83fd110 100644 (file)
@@ -264,11 +264,8 @@ void Client::setupDecorAndFunctions()
         _decorations &= ~Decor_Border;
       if (! (_mwmhints.decorations & MwmDecor_Handle))
         _decorations &= ~Decor_Handle;
-      if (! (_mwmhints.decorations & MwmDecor_Title)) {
+      if (! (_mwmhints.decorations & MwmDecor_Title))
         _decorations &= ~Decor_Titlebar;
-        // if we don't have a titlebar, then we cannot shade!
-        _functions &= ~Func_Shade;
-      }
       if (! (_mwmhints.decorations & MwmDecor_Iconify))
         _decorations &= ~Decor_Iconify;
       if (! (_mwmhints.decorations & MwmDecor_Maximize))
@@ -313,16 +310,17 @@ void Client::setupDecorAndFunctions()
   if (_disabled_decorations & Decor_Close)
     _decorations &= ~Decor_Close;
 
-  // You can't shade without a titlebar
+  // if we don't have a titlebar, then we cannot shade!
   if (!(_decorations & Decor_Titlebar))
     _functions &= ~Func_Shade;
-  
+
   changeAllowedActions();
 
   if (frame) {
     frame->adjustSize(); // change the decors on the frame
     frame->adjustPosition(); // with more/less decorations, we may need to be
                              // moved
+    remaximize(); // with new decor, the window's maximized size may change
   }
 }
 
@@ -1344,6 +1342,21 @@ void Client::changeAllowedActions(void)
 
   otk::Property::set(_window, otk::Property::atoms.net_wm_allowed_actions,
                      otk::Property::atoms.atom, actions, num);
+
+  // make sure the window isn't breaking any rules now
+  
+  if (!(_functions & Func_Shade) && _shaded)
+    if (frame) shade(false);
+    else _shaded = false;
+  if (!(_functions & Func_Iconify) && _iconic)
+    if (frame) setDesktop(openbox->screen(_screen)->desktop());
+    else _iconic = false;
+  if (!(_functions & Func_Fullscreen) && _fullscreen)
+    if (frame) fullscreen(false);
+    else _fullscreen = false;
+  if (!(_functions & Func_Maximize) && (_max_horz || _max_vert))
+    if (frame) maximize(false, 0);
+    else _max_vert = _max_horz = false;
 }
 
 
index a9fe942..c17431a 100644 (file)
@@ -443,9 +443,10 @@ private:
               be returned to normal state.
     @param savearea true to have the client's current size and position saved;
                     otherwise, they are not. You should not save when mapping a
-                    new window that is set to fullscreen.
+                    new window that is set to fullscreen. This has no effect
+                    when restoring a window from fullscreen.
   */
-  void fullscreen(bool fs, bool savearea);
+  void fullscreen(bool fs, bool savearea = true);
 
   //! Maximize or unmaximize the client window
   /*!
@@ -454,9 +455,10 @@ private:
     @param dir 0 to set both horz and vert, 1 to set horz, 2 to set vert.
     @param savearea true to have the client's current size and position saved;
                     otherwise, they are not. You should not save when mapping a
-                    new window that is set to fullscreen.
+                    new window that is set to fullscreen. This has no effect
+                    when unmaximizing a window.
   */
-  void maximize(bool max, int dir, bool savearea);
+  void maximize(bool max, int dir, bool savearea = true);
 
   //! Internal version of the Client::move function
   /*!