Skip to content
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

SDL_SetCursor doesn't work in fullscreen mode #261

Closed
SDLBugzilla opened this issue Feb 10, 2021 · 0 comments
Closed

SDL_SetCursor doesn't work in fullscreen mode #261

SDLBugzilla opened this issue Feb 10, 2021 · 0 comments

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

These attachments are available in the static archive:

Reported in version: 1.2.11
Reported for operating system, platform: Mac OS X (All), PowerPC

Comments on the original bug report:

On 2006-12-18 15:58:11 +0000, Rhythmic Fistman wrote:

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.

On 2007-07-06 01:04:34 +0000, Sam Lantinga wrote:

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.

On 2007-07-07 18:11:21 +0000, Ryan C. Gordon wrote:

Bumping to P1 for consideration in the 1.2.12 release (but it might bump back to P2).

--ryan.

On 2007-07-07 23:29:05 +0000, Sam Lantinga wrote:

This looks to be the result of Christian Walther's cocoa cursor code for 1.2.11. Christian, can you look into this?

On 2007-07-11 10:16:45 +0000, Christian Walther wrote:

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...

On 2007-07-12 13:29:14 +0000, Christian Walther wrote:

Created attachment 225
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.

On 2007-07-12 13:36:40 +0000, Sam Lantinga wrote:

Thanks for the update. I'm contacting Transgaming to find out the status of their patches now.

On 2007-07-13 21:55:38 +0000, Sam Lantinga wrote:

This patch doesn't seem to work for me with testcursor in fullscreen mode. The viewable window is in front of the cursor!

On 2007-07-13 22:11:25 +0000, Sam Lantinga wrote:

It turns out that the SDL_Flip() in the testcursor code was drawing over the cursor, but only in 8-bit mode.

On 2007-07-14 01:30:22 +0000, Sam Lantinga wrote:

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.

On 2007-07-15 07:24:36 +0000, Christian Walther wrote:

Created attachment 227
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.

On 2007-07-15 08:23:02 +0000, Sam Lantinga wrote:

I'm looking at this now, thanks!

On 2007-07-15 09:00:59 +0000, Sam Lantinga wrote:

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?

On 2007-07-15 10:04:56 +0000, Christian Walther wrote:

Created attachment 229
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.

On 2007-07-15 10:25:51 +0000, Sam Lantinga wrote:

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant