Skip to content

display: auto-grab mouse when the guest draws its own cursor - #207

Merged
dingusdev merged 3 commits into
dingusdev:masterfrom
probonopd:auto-grab-mouse
Aug 8, 2026
Merged

dingusdev merged 3 commits into
dingusdev:masterfrom
probonopd:auto-grab-mouse

Conversation

@probonopd

Copy link
Copy Markdown
Contributor

Fixes the double-cursor issue on the SDL display: when the guest OS draws its own (hardware) cursor into the framebuffer, the SDL host pointer was still visible on top, so the user saw two pointers that did not track each other.

Changes:

  • Hide the SDL host pointer whenever the guest draws its own cursor.
  • Auto-grab the host mouse when a guest cursor session starts, so the guest cursor can reach every screen area and the host pointer cannot wander off the window.
  • Release the automatic grab when the guest cursor disappears, so the user can move the pointer to other windows; re-grab on focus gain (SDL may drop the grab on focus loss).
  • A manual grab with Ctrl+G is sticky and overrides the automatic behavior.
  • Show the current grab state and the Ctrl+G shortcut in the window title.

When the guest OS draws a hardware cursor into the framebuffer, the SDL
host pointer was still shown on top, so the user saw two cursors that did
not track each other. Hide the host pointer while a guest cursor is drawn
and show it again otherwise, so the user can aim the mouse at the window
when no guest cursor is present.
While a guest cursor is drawn, the host mouse is now grabbed automatically
so the guest cursor can reach every screen area and the host pointer cannot
wander off the window. The grab is released again when the guest cursor
disappears, and re-established when the window regains focus, because SDL
may drop the grab on focus loss. A manual grab with Ctrl+G is sticky and
overrides the automatic behavior.
The window title now reflects whether the mouse is grabbed and how to toggle
it, so the user knows how to release the automatic grab and move the pointer
to other windows, or how to re-grab it.
@dingusdev
dingusdev merged commit 0f4957c into dingusdev:master Aug 8, 2026
7 checks passed
@dingusdev

Copy link
Copy Markdown
Owner

A few users are requesting to make this an option, as they find the force grabbing of the cursor annoying. I'll see what I can do regarding this.

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.

2 participants