Don't call ReleaseCapture() on any mouse-button-up event. Instead,
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Wed, 21 Jan 2009 18:47:03 +0000 (18:47 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Wed, 21 Jan 2009 18:47:03 +0000 (18:47 +0000)
only call it when the _last_ mouse button comes back up. Otherwise,
xterm mouse tracking will lose a button-up event if you press down
two buttons, move the mouse outside the window, then release them
one at a time.

git-svn-id: svn://svn.tartarus.org/sgt/putty@8425 cda61777-01e9-0310-a592-d414129be87e

windows/window.c

index b2dd5e6..416be3f 100644 (file)
@@ -2335,26 +2335,32 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
            switch (message) {
              case WM_LBUTTONDOWN:
                button = MBT_LEFT;
+               wParam |= MK_LBUTTON;
                press = 1;
                break;
              case WM_MBUTTONDOWN:
                button = MBT_MIDDLE;
+               wParam |= MK_MBUTTON;
                press = 1;
                break;
              case WM_RBUTTONDOWN:
                button = MBT_RIGHT;
+               wParam |= MK_RBUTTON;
                press = 1;
                break;
              case WM_LBUTTONUP:
                button = MBT_LEFT;
+               wParam &= ~MK_LBUTTON;
                press = 0;
                break;
              case WM_MBUTTONUP:
                button = MBT_MIDDLE;
+               wParam &= ~MK_MBUTTON;
                press = 0;
                break;
              case WM_RBUTTONUP:
                button = MBT_RIGHT;
+               wParam &= ~MK_RBUTTON;
                press = 0;
                break;
              default:
@@ -2413,7 +2419,8 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
                           TO_CHR_X(X_POS(lParam)),
                           TO_CHR_Y(Y_POS(lParam)), wParam & MK_SHIFT,
                           wParam & MK_CONTROL, is_alt_pressed());
-               ReleaseCapture();
+               if (!(wParam & (MK_LBUTTON | MK_MBUTTON | MK_RBUTTON)))
+                   ReleaseCapture();
            }
        }
        return 0;