From e26071e9903e9ba2f7a761352c31e52235f75121 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Thu, 20 Jan 2022 10:53:49 +0000 Subject: [PATCH] Make system tooltips display in the menu bar on Haiku * doc/emacs/haiku.texi (Haiku Basics): Update documentation. * src/haiku_support.cc (Highlight): Apply the hack used for regular menus to the menu bar as well. * src/haikumenu.c (digest_menu_items): Set help text on menu bar if `tooltip-mode' is t and system tooltips are used. (syms_of_haikumenu): New symbol `tooltip-mode'. --- doc/emacs/haiku.texi | 4 ---- src/haiku_support.cc | 10 +++++----- src/haikumenu.c | 7 +++++++ 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/doc/emacs/haiku.texi b/doc/emacs/haiku.texi index 0d3ed8339e7..ac631a39a69 100644 --- a/doc/emacs/haiku.texi +++ b/doc/emacs/haiku.texi @@ -92,10 +92,6 @@ features, customize the variable @code{use-system-tooltips} to the @code{nil} value, and Emacs will use its own implementation of tooltips. - System tooltips cannot display above the menu bar, so help text in -the menu bar will display in the echo area instead when they are -enabled. - @cindex X resources on Haiku Unlike the X window system, Haiku does not have a system-wide resource database. Since many important options are specified via diff --git a/src/haiku_support.cc b/src/haiku_support.cc index cd4e6e46cd2..ae2736110ec 100644 --- a/src/haiku_support.cc +++ b/src/haiku_support.cc @@ -1636,17 +1636,17 @@ public: { struct haiku_menu_bar_help_event rq; - if (menu_bar_id >= 0) + if (help) + { + Menu ()->SetToolTip (highlight_p ? help : NULL); + } + else if (menu_bar_id >= 0) { rq.window = wind_ptr; rq.mb_idx = highlight_p ? menu_bar_id : -1; haiku_write (MENU_BAR_HELP_EVENT, &rq); } - else if (help) - { - Menu ()->SetToolTip (highlight_p ? help : NULL); - } BMenuItem::Highlight (highlight_p); } diff --git a/src/haikumenu.c b/src/haikumenu.c index f335bdacb40..2ceb0ff3653 100644 --- a/src/haikumenu.c +++ b/src/haikumenu.c @@ -158,6 +158,12 @@ digest_menu_items (void *first_menu, int start, int menu_items_used, !NILP (enable), !NILP (selected), 0, window, !NILP (descrip) ? SSDATA (descrip) : NULL, STRINGP (help) ? SSDATA (help) : NULL); + else if (!use_system_tooltips || NILP (Fsymbol_value (Qtooltip_mode))) + BMenu_add_item (menu, SSDATA (item_name), + !NILP (def) ? (void *) (intptr_t) i : NULL, + !NILP (enable), !NILP (selected), 1, window, + !NILP (descrip) ? SSDATA (descrip) : NULL, + NULL); else BMenu_add_item (menu, SSDATA (item_name), !NILP (def) ? (void *) (intptr_t) i : NULL, @@ -664,6 +670,7 @@ syms_of_haikumenu (void) DEFSYM (Qdebug_on_next_call, "debug-on-next-call"); DEFSYM (Qpopup_menu, "popup-menu"); DEFSYM (Qmouse_menu_bar_map, "mouse-menu-bar-map"); + DEFSYM (Qtooltip_mode, "tooltip-mode"); defsubr (&Smenu_or_popup_active_p); defsubr (&Shaiku_menu_bar_open); -- 2.39.5