]> Dogcows Code - chaz/openbox/commitdiff
maximizing without bugs! can it be? i think so!
authorDana Jansens <danakj@orodu.net>
Sat, 1 Feb 2003 05:49:21 +0000 (05:49 +0000)
committerDana Jansens <danakj@orodu.net>
Sat, 1 Feb 2003 05:49:21 +0000 (05:49 +0000)
scripts/behavior.py
scripts/callbacks.py
src/client.cc

index 131cbe3f2bbab0abe7ddc96aa147896c914b0529..fa83175924a4d024fdba0f5d01688927e2286dff 100644 (file)
@@ -74,6 +74,10 @@ def setup_window_buttons():
              ob.MouseAction.Click, callbacks.iconify)
     ob.mbind("Left", ob.MouseContext.MaximizeButton,
              ob.MouseAction.Click, callbacks.toggle_maximize)
+    ob.mbind("Middle", ob.MouseContext.MaximizeButton,
+             ob.MouseAction.Click, callbacks.toggle_maximize_vert)
+    ob.mbind("Right", ob.MouseContext.MaximizeButton,
+             ob.MouseAction.Click, callbacks.toggle_maximize_horz)
 
 def setup_scroll():
     """Sets up the default behaviors for the mouse scroll wheel.
index 6d6ed51eafacace8765d01466f4708de324d98f3..07dca05efb1aacca07754d5f8eb6e8b8325cbeed 100644 (file)
@@ -131,14 +131,40 @@ def toggle_maximize(data):
     """Toggles the maximized status of the window on which the event occured"""
     state_maximize(data, StateToggle)
 
+def toggle_maximize_horz(data):
+    """Toggles the horizontal maximized status of the window on which the event
+       occured"""
+    state_maximize_horz(data, StateToggle)
+
+def toggle_maximize_vert(data):
+    """Toggles the vertical maximized status of the window on which the event
+       occured"""
+    state_maximize_vert(data, StateToggle)
+
 def maximize(data):
     """Maximizes the window on which the event occured"""
     state_maximize(data, StateAdd)
 
+def maximize_horz(data):
+    """Horizontally maximizes the window on which the event occured"""
+    state_maximize_horz(data, StateAdd)
+
+def maximize_vert(data):
+    """Vertically maximizes the window on which the event occured"""
+    state_maximize_vert(data, StateAdd)
+
 def unmaximize(data):
     """Unmaximizes the window on which the event occured"""
     state_maximize(data, StateRemove)
 
+def unmaximize_horz(data):
+    """Horizontally unmaximizes the window on which the event occured"""
+    state_maximize_horz(data, StateRemove)
+
+def unmaximize_vert(data):
+    """Vertically unmaximizes the window on which the event occured"""
+    state_maximize_vert(data, StateRemove)
+
 def toggle_shade(data):
     """Toggles the shade status of the window on which the event occured"""
     state_shaded(data, StateToggle)
index e9418cb34a8dc5bb31abe8c8af88b0f094cc32ad..55fe4c24d39454506016a97b71d089c7291eb4c8 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
@@ -1361,13 +1361,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);
@@ -1380,6 +1405,8 @@ void Client::maximize(bool max, int dir, bool savearea)
       y = a.y() + frame->size().top;
       h = a.height() - frame->size().top - frame->size().bottom;
     }
+
+    printf("dir %d x %d y %d w %d h %d\n", dir, x, y, w, h);
   } else {
     long *dimensions;
     long unsigned n = 4;
@@ -1419,7 +1446,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 +1453,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.02705 seconds and 4 git commands to generate.