From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Manuel Giraud Newsgroups: gmane.emacs.bugs Subject: bug#59351: 29.0.50; [PATCH] Fix mouse click position to menu bar entry Date: Fri, 18 Nov 2022 18:23:18 +0100 Message-ID: <87zgcotbw9.fsf@elite.giraud> References: <87tu2wlku7.fsf@elite.giraud> <878rk8ee6d.fsf@yahoo.com> <8735agr0g4.fsf@elite.giraud> <83o7t4bhk4.fsf@gnu.org> <87zgcov1ps.fsf@elite.giraud> <8335agbai5.fsf@gnu.org> <875yfcuw5r.fsf@elite.giraud> <83r0y09td6.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35489"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: luangruo@yahoo.com, 59351@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Nov 18 18:24:19 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ow56B-00091D-1J for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 18 Nov 2022 18:24:19 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ow55z-0008E6-10; Fri, 18 Nov 2022 12:24:07 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ow55v-0008DY-HI for bug-gnu-emacs@gnu.org; Fri, 18 Nov 2022 12:24:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ow55v-00087j-1i for bug-gnu-emacs@gnu.org; Fri, 18 Nov 2022 12:24:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ow55u-00024Y-UW for bug-gnu-emacs@gnu.org; Fri, 18 Nov 2022 12:24:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Manuel Giraud Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 18 Nov 2022 17:24:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59351 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 59351-submit@debbugs.gnu.org id=B59351.16687922047900 (code B ref 59351); Fri, 18 Nov 2022 17:24:02 +0000 Original-Received: (at 59351) by debbugs.gnu.org; 18 Nov 2022 17:23:24 +0000 Original-Received: from localhost ([127.0.0.1]:38162 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ow55I-00023M-0V for submit@debbugs.gnu.org; Fri, 18 Nov 2022 12:23:24 -0500 Original-Received: from ledu-giraud.fr ([51.159.28.247]:33999) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ow55F-00023B-L1 for 59351@debbugs.gnu.org; Fri, 18 Nov 2022 12:23:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=rsa; bh=CQXTGoOwHrfr7NID UeZ2n0y4JNq1HbfSyOz29iXkj5g=; h=date:references:in-reply-to:subject: cc:to:from; d=ledu-giraud.fr; b=kskCFa/s6Ss1Iz7qPsghZQQpJYgzCVGd5jZkS8 gXmwCmPxvn/YAMxzrDbnpOhrvb43TSok59GlvoC7VDaedYvyqIa9iNZYGR/lzTTjOkfAqH 3Xy1B11YX/3E6maJYoFu1zWRWGQ2BWyxUkGz35QKOVkOX3OKGlZHUjd1I+82L5wIfbr9hi dyb2906Y7i4fKJeAn0gmw8jiJSaBaV09pwVwcrX3v2QzSY2S/oz8pnUr54w8JaHpaPRift v4qMW/2njhRPfkDUkxfgF2/nfVCD0qwe+gI0oTOESygQ/ap2Q5qTCTtPkQyeQjY6iX9oSi tTFFv3NsWKxQbVxWv9AE0xhA== Original-Received: from elite.giraud ( [10.1.1.1]) by ledu-giraud.fr (OpenSMTPD) with ESMTPSA id 36979ae3 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Fri, 18 Nov 2022 18:23:19 +0100 (CET) In-Reply-To: <83r0y09td6.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 18 Nov 2022 17:26:13 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:248267 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii 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. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Fix-click-position-to-menu-bar-entry-with-no-toolkit.patch >From 6fc191dcfa85ac98a482a7e373a4221499f86825 Mon Sep 17 00:00:00 2001 From: Manuel Giraud 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 --=-=-= Content-Type: text/plain -- Manuel Giraud --=-=-=--