Skip to content

topbar: the Alt+Tab switcher lets the pointer leave a game's mouse-look clip - #194

Open
2sulraw wants to merge 1 commit into
Lemxy:mainfrom
2sulraw:fix/alttab-cursor-clip
Open

2sulraw wants to merge 1 commit into
Lemxy:mainfrom
2sulraw:fix/alttab-cursor-clip

Conversation

@2sulraw

@2sulraw 2sulraw commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

What

When a game is in mouse-look it confines the pointer to a pixel at its centre (ClipCursor) and keeps re-confining it while it holds the focus. Opening the Alt+Tab switcher left the game focused, so the pointer snapped straight back to the game's centre the moment it moved off the cards.

Fix

When the switcher opens and the pointer is clipped (plugins/topbar/src/main.rs):

  • release the clip (ClipCursor(NULL)) and keep it released with a 10 ms timer, in case the game re-clips without the focus;
  • take the focus like the system switcher does: temporarily clear WS_EX_NOACTIVATE on the switcher and orce_fg it, so the game receives WM_ACTIVATE(WA_INACTIVE) and stops clipping.

On close:

  • restore WS_EX_NOACTIVATE;
  • on Esc, return the focus to the game and give it its clip back;
  • when staying on / returning to the game, restore its clip; switching to another window leaves the pointer free.

No behaviour change when nothing is clipped (e.g. Alt+Tab from the desktop): the switcher stays NOACTIVATE and never takes the focus.

Tested

  • cargo test -p topbar: 19 pass.
  • Simulated a 1×1 centre clip, opened the switcher, then cancelled: on open the switcher becomes foreground, the clip is released to the full virtual desktop and WS_EX_NOACTIVATE is cleared; on cancel the clip is restored, the style is back and the previous window regains the focus.

…ok clip

A game in mouse-look clips the pointer to a pixel at its centre and re-clips it while it keeps the focus, so the pointer snapped back the moment it left the cards. When the switcher opens and the pointer is clipped, release the clip and take the focus (as the system switcher does) so the game lets the pointer go anywhere; on Esc return the focus and the clip, and on staying/returning to the game give the clip back.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant