emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 9916b49e41: Prevent delivery of duplicate events when window is g


From: Po Lu
Subject: master 9916b49e41: Prevent delivery of duplicate events when window is grabbed on Haiku
Date: Thu, 17 Mar 2022 01:57:57 -0400 (EDT)

branch: master
commit 9916b49e4197d3aa23b3a5e6a383ae40f65b8222
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    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.
---
 src/haiku_support.cc | 35 ++++++++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/src/haiku_support.cc b/src/haiku_support.cc
index 626b2fb607..f8acd2a4ec 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);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]