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 4465

Summary: Changing to/from fullscreen moves the cursor without user input
Product: SDL Reporter: xenotron007
Component: videoAssignee: Sam Lantinga <slouken>
Status: NEW --- QA Contact: Sam Lantinga <slouken>
Severity: minor    
Priority: P2    
Version: 2.0.9   
Hardware: All   
OS: Windows 10   

Description xenotron007 2019-01-20 12:17:21 UTC
Changing to/from fullscreen moves the mouse cursor. This is extremely noticeable with "fake" windowed fullscreen mode that doesn't change the actual video mode/resolution. A cursor that moves without user input is annoying and can disorient the user. At the same time the resized window might contain interface elements in a different location so even if the application wanted to keep the cursor over a specific user interface element the cursor adjustment could be done only by the application.

Changing to/from fullscreen mode seems to keep a constant offset of the cursor from the topleft corner of the window client area. The issue with this solution isn't only the annoyance and bad user experience but it gives totally wrong results when switching from a "large" fake fullscreen window into a "small" non-fullscreen window when the cursor is close the bottom-right area of the fullscreen window.

I had a quick look at the SDL sources and the likely source of the issue is this change: https://hg.libsdl.org/SDL/diff/5c4635640bf9/src/video/SDL_video.c

That change should've solved the issue by updating the cached cursor positions to the actual cursor positions instead of forcing the cursor on the screen to an older cached position. In certain cases (like on windows platform) caching might have more issues than benefits compared to querying the cursor position directly (assuming that the query doesn't happen too often).