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 2443

Summary: SDL thinks mouse button is held down
Product: SDL Reporter: Terry Welsh <mogumbo>
Component: eventsAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: grimfang4
Version: 2.0.2   
Hardware: x86_64   
OS: Windows (All)   

Description Terry Welsh 2014-03-11 04:33:53 UTC
Windows appears to send extra mouse button press events to SDL windows sometimes. There is no accompanying mouse button release event, causing SDL_GetMouseState() and SDL_GetRelativeMouseState() to return a non-zero button state while no buttons are held down.

Replicate it using an SDL program that uses the mouse button state or add this bit of code to the end of the main loop in testsprite2:

Uint32 mousestate = SDL_GetMouseState(NULL, NULL);
if(mousestate != 0)
    SDL_Delay(200);

Then click on the desktop or a random window. Hold a mouse button down while you Alt-Tab into your SDL program. Release the mouse button. SDL should now think the button is still held down.


Jonny D reports causing the problem a different way:
"I'm calling the Windows function GetOpenFileName() which opens a system
dialog.  When I double-click a file in the dialog, it returns to my program
with the mouse button stuck down.  If I click, the new mouse down event
doesn't happen and I get the new mouse up event instead of the old one
(which is lost completely).  If I Alt-Tab out and back in again, I also get
a new mouse up event without clicking at all.  Clicking other mouse buttons
does not affect the stuck one."


Related email thread: http://lists.libsdl.org/pipermail/sdl-libsdl.org/2014-March/093562.html
Comment 1 Sam Lantinga 2017-08-14 20:23:46 UTC
It looks like this is fixed in the latest SDL snapshot:
http://www.libsdl.org/tmp/SDL-2.0.zip