Prevent windows from drifting on restart.
authorIain Patterson <wm@iain.cx>
Fri, 16 Nov 2012 00:55:52 +0000 (15 16:55 -0800)
committerCarlos R. Mafra <crmafra@gmail.com>
Fri, 16 Nov 2012 08:06:29 +0000 (16 08:06 +0000)
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

index 9970c1a..b07d9d4 100644 (file)
@@ -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;
+               }
        }
 
        /*