mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-06-22 14:01:55 +00:00
fix: store dpi in SDL_WindowData.
This commit is contained in:
parent
7659c687f2
commit
1fed384b98
3 changed files with 11 additions and 2 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue