Subject: Re: bug#59351: 29.0.50; [PATCH] Fix mouse click position to menu bar entry

From: Manuel Giraud <[email-masked]>
Date: Mon, 28 Nov 2022 18:07:17 +0100

Hi,

Here is a new version of this patch that tries to adapt the menu bar
height in the non-toolkit build.

FWIW, I've also attached a quick video of how it works with the fvwm
window manager with an emacs evaluating the following code:
--8<---------------cut here---------------start------------->8---
(split-window-right)
(info-emacs-manual)
(dolist (font '("Iosevka-18" "Ttyp0-12" "Inconsolata-14" "Inconsolata-32"
		"Noto Sans-6"))
  (sit-for 2)
  (set-face-font 'menu font))
--8<---------------cut here---------------end--------------->8---

It also works as intended with EXWM.

>From 075e88eb94474a863e928db388b7af8adbeba038 Mon Sep 17 00:00:00 2001
From: Manuel Giraud <[email-masked]>
Date: Fri, 25 Nov 2022 15:50:41 +0100
Subject: [PATCH] ; * src/xdisp.c (display_menu_bar): Update menu_bar_window
 height.

---
 src/xdisp.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/xdisp.c b/src/xdisp.c
index 5dcf21dc4c..3d14914600 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -26272,11 +26272,11 @@ display_menu_bar (struct window *w)
   it.first_visible_x = 0;
   it.last_visible_x = FRAME_PIXEL_WIDTH (f);
 #elif defined (HAVE_X_WINDOWS) /* X without toolkit.  */
+  struct window *menu_w;
   if (FRAME_WINDOW_P (f))
     {
       /* Menu bar lines are displayed in the desired matrix of the
 	 dummy window menu_bar_window.  */
-      struct window *menu_w;
       menu_w = XWINDOW (f->menu_bar_window);
       init_iterator (&it, menu_w, -1, -1, menu_w->desired_matrix->rows,
 		     MENU_FACE_ID);
@@ -26335,6 +26335,22 @@ display_menu_bar (struct window *w)
 
   /* Compute the total height of the lines.  */
   compute_line_metrics (&it);
+
+#if defined (HAVE_X_WINDOWS) && !defined (USE_X_TOOLKIT) && !defined (USE_GTK)
+  /* With the non-toolkit version, modify the menu bar window height
+     accordingly.  */
+  if (FRAME_WINDOW_P (it.f))
+    {
+      struct glyph_row *row = it.glyph_row;
+      int delta_height = ((row->y + row->height)
+			  - WINDOW_BOX_HEIGHT_NO_MODE_LINE (menu_w));
+      if (delta_height != 0)
+        {
+	  FRAME_MENU_BAR_HEIGHT (it.f) += delta_height;
+	  adjust_frame_size (it.f, -1, -1, 3, false, Qmenu_bar_lines);
+	}
+    }
+#endif
 }
 
 /* Deep copy of a glyph row, including the glyphs.  */
-- 
2.38.1

-- 
Manuel Giraud