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 1894

Summary: Mouse handling needs to be verified to be consistent
Product: SDL Reporter: (disabled) Jørgen Tjernø <jorgen>
Component: eventsAssignee: Andreas Schiffler <aschiffler>
Status: ASSIGNED --- QA Contact: Sam Lantinga <slouken>
Severity: critical    
Priority: P2 CC: amaranth72, resmi
Version: 2.0.0   
Hardware: All   
OS: All   

Description (disabled) Jørgen Tjernø 2013-06-05 15:30:13 UTC
I'm writing this up to serve as a form of "test case" for what we expect mouse handling to be like across all platforms. Feel free to comment with more suggestions.

Test cases:

 Non-relative, non-grabbed:
   - Move cursor outside of window:
     - Ensure focus lost event
     - Ensure clamped values
     - Ensure no more mouse motion events
   - Move cursor into window
     - Ensure focus gained event before mouse motion event
   - Click inside window, drag outside of window, release outside of window
     - Ensure mouse motion events with values outside of the window bounds
     - Ensure no focus lost event until you release button
     - Ensure mouse up event when released
   - Click inside window, drag outside of window and back in again, release inside of window
     - Same as release outside of window, except no focus lost event
   - Hide cursor, move cursor out of window
     - Cursor should be displayed once it has left window
   - Hide cursor, command/alt+tab to change focus
     - Cursor should be displayed once you change focus
     - Once you change focus back (command/alt+tab), cursor should be hidden once inside window

 Relative:
   - Cursor should not be moveable outside of window
   - Cursor should be hidden
     - Cmd/alt-tab should reshow the cursor
     - Cmd/alt-tab back should hide the cursor again
     - SDL_ShowCursor(1) should not show the cursor
   - Enable relative mode while cursor is outside of window
     - Window with current keyboard focus should get a mouse focus event
     - Clicks should go inside window and not remove focus from application
     - Movement should not "jump" for the first mouse move
     - Cmd/alt-tab should remove focus from application and motion events should not be received
     - Cmd/alt-tab out of app should return cursor to the position it was in before enabling relative mode or the application last gained focus (if relative mode was enabled)
   - Enable relative mode, alt-tab back, move cursor away from application bounds
     - Cmd/alt-tab back should return to relative mode
     - Clicks after cmd/alt-tabbing back should not remove focus from the application
     - Movement should not "jump" for the first mouse move
   - Switching keyboard focus inside the application (if it has multiple windows) should update SDL_GetMouse()->focus if relative mode is enabled
   - Disable relative mode
     - Mouse cursor should return to the position it was in before enabling relative mode or the application last gained focus (if relative mode was enabled)
     - Focus lost events should be sent if cursor was previously outside of window
     - Cursor should be shown unless the user called SDL_ShowCursor(0)

 Grabbed:
   - ???? (Please help me fill this out.)
Comment 1 Sam Lantinga 2013-06-05 23:36:49 UTC
Hey Andreas, is it possible to set up tests for this functionality?
Comment 2 Alex Szpakowski 2013-07-29 05:27:56 UTC
Is the "Click inside window, drag outside of window, release outside of window" functionality something that can be implemented before 2.0's release?

Currently (at least in OS X) mouse events stop being generated when the mouse leaves the window even if the mouse button is held down, and it feels very unintuitive, especially considering SDL 1.2 had this functionality.
Comment 3 Sam Lantinga 2013-08-03 00:21:45 UTC
Probably not for release.  Fortunately this is the kind of thing we can easily fix  after release.
Comment 4 Ryan C. Gordon 2015-02-19 05:22:23 UTC
Marking a large number of bugs with the "triage-2.0.4" keyword at once. Sorry if you got a lot of email from this. This is to help me sort through some bugs in regards to a 2.0.4 release. We may or may not fix this bug for 2.0.4, though!
Comment 5 Resmi 2015-08-27 04:05:44 UTC
Noticed some odd behaviour while dragging windows on a Mac, I think it's relevant to this issue. Upon clicking on the window's title bar to move the window, the mousedown event is registered, but the following mouseup event is never received and the mouse button is assumed held down until you click and release again.
Comment 6 Resmi 2015-08-27 04:09:11 UTC
(In reply to Resmi from comment #5)
> Noticed some odd behaviour while dragging windows on a Mac, I think it's
> relevant to this issue. Upon clicking on the window's title bar to move the
> window, the mousedown event is registered, but the following mouseup event
> is never received and the mouse button is assumed held down until you click
> and release again.

On a source build SDL2-2.0.3, running from XCode, OSX10.10.15. Tried with the trackpad and a mouse.
Comment 7 Alex Szpakowski 2015-08-27 04:14:10 UTC
Can you try with the SDL 2.0.4 release candidate? (https://www.libsdl.org/tmp/download-2.0.php)

That issue should be fixed as of this commit: https://hg.libsdl.org/SDL/rev/525f13ccf27f
Comment 8 Resmi 2015-08-27 05:41:50 UTC
It's fixed. Thank you very much!