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 5305

Summary: Bogus position data in mouse event when right clicking over an unfocused window
Product: SDL Reporter: Miles <notnullnotvoid>
Component: eventsAssignee: Sam Lantinga <slouken>
Status: NEW --- QA Contact: Sam Lantinga <slouken>
Severity: minor    
Priority: P2 CC: sezeroz
Version: 2.0.12   
Hardware: x86_64   
OS: macOS 10.14   

Description Miles 2020-10-05 19:10:47 UTC
In MacOS, right-clicking into a window doesn't focus it. However, the window can still recieve those mouse events. This is fine, except that the position given in the events is not right. If you get a MOUSEBUTTONDOWN or MOUSEBUTTONUP event, instead of reporting the current position of the mouse, the event contains the position of the where the mouse was most recently dragged.

So for example, if you repeatedly click around without dragging, it will keep reporting the same stale location for both MOUSEBUTTONDOWN and MOUSEBUTTONUP events, regardless of where you click. But if you repeatedly click and drag, you will get a MOUSEBUTTONDOWN event with the same position as the previous MOUSEBUTTONUP event, but the MOUSEBUTTONUP event will have the correct (current) mouse position. Basically, it seems to only be updating the reported mouse position when the mouse is dragged.

The positions reported by SDL_GetMouseState() are similarly stale, but those reported by SDL_GetGlobalMouseState() are not.