]> git.eshelyaron.com Git - emacs.git/commitdiff
Make `haiku-menu-bar-open' faster
authorPo Lu <luangruo@yahoo.com>
Wed, 26 Jan 2022 01:20:48 +0000 (01:20 +0000)
committerPo Lu <luangruo@yahoo.com>
Wed, 26 Jan 2022 01:20:48 +0000 (01:20 +0000)
* src/haikumenu.c (Fhaiku_menu_bar_open): Get draw lock before
updating the menu bar.
* src/haikuterm.c (haiku_read_socket): Don't update menu bar if
b->no_lock.

src/haikumenu.c
src/haikuterm.c

index 3fee5831608986c7192884da691e732f178cf718..b73baf72e051f22df762ae4a138b70ddc729f3f8 100644 (file)
@@ -644,17 +644,20 @@ the position of the last non-menu event instead.  */)
   struct frame *f = decode_window_system_frame (frame);
 
   if (FRAME_EXTERNAL_MENU_BAR (f))
-    set_frame_menubar (f, 1);
+    {
+      block_input ();
+      BView_draw_lock (FRAME_HAIKU_VIEW (f));
+      set_frame_menubar (f, 1);
+      BMenuBar_start_tracking (FRAME_HAIKU_MENU_BAR (f));
+      BView_draw_unlock (FRAME_HAIKU_VIEW (f));
+      unblock_input ();
+    }
   else
     {
       return call2 (Qpopup_menu, call0 (Qmouse_menu_bar_map),
                    last_nonmenu_event);
     }
 
-  block_input ();
-  BMenuBar_start_tracking (FRAME_HAIKU_MENU_BAR (f));
-  unblock_input ();
-
   return Qnil;
 }
 
index c8cc02a29885f9695e94421767e5c72bb8cc98a7..e7d596cec3d76e98bac4d2346085e6a9361eba6b 100644 (file)
@@ -3178,15 +3178,25 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit)
 
            if (type == MENU_BAR_OPEN)
              {
-               BView_draw_lock (FRAME_HAIKU_VIEW (f));
-               /* This shouldn't be here, but nsmenu does it, so
-                  it should probably be safe.  */
-               int was_waiting_for_input_p = waiting_for_input;
-               if (waiting_for_input)
-                 waiting_for_input = 0;
-               set_frame_menubar (f, 1);
-               waiting_for_input = was_waiting_for_input_p;
-               BView_draw_unlock (FRAME_HAIKU_VIEW (f));
+               /* b->no_lock means that MenusBeginning was called
+                  from the main thread, which means tracking was
+                  started manually, and we have already updated the
+                  menu bar.  */
+               if (!b->no_lock)
+                 {
+                   BView_draw_lock (FRAME_HAIKU_VIEW (f));
+                   /* This shouldn't be here, but nsmenu does it, so
+                      it should probably be safe.  */
+                   int was_waiting_for_input_p = waiting_for_input;
+                   if (waiting_for_input)
+                     waiting_for_input = 0;
+                   set_frame_menubar (f, 1);
+                   waiting_for_input = was_waiting_for_input_p;
+                   BView_draw_unlock (FRAME_HAIKU_VIEW (f));
+                 }
+
+               /* But set the flag anyway, because the menu will end
+                  from the window thread.  */
                FRAME_OUTPUT_DATA (f)->menu_bar_open_p = 1;
                popup_activated_p += 1;