diff src/video/quartz/SDL_QuartzWM.m @ 4070:b8f2db95145e SDL-1.2

Patch from Christian Walther 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
author Sam Lantinga <slouken@libsdl.org>
date Sun, 15 Jul 2007 15:58:00 +0000
parents 58a5055da431
children cb7b118b400a
line wrap: on
line diff
--- a/src/video/quartz/SDL_QuartzWM.m	Sun Jul 15 14:14:45 2007 +0000
+++ b/src/video/quartz/SDL_QuartzWM.m	Sun Jul 15 15:58:00 2007 +0000
@@ -22,11 +22,8 @@
 #include "SDL_config.h"
 
 #include "SDL_QuartzVideo.h"
-
+#include "SDL_QuartzWM.h"
 
-struct WMcursor {
-    NSCursor *nscursor;
-};
 
 void QZ_FreeWMCursor     (_THIS, WMcursor *cursor) { 
 
@@ -90,18 +87,21 @@
     return(NULL);
 }
 
-void QZ_ShowMouse (_THIS, NSCursor *cursor) {
-    if (!cursor_visible) {
-        [ NSCursor unhide ];
-        cursor_visible = YES;
+void QZ_UpdateCursor (_THIS) {
+    BOOL state;
+
+    if (cursor_should_be_visible || !(SDL_GetAppState() & SDL_APPMOUSEFOCUS)) {
+        state = YES;
+    } else {
+        state = NO;
     }
-    [ cursor set ];
-}
-
-void QZ_HideMouse (_THIS) {
-    if ((SDL_GetAppState() & SDL_APPMOUSEFOCUS) && cursor_visible) {
-        [ NSCursor hide ];
-        cursor_visible = NO;
+    if (state != cursor_visible) {
+        if (state) {
+            [ NSCursor unhide ];
+        } else {
+            [ NSCursor hide ];
+        }
+        cursor_visible = state;
     }
 }
 
@@ -117,18 +117,24 @@
 int QZ_ShowWMCursor (_THIS, WMcursor *cursor) { 
 
     if ( cursor == NULL) {
-        QZ_HideMouse (this);
         if ( cursor_should_be_visible ) {
             cursor_should_be_visible = NO;
             QZ_ChangeGrabState (this, QZ_HIDECURSOR);
         }
+        QZ_UpdateCursor(this);
     }
     else {
-        QZ_ShowMouse (this, cursor->nscursor);
+        if (qz_window ==nil || (mode_flags & SDL_FULLSCREEN)) {
+            [ cursor->nscursor set ];
+        }
+        else {
+            [ qz_window invalidateCursorRectsForView: [ qz_window contentView ] ];
+        }
         if ( ! cursor_should_be_visible ) {
             cursor_should_be_visible = YES;
             QZ_ChangeGrabState (this, QZ_SHOWCURSOR);
         }
+        QZ_UpdateCursor(this);
     }
 
     return 1;