Fix for the bug reported by Paul Seelig whereby windows drift when Window Maker is restarted. This patch builds on b657f15344f193d70747689f96cefddc8baa2181 which is already in next.
From 614fe5887bc2d38f8d115b791dbaca09e6e4cf5e Mon Sep 17 00:00:00 2001
From: Iain Patterson <w...@iain.cx>
Date: Thu, 15 Nov 2012 16:55:52 -0800
Subject: [PATCH] Prevent windows from drifting on restart.

Bug report from Paul Seelig:

"Yet another rather strange glitch:

- open three terminal windows
- repeatedly restart wmaker
- all windows slowly drift to the left and up by just a few pixels

If i remember correctly, this is also a longstanding issue and nothing
new. It is no showstopper either, as one rarely restarts wmaker."

The slight drifting left and up seems to have been due to
wWindowConfigure() accounting for the window border when placing, which
was fixed in an earlier commit.

Windows could still shuffle down, however, because wWindowConfigure()
was moving the window down to make room for its window frame.
We now move it up by the titlebar height to cancel out that movement.
---
 src/window.c | 28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/src/window.c b/src/window.c
index 9970c1a..b07d9d4 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1144,11 +1144,7 @@ WWindow *wManageWindow(WScreen *scr, Window window)
                        y -= wwin->frame->top_width + wwin->frame->bottom_width;
        }
 
-       /* wWindowConfigure() will account for the window border
-        * when placing so the window would be shifted without
-        * the adjustment below
-        */
-       if (HAS_BORDER(wwin)) {
+       {
                WMRect rect;
                WArea usableArea;
                int head;
@@ -1161,10 +1157,24 @@ WWindow *wManageWindow(WScreen *scr, Window window)
                head = wGetHeadForRect(scr, rect);
                usableArea = wGetUsableAreaForHead(scr, head, NULL, True);
 
-               if (x >= usableArea.x1 + 2 * FRAME_BORDER_WIDTH)
-                       x -= 2 * FRAME_BORDER_WIDTH;
-               if (y >= usableArea.y1 + 2 * FRAME_BORDER_WIDTH)
-                       y -= 2 * FRAME_BORDER_WIDTH;
+               /* wWindowConfigure() will account for the frame
+                * when placing so the window would be shifted without
+                * the adjustment below
+                */
+
+               if (y >= usableArea.y1 + wwin->frame->top_width)
+                       y -= wwin->frame->top_width;
+
+               /* wWindowConfigure() will account for the window border
+                * when placing so the window would be shifted without
+                * the adjustment below
+                */
+               if (HAS_BORDER(wwin)) {
+                       if (x >= usableArea.x1 + FRAME_BORDER_WIDTH)
+                               x -= FRAME_BORDER_WIDTH;
+                       if (y >= usableArea.y1 + FRAME_BORDER_WIDTH)
+                               y -= FRAME_BORDER_WIDTH;
+               }
        }
 
        /*
-- 
1.7.11.4

Reply via email to