From 9f5c60c1bca7a64745728e4b7a82f30c39861c0c Mon Sep 17 00:00:00 2001 From: OBattler Date: Sat, 26 Dec 2020 17:21:38 +0100 Subject: [PATCH] Improved (and hopefully, properly fixed) window size and position restoring when returning back from full screen if the window is resizable and set to remember the size and position. --- src/include/86box/win.h | 2 +- src/win/win.c | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/include/86box/win.h b/src/include/86box/win.h index dd83af427..e73bcfd50 100644 --- a/src/include/86box/win.h +++ b/src/include/86box/win.h @@ -102,7 +102,7 @@ extern HANDLE ghMutex; extern LCID lang_id; extern HICON hIcon[256]; extern RECT oldclip; -extern int sbar_height; +extern int sbar_height, user_resize; // extern int status_is_open; diff --git a/src/win/win.c b/src/win/win.c index 1f62f2974..3e29062eb 100644 --- a/src/win/win.c +++ b/src/win/win.c @@ -811,8 +811,11 @@ plat_setfullscreen(int on) if (vid_resize) { /* scale the screen base on DPI */ if (window_remember) { - temp_x = window_w; - temp_y = window_h; + MoveWindow(hwndMain, window_x, window_y, window_w, window_h, TRUE); + GetClientRect(hwndMain, &rect); + + temp_x = rect.right - rect.left + 1; + temp_y = rect.bottom - rect.top + 1 - sbar_height; } else { if (dpi_scale) { temp_x = MulDiv(unscaled_size_x, dpi, 96); @@ -821,9 +824,10 @@ plat_setfullscreen(int on) temp_x = unscaled_size_x; temp_y = unscaled_size_y; } + + /* Main Window. */ + ResizeWindowByClientArea(hwndMain, temp_x, temp_y + sbar_height); } - /* Main Window. */ - ResizeWindowByClientArea(hwndMain, temp_x, temp_y + sbar_height); /* Render window. */ MoveWindow(hwndRender, 0, 0, temp_x, temp_y, TRUE);