From c0601961f1c50a61f7d0d28b23056da09a3d98fb Mon Sep 17 00:00:00 2001 From: martinfouilleul Date: Wed, 8 Feb 2023 18:51:26 +0100 Subject: [PATCH] Reposition window when changing dpi --- src/win32_app.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/win32_app.c b/src/win32_app.c index 59ffbf4..27176f7 100644 --- a/src/win32_app.c +++ b/src/win32_app.c @@ -262,7 +262,18 @@ LRESULT WinProc(HWND windowHandle, UINT message, WPARAM wParam, LPARAM lParam) case WM_DPICHANGED: { - printf("DPI changed!\n"); + u32 dpi = HIWORD(wParam); + RECT rect = *(RECT*)lParam; + + SetWindowPos(mpWindow->win32.hWnd, + HWND_TOP, + rect.left, + rect.top, + rect.right - rect.left, + rect.bottom - rect.top, + SWP_NOACTIVATE | SWP_NOZORDER); + + //TODO: send a message } break; @@ -270,6 +281,8 @@ LRESULT WinProc(HWND windowHandle, UINT message, WPARAM wParam, LPARAM lParam) case WM_SIZING: { + //TODO: take dpi into account + RECT* rect = (RECT*)lParam; mp_event event = {0}; @@ -281,6 +294,8 @@ LRESULT WinProc(HWND windowHandle, UINT message, WPARAM wParam, LPARAM lParam) case WM_MOVING: { + //TODO: take dpi into account + RECT* rect = (RECT*)lParam; mp_event event = {0};