We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1176

Summary: SDL_ShowCursor(1) doesn't work sometimes?
Product: SDL Reporter: Vern Jensen <vern>
Component: eventsAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: trivial    
Priority: P2 CC: buckyballreaction
Version: HG 2.0   
Hardware: All   
OS: Mac OS X (All)   

Description Vern Jensen 2011-03-28 10:07:06 UTC
I'm not sure whether to even report this as a bug, as what I'm doing is a little unusual. I've been porting a legacy Mac game over to SDL, and recently decided I would just leave the dialog box calls as-is: that is, port the dialog boxes over using Carbon function calls. It's very legacy code, but it still works, even on OS X 10.6.

The thing is, I've found that when I called SDL_ShowCursor(1) and then showed my dialog, the cursor was still invisible. Yet if I replaced SDL_ShowCursor(1) with the Mac Carbon call to InitCursor() it worked perfectly.

I also tried calling

SDL_ShowCursor(1);

4 times in a row, in case the old-style Mac cursor "level" variable had been decremented too many times, and SDL_ShowCursor() was simply incrementing it instead of doing InitCursor() or some equivalent. But this didn't help.

Anyway, feel free to disregard this report if it's unimportant. Just thought I'd mention it.

P.S. The headers for InitCursor() state that it's deprecated in 10.5 and later, yet it's working for me.
Comment 1 Sam Lantinga 2011-03-28 10:29:35 UTC
How are you hiding the cursor?  SDL is using cocoa cursor support, which doesn't work well if mixed with carbon cursor calls.
Comment 2 Vern Jensen 2011-03-28 11:10:56 UTC
I'm hiding it using SDL_ShowCursor(0). The only Carbon calls I make are to open a resource fork, and show a dialog box. Prior to that, NO Carbon calls are made. The Carbon additions were only made very recently, so the program is 99% SDL / OpenGL. Carbon headers are only included in two source code files -- files that handle dialog boxes.

But like I said, it's a special case that maybe shouldn't be considered a bug. Feel free to mark it as "Resolved" if you want. Just thought I'd mention it.
Comment 3 Sam Lantinga 2011-03-28 17:37:19 UTC
Can you attach a simple test case?

Thanks!
Comment 4 Vern Jensen 2011-03-30 15:10:51 UTC
I'll try to get a text case to you within a week or so.

In the mean time, I've discovered another, somewhat related, minor problem:

1) Push and hold a key.
2) Have program display a Carbon dialog box (such as Open File Navigation) while the key is still down. Release the key while the dialog box is visible.
3) Dismiss carbon dialog box.
4) Push the same key.

When SDL reports the keyDown event, it reports the keyRepeat as being true. This is because, from SDL's perspective, the key was never released. (It was released while "Carbon" had control of events.)

I've mostly worked around this for now. I'm guessing there's not much you can do about it. But if there is... it'd be nice to have fixed.
Comment 5 buckyballreaction 2012-11-14 13:27:29 UTC
Just to add another simple test case for which I think is the same issue:

1. Start and SDL application
2. CMD + TAB to another window
3. CMD + TAB back
4. The cursor is gone!

As a workaround, I've found that calling the following in each of SDL_WINDOWEVENT_FOCUS_LOST and SDL_WINDOWEVENT_FOCUS_GAINED seems to correct the issue:

SDL_ShowCursor(0);
SDL_ShowCursor(1);

Thanks
Comment 6 Sam Lantinga 2013-05-21 02:34:03 UTC
Can you verify whether this is fixed in the current snapshot?
http://www.libsdl.org/tmp/SDL-2.0.zip
Comment 7 buckyballreaction 2013-05-21 11:33:11 UTC
Hi,

I just tested this with rev ad1ee23309ca.  It is fixed to me.  The mouse cursor does reappear properly.

However, (and this may be a new bug,) the mouse is completely inoperable.  Movement does not map properly to the cursor in-game (very erratic) and no clicks are registered.
Comment 8 Sam Lantinga 2013-05-21 23:52:22 UTC
Thanks for verifying this issue!

Feel free to report a separate bug for that, if you still see it once you've installed SDL with the latest headers and completely rebuilt your application with it.  There was an event structure change that would cause the behavior you're seeing if you haven't rebuilt with the latest headers.
Comment 9 buckyballreaction 2013-05-22 10:45:23 UTC
Yep.  That was it.  I needed to fully recompile with the new header changes.  Thank you!