From bd3b2a6781331fc5b7d950af422fd0c3bd8db19b Mon Sep 17 00:00:00 2001 From: Po Lu Date: Wed, 20 Apr 2022 03:06:58 +0000 Subject: [PATCH] Fix enabling menu bar multiple times on Haiku * src/haiku_support.cc (FrameResized): Adjust width and height appropriately when sending menu bar resize event. * src/haikufns.c (haiku_set_menu_bar_lines): Don't always reset FRAME_MENU_BAR_LINES and FRAME_MENU_BAR_HEIGHT. * src/haikumenu.c (free_frame_menubar): Clear Haiku menu bar. (set_frame_menubar): Fix coding style. * src/haikuterm.c (haiku_read_socket): Don't adjust height here anymore. --- src/haiku_support.cc | 4 ++-- src/haikufns.c | 10 +++++----- src/haikumenu.c | 11 ++++++++--- src/haikuterm.c | 4 ++-- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/haiku_support.cc b/src/haiku_support.cc index 290b2541f4c..af37fe7a620 100644 --- a/src/haiku_support.cc +++ b/src/haiku_support.cc @@ -1272,8 +1272,8 @@ public: { struct haiku_menu_bar_resize_event rq; rq.window = this->Window (); - rq.height = std::lrint (newHeight); - rq.width = std::lrint (newWidth); + rq.height = std::lrint (newHeight + 1); + rq.width = std::lrint (newWidth + 1); haiku_write (MENU_BAR_RESIZE, &rq); BMenuBar::FrameResized (newWidth, newHeight); diff --git a/src/haikufns.c b/src/haikufns.c index 151874e26fd..b19fdd5488a 100644 --- a/src/haikufns.c +++ b/src/haikufns.c @@ -1278,9 +1278,6 @@ haiku_set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval fset_redisplay (f); - FRAME_MENU_BAR_LINES (f) = 0; - FRAME_MENU_BAR_HEIGHT (f) = 0; - if (nlines) { FRAME_EXTERNAL_MENU_BAR (f) = 1; @@ -1289,11 +1286,14 @@ haiku_set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval } else { + FRAME_MENU_BAR_LINES (f) = 0; + FRAME_MENU_BAR_HEIGHT (f) = 0; + if (FRAME_EXTERNAL_MENU_BAR (f)) free_frame_menubar (f); + FRAME_EXTERNAL_MENU_BAR (f) = 0; - if (FRAME_HAIKU_P (f)) - FRAME_HAIKU_MENU_BAR (f) = 0; + FRAME_HAIKU_MENU_BAR (f) = 0; } adjust_frame_glyphs (f); diff --git a/src/haikumenu.c b/src/haikumenu.c index 54ee3f160f6..9779c34a998 100644 --- a/src/haikumenu.c +++ b/src/haikumenu.c @@ -486,14 +486,19 @@ haiku_menu_show (struct frame *f, int x, int y, int menuflags, void free_frame_menubar (struct frame *f) { + void *mbar; + FRAME_MENU_BAR_LINES (f) = 0; FRAME_MENU_BAR_HEIGHT (f) = 0; FRAME_EXTERNAL_MENU_BAR (f) = 0; block_input (); - void *mbar = FRAME_HAIKU_MENU_BAR (f); + mbar = FRAME_HAIKU_MENU_BAR (f); + FRAME_HAIKU_MENU_BAR (f) = NULL; + if (mbar) BMenuBar_delete (mbar); + if (FRAME_OUTPUT_DATA (f)->menu_bar_open_p) --popup_activated_p; FRAME_OUTPUT_DATA (f)->menu_bar_open_p = 0; @@ -516,8 +521,7 @@ set_frame_menubar (struct frame *f, bool deep_p) { void *mbar = FRAME_HAIKU_MENU_BAR (f); void *view = FRAME_HAIKU_VIEW (f); - - int first_time_p = 0; + bool first_time_p = false; if (!mbar) { @@ -529,6 +533,7 @@ set_frame_menubar (struct frame *f, bool deep_p) initial dimensions of that menu bar. */ if (FRAME_VISIBLE_P (f)) haiku_wait_for_event (f, MENU_BAR_RESIZE); + unblock_input (); } diff --git a/src/haikuterm.c b/src/haikuterm.c index 9cd1d0f0158..64c657fef56 100644 --- a/src/haikuterm.c +++ b/src/haikuterm.c @@ -3514,11 +3514,11 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit) int old_height = FRAME_MENU_BAR_HEIGHT (f); - FRAME_MENU_BAR_HEIGHT (f) = b->height + 1; + FRAME_MENU_BAR_HEIGHT (f) = b->height; FRAME_MENU_BAR_LINES (f) = (b->height + FRAME_LINE_HEIGHT (f)) / FRAME_LINE_HEIGHT (f); - if (old_height != b->height + 1) + if (old_height != b->height) { adjust_frame_size (f, -1, -1, 3, true, Qmenu_bar_lines); haiku_clear_under_internal_border (f); -- 2.39.2