bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#61241: 29.0.60; Incoherent last_mouse_window (xterm.c) between XInpu


From: Eli Zaretskii
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

> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]