all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: "Adrián Medraño Calvo" <adrian@medranocalvo.com>,
	"Po Lu" <luangruo@yahoo.com>
Cc: 61241@debbugs.gnu.org
Subject: bug#61241: 29.0.60; Incoherent last_mouse_window (xterm.c) between XInput and XInput 2
Date: Sat, 04 Feb 2023 10:25:12 +0200	[thread overview]
Message-ID: <831qn5vnvb.fsf@gnu.org> (raw)
In-Reply-To: <16B04B25-8EB8-4967-947B-C03DF3690ADF@medranocalvo.com> (adrian@medranocalvo.com)

> From: Adrián Medraño Calvo
>  <adrian@medranocalvo.com>
> Date: Thu, 2 Feb 2023 23:28:01 +0100
> 
> For the implementation of `mouse-autoselect-window', the entered window
> is remembered and then compared when an mouse motion event is received.
> Up to Emacs 28, this value was stored in a static local variable named
> `last_mouse_window' in the block handling MotionNotify within
> `handle_one_xevent'.  With the introduction of XInput 2,
> `handle_one_xevent' was adjusted to account for XI_Motion events, with
> the oversight that a new local static `last_mouse_window' variable was
> declared in the new handler block for XI_Motion.  As a result, when
> Emacs receives motion events from XInput and XInput2 sources
> alternatively the value of each `last_mouse_window’ differs, leading to
> the window under the motion sometimes not being selected, as the
> value `last_mouse_window' is out-of-date for the particular XInput
> version.
> 
> This bug impacts the GNU ELPA package EXWM.  EXWM tries to extrapolate
> applicable Emacs functionality to X window management; among others
> assigns an Emacs buffer to each managed X window, and positions the X
> window over the Emacs window in which the buffer is displayed.  When
> `mouse-autoselect-windows’ and the user moves the mouse pointer over one
> X window managed by EXWM, this X window receives the mouse events and not
> Emacs, therefore the Emacs window is not selected.  In order to overcome
> this, EXWM sends a synthetic MotionNotify event to Emacs.
> 
> The attached patch fixes the issue.
> 
> Thank you,
> Adrián Medraño Calvo.
> 
> From e16d6ddbfdc4110fbbbcf763cff5a72b0f0df92c Mon Sep 17 00:00:00 2001
> Message-Id: <e16d6ddbfdc4110fbbbcf763cff5a72b0f0df92c.1675376734.git.adrian@medranocalvo.com>
> From: =?UTF-8?q?Adri=C3=A1n=20Medra=C3=B1o=20Calvo?=
>  <adrian@medranocalvo.com>
> Date: Wed, 1 Feb 2023 00:00:00 +0000
> Subject: [PATCH] Fix `mouse-autoselect-window' for alternating XInput and
>  XInput 2 events
> 
> * src/xterm.c (handle_one_xevent): Move `last_mouse_window' to
> main function scope to share value between XInput and XInput 2
> handlers.
> ---
>  src/xterm.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/xterm.c b/src/xterm.c
> index 6a4b84babe4..dd20c8c7fe5 100644
> --- a/src/xterm.c
> +++ b/src/xterm.c
> @@ -18364,6 +18364,9 @@ handle_one_xevent (struct x_display_info *dpyinfo,
>    GdkDisplay *gdpy = gdk_x11_lookup_xdisplay (dpyinfo->display);
>  #endif
>    int dx, dy;
> +  /* Holds the last window the mouse moved over, used for
> +     `mouse-autoselect-window' */
> +  static Lisp_Object last_mouse_window;
>  
>    /* Avoid warnings when SAFE_ALLOCA is not actually used.  */
>  #if defined HAVE_XINPUT2 || defined HAVE_XKB || defined HAVE_X_I18N
> @@ -20677,8 +20680,6 @@ handle_one_xevent (struct x_display_info *dpyinfo,
>  		&& (f == XFRAME (selected_frame)
>  		    || !NILP (focus_follows_mouse)))
>  	      {
> -		static Lisp_Object last_mouse_window;
> -
>  		if (xmotion.window != FRAME_X_WINDOW (f))
>  		  {
>  		    x_translate_coordinates (f, xmotion.x_root, xmotion.y_root,
> @@ -22587,7 +22588,6 @@ handle_one_xevent (struct x_display_info *dpyinfo,
>  		      && (f == XFRAME (selected_frame)
>  			  || !NILP (focus_follows_mouse)))
>  		    {
> -		      static Lisp_Object last_mouse_window;
>  		      Lisp_Object window = window_from_coordinates (f, ev.x, ev.y, 0, false, false);
>  
>  		      /* A window will be autoselected only when it is not
> -- 
> 2.39.1

Po Lu, any comments, or should this go in?





  reply	other threads:[~2023-02-04  8:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-02 22:28 bug#61241: 29.0.60; Incoherent last_mouse_window (xterm.c) between XInput and XInput 2 Adrián Medraño Calvo
2023-02-04  8:25 ` Eli Zaretskii [this message]
2023-02-04  8:43   ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-05 19:04 ` Adrián Medraño Calvo
2023-02-06  1:40   ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-22  5:45     ` Adrián Medraño Calvo
2023-08-22  6:59       ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors

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

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

  git send-email \
    --in-reply-to=831qn5vnvb.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=61241@debbugs.gnu.org \
    --cc=adrian@medranocalvo.com \
    --cc=luangruo@yahoo.com \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.