| Summary: | Invalid mouse state after losing focus with a captured mouse | ||
|---|---|---|---|
| Product: | SDL | Reporter: | sycobob |
| Component: | events | Assignee: | Sam Lantinga <slouken> |
| Status: | NEW --- | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | sycobob |
| Version: | 2.0.5 | ||
| Hardware: | x86 | ||
| OS: | Windows 10 | ||
When mouse capture is enabled, clicking off of a window then back onto the window will send mouse down, but not mouse up. This leads to a couple of strange effects: 1) Moving the mouse off the window sends mouse up, or 2) The next mouse click does not send a mouse down, but sends a mouse up When holding a keyboard button and clicking off of the window key up events are sent to release all buttons. Given this, I assume the mouse should do the same thing and clicking off the window should send mouse down and mouse up. The repro is straight forward: SDL_Event sdl; while (SDL_PollEvent(&sdl) != 0) { switch(sdl.type) { case SDL_MOUSEBUTTONDOWN: Print("Mouse Down"); break; case SDL_MOUSEBUTTONUP: Print("Mouse Up"); break; case SDL_WINDOWEVENT: { if (sdl.window.event == SDL_WINDOWEVENT_FOCUS_GAINED) { Print("Focus Gained"); SDL_CaptureMouse(SDL_TRUE); } if (sdl.window.event == SDL_WINDOWEVENT_FOCUS_LOST) { Print("Focus Gained"); SDL_CaptureMouse(SDL_TRUE); } break; } } } With the above code: 1) Click off the window to lose focus (receive mouse down and focus lost) 2) Click the window to regain focus (receive focus gained) 3) Move the mouse off the window without clicking (receive mouse up) I believe the core issue is that mouse up is not sent during step 1.