"Sloppy" or "Focus on Hover" window focus is slow to respond, some keystrokes go to the wrong (old) window

Bug #1814839 reported by jimav
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
gnome-shell (Ubuntu)
Invalid
Undecided
Unassigned
mutter (Ubuntu)
Won't Fix
Medium
Unassigned

Bug Description

https://gitlab.gnome.org/GNOME/mutter/issues/469

---

Ubuntu 18.04. Gnome X11 session.

When window focus policy is set to follow the mouse, then if the mouse is moved into a new window and keystrokes typed immediately afterwards, the keystrokes go to the old window (invariably causing application errors).

This is extremely annoying for rapid-fire developers, who for example run vim in one window to edit a script and bash in another to test the script; the sequence 1) save changes in vim; 2) move mouse to the bash window; 3) type the command to run the script results in the shell command (or part of it) being received by vim in the old window (with occasionally-entertaining effects).

It seems like mouse-movement events are not kept in-order with respect to keyboard events. I can see the mouse pointer move to the new window before I type on the keyboard, so I know the mouse-move events have been received before the keystrokes.

Speculations:

This might be a window-manager bug: Although the mouse cursor has moved before I type, the window borders may not yet have changed to indicate a changed focus (not certain because the sequence is so quick). Therefore the window manager might be (erroneously) continuing to pass keystrokes to the "current" (i.e. old) window after the mouse moves into the new window. I'm assuming here that the window manager is able to receive mouse-move and keyboard events in a single stream, or timestamped, or otherwise marked so they can be processed in the order they originally occurred.

Or maybe Xorg does not keep them in order or doesn't allow the window-manager to know their relative order. Or maybe keystrokes are going directly to the old window without filtering for the current mouse position (if this is the case, then IMO xorg should be told to stop delivering keystrokes if the mouse is outside a specified region until the window-manager tells it to resume delivery; or some similar way to allow the focus-change to occur first).

STEPS TO REPRODUCE:

1. Run gnome-tweaks, set Windows->Window Focus to "Sloppy"
2. Open two vertically-adjacent gnome-terminal windows
3. Put cursor in the top window. Wait 2 seconds.
4. Move mouse (with one hand) rapidly into the other window, then (immediately) type a character into the other window (with the other hand)

ACTUAL RESULTS: The keystroke appears in the old window

EXPECTED RESULTS: Keystroke appears in the new window (i.e. the keystroke is not processed at all until the window manager completes the focus change). In other words, "typeahead" should encompass both keystrokes and mouse movements.

Tags: bionic focus
jimav (james-avera)
description: updated
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Are you able to try Ubuntu 19.04 and tell us if the same problem happens there?

http://cdimages.ubuntu.com/daily-live/current/

If it does happen in 19.04 too, then please log the bug upstream at:

https://gitlab.gnome.org/GNOME/mutter

affects: xorg (Ubuntu) → gnome-shell (Ubuntu)
Changed in gnome-shell (Ubuntu):
status: New → Incomplete
Changed in mutter (Ubuntu):
status: New → Incomplete
tags: added: bionic
Revision history for this message
jimav (james-avera) wrote : Re: [Bug 1814839] Re: keystrokes go to wrong window immediately after moving mouse to change window focus

Daniel van Vugt wrote:
> Are you able to try Ubuntu 19.04 and tell us if the same problem happens
> there?

Yes I can download and install Ubuntu 19.04 in a virtual machine.  But
before you ask me to go to all that work, have you tried the test
yourself given in the bug ("STEPS TO REPRODUCE")?

Do you see the symptom?  If yes, on what OS version?

Thanks.

Revision history for this message
Daniel van Vugt (vanvugt) wrote : Re: keystrokes go to wrong window immediately after moving mouse to change window focus

Yes, confirmed in both 18.04 and 19.04. Although the mode changed names from "Sloppy" to "Focus on Hover". It's still the same bug.

However I can see the window highlight change is also delayed. So I expect that delay is the problem.

summary: - keystrokes go to wrong window immediately after moving mouse to change
- window focus
+ "Sloppy" or "Focus on Hover" window focus is slow to respond, some
+ keystrokes go to the wrong (old) window
Changed in gnome-shell (Ubuntu):
status: Incomplete → Confirmed
Changed in mutter (Ubuntu):
status: Incomplete → Confirmed
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Confirmed. If you would like to discuss the problem with Gnome developers then please report it here:

https://gitlab.gnome.org/GNOME/mutter/issues

Revision history for this message
jimav (james-avera) wrote :
description: updated
Changed in mutter (Ubuntu):
status: Confirmed → Triaged
importance: Undecided → Medium
Changed in gnome-shell (Ubuntu):
status: Confirmed → Invalid
tags: added: focus
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Thank you for reporting this bug to Ubuntu.

Ubuntu 18.04 (bionic) reached end-of-standard-support on May 31, 2023.

See this document for currently supported Ubuntu releases:
https://wiki.ubuntu.com/Releases

We appreciate that this bug may be old and you might not be interested in discussing it anymore. But if you are then please upgrade to the latest Ubuntu version and re-test. If you then find the bug is still present in the newer Ubuntu version, please add a comment here telling us which new version it is in.

Changed in mutter (Ubuntu):
status: Triaged → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.