From 0bccc3852b903e690e77e66d2486fb33166e112d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 7 Oct 2020 23:35:17 +0200 Subject: [PATCH] Win32: Filter out duplicate size events This mirrors the filtering done on X11 and Cocoa. Possibly this should be done by shared code instead. Fixes #1610. --- README.md | 2 ++ src/win32_platform.h | 3 +++ src/win32_window.c | 14 ++++++++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ab16fb1c..5d18e33f 100644 --- a/README.md +++ b/README.md @@ -158,6 +158,7 @@ information on what to include when reporting a bug. - [Win32] Bugfix: Monitor functions could return invalid values after configuration change (#1761) - [Win32] Bugfix: Initialization would segfault on Windows 8 (not 8.1) (#1775) + - [Win32] Bugfix: Duplicate size events were not filtered (#1610) - [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) @@ -326,6 +327,7 @@ skills. - Shane Liesegang - Anders Lindqvist - Leon Linhart + - Marco Lizza - Eyal Lotem - Aaron Loucks - Luflosi diff --git a/src/win32_platform.h b/src/win32_platform.h index 4f520514..6c81d4b5 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -314,6 +314,9 @@ typedef struct _GLFWwindowWin32 GLFWbool scaleToMonitor; GLFWbool keymenu; + // Cached size used to filter out duplicate events + int width, height; + // The last received cursor position, regardless of source int lastCursorPosX, lastCursorPosY; // The last recevied high surrogate when decoding pairs of UTF-16 messages diff --git a/src/win32_window.c b/src/win32_window.c index 8cb50500..ce06d37c 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -961,6 +961,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, case WM_SIZE: { + const int width = LOWORD(lParam); + const int height = HIWORD(lParam); const GLFWbool iconified = wParam == SIZE_MINIMIZED; const GLFWbool maximized = wParam == SIZE_MAXIMIZED || (window->win32.maximized && @@ -975,8 +977,14 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, if (window->win32.maximized != maximized) _glfwInputWindowMaximize(window, maximized); - _glfwInputFramebufferSize(window, LOWORD(lParam), HIWORD(lParam)); - _glfwInputWindowSize(window, LOWORD(lParam), HIWORD(lParam)); + if (width != window->win32.width || height != window->win32.height) + { + window->win32.width = width; + window->win32.height = height; + + _glfwInputFramebufferSize(window, width, height); + _glfwInputWindowSize(window, width, height); + } if (window->monitor && window->win32.iconified != iconified) { @@ -1315,6 +1323,8 @@ static int createNativeWindow(_GLFWwindow* window, window->win32.transparent = GLFW_TRUE; } + _glfwPlatformGetWindowSize(window, &window->win32.width, &window->win32.height); + return GLFW_TRUE; }