solv the issue with mouse poiter is hide, do not show the mousepointer when you are...
[reactos.git] / reactos / subsys / win32k / eng / mouse.c
index 6d540c5..3bc769c 100644 (file)
  *       06-06-2001  CSH  Created
  */
 /* INCLUDES ******************************************************************/
+
 #include <w32k.h>
 
+#define NDEBUG
+#include <debug.h>
+
 /* FUNCTIONS *****************************************************************/
 
 INT INTERNAL_CALL
@@ -45,12 +49,12 @@ MouseSafetyOnDrawStart(SURFOBJ *SurfObj, LONG HazardX1,
   ASSERT(SurfObj != NULL);
 
   ppdev = GDIDEV(SurfObj);
-  
+
   if(ppdev == NULL)
     {
       return(FALSE);
     }
-  
+
   pgp = &ppdev->Pointer;
 
   if (SPS_ACCEPT_NOEXCLUDE == pgp->Status ||
@@ -68,13 +72,13 @@ MouseSafetyOnDrawStart(SURFOBJ *SurfObj, LONG HazardX1,
       tmp = HazardY2; HazardY2 = HazardY1; HazardY1 = tmp;
     }
 
-  ppdev->SafetyRemoveCount++;
-
-  if (ppdev->SafetyRemoveLevel)
+  if (ppdev->SafetyRemoveLevel != 0)
     {
-      /* already hidden */
+      ppdev->SafetyRemoveCount++;
       return FALSE;
-    } 
+    }
+
+ ppdev->SafetyRemoveCount++;
 
   if (pgp->Exclude.right >= HazardX1
       && pgp->Exclude.left <= HazardX2
@@ -103,7 +107,7 @@ MouseSafetyOnDrawEnd(SURFOBJ *SurfObj)
   ASSERT(SurfObj != NULL);
 
   ppdev = GDIDEV(SurfObj);
-  
+
   if(ppdev == NULL)
     {
       return(FALSE);
@@ -149,10 +153,13 @@ IntHideMousePointer(GDIDEVICE *ppdev, SURFOBJ *DestSurface)
       return;
    }
 
+      
+
    pgp->Enabled = FALSE;
-   
+
    pt.x = pgp->Pos.x - pgp->HotSpot.x;
    pt.y = pgp->Pos.y - pgp->HotSpot.y;
+   
 
    if (pgp->SaveSurface != NULL)
    {
@@ -177,8 +184,9 @@ IntHideMousePointer(GDIDEVICE *ppdev, SURFOBJ *DestSurface)
       {
         if((MaskSurface = EngLockSurface(pgp->MaskSurface)))
         {
-          EngBitBlt(DestSurface, SaveSurface, MaskSurface, NULL, NULL,
-                    &DestRect, &SrcPoint, &SrcPoint, NULL, NULL, ROP3_TO_ROP4(SRCCOPY));
+          IntEngBitBltEx(DestSurface, SaveSurface, MaskSurface, NULL, NULL,
+                         &DestRect, &SrcPoint, &SrcPoint, NULL, NULL,
+                         ROP3_TO_ROP4(SRCCOPY), FALSE);
           EngUnlockSurface(MaskSurface);
         }
         EngUnlockSurface(SaveSurface);
@@ -202,9 +210,15 @@ IntShowMousePointer(GDIDEVICE *ppdev, SURFOBJ *DestSurface)
    {
       return;
    }
+   
+   if (pgp->ShowPointer == 1)
+   {
+      return ;
+   }
+
 
    pgp->Enabled = TRUE;
-   
+
    pt.x = pgp->Pos.x - pgp->HotSpot.x;
    pt.y = pgp->Pos.y - pgp->HotSpot.y;
 
@@ -230,8 +244,9 @@ IntShowMousePointer(GDIDEVICE *ppdev, SURFOBJ *DestSurface)
          pgp->Size.cy,
          DestSurface->sizlBitmap.cy - pt.y);
 
-      EngBitBlt(SaveSurface, DestSurface, NULL, NULL, NULL,
-                &DestRect, &SrcPoint, NULL, NULL, NULL, ROP3_TO_ROP4(SRCCOPY));
+      IntEngBitBltEx(SaveSurface, DestSurface, NULL, NULL, NULL,
+                     &DestRect, &SrcPoint, NULL, NULL, NULL,
+                     ROP3_TO_ROP4(SRCCOPY), FALSE);
       EngUnlockSurface(SaveSurface);
    }
 
@@ -266,18 +281,21 @@ IntShowMousePointer(GDIDEVICE *ppdev, SURFOBJ *DestSurface)
         {
            if((ColorSurf = EngLockSurface(pgp->ColorSurface)))
            {
-             EngBitBlt(DestSurface, ColorSurf, MaskSurf, NULL, pgp->XlateObject,
-                       &DestRect, &SrcPoint, &SrcPoint, NULL, NULL, R4_MASK);
+             IntEngBitBltEx(DestSurface, ColorSurf, MaskSurf, NULL,
+                            pgp->XlateObject, &DestRect, &SrcPoint, &SrcPoint,
+                            NULL, NULL, R4_MASK, FALSE);
              EngUnlockSurface(ColorSurf);
            }
         }
         else
         {
-           EngBitBlt(DestSurface, MaskSurf, NULL, NULL, pgp->XlateObject,
-                     &DestRect, &SrcPoint, NULL, NULL, NULL, ROP3_TO_ROP4(SRCAND));
+           IntEngBitBltEx(DestSurface, MaskSurf, NULL, NULL, pgp->XlateObject,
+                          &DestRect, &SrcPoint, NULL, NULL, NULL,
+                          ROP3_TO_ROP4(SRCAND), FALSE);
            SrcPoint.y += pgp->Size.cy;
-           EngBitBlt(DestSurface, MaskSurf, NULL, NULL, pgp->XlateObject,
-                     &DestRect, &SrcPoint, NULL, NULL, NULL, ROP3_TO_ROP4(SRCINVERT));
+           IntEngBitBltEx(DestSurface, MaskSurf, NULL, NULL, pgp->XlateObject,
+                          &DestRect, &SrcPoint, NULL, NULL, NULL,
+                          ROP3_TO_ROP4(SRCINVERT), FALSE);
         }
         EngUnlockSurface(MaskSurf);
       }
@@ -371,7 +389,7 @@ EngSetPointerShape(
      pgp->Pos.x = x;
      pgp->Pos.y = y;
    }
-   
+
    pgp->Size.cx = abs(psoMask->lDelta) << 3;
    pgp->Size.cy = (psoMask->cjBits / abs(psoMask->lDelta)) >> 1;
 
@@ -380,6 +398,11 @@ EngSetPointerShape(
       PBYTE Bits;
 
       Bits = EngAllocMem(0, psoColor->cjBits, TAG_MOUSE);
+      if (Bits == NULL)
+      {
+          return SPS_ERROR;
+      }
+      
       memcpy(Bits, psoColor->pvBits, psoColor->cjBits);
 
       pgp->ColorSurface = (HSURF)EngCreateBitmap(pgp->Size,
@@ -398,6 +421,11 @@ EngSetPointerShape(
       Size.cx = pgp->Size.cx;
       Size.cy = pgp->Size.cy << 1;
       Bits = EngAllocMem(0, psoMask->cjBits, TAG_MOUSE);
+      if (Bits == NULL)
+      {
+          return SPS_ERROR;
+      }
+      
       memcpy(Bits, psoMask->pvBits, psoMask->cjBits);
 
       pgp->MaskSurface = (HSURF)EngCreateBitmap(Size,
@@ -467,7 +495,7 @@ EngSetPointerShape(
    if(x != -1)
    {
      IntShowMousePointer(ppdev, pso);
-     
+
      if (prcl != NULL)
      {
        prcl->left = x - pgp->HotSpot.x;
@@ -500,9 +528,9 @@ EngMovePointer(
    ppdev = GDIDEV(pso);
 
    ASSERT(ppdev);
-   
+
    pgp = &ppdev->Pointer;
-   
+
    IntHideMousePointer(ppdev, pso);
    if (x != -1)
    {
@@ -520,7 +548,28 @@ EngMovePointer(
      }
    } else if (prcl != NULL)
      prcl->left = prcl->top = prcl->right = prcl->bottom = -1;
-   
+
+}
+
+VOID STDCALL
+IntEngMovePointer(
+   IN SURFOBJ *SurfObj,
+   IN LONG x,
+   IN LONG y,
+   IN RECTL *prcl)
+{
+  BITMAPOBJ *BitmapObj = CONTAINING_RECORD(SurfObj, BITMAPOBJ, SurfObj);
+
+  BITMAPOBJ_LockBitmapBits(BitmapObj);
+  if (GDIDEV(SurfObj)->Pointer.MovePointer)
+    {
+    GDIDEV(SurfObj)->Pointer.MovePointer(SurfObj, x, y, prcl);
+    }
+  else
+    {
+    EngMovePointer(SurfObj, x, y, prcl);
+    }
+  BITMAPOBJ_UnlockBitmapBits(BitmapObj);
 }
 
 /* EOF */