From 07eb764df67def20be08b4e359e3fba8c369aa85 Mon Sep 17 00:00:00 2001 From: OBattler Date: Tue, 14 Sep 2021 22:17:47 +0200 Subject: [PATCH] Locking a window to a specified size now also makes it remember the position, closes #1683. --- src/win/win.c | 3 +++ src/win/win_specify_dim.c | 10 ++++++---- src/win/win_ui.c | 11 ++++++++--- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/win/win.c b/src/win/win.c index ff7726459..5c50f975e 100644 --- a/src/win/win.c +++ b/src/win/win.c @@ -1093,6 +1093,9 @@ plat_setfullscreen(int on) ResizeWindowByClientArea(hwndMain, temp_x, temp_y); else ResizeWindowByClientArea(hwndMain, temp_x, temp_y + sbar_height); + + if (window_remember) + SetWindowPos(hwndMain, HWND_TOP, window_x, window_y, 0, 0, SWP_NOSIZE); } /* Render window. */ diff --git a/src/win/win_specify_dim.c b/src/win/win_specify_dim.c index 52336ad5e..0282f6061 100644 --- a/src/win/win_specify_dim.c +++ b/src/win/win_specify_dim.c @@ -97,7 +97,7 @@ SpecifyDimensionsDialogProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM if (lock) { vid_resize = 2; - window_remember = 0; + window_remember = 1; } else { vid_resize = 1; window_remember = 1; @@ -140,11 +140,13 @@ SpecifyDimensionsDialogProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM if (mouse_capture) ClipCursor(&r); - if (!(vid_resize & 2) && window_remember) { + if (window_remember) { window_x = r.left; window_y = r.top; - window_w = r.right - r.left; - window_h = r.bottom - r.top; + if (!(vid_resize & 2)) { + window_w = r.right - r.left; + window_h = r.bottom - r.top; + } } config_save(); diff --git a/src/win/win_ui.c b/src/win/win_ui.c index a7cf7be8f..f28021751 100644 --- a/src/win/win_ui.c +++ b/src/win/win_ui.c @@ -697,11 +697,13 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) window_remember = !window_remember; CheckMenuItem(hmenu, IDM_VID_REMEMBER, window_remember ? MF_CHECKED : MF_UNCHECKED); GetWindowRect(hwnd, &rect); - if (!(vid_resize & 2) && window_remember) { + if (window_remember) { window_x = rect.left; window_y = rect.top; - window_w = rect.right - rect.left; - window_h = rect.bottom - rect.top; + if (!(vid_resize & 2)) { + window_w = rect.right - rect.left; + window_h = rect.bottom - rect.top; + } } config_save(); break; @@ -1382,6 +1384,9 @@ ui_init(int nCmdShow) ResizeWindowByClientArea(hwndMain, scrnsz_x, scrnsz_y); else ResizeWindowByClientArea(hwndMain, scrnsz_x, scrnsz_y + sbar_height); + + if (window_remember) + SetWindowPos(hwndMain, HWND_TOP, window_x, window_y, 0, 0, SWP_NOSIZE); } /* Reset all menus to their defaults. */