Author: fireball
Date: Tue Jul 28 16:12:29 2009
New Revision: 42270

URL: http://svn.reactos.org/svn/reactos?rev=42270&view=rev
Log:
Giannis Adamopoulos
- Bring in mouse pointer functions to engpoint.c from trunk.
- Implement kernelmode part of mouse cursor support.

Added:
    branches/arwinss/reactos/subsystems/win32/win32k/gre/cursoricon.c   (with 
props)
    branches/arwinss/reactos/subsystems/win32/win32k/include/cursor.h   (with 
props)
    branches/arwinss/reactos/subsystems/win32/win32k/main/cursor.c   (with 
props)
Modified:
    branches/arwinss/reactos/subsystems/win32/win32k/eng/engpoint.c
    branches/arwinss/reactos/subsystems/win32/win32k/include/gre.h
    branches/arwinss/reactos/subsystems/win32/win32k/include/win32kp.h
    branches/arwinss/reactos/subsystems/win32/win32k/w32ksvc.db
    branches/arwinss/reactos/subsystems/win32/win32k/win32k.rbuild

Modified: branches/arwinss/reactos/subsystems/win32/win32k/eng/engpoint.c
URL: 
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32/win32k/eng/engpoint.c?rev=42270&r1=42269&r2=42270&view=diff
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/eng/engpoint.c 
[iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/eng/engpoint.c 
[iso-8859-1] Tue Jul 28 16:12:29 2009
@@ -12,35 +12,399 @@
 #define NDEBUG
 #include <debug.h>
 
+#define TAG_MOUSE       TAG('M', 'O', 'U', 'S') /* mouse */
+#define GDIDEV(SurfObj) ((PDEVOBJ *)((SurfObj)->hdev))
+
 /* PUBLIC FUNCTIONS **********************************************************/
 
+GDIPOINTER    Pointer;
+POINTL        ptlPointer;
+
 VOID
-APIENTRY
+IntHideMousePointer(
+    PDEVOBJ *ppdev,
+    SURFOBJ *psoDest)
+{
+    GDIPOINTER *pgp;
+    POINTL pt;
+    RECTL rclDest;
+    POINTL ptlSave;
+
+    ASSERT(ppdev);
+    ASSERT(psoDest);
+
+    pgp = &Pointer;
+
+    if (!pgp->Enabled)
+    {
+        return;
+    }
+
+    pgp->Enabled = FALSE;
+
+    if (!pgp->psurfSave)
+    {
+        return;
+    }
+
+    /* Calculate cursor coordinates */
+    pt.x = ptlPointer.x - pgp->HotSpot.x;
+    pt.y = ptlPointer.y - pgp->HotSpot.y;
+
+    rclDest.left = max(pt.x, 0);
+    rclDest.top = max(pt.y, 0);
+    rclDest.right = min(pt.x + pgp->Size.cx, psoDest->sizlBitmap.cx);
+    rclDest.bottom = min(pt.y + pgp->Size.cy, psoDest->sizlBitmap.cy);
+
+    ptlSave.x = rclDest.left - pt.x;
+    ptlSave.y = rclDest.top - pt.y;
+
+    GrepBitBltEx(psoDest,
+                   pgp->psurfSave,
+                   NULL,
+                   NULL,
+                   NULL,
+                   &rclDest,
+                   &ptlSave,
+                   &ptlSave,
+                   NULL,
+                   NULL,
+                   ROP3_TO_ROP4(SRCCOPY),
+                   FALSE);
+}
+
+VOID
+IntShowMousePointer(PDEVOBJ *ppdev, SURFOBJ *psoDest)
+{
+    GDIPOINTER *pgp;
+    POINTL pt;
+    RECTL rclSurf, rclPointer;
+
+    ASSERT(ppdev);
+    ASSERT(psoDest);
+
+
+    pgp = &Pointer;
+
+    if (pgp->Enabled)
+    {
+        return;
+    }
+
+    pgp->Enabled = TRUE;
+
+    /* Calculate pointer coordinates */
+    pt.x = ptlPointer.x - pgp->HotSpot.x;
+    pt.y = ptlPointer.y - pgp->HotSpot.y;
+
+    /* Calculate the rect on the surface */
+    rclSurf.left = max(pt.x, 0);
+    rclSurf.top = max(pt.y, 0);
+    rclSurf.right = min(pt.x + pgp->Size.cx, psoDest->sizlBitmap.cx);
+    rclSurf.bottom = min(pt.y + pgp->Size.cy, psoDest->sizlBitmap.cy);
+
+    /* Calculate the rect in the pointer bitmap */
+    rclPointer.left = rclSurf.left - pt.x;
+    rclPointer.top = rclSurf.top - pt.y;
+    rclPointer.right = min(pgp->Size.cx, psoDest->sizlBitmap.cx - pt.x);
+    rclPointer.bottom = min(pgp->Size.cy, psoDest->sizlBitmap.cy - pt.y);
+
+    /* Copy the pixels under the cursor to temporary surface. */
+    GrepBitBltEx(pgp->psurfSave,
+                   psoDest,
+                   NULL,
+                   NULL,
+                   NULL,
+                   &rclPointer,
+                   (POINTL*)&rclSurf,
+                   NULL,
+                   NULL,
+                   NULL,
+                   ROP3_TO_ROP4(SRCCOPY),
+                   FALSE);
+
+    /* Blt the pointer on the screen. */
+    if (pgp->psurfColor)
+    {
+        GrepBitBltEx(psoDest,
+                       pgp->psurfColor,
+                       pgp->psurfMask,
+                       NULL,
+                       pgp->XlateObject,
+                       &rclSurf,
+                       (POINTL*)&rclPointer,
+                       (POINTL*)&rclPointer,
+                       NULL,
+                       NULL,
+                       R4_MASK,
+                       FALSE);
+    }
+    else
+    {
+        GrepBitBltEx(psoDest,
+                       pgp->psurfMask,
+                       NULL,
+                       NULL,
+                       pgp->XlateObject,
+                       &rclSurf,
+                       (POINTL*)&rclPointer,
+                       NULL,
+                       NULL,
+                       NULL,
+                       ROP3_TO_ROP4(SRCAND),
+                       FALSE);
+
+        rclPointer.top += pgp->Size.cy;
+
+        GrepBitBltEx(psoDest,
+                       pgp->psurfMask,
+                       NULL,
+                       NULL,
+                       pgp->XlateObject,
+                       &rclSurf,
+                       (POINTL*)&rclPointer,
+                       NULL,
+                       NULL,
+                       NULL,
+                       ROP3_TO_ROP4(SRCINVERT),
+                       FALSE);
+    }
+}
+
+/*
+ * @implemented
+ */
+ULONG APIENTRY
+EngSetPointerShape(
+    IN SURFOBJ *pso,
+    IN SURFOBJ *psoMask,
+    IN SURFOBJ *psoColor,
+    IN XLATEOBJ *pxlo,
+    IN LONG xHot,
+    IN LONG yHot,
+    IN LONG x,
+    IN LONG y,
+    IN RECTL *prcl,
+    IN FLONG fl)
+{
+    PDEVOBJ *ppdev;
+    GDIPOINTER *pgp;
+    PBYTE Bits;
+    SIZEL Size;
+    LONG lDelta;
+    HBITMAP hbmp;
+
+    ASSERT(pso);
+
+    ppdev = GDIDEV(pso);
+    pgp = &Pointer;
+
+    IntHideMousePointer(ppdev, pso);
+
+    if (pgp->psurfColor)
+    {
+        /* FIXME: let GDI allocate/free memory */
+        EngFreeMem(pgp->psurfColor->pvBits);
+        pgp->psurfColor->pvBits = 0;
+
+        EngDeleteSurface(pgp->psurfColor->hsurf);
+        //SURFACE_ShareUnlockSurface(pgp->psurfColor);
+        pgp->psurfColor = NULL;
+    }
+
+    if (pgp->psurfMask)
+    {
+        /* FIXME: let GDI allocate/free memory */
+        EngFreeMem(pgp->psurfMask->pvBits);
+        pgp->psurfMask->pvBits = 0;
+
+        EngDeleteSurface(pgp->psurfMask->hsurf);
+        //SURFACE_ShareUnlockSurface(pgp->psurfMask);
+        pgp->psurfMask = NULL;
+    }
+
+    if (pgp->psurfSave != NULL)
+    {
+        EngDeleteSurface(pgp->psurfSave->hsurf);
+        //SURFACE_ShareUnlockSurface(pgp->psurfSave);
+        pgp->psurfSave = NULL;
+    }
+
+    if (pgp->XlateObject != NULL)
+    {
+        EngDeleteXlate(pgp->XlateObject);
+        pgp->XlateObject = NULL;
+    }
+
+    /* See if we are being asked to hide the pointer. */
+    if (psoMask == NULL)
+    {
+        return SPS_ACCEPT_NOEXCLUDE;
+    }
+
+    pgp->HotSpot.x = xHot;
+    pgp->HotSpot.y = yHot;
+
+    if (x != -1)
+    {
+        ptlPointer.x = x;
+        ptlPointer.y = y;
+    }
+
+    pgp->Size.cx = abs(psoMask->lDelta) << 3;
+    pgp->Size.cy = (psoMask->cjBits / abs(psoMask->lDelta)) >> 1;
+
+    if (psoColor != NULL)
+    {
+        /* FIXME: let GDI allocate/free memory */
+        Bits = EngAllocMem(0, psoColor->cjBits, TAG_MOUSE);
+        if (Bits == NULL)
+        {
+            return SPS_ERROR;
+        }
+
+        memcpy(Bits, psoColor->pvBits, psoColor->cjBits);
+
+        hbmp = EngCreateBitmap(pgp->Size,
+                               psoColor->lDelta,
+                               psoColor->iBitmapFormat,
+                               psoColor->lDelta < 0 ? 0 : BMF_TOPDOWN,
+                               Bits);
+
+        pgp->psurfColor = EngLockSurface(hbmp);
+    }
+    else
+    {
+        pgp->psurfColor = NULL;
+    }
+
+    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);
+
+    hbmp = EngCreateBitmap(Size,
+                           psoMask->lDelta,
+                           psoMask->iBitmapFormat,
+                           psoMask->lDelta < 0 ? 0 : BMF_TOPDOWN,
+                           Bits);
+
+    pgp->psurfMask = EngLockSurface(hbmp);
+
+    /* Create an XLATEOBJ that will be used for drawing masks.
+     * FIXME: We should get this in pxlo parameter! */
+    if (pxlo == NULL)
+    {
+        HPALETTE BWPalette, DestPalette;
+        ULONG BWColors[] = {0, 0xFFFFFF};
+
+        BWPalette = EngCreatePalette(PAL_INDEXED, sizeof(BWColors) / 
sizeof(ULONG),
+                                     BWColors, 0, 0, 0);
+
+        DestPalette = ppdev->DevInfo.hpalDefault;
+        pgp->XlateObject = IntEngCreateXlate(0, 0,
+                                             DestPalette, BWPalette);
+        EngDeletePalette(BWPalette);
+    }
+    else
+    {
+        pgp->XlateObject = pxlo;
+    }
+
+    /* Create surface for saving the pixels under the cursor. */
+    switch (pso->iBitmapFormat)
+    {
+        case BMF_1BPP:
+            lDelta = pgp->Size.cx >> 3;
+            break;
+        case BMF_4BPP:
+            lDelta = pgp->Size.cx >> 1;
+            break;
+        case BMF_8BPP:
+            lDelta = pgp->Size.cx;
+            break;
+        case BMF_16BPP:
+            lDelta = pgp->Size.cx << 1;
+            break;
+        case BMF_24BPP:
+            lDelta = pgp->Size.cx * 3;
+            break;
+        case BMF_32BPP:
+            lDelta = pgp->Size.cx << 2;
+            break;
+        default:
+            lDelta = 0;
+            break;
+    }
+
+    hbmp = EngCreateBitmap(pgp->Size,
+                           lDelta,
+                           pso->iBitmapFormat,
+                           BMF_TOPDOWN | BMF_NOZEROINIT,
+                           NULL);
+
+    pgp->psurfSave = EngLockSurface(hbmp);
+
+    if (x != -1)
+    {
+        IntShowMousePointer(ppdev, pso);
+
+        if (prcl != NULL)
+        {
+            prcl->left = x - pgp->HotSpot.x;
+            prcl->top = y - pgp->HotSpot.x;
+            prcl->right = prcl->left + pgp->Size.cx;
+            prcl->bottom = prcl->top + pgp->Size.cy;
+        }
+    } else if (prcl != NULL)
+        prcl->left = prcl->top = prcl->right = prcl->bottom = -1;
+
+    return SPS_ACCEPT_NOEXCLUDE;
+}
+
+/*
+ * @implemented
+ */
+
+VOID APIENTRY
 EngMovePointer(
-  IN SURFOBJ  *pso,
-  IN LONG  x,
-  IN LONG  y,
-  IN RECTL  *prcl)
+    IN SURFOBJ *pso,
+    IN LONG x,
+    IN LONG y,
+    IN RECTL *prcl)
 {
-    UNIMPLEMENTED;
-}
-
-ULONG
-APIENTRY
-EngSetPointerShape(
-  IN SURFOBJ  *pso,
-  IN SURFOBJ  *psoMask,
-  IN SURFOBJ  *psoColor,
-  IN XLATEOBJ  *pxlo,
-  IN LONG  xHot,
-  IN LONG  yHot,
-  IN LONG  x,
-  IN LONG  y,
-  IN RECTL  *prcl,
-  IN FLONG  fl)
-{
-    UNIMPLEMENTED;
-       return 0;
+    PDEVOBJ *ppdev;
+    GDIPOINTER *pgp;
+
+    ASSERT(pso);
+
+    ppdev = GDIDEV(pso);
+    ASSERT(ppdev);
+
+    pgp = &Pointer;
+
+    IntHideMousePointer(ppdev, pso);
+
+    ptlPointer.x = x;
+    ptlPointer.y = y;
+
+    if (x != -1)
+    {
+        IntShowMousePointer(ppdev, pso);
+        if (prcl != NULL)
+        {
+            prcl->left = x - pgp->HotSpot.x;
+            prcl->top = y - pgp->HotSpot.x;
+            prcl->right = prcl->left + pgp->Size.cx;
+            prcl->bottom = prcl->top + pgp->Size.cy;
+        }
+    } else if (prcl != NULL)
+        prcl->left = prcl->top = prcl->right = prcl->bottom = -1;
 }
 
 BOOL

Added: branches/arwinss/reactos/subsystems/win32/win32k/gre/cursoricon.c
URL: 
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32/win32k/gre/cursoricon.c?rev=42270&view=auto
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/gre/cursoricon.c (added)
+++ branches/arwinss/reactos/subsystems/win32/win32k/gre/cursoricon.c 
[iso-8859-1] Tue Jul 28 16:12:29 2009
@@ -1,0 +1,220 @@
+/*
+ * PROJECT:         ReactOS Win32K
+ * LICENSE:         LGPL - See COPYING in the top level directory
+ * FILE:            subsystems/win32/win32k/gre/cursoricon.c
+ * PURPOSE:         ReactOS cursor support routines
+ * PROGRAMMERS:     Giannis Adamopoulos
+ */
+
+#include <win32k.h>
+#define NDEBUG
+#include <debug.h>
+
+extern PDEVOBJ PrimarySurface;
+
+VOID NTAPI
+GreMovePointer(
+    IN SURFOBJ *pso,
+    IN LONG x,
+    IN LONG y,
+    IN RECTL *prcl)
+{
+    SURFACE_LockBitmapBits(pso);
+    GDIDEVFUNCS(pso).MovePointer(pso, x, y, prcl);
+    SURFACE_UnlockBitmapBits(pso);
+}
+
+
+ULONG NTAPI
+GreSetPointerShape(
+   IN SURFOBJ *pso,
+   IN SURFOBJ *psoMask,
+   IN SURFOBJ *psoColor,
+   IN XLATEOBJ *pxlo,
+   IN LONG xHot,
+   IN LONG yHot,
+   IN LONG x,
+   IN LONG y,
+   IN RECTL *prcl,
+   IN FLONG fl)
+{
+    ULONG ulResult = SPS_DECLINE;
+    PFN_DrvSetPointerShape pfnSetPointerShape;
+    PPDEVOBJ ppdev = &PrimarySurface;
+
+    pfnSetPointerShape = GDIDEVFUNCS(pso).SetPointerShape;
+
+    SURFACE_LockBitmapBits(pso);
+    if (pfnSetPointerShape)
+    {
+        ulResult = pfnSetPointerShape(pso,
+                                      psoMask,
+                                      psoColor,
+                                      pxlo,
+                                      xHot,
+                                      yHot,
+                                      x,
+                                      y,
+                                      prcl,
+                                      fl);
+    }
+
+    /* Check if the driver accepted it */
+    if (ulResult == SPS_ACCEPT_NOEXCLUDE)
+    {
+        /* Set MovePointer to the driver function */
+        ppdev->pfnMovePointer = GDIDEVFUNCS(pso).MovePointer;
+    }
+    else
+    {
+        /* Set software pointer */
+        ulResult = EngSetPointerShape(pso,
+                                      psoMask,
+                                      psoColor,
+                                      pxlo,
+                                      xHot,
+                                      yHot,
+                                      x,
+                                      y,
+                                      prcl,
+                                      fl);
+        /* Set MovePointer to the eng function */
+        ppdev->pfnMovePointer = EngMovePointer;
+    }
+
+    SURFACE_UnlockBitmapBits(pso);
+
+    return ulResult;
+}
+
+
+
+BOOL
+NTAPI
+GreSetCursor(ICONINFO* NewCursor, PSYSTEM_CURSORINFO CursorInfo)
+{
+   SURFOBJ *pso;
+   SURFOBJ *MaskBmpObj = NULL;
+   HBITMAP hMask = 0;
+   SURFOBJ *soMask = NULL, *soColor = NULL;
+   XLATEOBJ *XlateObj = NULL;
+   ULONG Status;
+
+   pso = EngLockSurface(PrimarySurface.pSurface);
+
+   if (!NewCursor)
+   {
+         if (CursorInfo->ShowingCursor)
+         {
+            DPRINT("Removing pointer!\n");
+            /* Remove the cursor if it was displayed */
+            GreMovePointer(pso, -1, -1, NULL);
+         }
+
+         CursorInfo->ShowingCursor = 0;
+
+         EngUnlockSurface(pso);
+
+         return TRUE;
+   }
+
+   MaskBmpObj = EngLockSurface((HSURF)NewCursor->hbmMask);
+   if (MaskBmpObj)
+   {
+      const int maskBpp = BitsPerFormat(MaskBmpObj->iBitmapFormat);
+      EngUnlockSurface(MaskBmpObj);
+      if (maskBpp != 1)
+      {
+         DPRINT1("SetCursor: The Mask bitmap must have 1BPP!\n");
+         EngUnlockSurface(pso);
+         return FALSE;
+      }
+
+      if ((PrimarySurface.DevInfo.flGraphicsCaps2 & GCAPS2_ALPHACURSOR) &&
+            pso->iBitmapFormat >= BMF_16BPP &&
+            pso->iBitmapFormat <= BMF_32BPP)
+      {
+         /* FIXME - Create a color pointer, only 32bit bitmap, set alpha bits!
+                    Do not pass a mask bitmap to DrvSetPointerShape()!
+                    Create a XLATEOBJ that describes the colors of the bitmap. 
*/
+         DPRINT1("SetCursor: (Colored) alpha cursors are not supported!\n");
+      }
+      else
+      {
+         if(NewCursor->hbmColor)
+         {
+            /* FIXME - Create a color pointer, create only one 32bit bitmap!
+                       Do not pass a mask bitmap to DrvSetPointerShape()!
+                       Create a XLATEOBJ that describes the colors of the 
bitmap.
+                       (16bit bitmaps are propably allowed) */
+            DPRINT1("SetCursor: Cursors with colors are not supported!\n");
+         }
+         else
+         {
+            MaskBmpObj = EngLockSurface((HSURF)NewCursor->hbmMask);
+            if(MaskBmpObj)
+            {
+               RECTL DestRect = {0, 0, MaskBmpObj->sizlBitmap.cx, 
MaskBmpObj->sizlBitmap.cy};
+               POINTL SourcePoint = {0, 0};
+
+               /*
+                * NOTE: For now we create the cursor in top-down bitmap,
+                * because VMware driver rejects it otherwise. This should
+                * be fixed later.
+                */
+               hMask = EngCreateBitmap(
+                          MaskBmpObj->sizlBitmap, abs(MaskBmpObj->lDelta),
+                          MaskBmpObj->iBitmapFormat, BMF_TOPDOWN,
+                          NULL);
+               if ( !hMask )
+               {
+                  EngUnlockSurface(MaskBmpObj);
+                  EngUnlockSurface(pso);
+                  return FALSE;
+               }
+               soMask = EngLockSurface((HSURF)hMask);
+               EngCopyBits(soMask, MaskBmpObj, NULL, NULL,
+                           &DestRect, &SourcePoint);
+               EngUnlockSurface(MaskBmpObj);
+            }
+         }
+      }
+      CursorInfo->ShowingCursor = TRUE;
+      CursorInfo->CurrentCursorObject = *NewCursor;
+   }
+   else
+   {
+      CursorInfo->ShowingCursor = FALSE;
+   }
+
+   Status  = GreSetPointerShape(pso,
+                                   soMask,
+                                   soColor,
+                                   XlateObj,
+                                   NewCursor->xHotspot,
+                                   NewCursor->yHotspot,
+                                   CursorInfo->CursorPos.x,
+                                   CursorInfo->CursorPos.y,
+                                   NULL,
+                                   SPS_CHANGE);
+
+   if (Status != SPS_ACCEPT_NOEXCLUDE)
+   {
+       DPRINT1("GreSetPointerShape returned %lx\n", Status);
+   }
+
+   if(hMask)
+   {
+      EngUnlockSurface(soMask);
+      EngDeleteSurface((HSURF)hMask);
+   }
+   if(XlateObj)
+   {
+      EngDeleteXlate(XlateObj);
+   }
+
+   EngUnlockSurface(pso);
+
+   return TRUE;
+}
+

Propchange: branches/arwinss/reactos/subsystems/win32/win32k/gre/cursoricon.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: branches/arwinss/reactos/subsystems/win32/win32k/include/cursor.h
URL: 
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32/win32k/include/cursor.h?rev=42270&view=auto
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/include/cursor.h (added)
+++ branches/arwinss/reactos/subsystems/win32/win32k/include/cursor.h 
[iso-8859-1] Tue Jul 28 16:12:29 2009
@@ -1,0 +1,22 @@
+
+typedef struct _SYSTEM_CURSORINFO
+{
+  BOOL Enabled;
+  RECT ClipRect;
+  BOOL IsClipped;
+  ICONINFO CurrentCursorObject;
+  BOOL ShowingCursor;
+  POINT CursorPos;
+} SYSTEM_CURSORINFO, *PSYSTEM_CURSORINFO;
+
+typedef struct _GDIPOINTER 
+{
+  BOOL     Enabled;
+  SIZEL    Size;
+  POINTL   HotSpot;
+  XLATEOBJ *XlateObject;
+  SURFOBJ  *psurfColor;
+  SURFOBJ  *psurfMask;
+  SURFOBJ  *psurfSave;
+  RECTL    Exclude; /* required publicly for SPS_ACCEPT_EXCLUDE */
+} GDIPOINTER, *PGDIPOINTER;

Propchange: branches/arwinss/reactos/subsystems/win32/win32k/include/cursor.h
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: branches/arwinss/reactos/subsystems/win32/win32k/include/gre.h
URL: 
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32/win32k/include/gre.h?rev=42270&r1=42269&r2=42270&view=diff
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/include/gre.h [iso-8859-1] 
(original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/include/gre.h [iso-8859-1] 
Tue Jul 28 16:12:29 2009
@@ -212,5 +212,15 @@
        BRUSHOBJ* pbo, LONG x, LONG y, LONG deltax, LONG deltay,
        POINTL* Translate);
 
+BOOL NTAPI
+GreSetCursor(ICONINFO* NewCursor, PSYSTEM_CURSORINFO CursorInfo);
+
+VOID NTAPI
+GreMovePointer(
+    SURFOBJ *pso,
+    LONG x,
+    LONG y,
+    RECTL *prcl);
+
 
 #endif

Modified: branches/arwinss/reactos/subsystems/win32/win32k/include/win32kp.h
URL: 
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32/win32k/include/win32kp.h?rev=42270&r1=42269&r2=42270&view=diff
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/include/win32kp.h 
[iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/include/win32kp.h 
[iso-8859-1] Tue Jul 28 16:12:29 2009
@@ -46,6 +46,7 @@
 #include <floatobj.h>
 #include <xformobj.h>
 #include <xlateobj.h>
+#include <cursor.h>
 #include <gre.h>
 
 #include "winesup.h"

Added: branches/arwinss/reactos/subsystems/win32/win32k/main/cursor.c
URL: 
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32/win32k/main/cursor.c?rev=42270&view=auto
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/main/cursor.c (added)
+++ branches/arwinss/reactos/subsystems/win32/win32k/main/cursor.c [iso-8859-1] 
Tue Jul 28 16:12:29 2009
@@ -1,0 +1,135 @@
+/*
+ * PROJECT:         ReactOS Win32K
+ * LICENSE:         LGPL - See COPYING in the top level directory
+ * FILE:            subsystems/win32/win32k/main/cursor.c
+ * PURPOSE:         ReactOS cursor support routines
+ * PROGRAMMERS:     Giannis Adamopoulos
+ */
+
+#include <win32k.h>
+#define NDEBUG
+#include <debug.h>
+
+static SYSTEM_CURSORINFO CursorInfo;
+
+extern PDEVOBJ PrimarySurface;
+
+BOOL
+APIENTRY
+RosUserGetCursorPos(LPPOINT pt)
+{
+    NTSTATUS Status = STATUS_SUCCESS;
+
+    _SEH2_TRY
+    {
+        ProbeForWrite(pt, sizeof(POINT), 1);
+        *pt = CursorInfo.CursorPos;
+    }
+    _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+    {
+        Status = _SEH2_GetExceptionCode();
+    }
+    _SEH2_END;
+
+    return NT_SUCCESS(Status);
+}
+
+static void NTAPI clip_point_to_rect(LPCRECT rect, LPPOINT pt)
+{
+    if      (pt->x <  rect->left)   pt->x = rect->left;
+    else if (pt->x >= rect->right)  pt->x = rect->right - 1;
+    if      (pt->y <  rect->top)    pt->y = rect->top;
+    else if (pt->y >= rect->bottom) pt->y = rect->bottom - 1;
+}
+
+BOOL
+APIENTRY
+RosUserSetCursorPos(INT x, INT y)
+{
+    POINT pos;
+    SURFOBJ *pso;
+
+    pos.x = x;
+    pos.y = y;
+
+    if(CursorInfo.IsClipped)
+    {
+        clip_point_to_rect(&CursorInfo.ClipRect, &pos);
+    }
+
+    if (CursorInfo.ShowingCursor)
+    {
+        pso = EngLockSurface(PrimarySurface.pSurface);
+        GreMovePointer(pso, pos.x, pos.y, NULL);
+        EngUnlockSurface(pso);
+    }
+
+    CursorInfo.CursorPos = pos;
+
+    return TRUE;
+}
+
+BOOL
+APIENTRY
+RosUserClipCursor( LPCRECT UnsafeRect )
+{
+    NTSTATUS Status = STATUS_SUCCESS;
+    RECT Rect;
+
+    if (!UnsafeRect)
+    {
+        CursorInfo.IsClipped = FALSE;
+        return TRUE;
+    }
+
+    _SEH2_TRY
+    {
+        ProbeForRead(UnsafeRect, sizeof(RECT), 1);
+        RtlCopyMemory(&Rect, UnsafeRect , sizeof(RECT));
+    }
+    _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+    {
+        Status = _SEH2_GetExceptionCode();
+    }
+    _SEH2_END;
+
+    if (!NT_SUCCESS(Status))
+    {
+        SetLastWin32Error(ERROR_INVALID_PARAMETER);
+        return FALSE;
+    }
+
+    CursorInfo.IsClipped = TRUE;
+    CursorInfo.ClipRect = Rect;
+
+    RosUserSetCursorPos(CursorInfo.CursorPos.x, CursorInfo.CursorPos.y);
+
+    return TRUE;
+}
+
+VOID
+APIENTRY
+RosUserSetCursor( ICONINFO* IconInfoUnsafe )
+{
+    ICONINFO IconInfo;
+    NTSTATUS Status = STATUS_SUCCESS;
+
+    _SEH2_TRY
+    {
+        ProbeForRead(IconInfoUnsafe, sizeof(ICONINFO), 1);
+        RtlCopyMemory(&IconInfo, IconInfoUnsafe , sizeof(ICONINFO));
+    }
+    _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+    {
+        Status = _SEH2_GetExceptionCode();
+    }
+    _SEH2_END;
+
+    if (NT_SUCCESS(Status))
+    {
+        IconInfo.hbmMask = GDI_MapUserHandle(IconInfo.hbmMask);
+        IconInfo.hbmColor = GDI_MapUserHandle(IconInfo.hbmColor);
+        GreSetCursor(&IconInfo, &CursorInfo);
+    }
+}
+

Propchange: branches/arwinss/reactos/subsystems/win32/win32k/main/cursor.c
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: branches/arwinss/reactos/subsystems/win32/win32k/w32ksvc.db
URL: 
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32/win32k/w32ksvc.db?rev=42270&r1=42269&r2=42270&view=diff
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/w32ksvc.db [iso-8859-1] 
(original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/w32ksvc.db [iso-8859-1] 
Tue Jul 28 16:12:29 2009
@@ -61,4 +61,8 @@
 RosGdiRoundRect                    7
 RosGdiSwapBuffers                  1
 RosGdiUnrealizePalette             1
-RosUserConnectCsrss                0
+RosUserConnectCsrss                0
+RosUserGetCursorPos                1
+RosUserSetCursorPos                2
+RosUserClipCursor                  1
+RosUserSetCursor                   1

Modified: branches/arwinss/reactos/subsystems/win32/win32k/win32k.rbuild
URL: 
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32/win32k/win32k.rbuild?rev=42270&r1=42269&r2=42270&view=diff
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/win32k.rbuild [iso-8859-1] 
(original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/win32k.rbuild [iso-8859-1] 
Tue Jul 28 16:12:29 2009
@@ -106,12 +106,14 @@
                <file>surfobj.c</file>
                <file>xformobj.c</file>
                <file>xlateobj.c</file>
+               <file>cursoricon.c</file>
        </directory>
        <directory name="main">
                <file>csr.c</file>
                <file>err.c</file>
                <file>init.c</file>
                <file>usrheap.c</file>
+               <file>cursor.c</file>
        </directory>
        <directory name="wine">
                <file>atom.c</file>


Reply via email to