Bug 432536 - Move Mouse To Focus doesn't work as expected on Wayland
Summary: Move Mouse To Focus doesn't work as expected on Wayland
Status: RESOLVED DUPLICATE of bug 493217
Alias: None
Product: kwin
Classification: Plasma
Component: general (show other bugs)
Version: 5.27.7
Platform: openSUSE Linux
: NOR minor
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-02-05 13:58 UTC by zerocostabstraction
Modified: 2024-09-21 16:02 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.2.0
Sentry Crash Report:


Attachments
Unofficial patch for KWin 5.27 (1.08 KB, patch)
2023-11-28 09:02 UTC, Yevhen Popok
Details
Unofficial patch for KWin 5.80 (Plasma 6 Alpha) (1.31 KB, patch)
2023-11-28 09:03 UTC, Yevhen Popok
Details
Demo of the "move window" workaround (1.93 MB, video/webm)
2024-02-13 14:25 UTC, Yevhen Popok
Details

Note You need to log in before you can comment on or make changes to this bug.
Description zerocostabstraction 2021-02-05 13:58:25 UTC
SUMMARY

Move mouse to focus, using the default shortcut Meta+F5 focuses the top left corner of the screen where the mouse is on a 3 monitor setup.

STEPS TO REPRODUCE
1. Use Switch To Next Screen shortcut to focus a window on monitor 1 from monitor 0
2. A window on monitor 1 is successfully focused, the cursor stays on monitor 0
3. Press the shortcut for Move Mouse to Focus (Meta + F5) or a custom shortcut

OBSERVED RESULT

The cursor moves to the top left corner of monitor 0, focus remains unchanged. 

EXPECTED RESULT

Mouse cursor moves to the center of the window of monitor 1, where the focus is.

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 5.20.5
KDE Frameworks Version: 5.78.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION

The output of kscreen doctor:

Output: 33 XWAYLAND0 enabled connected  Unknown Modes: 38:1920x1080@60*! Geometry: 4480,360 1920x1080 Scale: 1 Rotation: 1
Output: 35 XWAYLAND1 enabled connected  Unknown Modes: 38:1920x1080@60*! Geometry: 0,360 1920x1080 Scale: 1 Rotation: 1
Output: 37 XWAYLAND2 enabled connected primary Unknown Modes: 39:2560x1440@60*! Geometry: 1920,0 2560x1440 Scale: 1 Rotation: 1 primary

It seems that the problem persists through all sorts of applications I've tested:
- 2 instances of Konsole on different monitors
- 2 instances of Alacritty on different monitors 
- Brave-Browser and a KDE settings window

Also I should mention that I haven't tested this on Xorg. I cannot confirm this is a Wayland only bug, or a new bug of any sort. I found out about the capability earlier today.
Comment 1 Yevhen Popok 2023-11-10 06:22:53 UTC
I see a similar behaviour on X11 as well so it doesn't look like a Wayland regression.
Comment 2 Yevhen Popok 2023-11-12 09:53:28 UTC
I did some research on this
1. "Move Mouse to Focus", as well as "Move Mouse To Center", are still a part of the Zoom effect. So "Move Mouse To Center" doesn't work with the "Zoom" effect disabled. However, the former KWin maintainer previously announced the intention to move both actions to the KWin core (https://invent.kde.org/plasma/kwin/-/commit/80bd289e065634cd034e69325c0cc15bf5b5e7de , "Better names for global shortcuts in Zoom Effect"),  
2. "Move Mouse to Focus" somehow depends on the "focusPoint" which calculation was changed a few years ago (https://invent.kde.org/plasma/kwin/-/commit/c1ea0412a45a64d99c120eedfa80ef376c7e6610 , "[effects/zoom] Implement focus tracking with QAccessibilityClient").
3. I've also tried Kubuntu 14.04.5 live USB (with KDE SC 4.13) but unfortunately haven't figured out how to get the "Move Mouse to Focus" action to work.

---

Conclusions:
1. "Move Mouse To Center" action still works well on both X11 and Wayland and doesn't seem to have a direct connection to the Zoom effect, so probably can be moved to the KWin core.
2. "Move Mouse to Focus" action seems broken even on the KDE SC 4.13, and if someone is going to fix or re-implement it, please make it independent of the "Zoom" effect's "Focus Tracking".
Comment 3 hinsch.martin 2023-11-22 12:26:13 UTC
I can confirm that the bug also shows up on X11 (kwin 5.27.9 on Manjaro).
Comment 4 Yevhen Popok 2023-11-28 09:02:57 UTC
Created attachment 163558 [details]
Unofficial patch for KWin 5.27
Comment 5 Yevhen Popok 2023-11-28 09:03:27 UTC
Created attachment 163559 [details]
Unofficial patch for KWin 5.80 (Plasma 6 Alpha)
Comment 6 Yevhen Popok 2024-02-13 14:25:13 UTC
Created attachment 165807 [details]
Demo of the "move window" workaround

From https://invent.kde.org/plasma/kwin/-/merge_requests/4721 I've learned that at least for now "Move Mouse to Focus" might work for some applications under X11 session.

For now, users can try to use "Move Window" shortcut as a more universal workaround.
1.  Assign some keyboard shortcut (e.g.  Meta+Ctrl+w) for the "Move Window" action. it can be set at "System Settings" > "Keyboard" > "Shortcuts" > "KWin"
2. Use keyboard only (don't use mouse or touchpad) while performing further steps
3. With Alt+Tab or Meta+Number switch to the window where you want to place cursor
4.  Press "Move Window" shortcut
5. Cursor will move to the center of the active window
6. Press "Esc" key to cancel "Move window" action. Cursor will stay in the center of the active window.

I'm attaching screencast that shows this workaround in action.
Comment 7 Yevhen Popok 2024-09-21 06:06:57 UTC
https://bugs.kde.org/show_bug.cgi?id=493217
is the same bug and it was lately resolved in 6.2.0.
The fix works only on Wayland. Hope support will be extended to X11 (I wasn't able to use Focus tracking with accessibility API there)

*** This bug has been marked as a duplicate of bug 493217 ***
Comment 8 reports_go_brrr 2024-09-21 16:02:37 UTC
Your report was earlier than mine, despite that yours is duplicate...
Anyways, thank you for the patch.