From 3cd382bccc46b957c9a699fe5fa827f32704dfcd Mon Sep 17 00:00:00 2001 From: Iain Patterson 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 9970c1a7..b07d9d43 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; + } } /* -- 2.11.4.GIT