diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c index 0aa178f9d8..e376bd2aa0 100644 --- a/src/video/windows/SDL_windowsevents.c +++ b/src/video/windows/SDL_windowsevents.c @@ -1148,7 +1148,7 @@ static bool DispatchModalLoopMessageHook(HWND *hwnd, UINT *msg, WPARAM *wParam, static WIN_OnDPIUpdateMinMaxSize(SDL_Window *window, int old_dpi, int new_dpi) { - auto scale = (float)new_dpi / old_dpi; + float scale = (float)new_dpi / old_dpi; if (window->min_w || window->min_h) { @@ -2400,7 +2400,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara return 0; } // Update minimum size and maximum size for new dpi - const int prevDPI = (int)data->videodata->GetDpiForWindow(hwnd); + const int prevDPI = data->dpi; WIN_OnDPIUpdateMinMaxSize(data->window, prevDPI, newDPI); // Interactive user-initiated resizing/movement @@ -2437,6 +2437,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara h, SWP_NOZORDER | SWP_NOACTIVATE); data->expected_resize = false; + data->dpi = newDPI; return 0; } break; diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c index 02ed14018c..9724ee87f1 100644 --- a/src/video/windows/SDL_windowswindow.c +++ b/src/video/windows/SDL_windowswindow.c @@ -392,6 +392,7 @@ static bool SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, HWND hwn data->videodata = videodata; data->initializing = true; data->hint_erase_background_mode = GetEraseBackgroundModeHint(); + data->dpi = _this->internal->GetDpiForWindow(hwnd); // WIN_WarpCursor() jitters by +1, and remote desktop warp wobble is +/- 1 @@ -2296,4 +2297,9 @@ bool WIN_SetWindowModal(SDL_VideoDevice *_this, SDL_Window *window, bool modal) return true; } +int WIN_GetWindowDpi(SDL_VideoDevice *_this, SDL_Window *window) +{ + return window->internal->dpi; +} + #endif // SDL_VIDEO_DRIVER_WINDOWS diff --git a/src/video/windows/SDL_windowswindow.h b/src/video/windows/SDL_windowswindow.h index 5d22b4fb9e..24218a1e31 100644 --- a/src/video/windows/SDL_windowswindow.h +++ b/src/video/windows/SDL_windowswindow.h @@ -104,6 +104,7 @@ struct SDL_WindowData // Whether we retain the content of the window when changing state UINT copybits_flag; SDLDropTarget *drop_target; + int dpi; }; extern bool WIN_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props); @@ -144,6 +145,7 @@ extern bool WIN_AdjustWindowRect(SDL_Window *window, int *x, int *y, int *width, extern bool WIN_AdjustWindowRectForHWND(HWND hwnd, LPRECT lpRect, UINT frame_dpi); extern bool WIN_SetWindowParent(SDL_VideoDevice *_this, SDL_Window *window, SDL_Window *parent); extern bool WIN_SetWindowModal(SDL_VideoDevice *_this, SDL_Window *window, bool modal); +extern int WIN_GetWindowDpi(SDL_VideoDevice *_this, SDL_Window *window); // Ends C function definitions when using C++ #ifdef __cplusplus