-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[macOS][SDL3] SDL_HideCursor() has no effect in fullscreen #8190
Comments
I found the first commit (a077cc8) this behavior occurs. @sridenour Is there any countermeasure? |
I'll investigate when I get time, hopefully this weekend. It's worth pointing out that SDL2 has had the exact same change for a few versions now and, as you pointed out, doesn't exhibit this problem. Creating the window as fullscreen and then hiding the cursor does work (which is what I tested when I made the change). But changing to/from fullscreen seems to reset the cursor's visibility at the OS level without updating SDL's internal state (calling @kanjitalk755 As a temporary fix, showing and then re-hiding the cursor works. SDL_SetWindowFullscreen(window, fullscreen ? SDL_TRUE : SDL_FALSE);
SDL_SetWindowGrab(window, fullscreen ? SDL_TRUE : SDL_FALSE);
SDL_ShowCursor();
SDL_HideCursor(); |
No equivalent changes were found in the SDL2 branch.
For the example source, the above workaround worked fine. But if I insert the following code in the initialization to make fullscreen exclusive: SDL_DisplayID displayID = SDL_GetPrimaryDisplay();
int count;
const SDL_DisplayMode **displayModes = SDL_GetFullscreenDisplayModes(displayID, &count);
if (displayModes == NULL || count <= 0 || SDL_SetWindowFullscreenMode(window, *displayModes)) exit(1); The cursor appear even if using the workaround. Reverting commit a077cc8 (partly) works fine in both cases. |
Apparently I had a huge brain malfunction and forgot that the pull request for SDL2 I submitted at the same time as the one for SDL3 only had the early-out in
If you haven't already, submit a pull request for your partial revert. |
Actually, I think the early out in SDL_SetCursor() is wrong. See the note above the function:
|
Since it's been in SDL2 since February with no reported problems, maybe the early out could be adjusted to also check for Without the early out, SDL is unusable with Dear ImGui on macOS. Dear ImGui calls |
From libsdl-org#7249, reverted the hunks other than libsdl-org#7239.
@sridenour, I'm not following what needs to be reverted and why. Can you check #8224 to see if it's actually what we want, and whether we need similar changes in SDL2? |
@slouken #8224 looks good to me. And it matches what's been in SDL2 since February with no reported problems. What/WhyThe way SDL2 handles cursor changes on macOS (and the way SDL3 used to do it, before a077cc8) is by invalidating the window's cursor rectangles (which the OS uses to determine what cursor to use and where), causing the OS to ask the application to create new ones by calling My SDL3 change tried to make it faster by not going the invalidate-reset cursor rects route, but instead change the cursor for the whole screen (which is almost instant), with some guards to catch the cursor going out of the window and change it back. It also added an early out to My SDL2 change, to keep the change small and avoid unintended behavior changes, just had the Unfortunately, and I'm embarrassed I didn't catch this, my SDL3 change doesn't play nice with changing to fullscreen after the window has been created. #8224 just reverts to the previous way cursor changes were done, but leaves in the early out in |
@slouken This issue should be fixed to at least the same specification as SDL2 by the 3.2.0 release. |
Thanks for the investigation guys, I merged #8224. |
From libsdl-org#7249, reverted the hunks other than libsdl-org#7239.
When you build and run the following source, a white rectangle that moves according to the mouse movement will be displayed in the window.
Press any key to switch to full screen.
The mouse cursor is not displayed in SDL2 (expected behavior), but it is displayed in SDL3.
Build with SDL2:
Build with SDL3:
The text was updated successfully, but these errors were encountered: