mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-01-07 05:43:18 +00:00
Pass the frame DPI to WIN_AdjustWindowRectForHWND()
This commit is contained in:
@@ -1045,7 +1045,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
size.left = 0;
|
||||
size.bottom = h;
|
||||
size.right = w;
|
||||
WIN_AdjustWindowRectForHWND(hwnd, &size);
|
||||
WIN_AdjustWindowRectForHWND(hwnd, &size, 0);
|
||||
w = size.right - size.left;
|
||||
h = size.bottom - size.top;
|
||||
#ifdef HIGHDPI_DEBUG
|
||||
@@ -1493,10 +1493,6 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
int frame_w, frame_h;
|
||||
int query_client_w_win, query_client_h_win;
|
||||
|
||||
const DWORD style = GetWindowLong(hwnd, GWL_STYLE);
|
||||
const DWORD styleEx = GetWindowLong(hwnd, GWL_EXSTYLE);
|
||||
const BOOL menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL);
|
||||
|
||||
#ifdef HIGHDPI_DEBUG
|
||||
SDL_Log("WM_GETDPISCALEDSIZE: current DPI: %d potential DPI: %d input size: (%dx%d)",
|
||||
prevDPI, nextDPI, sizeInOut->cx, sizeInOut->cy);
|
||||
@@ -1507,7 +1503,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
RECT rect = { 0 };
|
||||
|
||||
if (!(data->window->flags & SDL_WINDOW_BORDERLESS)) {
|
||||
data->videodata->AdjustWindowRectExForDpi(&rect, style, menu, styleEx, prevDPI);
|
||||
WIN_AdjustWindowRectForHWND(hwnd, &rect, prevDPI);
|
||||
}
|
||||
|
||||
frame_w = -rect.left + rect.right;
|
||||
@@ -1524,7 +1520,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
rect.bottom = query_client_h_win;
|
||||
|
||||
if (!(data->window->flags & SDL_WINDOW_BORDERLESS)) {
|
||||
data->videodata->AdjustWindowRectExForDpi(&rect, style, menu, styleEx, nextDPI);
|
||||
WIN_AdjustWindowRectForHWND(hwnd, &rect, nextDPI);
|
||||
}
|
||||
|
||||
/* This is supposed to control the suggested rect param of WM_DPICHANGED */
|
||||
@@ -1570,7 +1566,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
rect.bottom = data->window->h;
|
||||
|
||||
if (!(data->window->flags & SDL_WINDOW_BORDERLESS)) {
|
||||
WIN_AdjustWindowRectForHWND(hwnd, &rect);
|
||||
WIN_AdjustWindowRectForHWND(hwnd, &rect, newDPI);
|
||||
}
|
||||
|
||||
w = rect.right - rect.left;
|
||||
|
||||
@@ -248,7 +248,7 @@ int WIN_AdjustWindowRect(SDL_Window *window, int *x, int *y, int *width, int *he
|
||||
return WIN_AdjustWindowRectWithStyle(window, style, styleEx, menu, x, y, width, height, rect_type);
|
||||
}
|
||||
|
||||
int WIN_AdjustWindowRectForHWND(HWND hwnd, LPRECT lpRect)
|
||||
int WIN_AdjustWindowRectForHWND(HWND hwnd, LPRECT lpRect, UINT frame_dpi)
|
||||
{
|
||||
SDL_VideoDevice *videodevice = SDL_GetVideoDevice();
|
||||
SDL_VideoData *videodata = videodevice ? videodevice->driverdata : NULL;
|
||||
@@ -268,7 +268,9 @@ int WIN_AdjustWindowRectForHWND(HWND hwnd, LPRECT lpRect)
|
||||
#else
|
||||
if (WIN_IsPerMonitorV2DPIAware(videodevice)) {
|
||||
/* With per-monitor v2, the window border/titlebar size depend on the DPI, so we need to call AdjustWindowRectExForDpi instead of AdjustWindowRectEx. */
|
||||
UINT frame_dpi = videodata->GetDpiForWindow ? videodata->GetDpiForWindow(hwnd) : USER_DEFAULT_SCREEN_DPI;
|
||||
if (!frame_dpi) {
|
||||
frame_dpi = videodata->GetDpiForWindow ? videodata->GetDpiForWindow(hwnd) : USER_DEFAULT_SCREEN_DPI;
|
||||
}
|
||||
if (!videodata->AdjustWindowRectExForDpi(lpRect, style, menu, styleEx, frame_dpi)) {
|
||||
return WIN_SetError("AdjustWindowRectExForDpi()");
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ extern int WIN_SetWindowPositionInternal(SDL_Window *window, UINT flags, SDL_Win
|
||||
extern void WIN_ShowWindowSystemMenu(SDL_Window *window, int x, int y);
|
||||
extern int WIN_SetWindowFocusable(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool focusable);
|
||||
extern int WIN_AdjustWindowRect(SDL_Window *window, int *x, int *y, int *width, int *height, SDL_WindowRect rect_type);
|
||||
extern int WIN_AdjustWindowRectForHWND(HWND hwnd, LPRECT lpRect);
|
||||
extern int WIN_AdjustWindowRectForHWND(HWND hwnd, LPRECT lpRect, UINT frame_dpi);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
|
||||
Reference in New Issue
Block a user