win32: use USER_DEFAULT_SCREEN_DPI instead of explicit 96 value

main
Dimitriy Ryazantcev 2023-12-21 14:47:56 +02:00 committed by Sam Lantinga
parent a2e05480d6
commit cb90653695
4 changed files with 6 additions and 8 deletions

View File

@ -948,7 +948,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
BOOL menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL); BOOL menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL);
UINT dpi; UINT dpi;
dpi = 96; dpi = USER_DEFAULT_SCREEN_DPI;
size.top = 0; size.top = 0;
size.left = 0; size.left = 0;
size.bottom = h; size.bottom = h;

View File

@ -186,9 +186,9 @@ static float WIN_GetContentScale(SDL_VideoDevice *_this, HMONITOR hMonitor)
} }
if (dpi == 0) { if (dpi == 0) {
/* Safe default */ /* Safe default */
dpi = 96; dpi = USER_DEFAULT_SCREEN_DPI;
} }
return dpi / 96.0f; return dpi / (float)USER_DEFAULT_SCREEN_DPI;
} }
static SDL_bool WIN_GetDisplayMode(SDL_VideoDevice *_this, HMONITOR hMonitor, LPCWSTR deviceName, DWORD index, SDL_DisplayMode *mode, SDL_DisplayOrientation *natural_orientation, SDL_DisplayOrientation *current_orientation) static SDL_bool WIN_GetDisplayMode(SDL_VideoDevice *_this, HMONITOR hMonitor, LPCWSTR deviceName, DWORD index, SDL_DisplayMode *mode, SDL_DisplayOrientation *natural_orientation, SDL_DisplayOrientation *current_orientation)

View File

@ -508,7 +508,7 @@ static void WIN_SetEnhancedMouseScale(int mouse_speed)
float xpoints[5]; float xpoints[5];
float ypoints[5]; float ypoints[5];
float scale_points[10]; float scale_points[10];
const int dpi = 96; // FIXME, how do we handle different monitors with different DPI? const int dpi = USER_DEFAULT_SCREEN_DPI; // FIXME, how do we handle different monitors with different DPI?
const float display_factor = 3.5f * (150.0f / dpi); const float display_factor = 3.5f * (150.0f / dpi);
if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Control Panel\\Mouse", 0, KEY_READ, &hKey) == ERROR_SUCCESS) { if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Control Panel\\Mouse", 0, KEY_READ, &hKey) == ERROR_SUCCESS) {

View File

@ -158,9 +158,6 @@ static int WIN_AdjustWindowRectWithStyle(SDL_Window *window, DWORD style, BOOL m
{ {
SDL_VideoData *videodata = SDL_GetVideoDevice() ? SDL_GetVideoDevice()->driverdata : NULL; SDL_VideoData *videodata = SDL_GetVideoDevice() ? SDL_GetVideoDevice()->driverdata : NULL;
RECT rect; RECT rect;
#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__)
UINT frame_dpi;
#endif
/* Client rect, in points */ /* Client rect, in points */
switch (rect_type) { switch (rect_type) {
@ -202,8 +199,9 @@ static int WIN_AdjustWindowRectWithStyle(SDL_Window *window, DWORD style, BOOL m
/* With per-monitor v2, the window border/titlebar size depend on the DPI, so we need to call AdjustWindowRectExForDpi instead of /* With per-monitor v2, the window border/titlebar size depend on the DPI, so we need to call AdjustWindowRectExForDpi instead of
AdjustWindowRectEx. */ AdjustWindowRectEx. */
if (videodata) { if (videodata) {
UINT frame_dpi;
SDL_WindowData *data = window->driverdata; SDL_WindowData *data = window->driverdata;
frame_dpi = (data && videodata->GetDpiForWindow) ? videodata->GetDpiForWindow(data->hwnd) : 96; frame_dpi = (data && videodata->GetDpiForWindow) ? videodata->GetDpiForWindow(data->hwnd) : USER_DEFAULT_SCREEN_DPI;
if (videodata->AdjustWindowRectExForDpi(&rect, style, menu, 0, frame_dpi) == 0) { if (videodata->AdjustWindowRectExForDpi(&rect, style, menu, 0, frame_dpi) == 0) {
return WIN_SetError("AdjustWindowRectExForDpi()"); return WIN_SetError("AdjustWindowRectExForDpi()");
} }