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 373 - SDL_SetCursor doesn't work in fullscreen mode
Summary: SDL_SetCursor doesn't work in fullscreen mode
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: 1.2.11
Hardware: PowerPC Mac OS X (All)
: P1 normal
Assignee: Christian Walther
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-12-18 15:58 UTC by Rhythmic Fistman
Modified: 2007-07-15 10:25 UTC (History)
1 user (show)

See Also:


Attachments
patch for fullscreen cursor switching from Cider (4.35 KB, patch)
2007-07-12 13:29 UTC, Christian Walther
Details | Diff
patch to use a cursor rectangle (1.89 KB, patch)
2007-07-15 07:24 UTC, Christian Walther
Details | Diff
patch to reinstate the SDL cursor after an NSApplicationActivatedEvent (1.20 KB, patch)
2007-07-15 10:04 UTC, Christian Walther
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Rhythmic Fistman 2006-12-18 15:58:11 UTC
SDL_SetCursor has no effect when running in fullscreen mode
 on osx 10.4 (intel) and osx 10.3 (ppc), neither with framework
 nor with traditional cmd line lib.

Does work with 1.2.10.
Comment 1 Sam Lantinga 2007-07-06 01:04:34 UTC
I can reproduce this with the testcursor test program, BTW.  I've no idea why it's not working though.

Actually, I noticed that the cursor is supposed to be the 4-square cursor right at the start, but it doesn't change at all until the mouse is first clicked in the window.
Comment 2 Ryan C. Gordon 2007-07-07 18:11:21 UTC
Bumping to P1 for consideration in the 1.2.12 release (but it might bump back to P2).

--ryan.

Comment 3 Sam Lantinga 2007-07-07 23:29:05 UTC
This looks to be the result of Christian Walther's cocoa cursor code for 1.2.11.  Christian, can you look into this?
Comment 4 Christian Walther 2007-07-11 10:16:45 UTC
Brief progress report:

With respect to the 4-square cursor not being set at the start, what I found out so far is that the first call to SDL_PumpEvents(), which handles the NSApplicationActivatedEventType event, resets the cursor to the system arrow. So, any cursor set with SDL_SetCursor() at the beginning of the program is lost when the event loop starts. This, along with the fact that the cursor also reverts to the default arrow when switching away from the application and back, can probably be fixed by re-setting the SDL cursor in QZ_DoActivate().

On to the fullscreen issue now...
Comment 5 Christian Walther 2007-07-12 13:29:14 UTC
Created attachment 225 [details]
patch for fullscreen cursor switching from Cider

It appears that the guys at Transgaming have solved the fullscreen problem for us. The attached patch was extracted from the SDL sources shipped with http://static.g.gametap.com/static/uru-client/mac/mac_myst_setup.dmg (in Myst Online.app/Contents/Resources/Myst Online.app/Contents/Frameworks/SDL.framework/SDL-source-with-transgaming-updates.tar.gz). I couldn't find this anywhere on www.transgaming.com, www.cedega.com, or cvs.transgaming.org.

I can't vouch for this patch to be the right thing to do or to have no adverse side effects, but in my limited testing so far it appears to work well. Perhaps it wouldn't be a bad idea to ask the Cider developers about its status before integrating it.
Comment 6 Sam Lantinga 2007-07-12 13:36:40 UTC
Thanks for the update.  I'm contacting Transgaming to find out the status of their patches now.
Comment 7 Sam Lantinga 2007-07-13 21:55:38 UTC
This patch doesn't seem to work for me with testcursor in fullscreen mode.  The viewable window is in front of the cursor!
Comment 8 Sam Lantinga 2007-07-13 22:11:25 UTC
It turns out that the SDL_Flip() in the testcursor code was drawing over the cursor, but only in 8-bit mode.
Comment 9 Sam Lantinga 2007-07-14 01:30:22 UTC
The Cider patch is applied, and appears to fix things for 16-bit and 32-bit fullscreen modes.

I added code to set the cursor to the SDL cursor while in the window, and set the arrow cursor outside the SDL window.  I also call this code in QZ_DoActivate(), but that didn't work.  As far as I can tell you can't set the cursor inside of windowDidBecomeKey, even though the window thinks it's already key.  From the documentation it looks like the correct way to do this is to set up the cursor rect on the NSView.
Comment 10 Christian Walther 2007-07-15 07:24:36 UTC
Created attachment 227 [details]
patch to use a cursor rectangle

Yes, the idea to use a cursor rectangle instead of [NSCursor set] has occurred to me too, and it does seem to be the most elegant way. Here's my attempt at an implementation. The patch is against r3264 for clarity, to apply it to HEAD you need to 'svn merge -r3265:3264 .' first. Appears to work with testcursor.c in windowed and fullscreen modes, 2D or OpenGL, of depths 8, 16, 32, on 10.4.10 x86 and 10.3.9 PPC, modulo the overdrawn cursor in 8-bit fullscreen mode. Not tested in any real-world application.

I'm not sure if we'd need to swap the content view as well in the case of SDL_NSWindowPointer and SDL_NSQuickDrawViewPointer environment variables given, as I'm not familiar with how these are used.
Comment 11 Sam Lantinga 2007-07-15 08:23:02 UTC
I'm looking at this now, thanks!
Comment 12 Sam Lantinga 2007-07-15 09:00:59 UTC
Okay, I cleaned up the code and applied it as revision 3291.

It still doesn't show the initial cursor correctly if I change testcursor to set a 32-bit fullscreen mode.  It shows the default arrow cursor instead of the square cursor.  Is that something that I broke in the cleanup?
Comment 13 Christian Walther 2007-07-15 10:04:56 UTC
Created attachment 229 [details]
patch to reinstate the SDL cursor after an NSApplicationActivatedEvent

Oops, you're right. My testcursor.c has diverged so far from the original that I missed that. In fact, now that I think about it, that issue isn't even addressed by the cursor rectangle patch - it is only concerned with windowed mode (and fixes the problem there as a side effect). The problem in fullscreen is still the same as before. How about the attachment for a fix? (I can confirm that [NSCursor set] doesn't seem to have any effect when called from QZ_DoActivate().)

On a side note, fixing this bug has the side effect that applications that never call SDL_SetCursor() now get the pixelated black-and-white SDL standard arrow instead of the anti-aliased system standard arrow. That's the intended result, of course, but it still kinda feels like a step backwards...

Continuing on this tangent, are there any plans for a 32-bit RGBA version of SDL_SetCursor() for 1.3? No idea about the feasibility of this on other platforms, but on Cocoa it would be a trivial change from the current code.
Comment 14 Sam Lantinga 2007-07-15 10:25:51 UTC
Yay!  This fixes the bug, and is checked in with revision 3295.  Thanks!

The fact that it uses the standard SDL arrow is fine, that's the behavior on all systems with SDL 1.2

With SDL 1.3 we can certainly add support for RGBA cursors and have a nicer default one for systems that support it - or even leave the system cursor unchanged by default.