GNU bug report logs - #64658
30.0.50; NotifyGrab and NotifyUngrab should be filtered with XInput2

Previous Next

Package: emacs;

Reported by: 左 智杰 <hardirq <at> outlook.com>

Date: Sun, 16 Jul 2023 06:40:01 UTC

Severity: normal

Found in version 30.0.50

Full log


View this message in rfc822 format

From: Po Lu <luangruo <at> yahoo.com>
To: 左 智杰 <hardirq <at> outlook.com>
Cc: 64658 <at> debbugs.gnu.org
Subject: bug#64658: 30.0.50; NotifyGrab and NotifyUngrab should be filtered with XInput2
Date: Sun, 16 Jul 2023 17:09:13 +0800
左 智杰 <hardirq <at> outlook.com> writes:

> In i3wm + xfce4 setup, when multiple frames opened, switch between frames
> using only keyboard, and leave the mouse as:
>
> +-----------------+  +-----------------+
> |                 |  |                 |
> |                 |  |                 |
> |                 |  |                 |
> |                 |  |                 |
> |                 |  |                 |
> |                 |  |                 |
> |     FRAME 1     |  |     FRAME 2     |
> |    *FOCUSED*    |  |   *UNFOCUSED*   |
> |                 |  |          ^      |
> |                 |  |          |      |
> |                 |  |        MOUSE    |
> |                 |  |         HERE    |
> |                 |  |                 |
> +-----------------+  +-----------------+
>
> This will make the ~emacsclient -e '(selected-frame)'~ returns wrong frame, due to
> XInput2 sends a ~NotifyGrab~ with the unfocused frame, making Emacs selects it.
>
> We've make a small but ugly changes to fix this issue:
>
> #+begin_src
> diff --git a/src/xterm.c b/src/xterm.c
> index 9ecead03b0..d4836afeeb 100644
> --- a/src/xterm.c
> +++ b/src/xterm.c
> @@ -13193,6 +13193,11 @@ xi_focus_handle_for_device (struct x_display_info *dpyinfo,
>    if (!device)
>      return;
>  
> +  /* Same as x_detect_focus_change, issue persists in XInput2. */
> +  if (event->evtype == XI_FocusIn || event->evtype == XI_FocusOut)
> +    if (event->mode == XINotifyGrab || event->mode == XINotifyUngrab)
> +      return;
> +
>    switch (event->evtype)
>      {
>      case XI_FocusIn:
> #+end_src
>
> Wonder if we're correct?

I don't want this hack in the input extension code, because it is much
more sensitive to inconsistencies in the keyboard focus state.

What is the value of event->send_event for these unwanted focus events?




This bug report was last modified 2 years and 32 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.