| Summary: | SDL_SetWindowGrab allows clicking outside the window | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Thierry Crozat <criezy> |
| Component: | video | Assignee: | Sam Lantinga <slouken> |
| Status: | NEW --- | QA Contact: | Sam Lantinga <slouken> |
| Severity: | minor | ||
| Priority: | P2 | CC: | amaranth72, sezeroz |
| Version: | 2.0.5 | ||
| Hardware: | x86 | ||
| OS: | macOS 10.12 | ||
|
Description
Thierry Crozat
2017-09-20 23:39:56 UTC
I should add that this behaviour happens when the window is *not* resizable. When using SDL_WINDOW_RESIZABLE then I cannot click outside the window and the cursor does not seem to bump/flicker on the borders of the window. I does allow to resize the window, which is a bit strange in my opinion, but might be the expected behaviour. Somebody also pointed me to bug #2150, which looks like it might be the same bug. So I apologise if you think this bug is a duplicate of bug #2150. I did look for existing bug before opening this one, but the "broken on Linux" bit in the title of bug #2150 made me fail to realise it also mentioned macOS X. If you don't plan on distributing your app in the Mac App Store you can compile SDL2 with SDL_MAC_NO_SANDBOX defined, which allows SDL to use a better method of making sure the cursor doesn't leave the window. It's also worth mentioning that SDL_SetRelativeMouseMode should be used when possible instead of SDL_SetWindowGrab, when feasible (e.g. when doing mouse movement tracking for a FPS game). The former avoids most of the issues SetWindowGrab may have. (In reply to Alex Szpakowski from comment #2) > If you don't plan on distributing your app in the Mac App Store you can > compile SDL2 with SDL_MAC_NO_SANDBOX defined, which allows SDL to use a > better method of making sure the cursor doesn't leave the window. Specifically, SDL_MAC_NO_SANDBOX defined to 1. Thank you for the suggestions. I have now updated to SDL 2.0.6, which shows the same behaviour as SDL 2.0.5 when not defining SDL_MAC_NO_SANDBOX. I have also tried with SDL_MAC_NO_SANDBOX defined, and the behaviour is marginally better. It is no longer possible to click on the title bar of the window when the mouse is grabbed and there is less flickering with non-resizable windows when the mouse reaches one of the window edges (although it still happens a bit with the right or bottom edges). It does feel a bit strange to see the system cursor appearing when the mouse reaches one of the edge of the window though, and it is still possible to click outside the window when the mouse is in one of the bottom corners. Also we are working with point&click games and not FPS, so SDL_SetRelativeMouseMode does not look like it would be very adapted. Although since we draw our own cursor and deliver our own mouse positioning events to the game engines, I guess we could try to use it when we want to grab the mouse and track absolute position of the game cursor in the window from the relative events received. |