Mercurial > sdl-ios-xcode
diff src/video/quartz/SDL_QuartzEvents.m @ 4066:58a5055da431 SDL-1.2
More improvements for bug #373
Show the SDL cursor in the window and the arrow cursor outside the window.
This is also supposed to show the SDL cursor when activated, but that code
isn't working yet...
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 14 Jul 2007 08:27:06 +0000 |
parents | 60f677630282 |
children | b8f2db95145e |
line wrap: on
line diff
--- a/src/video/quartz/SDL_QuartzEvents.m Sat Jul 14 08:00:50 2007 +0000 +++ b/src/video/quartz/SDL_QuartzEvents.m Sat Jul 14 08:27:06 2007 +0000 @@ -623,11 +623,22 @@ void QZ_DoActivate (_THIS) { - SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS | (QZ_IsMouseInWindow (this) ? SDL_APPMOUSEFOCUS : 0)); - - /* Hide the cursor if it was hidden by SDL_ShowCursor() */ - if (!cursor_should_be_visible) - QZ_HideMouse (this); + BOOL isInGameWin = QZ_IsMouseInWindow (this); + + SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS | (isInGameWin ? SDL_APPMOUSEFOCUS : 0)); + + /* Reset the cursor state */ + /* FIXME: This doesn't currently work... + Apparently you can't set the cursor inside windowDidBecomeKey + */ + if ( isInGameWin ) { + if (cursor_should_be_visible) + SDL_SetCursor (NULL); + else + QZ_HideMouse (this); + } else { + QZ_ShowMouse (this, [NSCursor arrowCursor]); + } /* Regrab input, only if it was previously grabbed */ if ( current_grab_mode == SDL_GRAB_ON ) { @@ -656,7 +667,7 @@ /* Show the cursor if it was hidden by SDL_ShowCursor() */ if (!cursor_should_be_visible) - QZ_ShowMouse (this); + QZ_ShowMouse (this, [NSCursor arrowCursor]); } void QZ_SleepNotificationHandler (void * refcon, @@ -870,8 +881,7 @@ into the game window. This still generates a mouse moved event, but not as a result of the warp (so it's in the right direction). */ - if ( grab_state == QZ_VISIBLE_GRAB && - !isInGameWin ) { + if ( grab_state == QZ_VISIBLE_GRAB && !isInGameWin ) { NSPoint p; QZ_GetMouseLocation (this, &p); @@ -909,15 +919,20 @@ cursor enters the window again, making it obvious to the user that the grab is broken.*/ CGAssociateMouseAndMouseCursorPosition (1); - if (!cursor_should_be_visible) - QZ_ShowMouse (this); + + QZ_ShowMouse (this, [NSCursor arrowCursor]); } else if ( isInGameWin && (SDL_GetAppState() & (SDL_APPMOUSEFOCUS | SDL_APPINPUTFOCUS)) == SDL_APPINPUTFOCUS ) { SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS); - if (!cursor_should_be_visible) + + if (cursor_should_be_visible) { + SDL_SetCursor (NULL); + } else { QZ_HideMouse (this); + } + if (grab_state == QZ_INVISIBLE_GRAB) { /*see comment above*/ QZ_PrivateWarpCursor (this, SDL_VideoSurface->w / 2, SDL_VideoSurface->h / 2); CGAssociateMouseAndMouseCursorPosition (0);