]> Dogcows Code - chaz/openbox/blobdiff - src/client.cc
no more configuration.hh
[chaz/openbox] / src / client.cc
index e9418cb34a8dc5bb31abe8c8af88b0f094cc32ad..f60a8da62e33882c38631cd62f3d9751ae5f6e0f 100644 (file)
@@ -895,7 +895,7 @@ void Client::setState(StateAction action, long data1, long data2)
       if (maxh != _max_horz)
         maximize(maxh, 1, true);
       else
-        maximize(maxv, 1, true);
+        maximize(maxv, 2, true);
     }
   }
   // change fullscreen state before shading, as it will affect if the window
@@ -1071,12 +1071,19 @@ void Client::internal_resize(Corner anchor, int w, int h, bool user,
   w -= _base_size.x(); 
   h -= _base_size.y();
 
-  // for interactive resizing. have to move half an increment in each
-  // direction.
-  w += _size_inc.x() / 2;
-  h += _size_inc.y() / 2;
-
   if (user) {
+    // for interactive resizing. have to move half an increment in each
+    // direction.
+    int mw = w % _size_inc.x(); // how far we are towards the next size inc
+    int mh = h % _size_inc.y();
+    int aw = _size_inc.x() / 2; // amount to add
+    int ah = _size_inc.y() / 2;
+    // don't let us move into a new size increment
+    if (mw + aw >= _size_inc.x()) aw = _size_inc.x() - mw - 1;
+    if (mh + ah >= _size_inc.y()) ah = _size_inc.y() - mh - 1;
+    w += aw;
+    h += ah;
+    
     // if this is a user-requested resize, then check against min/max sizes
     // and aspect ratios
 
@@ -1277,6 +1284,22 @@ void Client::changeAllowedActions(void)
 }
 
 
+void Client::remaximize()
+{
+  int dir;
+  if (_max_horz && _max_vert)
+    dir = 0;
+  else if (_max_horz)
+    dir = 1;
+  else if (_max_vert)
+    dir = 2;
+  else
+    return; // not maximized
+  _max_horz = _max_vert = false;
+  maximize(true, dir, false);
+}
+
+
 void Client::applyStartupState()
 {
   // these are in a carefully crafted order..
@@ -1361,13 +1384,38 @@ void Client::maximize(bool max, int dir, bool savearea)
   if (max) {
     // when maximizing, put the client where we want, NOT the frame!
     _gravity = StaticGravity;
+    // adjust our idea of position based on StaticGravity, so we stay put
+    // unless asked
+    frame->frameGravity(x, y);
 
     if (savearea) {
       long dimensions[4];
+      long *readdim;
+      unsigned long n = 4;
+
       dimensions[0] = x;
       dimensions[1] = y;
       dimensions[2] = w;
       dimensions[3] = h;
+
+      // get the property off the window and use it for the dimentions we are
+      // already maxed on
+      if (otk::Property::get(_window, otk::Property::atoms.openbox_premax,
+                             otk::Property::atoms.cardinal, &n,
+                             (long unsigned**) &readdim)) {
+        if (n >= 4) {
+          if (_max_horz) {
+            dimensions[0] = readdim[0];
+            dimensions[2] = readdim[2];
+          }
+          if (_max_vert) {
+            dimensions[1] = readdim[1];
+            dimensions[3] = readdim[3];
+          }
+        }
+        delete readdim;
+      }
+      
       otk::Property::set(_window, otk::Property::atoms.openbox_premax,
                          otk::Property::atoms.cardinal,
                          (long unsigned*)dimensions, 4);
@@ -1419,7 +1467,6 @@ void Client::maximize(bool max, int dir, bool savearea)
   changeState(); // change the state hints on the client
 
   internal_resize(TopLeft, w, h, true, x, y);
-  printf("before x %d y %d w %d h %d\n", x, y, w, h);
   _gravity = g;
   if (max) {
     // because of my little gravity trick in here, we have to set the position
@@ -1427,7 +1474,6 @@ void Client::maximize(bool max, int dir, bool savearea)
     int x, y;
     frame->frameGravity(x, y);
     _area.setPos(x, y);
-    printf("after x %d y %d w %d h %d\n", x, y, w, h);
   }
 }
 
This page took 0.024114 seconds and 4 git commands to generate.