From 9a7430ce8414f68de1022b3b6068ba60e8cd87cf Mon Sep 17 00:00:00 2001 From: Po Lu Date: Sun, 17 Apr 2022 08:10:01 +0000 Subject: [PATCH] Fix race conditions waiting for menu bar resize events on Haiku * src/haikufns.c (haiku_create_frame, haiku_create_tip_frame) (haiku_set_menu_bar_lines): Clear `wait_for_event_type'. * src/haikumenu.c (set_frame_menubar): Wait for menu bar resize event. * src/haikuterm.c (haiku_wait_for_event): New function. (haiku_read_socket): Handle waiting for MENU_BAR_RESIZE. * src/haikuterm.h (struct haiku_output): New field `wait_for_event_type'. --- src/haikumenu.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/haikumenu.c b/src/haikumenu.c index 5b370f8f992..46dde6496bb 100644 --- a/src/haikumenu.c +++ b/src/haikumenu.c @@ -521,8 +521,15 @@ set_frame_menubar (struct frame *f, bool deep_p) if (!mbar) { + block_input (); mbar = FRAME_HAIKU_MENU_BAR (f) = BMenuBar_new (view); first_time_p = 1; + + /* Now wait for the MENU_BAR_RESIZE event informing us of the + initial dimensions of that menu bar. */ + if (FRAME_VISIBLE_P (f)) + haiku_wait_for_event (f, MENU_BAR_RESIZE); + unblock_input (); } Lisp_Object items; -- 2.39.2