Skip to content

Ignore SDL3 mouse delta while window is unfocused#2859

Open
Copilot wants to merge 2 commits into
masterfrom
copilot/fix-mouse-delta-issue
Open

Ignore SDL3 mouse delta while window is unfocused#2859
Copilot wants to merge 2 commits into
masterfrom
copilot/fix-mouse-delta-issue

Conversation

Copilot AI commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

SDL3 mouse motion events can continue arriving after the window loses focus on Windows, which allows hover movement over an unfocused window to generate camera delta. This change gates mouse motion on window focus and re-syncs mouse state when focus returns.

  • Focus-aware mouse motion handling

    • Track SDL window focus inside SdlMouseInput
    • Drop SDL_EVENT_MOUSE_MOTION events while the window is unfocused
    • Clear queued motion events on focus loss so stale deltas are not delivered later
  • State resync on focus regain

    • Refresh window metrics and reinitialize the current mouse position on SDL_EVENT_WINDOW_FOCUS_GAINED
    • Preserve existing cursor visibility / relative-mode behavior while preventing the first post-focus event from using stale coordinates
  • Regression coverage

    • Add a focused unit test that verifies mouse motion is ignored when the SDL window is marked unfocused
if (event.motion().windowID() != context.getWindowId() || !windowFocused) {
    return;
}

Copilot AI changed the title [WIP] Fix mouse delta detection when tabbed out with SDL3 Ignore SDL3 mouse delta while window is unfocused Jun 9, 2026
Copilot AI requested a review from riccardobl June 9, 2026 12:58

@riccardobl riccardobl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@riccardobl riccardobl marked this pull request as ready for review June 9, 2026 14:16
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.

Mouse Delta is detected when tabbed out with SDL3 on windows

2 participants