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 898

Summary: Quartz SDL_WarpCursor not symmetric with SDL_GetMouseState
Product: SDL Reporter: Jeremiah Morris <bugzilla>
Component: videoAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: minor    
Priority: P2 CC: wolfy
Version: 1.2.14   
Hardware: x86   
OS: Mac OS X 10.6   
Attachments: No-op GlobalToLocal translations in fullscreen mode
Use LocalToGlobal translation when warping cursor in fullscreen mode

Description Jeremiah Morris 2009-12-09 16:07:17 UTC
Created attachment 457 [details]
No-op GlobalToLocal translations in fullscreen mode

On my MacBook Pro running 10.6, I noticed a small upward bias on mouse movement
in a fullscreen SDL application. The app uses WarpCursor and GetMouseState in a
loop to measure relative movement. I tracked it down to NSWindow's
convertBaseToScreen: routine, which added a 2-pixel offset on the Y coordinate
instead of the expected (+0,+0) translation.

In fullscreen mode, QZ_PrivateWarpCursor() does not translate the desired
position through QZ_PrivateGlobalToLocal() before passing it to the Core
Graphics system. However, QZ_GetMouseLocation() does call the reverse
QZ_PrivateLocalToGlobal() even in fullscreen mode. This asymmetry caused
problems each time the mouse was moved.

I see two solutions: either skip the convertBaseToScreen: translation in
fullscreen mode, or add it on the warping side to match the GetMouse side. I
didn't try lining the cursor up with a pixel in SDL window coordinates, so I
don't know which solution is more correct; I'm attaching patches for both
cases.
Comment 1 Jeremiah Morris 2009-12-09 16:08:07 UTC
Created attachment 458 [details]
Use LocalToGlobal translation when warping cursor in fullscreen mode
Comment 2 Sam Lantinga 2009-12-11 07:32:54 UTC
I opted to make the translation a no-op in fullscreen mode, which I think is the correct fix and matches what I do in SDL 1.3.

Thanks!