mirror of
https://github.com/glfw/glfw.git
synced 2024-11-26 14:24:35 +00:00
Win32: Fix content area rescaling on older systems
GLFW_SCALE_TO_MONITOR had no effect on Windows 8.1 up to and including
Windows 10 version 1607 (Anniversary Update), despite those having
support for per-monitor DPI.
That done was to avoid handling systems that have non-client scaling,
introduced in Windows 10 version 1607, without reliable overriding of
the new window size, introduced in Windows 10 version 1703 (Creators
Update). Both are needed to keep the content area at a fixed size for
windows that have GLFW_SCALE_TO_MONITOR disabled.
This change enables window rescaling on Windows 8.1 and all later
versions but disables non-client scaling for unscaled windows on Windows
10 version 1607. Versions after 1607 are unaffected.
Fixes #1511.
(cherry picked from commit 729c9988d0
)
This commit is contained in:
parent
56230ca173
commit
900dda7e89
@ -129,6 +129,8 @@ information on what to include when reporting a bug.
|
|||||||
- [Win32] Bugfix: Duplicate size events were not filtered (#1610)
|
- [Win32] Bugfix: Duplicate size events were not filtered (#1610)
|
||||||
- [Win32] Bugfix: Full screen windows were incorrectly resized by DPI changes
|
- [Win32] Bugfix: Full screen windows were incorrectly resized by DPI changes
|
||||||
(#1582)
|
(#1582)
|
||||||
|
- [Win32] Bugfix: `GLFW_SCALE_TO_MONITOR` had no effect on systems older than
|
||||||
|
Windows 10 version 1703 (#1511)
|
||||||
- [Cocoa] Changed `EGLNativeWindowType` from `NSView` to `CALayer` (#1169)
|
- [Cocoa] Changed `EGLNativeWindowType` from `NSView` to `CALayer` (#1169)
|
||||||
- [Cocoa] Bugfix: Non-BMP Unicode codepoint input was reported as UTF-16
|
- [Cocoa] Bugfix: Non-BMP Unicode codepoint input was reported as UTF-16
|
||||||
(#1635)
|
(#1635)
|
||||||
|
@ -505,7 +505,17 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
case WM_NCCREATE:
|
case WM_NCCREATE:
|
||||||
{
|
{
|
||||||
if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
|
if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
|
||||||
|
{
|
||||||
|
const CREATESTRUCTW* cs = (const CREATESTRUCTW*) lParam;
|
||||||
|
const _GLFWwndconfig* wndconfig = cs->lpCreateParams;
|
||||||
|
|
||||||
|
// On per-monitor DPI aware V1 systems, only enable
|
||||||
|
// non-client scaling for windows that scale the client area
|
||||||
|
// We need WM_GETDPISCALEDSIZE from V2 to keep the client
|
||||||
|
// area static when the non-client area is scaled
|
||||||
|
if (wndconfig && wndconfig->scaleToMonitor)
|
||||||
EnableNonClientDpiScaling(hWnd);
|
EnableNonClientDpiScaling(hWnd);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1131,9 +1141,11 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
const float xscale = HIWORD(wParam) / (float) USER_DEFAULT_SCREEN_DPI;
|
const float xscale = HIWORD(wParam) / (float) USER_DEFAULT_SCREEN_DPI;
|
||||||
const float yscale = LOWORD(wParam) / (float) USER_DEFAULT_SCREEN_DPI;
|
const float yscale = LOWORD(wParam) / (float) USER_DEFAULT_SCREEN_DPI;
|
||||||
|
|
||||||
// Only apply the suggested size if the OS is new enough to have
|
// Resize windowed mode windows that either permit rescaling or that
|
||||||
// sent a WM_GETDPISCALEDSIZE before this
|
// need it to compensate for non-client area scaling
|
||||||
if (_glfwIsWindows10CreatorsUpdateOrGreaterWin32() && !window->monitor)
|
if (!window->monitor &&
|
||||||
|
(window->win32.scaleToMonitor ||
|
||||||
|
_glfwIsWindows10CreatorsUpdateOrGreaterWin32()))
|
||||||
{
|
{
|
||||||
RECT* suggested = (RECT*) lParam;
|
RECT* suggested = (RECT*) lParam;
|
||||||
SetWindowPos(window->win32.handle, HWND_TOP,
|
SetWindowPos(window->win32.handle, HWND_TOP,
|
||||||
@ -1248,7 +1260,7 @@ static int createNativeWindow(_GLFWwindow* window,
|
|||||||
NULL, // No parent window
|
NULL, // No parent window
|
||||||
NULL, // No window menu
|
NULL, // No window menu
|
||||||
GetModuleHandleW(NULL),
|
GetModuleHandleW(NULL),
|
||||||
NULL);
|
(LPVOID) wndconfig);
|
||||||
|
|
||||||
free(wideTitle);
|
free(wideTitle);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user