From 53d86c64d709ff52886580d338d9b3b2b1f27266 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 1 Dec 2021 18:09:56 +0100 Subject: [PATCH] Win32: Handle content scale error on creation Only apply the content scale to the initial size of the window if content scale retrieval succeeded. Related to #1615. --- src/win32_window.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/win32_window.c b/src/win32_window.c index 9fb0baa1..e03b8564 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1304,8 +1304,12 @@ static int createNativeWindow(_GLFWwindow* window, { float xscale, yscale; _glfwGetWindowContentScaleWin32(window, &xscale, &yscale); - rect.right = (int) (rect.right * xscale); - rect.bottom = (int) (rect.bottom * yscale); + + if (xscale > 0.f && yscale > 0.f) + { + rect.right = (int) (rect.right * xscale); + rect.bottom = (int) (rect.bottom * yscale); + } } ClientToScreen(window->win32.handle, (POINT*) &rect.left);