Bug 395970 - In a Wayland session, focus-follows-mouse doesn't work when moving from Xwayland to native Wayland application
Summary: In a Wayland session, focus-follows-mouse doesn't work when moving from Xwayl...
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (show other bugs)
Version: 5.12.5
Platform: Kubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords: wayland
: 432010 434180 (view as bug list)
Depends on:
Blocks:
 
Reported: 2018-06-28 17:24 UTC by Alex Wauck
Modified: 2021-05-14 21:22 UTC (History)
7 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.22.0
Sentry Crash Report:
mgraesslin: Wayland+
mgraesslin: X11-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Wauck 2018-06-28 17:24:20 UTC
I have a multi-monitor setup.  Since two of my monitors are 1080p and one is 4k, I decided to use Wayland.  I also have focus-follows-mouse enabled.  However, I've noticed that only Firefox seems to get focus when the mouse pointer moves from one monitor to the other.

Right now, I have Firefox (maximized) on my right monitor and Konsole (also maximized) on my left monitor.  When I move my mouse pointer from Firefox to Konsole, Konsole doesn't get focus.  If I click on Konsole, it gets focus.  If I then move the pointer over to Firefox, Firefox gets focus as expected.

If I have KeePassXC (also a QT program) open on my left monitor and NOT maximized, then it gets focus once my pointer reaches it, but Konsole doesn't get focus while my pointer is moving from my right monitor to KeePassXC.  Once KeePassXC gets focus, I can then give Konsole focus by moving my pointer to it.  Focus switches between KeePassXC and Konsole as expected.

Neither of these monitors is the primary.  (Well, probably; I changed the primary to my laptop monitor (below the two other monitors) in System Settings, but the Plasma bar didn't move, so I'm not 100% sure.)
Comment 1 Erin Yuki Schlarb 2019-10-01 12:12:07 UTC
The original report here is overly long and hard to reproduce. Here's a simpler more general description of the problem:

 1. Ensure focus-follows-mouse is enabled
 2. Open any X11/Xwayland application (such as Firefox)
 3. Open any native Wayland application (such as Konsole)
 4. Place the windows next to each other so that both are visible 
 5. Click on Konsole to ensure focus
 6. Move mouse cursor to Firefox → Focus will switch to Firefox
 7. Move mouse cursor back to Konsole → Focus will stay on Firefox

The behaviour in step 6 is OK, the one in step 7 is not.

(And yes, I also tested this on multi-monitor and there is no difference in behaviour as compared to having the windows on the same screen.)
Comment 2 groot 2021-05-01 20:12:55 UTC
Testing Alexander Schlarb's scenario:

- enable focus-follows-mouse
- start konsole
- start xterm and place it beside konsole
- click on konsole to give it focus
- move mouse to xterm
- .. and back to konsole

Repeat the last two steps several times. I often get 3 or 4 times that the focus does change from one window to the other .. and then it stops switching, for maybe another 3 or 4 tries, and then it resumes switching. The windows do not have to be side-by-side, the xterm can overlap konsole too.

It **might** be related to window decorations (shadows?) and changing cursors during the switch: if I move the mouse cursor **slowly** (and the mouse cursor changes to resize as it crosses the edge of the xterm, into konsole), the focus **rarely**changes. If I move the mouse cursor **quickly** into the other window,  I've got a good chance to move the focus over.
Comment 3 groot 2021-05-01 20:19:45 UTC
I can also recreate this with two konsole native-Wayland windows (at least, both started via `konsole -platform wayland`). Moving the mouse slowly from one to the other does not move focus, while moving the mouse quickly, does. Setting window borders to "tiny" makes it more likely that focus will change to the new window, since you are less (?) likely to hit the spot where the cursor changes.
Comment 4 Thiago Sueto 2021-05-05 14:57:25 UTC
*** Bug 432010 has been marked as a duplicate of this bug. ***
Comment 5 Vlad Zahorodnii 2021-05-05 15:33:35 UTC
This bug should be fixed in git master. Please reopen this bug report if the issue is still present.
Comment 6 Bharadwaj Raju 2021-05-05 16:34:27 UTC
*** Bug 434180 has been marked as a duplicate of this bug. ***