Skip to content
Permalink
Browse files

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 #843.
  • Loading branch information
rdb committed Mar 18, 2020
1 parent eeeea27 commit 43fa7efaaa6a6fe6456c008a91e00407a3f7950f
Showing with 16 additions and 5 deletions.
  1. +16 −5 panda/src/tform/mouseWatcher.cxx
@@ -990,18 +990,29 @@ release(ButtonHandle button) {
// Button up. Send the up event associated with the region(s) we were
// over when the button went down.

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

_button_down = false;
_preferred_button_down_region = nullptr;
// Do not stop capturing until the last mouse button has gone up. This is
// needed to prevent stopping the capture until the capturing region has
// finished processing all the releases.
bool has_button = false;
for (size_t i = 0; i < MouseButton::num_mouse_buttons; ++i) {
if (MouseButton::_buttons[i] != button &&
_current_buttons_down.get_bit(MouseButton::_buttons[i].get_index())) {
has_button = true;
}
}

if (!has_button) {
// The last mouse button went up.
_button_down = false;
_preferred_button_down_region = nullptr;
}

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

0 comments on commit 43fa7ef

Please sign in to comment.
You can’t perform that action at this time.