Skip to content

Commit 43fa7ef

Browse files
committed
tform: do not stop mouse button capture until all buttons are released
We may want to consider a more elegant solution for capturing in the future. In the meantime, this fixes panda3d#843.
1 parent eeeea27 commit 43fa7ef

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

panda/src/tform/mouseWatcher.cxx

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -990,18 +990,29 @@ release(ButtonHandle button) {
990990
// Button up. Send the up event associated with the region(s) we were
991991
// over when the button went down.
992992

993-
// There is some danger of losing button-up events here. If more than one
994-
// button goes down together, we won't detect both of the button-up events
995-
// properly.
996993
if (_preferred_button_down_region != nullptr) {
997994
param.set_outside(_preferred_button_down_region != _preferred_region);
998995
_preferred_button_down_region->release(param);
999996
throw_event_pattern(_button_up_pattern,
1000997
_preferred_button_down_region, button);
1001998
}
1002999

1003-
_button_down = false;
1004-
_preferred_button_down_region = nullptr;
1000+
// Do not stop capturing until the last mouse button has gone up. This is
1001+
// needed to prevent stopping the capture until the capturing region has
1002+
// finished processing all the releases.
1003+
bool has_button = false;
1004+
for (size_t i = 0; i < MouseButton::num_mouse_buttons; ++i) {
1005+
if (MouseButton::_buttons[i] != button &&
1006+
_current_buttons_down.get_bit(MouseButton::_buttons[i].get_index())) {
1007+
has_button = true;
1008+
}
1009+
}
1010+
1011+
if (!has_button) {
1012+
// The last mouse button went up.
1013+
_button_down = false;
1014+
_preferred_button_down_region = nullptr;
1015+
}
10051016

10061017
} else {
10071018
// It's a keyboard button; therefore, send the event to every region that

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy