From 711b9694a133ef338482ae75ada724e3a9915d91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 13 Aug 2019 15:18:02 +0200 Subject: [PATCH] Win32: Fix GLFW_MAXIMIZED not maximizing window The window rect adjustment for content scale broke the initial, correct maximization performed when creating the window with WS_MAXIMIZE. This switches to updating the restored rect instead of the current rect. Fixes #1499. Closes #1503. --- README.md | 2 ++ src/win32_window.c | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index fb63b4fe..09fb5f97 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,8 @@ information on what to include when reporting a bug. symbol redefinition (#1524) - [Win32] Bugfix: The cursor position event was emitted before its cursor enter event (#1490) + - [Win32] Bugfix: The window hint `GLFW_MAXIMIZED` did not move or resize the + window (#1499) - [X11] Bugfix: The CMake files did not check for the XInput headers (#1480) - [X11] Bugfix: Key names were not updated when the keyboard layout changed (#1462,#1528) diff --git a/src/win32_window.c b/src/win32_window.c index c6876fa8..9e06d23c 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1281,6 +1281,7 @@ static int createNativeWindow(_GLFWwindow* window, if (!window->monitor) { RECT rect = { 0, 0, wndconfig->width, wndconfig->height }; + WINDOWPLACEMENT wp = { sizeof(wp) }; if (wndconfig->scaleToMonitor) { @@ -1301,10 +1302,11 @@ static int createNativeWindow(_GLFWwindow* window, else AdjustWindowRectEx(&rect, style, FALSE, exStyle); - SetWindowPos(window->win32.handle, NULL, - rect.left, rect.top, - rect.right - rect.left, rect.bottom - rect.top, - SWP_NOACTIVATE | SWP_NOZORDER); + // Only update the restored window rect as the window may be maximized + GetWindowPlacement(window->win32.handle, &wp); + wp.rcNormalPosition = rect; + wp.showCmd = SW_HIDE; + SetWindowPlacement(window->win32.handle, &wp); } DragAcceptFiles(window->win32.handle, TRUE);