Browse Source

Win32: Fix mouse button messages lost by capture

Fixes #954.
Camilla Löwy 8 năm trước cách đây
mục cha
commit
dd96d0ac93
2 tập tin đã thay đổi với 19 bổ sung4 xóa
  1. 1 0
      README.md
  2. 18 4
      src/win32_window.c

+ 1 - 0
README.md

@@ -151,6 +151,7 @@ information on what to include when reporting a bug.
                   a loader but no ICD (#916)
 - [Win32] Bugfix: Non-iconified full sreeen windows did not prevent screen
                   blanking or password enabled screensavers (#851)
+- [Win32] Bugfix: Mouse capture logic lost secondary release messages (#954)
 - [X11] Replaced `_GLFW_HAS_XF86VM` compile-time option with dynamic loading
 - [X11] Bugfix: `glfwGetVideoMode` would segfault on Cygwin/X
 - [X11] Bugfix: Dynamic X11 library loading did not use full sonames (#941)

+ 18 - 4
src/win32_window.c

@@ -614,7 +614,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
         case WM_MBUTTONUP:
         case WM_XBUTTONUP:
         {
-            int button, action;
+            int i, button, action;
 
             if (uMsg == WM_LBUTTONDOWN || uMsg == WM_LBUTTONUP)
                 button = GLFW_MOUSE_BUTTON_LEFT;
@@ -631,16 +631,30 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
                 uMsg == WM_MBUTTONDOWN || uMsg == WM_XBUTTONDOWN)
             {
                 action = GLFW_PRESS;
-                SetCapture(hWnd);
             }
             else
-            {
                 action = GLFW_RELEASE;
-                ReleaseCapture();
+
+            for (i = 0;  i < GLFW_MOUSE_BUTTON_LAST;  i++)
+            {
+                if (window->mouseButtons[i] == GLFW_PRESS)
+                    break;
             }
 
+            if (i == GLFW_MOUSE_BUTTON_LAST)
+                SetCapture(hWnd);
+
             _glfwInputMouseClick(window, button, action, getKeyMods());
 
+            for (i = 0;  i < GLFW_MOUSE_BUTTON_LAST;  i++)
+            {
+                if (window->mouseButtons[i] == GLFW_PRESS)
+                    break;
+            }
+
+            if (i == GLFW_MOUSE_BUTTON_LAST)
+                ReleaseCapture();
+
             if (uMsg == WM_XBUTTONDOWN || uMsg == WM_XBUTTONUP)
                 return TRUE;