From 367d06deafb00057850796abc02489756a7c6c18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 7 Mar 2022 19:19:31 +0100 Subject: [PATCH] Win32: Fix scale fixup losing initial position The window content scale correction at creation overwrote the inital, more pleasant placement of the window by CW_USEDEFAULT, if the window was created with GLFW_MAXIMIZED set. This is because the translation to screen coordinates was done using the current position, not the position from the restored window rect. --- README.md | 2 ++ src/win32_window.c | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f4ef3791..cc3e3ccc 100644 --- a/README.md +++ b/README.md @@ -209,6 +209,8 @@ information on what to include when reporting a bug. and later (#2018) - [Win32] Bugfix: A window created maximized and undecorated would cover the whole monitor (#1806) + - [Win32] Bugfix: The default restored window position was lost when creating a maximized + window - [Cocoa] Added support for `VK_EXT_metal_surface` (#1619) - [Cocoa] Added locating the Vulkan loader at runtime in an application bundle - [Cocoa] Moved main menu creation to GLFW initialization time (#1649) diff --git a/src/win32_window.c b/src/win32_window.c index c8f7782e..0f76cf56 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1316,9 +1316,6 @@ static int createNativeWindow(_GLFWwindow* window, } } - ClientToScreen(window->win32.handle, (POINT*) &rect.left); - ClientToScreen(window->win32.handle, (POINT*) &rect.right); - if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32()) { AdjustWindowRectExForDpi(&rect, style, FALSE, exStyle, @@ -1328,6 +1325,10 @@ static int createNativeWindow(_GLFWwindow* window, AdjustWindowRectEx(&rect, style, FALSE, exStyle); GetWindowPlacement(window->win32.handle, &wp); + OffsetRect(&rect, + wp.rcNormalPosition.left - rect.left, + wp.rcNormalPosition.top - rect.top); + wp.rcNormalPosition = rect; wp.showCmd = SW_HIDE; SetWindowPlacement(window->win32.handle, &wp);