| Summary: | Add optional “Mouse follows focus” (pointer warp on focus change) to complement focus-follows-mouse | ||
|---|---|---|---|
| Product: | [Plasma] kwin | Reporter: | Aaron <mullein> |
| Component: | general | Assignee: | KWin default assignee <kwin-bugs-null> |
| Status: | REPORTED --- | ||
| Severity: | wishlist | CC: | kde |
| Priority: | NOR | ||
| Version First Reported In: | unspecified | ||
| Target Milestone: | --- | ||
| Platform: | Other | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
|
Description
Aaron
2026-01-20 22:51:44 UTC
The problem is that we already have too many focus modes (that we even need to provide helper text to explain what they do), and adding more won't help us. That big number of focus modes prevented us from implementing some wayland protocols because the relevant code is not easy to work with. So rather than adding a new mode or options, I'd suggest that you write a script to achieve this. You can query the current pointer position, I believe you can't warp the pointer but APIs can be added for that (and other missing bits). After some more reading, I discovered that KWin already has an internal implementation for pointer centering via the default Meta+F5 shortcut ("Move Mouse to Focus"), which centers the mouse on the currently focused window. That code path clearly has access to pointer warping, window geometry, and the relevant input backend, so the underlying capability already exists.
Rather than pursuing a KWin script solution (which doesn't support pointer warping, as you stated), would it be feasible to reuse that existing internal mechanism selectively for keyboard-induced focus changes, such as when focus is finalized via the the keyboard (i.e., Alt+Tab task switcher and "Switch to Window" shortcuts)?
I imagine this should be gated by focus reason and not applied to all focus changes, as in, applied:
- Only after focus changes initiated by the keyboard
- Never for pointer-driven focus (hover, click)
- Opt-in, disabled by default
Conceptually, this seems closer to “pointer centering after keyboard window activation” than traditional mouse-follows-focus behavior, and avoids pointer/focus feedback loops.
From the user side, this would mirror the existing "Move Mouse to Focus" (Meta+F5) behavior, just automatically invoked at a well-defined internal point (e.g., task switcher/switch-to-window focus), rather than on every activation.
Would this approach be acceptable architecturally?
|