Fix #9993: Handle DPI changes on macOS and Windows

This commit is contained in:
Bouke Haarsma
2022-09-07 22:17:10 +02:00
committed by Michael Lutz
parent bda602f4b0
commit 45d98f689a
7 changed files with 86 additions and 2 deletions

View File

@@ -38,6 +38,10 @@
#define PM_QS_INPUT 0x20000
#endif
#ifndef WM_DPICHANGED
#define WM_DPICHANGED 0x02E0
#endif
bool _window_maximize;
static Dimension _bck_resolution;
DWORD _imm_props;
@@ -670,6 +674,24 @@ LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
return TRUE;
}
case WM_DPICHANGED: {
auto did_adjust = AdjustGUIZoom();
/* Resize the window to match the new DPI setting. */
RECT *prcNewWindow = (RECT *)lParam;
SetWindowPos(hwnd,
NULL,
prcNewWindow->left,
prcNewWindow->top,
prcNewWindow->right - prcNewWindow->left,
prcNewWindow->bottom - prcNewWindow->top,
SWP_NOZORDER | SWP_NOACTIVATE);
if (did_adjust) ReInitAllWindows(true);
return 0;
}
/* needed for wheel */
#if !defined(WM_MOUSEWHEEL)
# define WM_MOUSEWHEEL 0x020A