We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4974 - Incorrect SDL_MOUSEMOTION on window refocus in SDL_SetRelativeMouseMode
Summary: Incorrect SDL_MOUSEMOTION on window refocus in SDL_SetRelativeMouseMode
Status: NEW
Alias: None
Product: SDL
Classification: Unclassified
Component: events (show other bugs)
Version: 2.0.10
Hardware: x86 Windows 10
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-02-12 12:04 UTC by Dom
Modified: 2020-02-12 12:04 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dom 2020-02-12 12:04:07 UTC
Reproducable in SDL testrelative.c test application:
1. Unfocus window (Alt+Tab away or press windows key to open start menu)
2. Refocus window by clicking on it
3. Or refocus window by using Alt+Tab

Current behavior:
Causes the mouse position to jump relative to the clicked mouse position (case 2).
Or causes the mouse position to jump to somewhat left of the center (case 3).

Expected behavior:
No mouse movement (SDL_MOUSEMOTION) should be reported on window refocus while in relative mouse mode.

Workaround to fix this is to disable and enable relative mouse mode on SDL_WINDOWEVENT_FOCUS_GAINED like so:
SDL_SetRelativeMouseMode(SDL_FALSE);
SDL_SetRelativeMouseMode(SDL_TRUE);

Happens on all tested versions of SDL: 2.0.8, 2.0.9, 2.0.10 and on the current version on master.