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 - Bogus position data in mouse event when right clicking over an unfocused window
Summary: Bogus position data in mouse event when right clicking over an unfocused window
Status: NEW
Alias: None
Product: SDL
Classification: Unclassified
Component: events (show other bugs)
Version: 2.0.12
Hardware: x86_64 macOS 10.14
: P2 minor
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-10-05 19:10 UTC by Miles
Modified: 2020-10-18 10:36 UTC (History)
1 user (show)

See Also:


Attachments

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