From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#59351: 29.0.50; [PATCH] Fix mouse click position to menu bar entry Date: Fri, 18 Nov 2022 17:26:13 +0200 Message-ID: <83r0y09td6.fsf@gnu.org> 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> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32078"; mail-complaints-to="usenet@ciao.gmane.io" Cc: luangruo@yahoo.com, 59351@debbugs.gnu.org To: Manuel Giraud Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Nov 18 16:27:18 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 1ow3Gv-0008CY-Q0 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 18 Nov 2022 16:27:17 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ow3Gj-0000cG-Dp; Fri, 18 Nov 2022 10:27:05 -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 1ow3Gg-0000bq-Uq for bug-gnu-emacs@gnu.org; Fri, 18 Nov 2022 10:27:03 -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 1ow3Gg-00069n-LD for bug-gnu-emacs@gnu.org; Fri, 18 Nov 2022 10:27:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ow3Gg-000363-GT for bug-gnu-emacs@gnu.org; Fri, 18 Nov 2022 10:27:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 18 Nov 2022 15:27: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.166878517711847 (code B ref 59351); Fri, 18 Nov 2022 15:27:02 +0000 Original-Received: (at 59351) by debbugs.gnu.org; 18 Nov 2022 15:26:17 +0000 Original-Received: from localhost ([127.0.0.1]:37990 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ow3Fx-000350-A7 for submit@debbugs.gnu.org; Fri, 18 Nov 2022 10:26:17 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:35004) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ow3Fv-00034n-7a for 59351@debbugs.gnu.org; Fri, 18 Nov 2022 10:26:16 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ow3Fq-0005ww-0k; Fri, 18 Nov 2022 10:26:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=6ZurcPUpIkaOtpwVX3AgVxwSdg+vQqJ0i7hnK4WwYDw=; b=jQBe0uUFo4vc kP9durG3lw9LPMY8amrMJm37yOLosFGemsw4cAZ3QScdM9BWnat0t29fX21aUVxBq8oQdpA+OLqQ9 778uXR+b86vk9gF7guDZ2lGAp8dsYXI5gfpeqMBJMetRF8w3mLeFu6Ao617Cv9jYJ6h/lLgpcI/cZ uMOtPb52gyhrd+Y2kfxR0xXGfVEJGh2QA9bTb2DS9Ijft1rfFwTyZtdMOFyBCd8+1Uii2IK9/4WpE kr5QoFpgmbAiworbUwcAtPCuKOgWW/+T14hMS0Uzblmj1YNCYVfSQObzQrdN4Vt/N4owhyzZIq115 DxrOAflruSR5Zxddyq9DxQ==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ow3Fp-0008NO-2P; Fri, 18 Nov 2022 10:26:09 -0500 In-Reply-To: <875yfcuw5r.fsf@elite.giraud> (message from Manuel Giraud on Fri, 18 Nov 2022 16:20:16 +0100) 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:248254 Archived-At: > From: Manuel Giraud > Cc: luangruo@yahoo.com, 59351@debbugs.gnu.org > Date: Fri, 18 Nov 2022 16:20:16 +0100 > > > This cannot be a compile-time condition, because Emacs compiled with X > > support can still have TTY frames. So you need to test for > > FRAME_WINDOW_P, and only call x_y_to_hpos_vpos if FRAME_WINDOW_P > > returns non-zero; otherwise call pixel_to_glyph_coords even in a build > > where HAVE_WINDOW_SYSTEM is defined. > > Ok. Sorry about that. Here is a new one. No need to be sorry, no one can possibly remember all this stuff all the time. > --- a/src/keyboard.c > +++ b/src/keyboard.c > @@ -5974,8 +5974,20 @@ 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 (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 > + pixel_to_glyph_coords (f, XFIXNUM (event->x), XFIXNUM (event->y), > + &column, &row, NULL, 1); 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.