This fixes the known bug in the previous patch (Left Half / Right Half 
Maximize).
>From 4c17b0042b286ef242824562638313840381896c Mon Sep 17 00:00:00 2001
From: klaasvakie <[email protected]>
Date: Fri, 28 Aug 2009 23:02:29 +0200
Subject: [PATCH] Fixed Windows Losing Size After Maximize

This fixes the bug introduced in the previous commit (Left Half / Right
Half Maximize).

Windows now remember their previous size after being closed while
maximized.

Also, added "tags" to .gitignore
---
 .gitignore    |    1 +
 src/actions.c |   18 +++++++++++++++---
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/.gitignore b/.gitignore
index 7f83b72..fb649bd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -20,6 +20,7 @@ src/wconfig.h
 wmlib/wmlib.pc
 wrlib/get-wraster-flags
 wrlib/wrlib.pc
+tags
 *.o
 *.lo
 WINGs/Examples/.libs/colorpick
diff --git a/src/actions.c b/src/actions.c
index 8a38f10..1cb78eb 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -361,6 +361,7 @@ void wMaximizeWindow(WWindow * wwin, int directions)
 {
        int new_x, new_y;
        unsigned int new_width, new_height;
+       int changed_h, changed_v, shrink_h, shrink_v;
        WArea usableArea, totalArea;
 
        if (!IS_RESIZABLE(wwin))
@@ -395,6 +396,11 @@ void wMaximizeWindow(WWindow * wwin, int directions)
        /* Only save directions, not kbd or xinerama hints */
        directions &= (MAX_HORIZONTAL|MAX_VERTICAL|MAX_LEFTHALF|MAX_RIGHTHALF);
 
+       changed_h = ((wwin->flags.maximized ^ directions) & MAX_HORIZONTAL);
+       changed_v = ((wwin->flags.maximized ^ directions) & MAX_VERTICAL);
+       shrink_h = (changed_h && (directions & MAX_HORIZONTAL) == 0);
+       shrink_v = (changed_v && (directions & MAX_VERTICAL) == 0);
+
        if (wwin->flags.maximized) {
                /* if already maximized in some direction, we only update the
                 * appropriate old x, old y coordinates. This is necessary to
@@ -430,10 +436,13 @@ void wMaximizeWindow(WWindow * wwin, int directions)
                if (HAS_BORDER(wwin))
                        new_width -= FRAME_BORDER_WIDTH * 2;
                new_x = usableArea.x1+((usableArea.x2 - usableArea.x1)/2);
-       } else {
+       } else if (shrink_h) {
                new_x = wwin->old_geometry.x;
                new_width = wwin->old_geometry.width;
-       }
+       } else {
+               new_x = wwin->frame_x;
+               new_width = wwin->frame->core->width;
+       } 
 
        if (directions & MAX_VERTICAL) {
                new_height = usableArea.y2 - usableArea.y1;
@@ -444,9 +453,12 @@ void wMaximizeWindow(WWindow * wwin, int directions)
                        new_y -= wwin->frame->top_width;
                        new_height += wwin->frame->bottom_width - 1;
                }
-       } else {
+       } else if (shrink_v) {
                new_y = wwin->old_geometry.y;
                new_height = wwin->old_geometry.height;
+       } else {
+               new_y = wwin->frame_y;
+               new_height = wwin->frame->core->height;
        }
 
        if (!WFLAGP(wwin, full_maximize)) {
-- 
1.6.0.3

Reply via email to