emacs-diffs
[Top][All Lists]
Advanced

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

master 977aed9f79: Fix grab view persisting on Haiku after popup menu cl


From: Po Lu
Subject: master 977aed9f79: Fix grab view persisting on Haiku after popup menu closes
Date: Thu, 28 Jul 2022 09:25:25 -0400 (EDT)

branch: master
commit 977aed9f7981fee0ba9ac8711a86da908fc5057e
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Fix grab view persisting on Haiku after popup menu closes
    
    * src/haiku_support.cc (BasicMouseUp): Improve handling of
    wait_for_release_message.
    (be_clear_grab_view): New function.
    * src/haiku_support.h: Update prototypes.
    * src/haikumenu.c (haiku_menu_show): Call it here.
---
 src/haiku_support.cc | 25 +++++++++++++++++++++----
 src/haiku_support.h  |  1 +
 src/haikumenu.c      |  5 +++++
 3 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/src/haiku_support.cc b/src/haiku_support.cc
index cb378d2d81..b7590f68a4 100644
--- a/src/haiku_support.cc
+++ b/src/haiku_support.cc
@@ -1930,11 +1930,14 @@ public:
     button = (grabbed_buttons & ~buttons);
     grabbed_buttons = buttons;
 
-    if (!grabbed_buttons && wait_for_release_message)
+    if (wait_for_release_message)
       {
-       wait_for_release_message->SendReply (wait_for_release_message);
-       delete wait_for_release_message;
-       wait_for_release_message = NULL;
+       if (!grabbed_buttons)
+         {
+           wait_for_release_message->SendReply (wait_for_release_message);
+           delete wait_for_release_message;
+           wait_for_release_message = NULL;
+         }
 
        return;
       }
@@ -5457,3 +5460,17 @@ be_get_explicit_workarea (int *x, int *y, int *width, 
int *height)
 
   return true;
 }
+
+/* Clear the grab view.  This has to be called manually from some
+   places, since we don't get B_MOUSE_UP messages after a popup menu
+   is run.  */
+
+void
+be_clear_grab_view (void)
+{
+  if (grab_view_locker.Lock ())
+    {
+      grab_view = NULL;
+      grab_view_locker.Unlock ();
+    }
+}
diff --git a/src/haiku_support.h b/src/haiku_support.h
index 5577d2f151..76fe071f2c 100644
--- a/src/haiku_support.h
+++ b/src/haiku_support.h
@@ -727,6 +727,7 @@ extern void be_set_window_fullscreen_mode (void *, enum 
haiku_fullscreen_mode);
 extern void be_lock_window (void *);
 extern void be_unlock_window (void *);
 extern bool be_get_explicit_workarea (int *, int *, int *, int *);
+extern void be_clear_grab_view (void);
 #ifdef __cplusplus
 }
 
diff --git a/src/haikumenu.c b/src/haikumenu.c
index 929ed95210..69bb56c124 100644
--- a/src/haikumenu.c
+++ b/src/haikumenu.c
@@ -432,6 +432,11 @@ haiku_menu_show (struct frame *f, int x, int y, int 
menuflags,
 
   FRAME_DISPLAY_INFO (f)->grabbed = 0;
 
+  /* Clear the grab view manually.  There is a race condition here if
+     the window thread receives a button press between here and the
+     end of BMenu_run.  */
+  be_clear_grab_view ();
+
   if (menu_item_selection)
     {
       prefix = entry = Qnil;



reply via email to

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