unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Po Lu via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Manuel Giraud <manuel@ledu-giraud.fr>
Cc: Eli Zaretskii <eliz@gnu.org>, 59351@debbugs.gnu.org
Subject: bug#59351: 29.0.50; [PATCH] Fix mouse click position to menu bar entry
Date: Sat, 19 Nov 2022 08:22:28 +0800	[thread overview]
Message-ID: <87zgcnbxob.fsf@yahoo.com> (raw)
In-Reply-To: <87zgcotbw9.fsf@elite.giraud> (Manuel Giraud's message of "Fri, 18 Nov 2022 18:23:18 +0100")

Manuel Giraud <manuel@ledu-giraud.fr> writes:

> Eli Zaretskii <eliz@gnu.org> writes:
>
>> I thought you said XWINDOW (f->menu_bar_window) doesn't compile in the
>> "--without-x" build?  I think you need the HAVE_WINDOW_SYSTEM
>> condition as well.
>
> This new one does compile "--without-x".
>
> 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.
>
> From 6fc191dcfa85ac98a482a7e373a4221499f86825 Mon Sep 17 00:00:00 2001
> From: Manuel Giraud <manuel@ledu-giraud.fr>
> Date: Fri, 18 Nov 2022 09:24:55 +0100
> Subject: [PATCH] Fix click position to menu bar entry with no-toolkit
>
> * src/keyboard.c (make_lispy_event): Use x_y_to_hpos_vpos to
> compute correct menu bar position should the menu face change.
> * src/xdisp.c (x_y_to_hpos_vpos): Not static anymore.
> * src/dispextern.h: Export x_y_to_hpos_vpos.
> ---
>  src/dispextern.h |  3 ++-
>  src/keyboard.c   | 18 ++++++++++++++++--
>  src/xdisp.c      |  2 +-
>  3 files changed, 19 insertions(+), 4 deletions(-)
>
> diff --git a/src/dispextern.h b/src/dispextern.h
> index 2f5f4335fe..2afbdeabaa 100644
> --- a/src/dispextern.h
> +++ b/src/dispextern.h
> @@ -3495,7 +3495,8 @@ #define TTY_CAP_STRIKE_THROUGH	0x20
>  extern void tty_draw_row_with_mouse_face (struct window *, struct glyph_row *,
>  					  int, int, enum draw_glyphs_face);
>  extern void display_tty_menu_item (const char *, int, int, int, int, bool);
> -
> +extern struct glyph *x_y_to_hpos_vpos (struct window *, int, int, int *, int *,
> +				       int *, int *, int *);
>  /* Flags passed to try_window.  */
>  #define TRY_WINDOW_CHECK_MARGINS	(1 << 0)
>  #define TRY_WINDOW_IGNORE_FONTS_CHANGE	(1 << 1)
> diff --git a/src/keyboard.c b/src/keyboard.c
> index 069cf0627b..6ce6ce17f2 100644
> --- a/src/keyboard.c
> +++ b/src/keyboard.c
> @@ -5974,8 +5974,22 @@ make_lispy_event (struct input_event *event)
>  	       in a menu (non-toolkit version).  */
>  	    if (!toolkit_menubar_in_use (f))
>  	      {
> -		pixel_to_glyph_coords (f, XFIXNUM (event->x), XFIXNUM (event->y),
> -				       &column, &row, NULL, 1);
> +#if defined HAVE_WINDOW_SYSTEM
> +		if (FRAME_WINDOW_P (f))
> +		  {
> +		    struct window *menu_w = XWINDOW (f->menu_bar_window);
> +		    int x, y, dummy;
> +
> +		    x = FRAME_TO_WINDOW_PIXEL_X (menu_w, XFIXNUM (event->x));
> +		    y = FRAME_TO_WINDOW_PIXEL_Y (menu_w, XFIXNUM (event->y));
> +
> +		    x_y_to_hpos_vpos (XWINDOW (f->menu_bar_window), x, y, &column, &row,
> +				      NULL, NULL, &dummy);
> +		  }
> +		else
> +#endif
> +		  pixel_to_glyph_coords (f, XFIXNUM (event->x), XFIXNUM (event->y),
> +					 &column, &row, NULL, 1);
>  
>  		/* In the non-toolkit version, clicks on the menu bar
>  		   are ordinary button events in the event buffer.
> diff --git a/src/xdisp.c b/src/xdisp.c
> index f6a279636a..0c073c0fb5 100644
> --- a/src/xdisp.c
> +++ b/src/xdisp.c
> @@ -2330,7 +2330,7 @@ pixel_to_glyph_coords (struct frame *f, int pix_x, int pix_y, int *x, int *y,
>     text, or we can't tell because W's current matrix is not up to
>     date.  */
>  
> -static struct glyph *
> +struct glyph *
>  x_y_to_hpos_vpos (struct window *w, int x, int y, int *hpos, int *vpos,
>  		  int *dx, int *dy, int *area)
>  {
> -- 
> 2.38.1

LGTM.  I installed this and am closing this bug.  Thanks for working on
Emacs.





  parent reply	other threads:[~2022-11-19  0:22 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-18  8:37 bug#59351: 29.0.50; [PATCH] Fix mouse click position to menu bar entry Manuel Giraud
2022-11-18 10:43 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-18 11:01   ` Manuel Giraud
2022-11-18 11:42     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-18 12:10       ` Manuel Giraud
2022-11-18 13:19         ` Eli Zaretskii
2022-11-18 13:24         ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-18 11:58     ` Eli Zaretskii
2022-11-18 12:15       ` Manuel Giraud
2022-11-18 12:29         ` Eli Zaretskii
2022-11-18 12:41           ` Manuel Giraud
2022-11-18 12:51             ` Eli Zaretskii
2022-11-18 13:12               ` Manuel Giraud
2022-11-18 13:23               ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-18 13:40                 ` Manuel Giraud
2022-11-18 14:08                 ` Manuel Giraud
2022-11-18 14:14                   ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-18 14:31                 ` Eli Zaretskii
2022-11-18 13:20           ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-18 13:20       ` Manuel Giraud
2022-11-18 14:30         ` Eli Zaretskii
2022-11-18 15:20           ` Manuel Giraud
2022-11-18 15:26             ` Eli Zaretskii
2022-11-18 17:23               ` Manuel Giraud
2022-11-18 18:45                 ` Eli Zaretskii
2022-11-21 13:40                   ` Manuel Giraud
2022-11-21 14:23                     ` Eli Zaretskii
2022-11-21 14:46                       ` Manuel Giraud
2022-11-21 18:12                         ` Eli Zaretskii
2022-11-22  0:34                           ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-23 16:43                   ` Manuel Giraud
2022-11-23 17:31                     ` Eli Zaretskii
2022-11-24 13:49                       ` Manuel Giraud
2022-11-25 14:55                       ` Manuel Giraud
2022-11-25 15:00                         ` Manuel Giraud
2022-11-26 12:49                           ` Eli Zaretskii
2022-11-26 17:26                             ` Manuel Giraud
2022-11-26 17:38                               ` Eli Zaretskii
2022-11-27  0:51                                 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-27  6:40                                   ` Eli Zaretskii
2022-11-28 17:07                                     ` Manuel Giraud
2022-11-29  0:47                                       ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-29  8:00                                         ` Manuel Giraud
2022-11-29  9:37                                           ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-01 10:30                                             ` Manuel Giraud
2022-11-29 12:14                                         ` Eli Zaretskii
2022-11-29 12:19                                           ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-01 12:31                                       ` Eli Zaretskii
2022-12-01 16:23                                         ` Manuel Giraud
2022-12-01 16:50                                           ` Eli Zaretskii
2022-11-19  0:22                 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2022-11-19  9:19                   ` Manuel Giraud
2022-11-18 11:42 ` Eli Zaretskii
2022-11-18 12:12   ` Manuel Giraud
2022-11-18 12:26     ` Eli Zaretskii
2022-11-18 13:16       ` Manuel Giraud
2022-11-18 14:16         ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zgcnbxob.fsf@yahoo.com \
    --to=bug-gnu-emacs@gnu.org \
    --cc=59351@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=luangruo@yahoo.com \
    --cc=manuel@ledu-giraud.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).