From 06bd841203426efe55aac6f93bb75cce3e6d02cd Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sat, 23 Jan 2021 15:50:38 +0200 Subject: [PATCH] Window mode status bar DPI change handling. --- od-win32/dxwrap.h | 2 +- od-win32/win32.cpp | 8 ++++---- od-win32/win32gfx.cpp | 24 +++++++++++++++--------- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/od-win32/dxwrap.h b/od-win32/dxwrap.h index 2672add9..d31dcbac 100644 --- a/od-win32/dxwrap.h +++ b/od-win32/dxwrap.h @@ -110,6 +110,7 @@ struct AmigaMonitor { RECT amigawin_rect, mainwin_rect; RECT amigawinclip_rect; int window_extra_width, window_extra_height; + int window_extra_height_bar; int win_x_diff, win_y_diff; int setcursoroffset_x, setcursoroffset_y; int mouseposx, mouseposy; @@ -118,7 +119,6 @@ struct AmigaMonitor { int ratio_width, ratio_height; int ratio_adjust_x, ratio_adjust_y; bool ratio_sizing; - int prevsbheight; bool render_ok, wait_render; int in_sizemove; diff --git a/od-win32/win32.cpp b/od-win32/win32.cpp index 4c7bdf78..8639a519 100644 --- a/od-win32/win32.cpp +++ b/od-win32/win32.cpp @@ -2740,9 +2740,9 @@ static LRESULT CALLBACK MainWindowProc (HWND hWnd, UINT message, WPARAM wParam, LPMINMAXINFO lpmmi; lpmmi = (LPMINMAXINFO)lParam; lpmmi->ptMinTrackSize.x = 160 + mon->window_extra_width; - lpmmi->ptMinTrackSize.y = 128 + mon->window_extra_height; + lpmmi->ptMinTrackSize.y = 128 + mon->window_extra_height + mon->window_extra_height_bar; lpmmi->ptMaxTrackSize.x = max_uae_width + mon->window_extra_width; - lpmmi->ptMaxTrackSize.y = max_uae_height + mon->window_extra_height; + lpmmi->ptMaxTrackSize.y = max_uae_height + mon->window_extra_height + mon->window_extra_height_bar; } return 0; @@ -2793,9 +2793,9 @@ static LRESULT CALLBACK MainWindowProc (HWND hWnd, UINT message, WPARAM wParam, int w = mon->mainwin_rect.right - mon->mainwin_rect.left; int h = mon->mainwin_rect.bottom - mon->mainwin_rect.top; if (w != changed_prefs.gfx_monitor[mon->monitor_id].gfx_size_win.width + mon->window_extra_width || - h != changed_prefs.gfx_monitor[mon->monitor_id].gfx_size_win.height + mon->window_extra_height) { + h != changed_prefs.gfx_monitor[mon->monitor_id].gfx_size_win.height + mon->window_extra_height + mon->window_extra_height_bar) { changed_prefs.gfx_monitor[mon->monitor_id].gfx_size_win.width = w - mon->window_extra_width; - changed_prefs.gfx_monitor[mon->monitor_id].gfx_size_win.height = h - mon->window_extra_height; + changed_prefs.gfx_monitor[mon->monitor_id].gfx_size_win.height = h - (mon->window_extra_height + mon->window_extra_height_bar); set_config_changed(); } } diff --git a/od-win32/win32gfx.cpp b/od-win32/win32gfx.cpp index d1588f74..beab1e12 100644 --- a/od-win32/win32gfx.cpp +++ b/od-win32/win32gfx.cpp @@ -2249,8 +2249,11 @@ static int getstatuswindowheight(int monid, HWND hwnd) if (!h) return def; wi.cbSize = sizeof wi; - if (GetWindowInfo (h, &wi)) + if (GetWindowInfo(h, &wi)) { + int dpi = getdpiforwindow(h); def = wi.rcWindow.bottom - wi.rcWindow.top; + def = def * dpi / 96; + } DestroyWindow(h); return def; } @@ -3690,18 +3693,18 @@ static int create_windows_2(struct AmigaMonitor *mon) else ny = rc.top + (rc.bottom - rc.top - nh); } - if (w != nw || h != nh || x != nx || y != ny || sbheight != mon->prevsbheight) { + if (w != nw || h != nh || x != nx || y != ny || sbheight != mon->window_extra_height_bar) { w = nw; h = nh; x = nx; y = ny; + mon->window_extra_height_bar = sbheight; mon->in_sizemove++; - if (mon->hMainWnd && !fsw && !dxfs && !d3dfs && !rp_isactive ()) { - mon->window_extra_height += (sbheight - mon->prevsbheight); + if (mon->hMainWnd && !fsw && !dxfs && !d3dfs && !rp_isactive()) { GetWindowRect(mon->hMainWnd, &r); x = r.left; y = r.top; - SetWindowPos(mon->hMainWnd, HWND_TOP, x, y, w + mon->window_extra_width, h + mon->window_extra_height, + SetWindowPos(mon->hMainWnd, HWND_TOP, x, y, w + mon->window_extra_width, h + mon->window_extra_height + mon->window_extra_height_bar, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSENDCHANGING | SWP_NOZORDER); x = gap; y = gap; @@ -3725,7 +3728,6 @@ static int create_windows_2(struct AmigaMonitor *mon) mon->amigawin_rect.left, mon->amigawin_rect.top, mon->amigawin_rect.right - mon->amigawin_rect.left, mon->amigawin_rect.bottom - mon->amigawin_rect.top); updatemouseclip(mon); rp_screenmode_changed (); - mon->prevsbheight = sbheight; return 1; } @@ -3823,14 +3825,18 @@ static int create_windows_2(struct AmigaMonitor *mon) rc.bottom -= sbheight; rc.bottom += sbheight2; sbheight = sbheight2; + DestroyWindow(mon->hMainWnd); + mon->hMainWnd = NULL; continue; } } break; } GetWindowRect(mon->hMainWnd, &rc2); - mon->window_extra_width = rc2.right - rc2.left - mon->currentmode.current_width; - mon->window_extra_height = rc2.bottom - rc2.top - mon->currentmode.current_height; + mon->window_extra_width = (rc2.right - rc2.left) - mon->currentmode.current_width; + mon->window_extra_height = (rc2.bottom - rc2.top) - mon->currentmode.current_height; + mon->window_extra_height -= sbheight; + mon->window_extra_height_bar = sbheight; createstatuswindow(mon); createstatusline(mon->monitor_id); } else { @@ -3891,7 +3897,7 @@ static int create_windows_2(struct AmigaMonitor *mon) if (dxfs || d3dfs) movecursor (x + w / 2, y + h / 2); addnotifications (mon->hAmigaWnd, FALSE, FALSE); - mon->prevsbheight = sbheight; + mon->window_extra_height_bar = sbheight; if (mon->monitor_id) { ShowWindow(mon->hMainWnd, SW_SHOWNOACTIVATE); -- 2.47.3