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

From: Manuel Giraud <[email-masked]>
Date: Wed, 23 Nov 2022 17:43:39 +0100

Eli Zaretskii <[email-masked]> writes:

[...]

>> About the height of the menu bar, you were right.  I've tested and
>> display_menu_bar is called quite often and is called after a
>> (set-face-font 'menu "Iosevka-18").  So maybe it is the last call to
>> compute_line_metrics that does not do the required job.
>
> I suggest to step through the code there and see why that happens.
> Feel free to describe what you see if the reason is not obvious.

Hi,

I think I might be onto something for the misbehaving update of the menu
bar height when changing font face (in --with-x-toolkit=no build).

The main difficulty was to set correct breakpoint because
display_menu_bar is called quite often.  So I'm starting my GDB session
with:

--8<---------------cut here---------------start------------->8---
set args -Q
break xdisp.c:3412 if ((base_face_id == MENU_FACE_ID) && (face->font->height > 14))
run
--8<---------------cut here---------------end--------------->8---

I think the previous 14 in the breakpoint should be adapt to not trigger
at the initial face and to do trigger after face font changed.  Then
from the scracth buffer of this emacs, I type: (set-face-font 'menu
"Iosevka-18") and evaluate it.  The breakpoint triggers as this font is
quite big.

Then from GDB, I do:

--8<---------------cut here---------------start------------->8---
tbreak 26337
continue
step
--8<---------------cut here---------------end--------------->8---

This last step goes into this compute_line_metrics call.  Everything
seems fine up to xdisp.c:22886.  Before this conditional, I have the
following values:

--8<---------------cut here---------------start------------->8---
row->y = 0
row->height = 31
row->visible_height = 31
max_y = 13
--8<---------------cut here---------------end--------------->8---

And so after it, row->visible_height becomes 13.  So maybe that is why
the menu bar is not update to have more height here.  WDYT?
-- 
Manuel Giraud