tinus <o112w8r02@sneakemail.com>
This patch fixes some weirdness in the clipping logic. It also seems to make
these 'black cursor' images happen less often, but I can't tell for sure.
Modified: trunk/reactos/include/win32k/dc.h
Modified: trunk/reactos/subsys/win32k/eng/mouse.c

Modified: trunk/reactos/include/win32k/dc.h
--- trunk/reactos/include/win32k/dc.h	2005-01-19 14:15:29 UTC (rev 13132)
+++ trunk/reactos/include/win32k/dc.h	2005-01-19 14:25:10 UTC (rev 13133)
@@ -124,7 +124,8 @@
   RECTL Exclude; /* required publicly for SPS_ACCEPT_EXCLUDE */
   PGD_MOVEPOINTER MovePointer;
   ULONG Status;
-  BOOL SafetySwitch;
+  UINT SafetyRemoveLevel; /* at what level was the cursor removed?
+			     0 for not removed */
   UINT SafetyRemoveCount;
 } GDIPOINTER, *PGDIPOINTER;
 

Modified: trunk/reactos/subsys/win32k/eng/mouse.c
--- trunk/reactos/subsys/win32k/eng/mouse.c	2005-01-19 14:15:29 UTC (rev 13132)
+++ trunk/reactos/subsys/win32k/eng/mouse.c	2005-01-19 14:25:10 UTC (rev 13133)
@@ -68,16 +68,20 @@
       tmp = HazardY2; HazardY2 = HazardY1; HazardY1 = tmp;
     }
 
+  pgp->SafetyRemoveCount++;
+
+  if (pgp->SafetyRemoveLevel)
+    {
+      /* already hidden */
+      return FALSE;
+    } 
+
   if (pgp->Exclude.right >= HazardX1
       && pgp->Exclude.left <= HazardX2
       && pgp->Exclude.bottom >= HazardY1
       && pgp->Exclude.top <= HazardY2)
     {
-      if (0 != pgp->SafetyRemoveCount++)
-        {
-          return FALSE;
-        }
-      pgp->SafetySwitch = TRUE;
+      pgp->SafetyRemoveLevel = pgp->SafetyRemoveCount;
       if (pgp->MovePointer)
         pgp->MovePointer(SurfObj, -1, -1, NULL);
       else
@@ -113,26 +117,23 @@
     return FALSE;
   }
 
-  if (pgp->SafetySwitch)
-    {
-      if (1 < pgp->SafetyRemoveCount--)
-        {
-          /* Someone else removed it too, let them restore it */
-          return FALSE;
-        }
-      /* FIXME - this is wrong!!!!!! we must NOT access pgp->Pos from here, it's
-                 a private field for ENG/driver. This will paint the cursor to the
-                 wrong screen coordinates when a driver overrides DrvMovePointer()!
-                 We should store the coordinates before calling Drv/EngMovePointer()
-                 and Drv/EngSetPointerShape() separately in the GDIDEVICE structure
-                 or somewhere where ntuser can access it! */
-      if (pgp->MovePointer)
-        pgp->MovePointer(SurfObj, pgp->Pos.x, pgp->Pos.y, &pgp->Exclude);
-      else
-        EngMovePointer(SurfObj, pgp->Pos.x, pgp->Pos.y, &pgp->Exclude);
-     pgp->SafetySwitch = FALSE;
-    }
+  if (--pgp->SafetyRemoveCount >= pgp->SafetyRemoveLevel)
+   {
+      return FALSE;
+   }
+   /* FIXME - this is wrong!!!!!! we must NOT access pgp->Pos from here, it's
+	      a private field for ENG/driver. This will paint the cursor to the
+	      wrong screen coordinates when a driver overrides DrvMovePointer()!
+	      We should store the coordinates before calling Drv/EngMovePointer()
+	      and Drv/EngSetPointerShape() separately in the GDIDEVICE structure
+	      or somewhere where ntuser can access it! */
+  if (pgp->MovePointer)
+    pgp->MovePointer(SurfObj, pgp->Pos.x, pgp->Pos.y, &pgp->Exclude);
+  else
+    EngMovePointer(SurfObj, pgp->Pos.x, pgp->Pos.y, &pgp->Exclude);
 
+  pgp->SafetyRemoveLevel = 0;
+
   return(TRUE);
 }