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 3384 - Mouse focus is 0 if exiting fullscreen overlaps mouse button event while in relative mouse mode.
Summary: Mouse focus is 0 if exiting fullscreen overlaps mouse button event while in r...
Status: NEW
Alias: None
Product: SDL
Classification: Unclassified
Component: events (show other bugs)
Version: 2.0.4
Hardware: x86_64 Linux
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-07-07 14:08 UTC by Jason Wyatt
Modified: 2016-08-17 17:08 UTC (History)
1 user (show)

See Also:


Attachments
Demo for mouse focus loss. (1.24 KB, text/x-c++src)
2016-07-07 14:08 UTC, Jason Wyatt
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jason Wyatt 2016-07-07 14:08:09 UTC
Created attachment 2527 [details]
Demo for mouse focus loss.

While in SDL_WINDOW_FULLSCREEN_DESKTOP mode, with relative mouse mode enabled. If a mouse button down event triggers switching to windowed mode, the following sequence of events causes the current mouse focus to be NULL.

 - Mouse button down event, at a point outside where the window will be.

 - Leave fullscreen, causing resize.

 - (LeaveNotify and EnterNotify cause mouse focus to be lost and gained again, however relative mouse mode prevents this being used to update coordinates).

 - Mouse button up event. Coordinates have not been updated, so this calls SDL_UpdateMouseFocus with coordinates outside the window, resulting in the mouse focus being set to NULL.

Mouse focus won't be reset until the next EnterNotify event or similar (e.g. alt-tabbing out then in again).

(Again, relative mouse mode prevents the focus being updated in SDL_SendMouseMotion)

Seen in Fedora 23, under Gnome.

Demo attached - move the cursor to some large coordinates and click (being careful not to move the mouse during the click, as this may cause the mouse position to be updated.)
The mouse motion events will report a window id of 0, despite the window still having the mouse grab. Also alt-tabbing to other programs may be broken, because SDL won't properly release the mouse.