| Summary: | [OS X 10.9] Cmd+Tab app switching breaks out of relative mouse mode | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Eric Wasylishen <ewasylishen> |
| Component: | video | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | courteauxmartijn, icculus |
| Version: | HG 2.0 | Keywords: | target-2.0.4, triage-2.0.4 |
| Hardware: | x86 | ||
| OS: | Mac OS X (All) | ||
| Attachments: | Proposed fix | ||
|
Description
Eric Wasylishen
2014-09-05 01:22:59 UTC
Still happening with OS X 10.10.1, SDL2 HG as of today (8d826bc39a45). The same bug also affects SDL_WINDOW_FULLSCREEN_DESKTOP windows; if you switch to a different desktop Space using Control+Left/Right, or using Mission Control, and then return to the SDL fullscreen desktop space, the relative mouse mode is messed up (the cursor isn't really grabbed, so you stop getting relative mouse events when the cursor reaches the edge of the screen.) This can be seen using the "testrelative" sammple, and going into fullscreen-desktop mode with Alt+Enter. Created attachment 2001 [details]
Proposed fix
Ok, I think I have a fix..
In the -windowDidBecomeKey: method in SDL_cocoawindow.m, there was a call to mouse->SetRelativeMouseMode to restore relative mouse mode. But that was bailing out and not doing anything on SDL_cocoamouse.m:244, because SDL_GetMouseFocus() was returning NULL.
I moved the SDL_SetKeyboardFocus() call in -windowDidBecomeKey: to before the SetRelativeMouseMode() call, and this seemed to fix the issue.
In addition to testing on 10.10, I just tried OS X 10.6, and my fix works there as well (the bug also affected 10.6). Thanks for this fix. It works for me as well! I'm on OS X 10.10.2. I'm not an SDL expert, but I think it's safe to merge this patch in the main source. 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! (sorry if you get a lot of copies of this email, I'm marking several bugs at once) Marking bugs for the (mostly) final 2.0.4 TODO list. This means we're hoping to resolve this bug before 2.0.4 ships if possible. In a perfect world, the open bug count with the target-2.0.4 keyword is zero when we ship. (Note that closing a bug report as WONTFIX, INVALID or WORKSFORME might still happen.) --ryan. Your patch is now https://hg.libsdl.org/SDL/rev/065e4ddc8753, thanks! --ryan. |