From 12f0dd7c60ef0f5baa6af2a2b5dc06fc2eab576c Mon Sep 17 00:00:00 2001 From: Ansariel Date: Sat, 19 Nov 2016 12:05:40 +0100 Subject: [PATCH] Fix DPI scaling calculation --- indra/llwindow/llwindowwin32.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 8ef742262a..f55be68520 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -2644,7 +2644,10 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ case WM_DPICHANGED: { LPRECT lprc_new_scale; - F32 new_scale = LOWORD(w_param) / USER_DEFAULT_SCREEN_DPI; + // Fix DPI scaling + //F32 new_scale = LOWORD(w_param) / USER_DEFAULT_SCREEN_DPI; + F32 new_scale = F32(LOWORD(w_param)) / F32(USER_DEFAULT_SCREEN_DPI); + // lprc_new_scale = (LPRECT)l_param; S32 new_width = lprc_new_scale->right - lprc_new_scale->left; S32 new_height = lprc_new_scale->bottom - lprc_new_scale->top; @@ -4060,7 +4063,10 @@ F32 LLWindowWin32::getSystemUISize() hr = pGDFM(hMonitor, MDT_EFFECTIVE_DPI, &dpix, &dpiy); if (hr == S_OK) { - scale_value = dpix / USER_DEFAULT_SCREEN_DPI; + // Fix DPI scaling + //scale_value = dpix / USER_DEFAULT_SCREEN_DPI; + scale_value = F32(dpix) / F32(USER_DEFAULT_SCREEN_DPI); + // } else { @@ -4079,7 +4085,10 @@ F32 LLWindowWin32::getSystemUISize() else { LL_WARNS() << "Could not load shcore.dll library (included by from Win 8.1 SDK). Using legacy DPI awareness API of Win XP/7" << LL_ENDL; - scale_value = GetDeviceCaps(hdc, LOGPIXELSX) / USER_DEFAULT_SCREEN_DPI; + // Fix DPI scaling + //scale_value = GetDeviceCaps(hdc, LOGPIXELSX) / USER_DEFAULT_SCREEN_DPI; + scale_value = F32(GetDeviceCaps(hdc, LOGPIXELSX)) / F32(USER_DEFAULT_SCREEN_DPI); + // } ReleaseDC(hWnd, hdc);