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 1978

Summary: Incorrect mouse position on first SDL_WarpMouseInWindow() call in fullscreen
Product: SDL Reporter: bonsairobo
Component: *don't know*Assignee: Sam Lantinga <slouken>
Status: ASSIGNED --- QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: jonlst
Version: HG 2.0   
Hardware: x86   
OS: Linux   
Attachments: A short SDL program that demonstrates the bug

Description bonsairobo 2013-07-18 23:30:08 UTC
Created attachment 1241 [details]
A short SDL program that demonstrates the bug

Upon calling SDL_WarpMouseInWindow(window, WINDOW_SIZE_X / 2, WINDOW_SIZE_Y / 2) (immediately after creating the window) in a fullscreen SDL window, the cursor is not placed in the center, but slightly to the lower right. If the mouse is not moved (by the user) before exiting the program, the cursor will be moved (by SDL) to the center of the screen on exit. If SDL_Delay(x) is called before SDL_WarpMouseInWindow (where x > ~10), this fixes the bug.
Comment 1 bonsairobo 2013-07-24 17:16:17 UTC
I just found out that this doesn't happen if I wait until a SDL_WINDOWEVENT_FOCUS_GAINED event to warp the mouse.
Comment 2 (disabled) Jørgen Tjernø 2013-10-07 21:17:33 UTC
Bonsairobo, can you try reproducing with the latest HG version of SDL2? (I.e. one including this change: http://hg.libsdl.org/SDL/rev/b8d4be87970a)

Hopefully that fixes your issue.
Comment 3 bonsairobo 2013-10-07 21:47:49 UTC
(In reply to Jørgen Tjernø from comment #2)
> Bonsairobo, can you try reproducing with the latest HG version of SDL2?
> (I.e. one including this change: http://hg.libsdl.org/SDL/rev/b8d4be87970a)
> 
> Hopefully that fixes your issue.

I didn't notice a change. The bug persists for me. Used "hg clone http://hg.libsdl.org/SDL".
Comment 4 (disabled) Jørgen Tjernø 2013-10-08 00:23:46 UTC
This seems to be due to the SDL_WarpMouseInWindow being called, and afterwards then we get an EnterNotify from the X server, telling us that the cursor is somewhere else. This is possibly related to how we fullscreen? This is not code I'm familiar with, so assigning back to Sam.
Comment 5 Jon Lund Steffensen 2014-01-28 11:02:48 UTC
I'm stuck with porting to SDL2 on this same issue. It seems that the mouse position is incorrect after SDL_WarpMouseInWindow() both in (desktop) fullscreen mode and windowed mode whenever scaling is applied. If the logical screen is the same size as the window everything works as expected. SDL version 2.0.1.