From 8a46c3dc640bd44819cc7c0344b5ec537cebcf73 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 6 Dec 2022 13:36:14 +0100 Subject: [PATCH] windisplay: Only release capture when last mouse button is released This fixes issues with lost up events when dragging out of the window with multiple buttons held Fixes #1396 --- panda/src/windisplay/winGraphicsWindow.cxx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/panda/src/windisplay/winGraphicsWindow.cxx b/panda/src/windisplay/winGraphicsWindow.cxx index 8b70b51938..1ca0425273 100644 --- a/panda/src/windisplay/winGraphicsWindow.cxx +++ b/panda/src/windisplay/winGraphicsWindow.cxx @@ -1671,7 +1671,9 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { if (_lost_keypresses) { resend_lost_keypresses(); } - ReleaseCapture(); + if (wparam == 0) { + ReleaseCapture(); + } _input->button_up(MouseButton::button(0), get_message_time()); return 0; @@ -1679,7 +1681,9 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { if (_lost_keypresses) { resend_lost_keypresses(); } - ReleaseCapture(); + if (wparam == 0) { + ReleaseCapture(); + } _input->button_up(MouseButton::button(1), get_message_time()); return 0; @@ -1687,7 +1691,9 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { if (_lost_keypresses) { resend_lost_keypresses(); } - ReleaseCapture(); + if (wparam == 0) { + ReleaseCapture(); + } _input->button_up(MouseButton::button(2), get_message_time()); return 0; @@ -1696,7 +1702,9 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { if (_lost_keypresses) { resend_lost_keypresses(); } - ReleaseCapture(); + if (wparam == 0) { + ReleaseCapture(); + } int whichButton = GET_XBUTTON_WPARAM(wparam); if (whichButton == XBUTTON1) { _input->button_up(MouseButton::button(3), get_message_time());