From b21eed2ad43f6ca2b76e202d2e1b561054d339d7 Mon Sep 17 00:00:00 2001 From: "robbin.marcus" Date: Mon, 26 Sep 2022 17:28:38 +0200 Subject: [PATCH] Win32: set mouse button released after drag/resize When calling the drag/resize operation GLFW would keep the left mouse button pressed even after drag/resize was completed. The other changes will hopefully make the build compile for other platforms. --- README.md | 2 +- src/win32_window.c | 6 ++++++ src/wl_window.c | 10 +++++----- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index fe7a51d7..8b4a1546 100644 --- a/README.md +++ b/README.md @@ -121,7 +121,6 @@ information on what to include when reporting a bug. ## Changelog -User-visible changes since the last release. - Added `GLFW_PLATFORM` init hint for runtime platform selection (#1958) - Added `GLFW_ANY_PLATFORM`, `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`, `GLFW_PLATFORM_WAYLAND`, `GLFW_PLATFORM_X11` and `GLFW_PLATFORM_NULL` symbols to @@ -402,6 +401,7 @@ User-visible changes since the last release. - [GLX] Added loading of glvnd `libGLX.so.0` where available - [GLX] Bugfix: Context creation failed if GLX 1.4 was not exported by GLX library + ## Contact On [glfw.org](https://www.glfw.org/) you can find the latest version of GLFW, as diff --git a/src/win32_window.c b/src/win32_window.c index 024a174e..ca16f044 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1779,6 +1779,9 @@ void _glfwPlatformDragWindow(_GLFWwindow* window) { ReleaseCapture(); SendMessage(window->win32.handle, WM_NCLBUTTONDOWN, HTCAPTION, 0); + + // Mouse button will be released after drag, so prepare released state here already + _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_1, GLFW_RELEASE, 0); } void _glfwPlatformResizeWindow(_GLFWwindow* window, int border) @@ -1815,6 +1818,9 @@ void _glfwPlatformResizeWindow(_GLFWwindow* window, int border) } ReleaseCapture(); SendMessage(window->win32.handle, WM_NCLBUTTONDOWN, wBorder, 0); + + // Mouse button will be released after drag, so prepare released state here already + _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_1, GLFW_RELEASE, 0); } void _glfwSetWindowMonitorWin32(_GLFWwindow* window, diff --git a/src/wl_window.c b/src/wl_window.c index 783061c9..c18fc907 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -2100,7 +2100,7 @@ void _glfwFocusWindowWayland(_GLFWwindow* window) void _glfwPlatformDragWindow(_GLFWwindow* window) { - wl_shell_surface_move(window->wl.surface, _glfw.wl.seat, _glfw.wl.serial); + xdg_toplevel_move(window->wl.xdg.toplevel, _glfw.wl.seat, _glfw.wl.serial); } void _glfwPlatformResizeWindow(_GLFWwindow* window, int border) @@ -2135,10 +2135,10 @@ void _glfwPlatformResizeWindow(_GLFWwindow* window, int border) default: assert(GLFW_FALSE); } - wl_shell_surface_resize(window->wl.surface, - _glfw.wl.seat, - _glfw.wl.serial, - wlBorder); + xdg_toplevel_resize(window->wl.xdg.toplevel, + _glfw.wl.seat, + _glfw.wl.serial, + wlBorder); } void _glfwSetWindowMonitorWayland(_GLFWwindow* window,