diff options
author | Po Lu <luangruo@yahoo.com> | 2022-03-17 05:31:03 +0000 |
---|---|---|
committer | Po Lu <luangruo@yahoo.com> | 2022-03-17 05:31:03 +0000 |
commit | 9916b49e4197d3aa23b3a5e6a383ae40f65b8222 (patch) | |
tree | bab92b1fff46fe161bdec0645c2b50b722c331e4 | |
parent | f4a71e17f49da40ec625ad4771362d96712aff61 (diff) | |
download | emacs-9916b49e4197d3aa23b3a5e6a383ae40f65b8222.tar.gz |
Prevent delivery of duplicate events when window is grabbed on Haiku
* src/haiku_support.cc (grab_view, grab_view_locker): New
variables.
(MouseMoved, MouseDown, MouseUp): Keep track of the grab and
don't deliver motion events to any other view.
-rw-r--r-- | src/haiku_support.cc | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/src/haiku_support.cc b/src/haiku_support.cc index 626b2fb607b..f8acd2a4eca 100644 --- a/src/haiku_support.cc +++ b/src/haiku_support.cc @@ -118,6 +118,9 @@ static BLocker movement_locker; static BMessage volatile *popup_track_message; static int32 volatile alert_popup_value; +static void *grab_view = NULL; +static BLocker grab_view_locker; + /* This could be a private API, but it's used by (at least) the Qt port, so it's probably here to stay. */ extern status_t get_subpixel_antialiasing (bool *); @@ -1193,6 +1196,12 @@ public: gui_abort ("Wait for release message still exists"); TearDownDoubleBuffering (); + + if (!grab_view_locker.Lock ()) + gui_abort ("Couldn't lock grab view locker"); + if (grab_view == this) + grab_view = NULL; + grab_view_locker.Unlock (); } void @@ -1447,6 +1456,17 @@ public: ToolTip ()->SetMouseRelativeLocation (BPoint (-(point.x - tt_absl_pos.x), -(point.y - tt_absl_pos.y))); + if (!grab_view_locker.Lock ()) + gui_abort ("Couldn't lock grab view locker"); + + if (this != grab_view) + { + grab_view_locker.Unlock (); + return; + } + + grab_view_locker.Unlock (); + if (movement_locker.Lock ()) { haiku_write (MOUSE_MOTION, &rq); @@ -1462,6 +1482,12 @@ public: this->GetMouse (&point, &buttons, false); + if (!grab_view_locker.Lock ()) + gui_abort ("Couldn't lock grab view locker"); + if (buttons) + grab_view = this; + grab_view_locker.Unlock (); + rq.window = this->Window (); if (!(previous_buttons & B_PRIMARY_MOUSE_BUTTON) @@ -1496,7 +1522,8 @@ public: if (mods & B_OPTION_KEY) rq.modifiers |= HAIKU_MODIFIER_SUPER; - SetMouseEventMask (B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS); + SetMouseEventMask (B_POINTER_EVENTS, (B_LOCK_WINDOW_FOCUS + | B_NO_POINTER_HISTORY)); rq.time = system_time (); haiku_write (BUTTON_DOWN, &rq); @@ -1510,6 +1537,12 @@ public: this->GetMouse (&point, &buttons, false); + if (!grab_view_locker.Lock ()) + gui_abort ("Couldn't lock grab view locker"); + if (!buttons) + grab_view = NULL; + grab_view_locker.Unlock (); + if (!buttons && wait_for_release_message) { wait_for_release_message->SendReply (wait_for_release_message); |