| Summary: | SDL enters infinite loop in X11_SetWindowGrab | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Jason Wyatt <jwyatt> |
| Component: | video | Assignee: | Ryan C. Gordon <icculus> |
| Status: | ASSIGNED --- | QA Contact: | Sam Lantinga <slouken> |
| Severity: | blocker | ||
| Priority: | P2 | CC: | jwyatt |
| Version: | 2.0.4 | Keywords: | target-2.0.6 |
| Hardware: | x86_64 | ||
| OS: | Linux | ||
| Attachments: | Demo for hang. | ||
Actually, calling SDL_PumpEvents after SDL_HideWindow() always seems to cause this hang, because SDL_HideWindow() causes the following series of events:
UnmapNotify event, serial 27, synthetic NO, window 0x2400005,
event 0x2400005, window 0x2400005, from_configure NO
FocusOut event, serial 27, synthetic NO, window 0x2400005,
mode NotifyNormal, detail NotifyNonlinear
FocusIn event, serial 27, synthetic NO, window 0x2400005,
mode NotifyNormal, detail NotifyPointer
With relative mouse mode disabled: SDL_HideWindow(window) SDL_PumpEvents() SDL_SetRelativeMouseMode(SDL_TRUE) will also cause the hang, because the focus is still set to the hidden window. https://hg.libsdl.org/SDL/rev/79be3e82dcf1 prevents the infinite loops. However it makes it impossible to grab the cursor again if the grab fails. https://hg.libsdl.org/SDL/rev/7cfe088fafba somewhat reduces the chances of coming across this issue, since the hidden state of a window is now properly reflected. However it still seems to be possible to cause the grab to fail (I haven't narrowed this down beyond rapid window interaction while SDL tries to set the mouse grab). I think we should punt on this for 2.0.6. |
Created attachment 2549 [details] Demo for hang. If relative mouse mode is on, and SDL_ShowWindow is followed by SDL_HideWindow without a call to SDL_PumpEvents in between, the SDL enters an infinite loop. This is because SDL will call X11_SetWindowGrab in response to the focus in event that resulted from SDL_ShowWindow. X11_SetWindowGrab will call XGrabPointer until it returns GrabSuccess. However the window is now hidden, so XGrabPointer will always return GrabNotViewable.