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 - Incorrect mouse position on first SDL_WarpMouseInWindow() call in fullscreen
Summary: Incorrect mouse position on first SDL_WarpMouseInWindow() call in fullscreen
Status: ASSIGNED
Alias: None
Product: SDL
Classification: Unclassified
Component: *don't know* (show other bugs)
Version: HG 2.0
Hardware: x86 Linux
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-18 23:30 UTC by bonsairobo
Modified: 2014-01-28 11:02 UTC (History)
1 user (show)

See Also:


Attachments
A short SDL program that demonstrates the bug (1015 bytes, text/x-c++src)
2013-07-18 23:30 UTC, bonsairobo
Details

Note You need to log in before you can comment on or make changes to this 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.