https://git.reactos.org/?p=reactos.git;a=commitdiff;h=57c07ba117dca721676dfa3876b26e3fd63c4106

commit 57c07ba117dca721676dfa3876b26e3fd63c4106
Author:     Hervé Poussineau <[email protected]>
AuthorDate: Sat May 14 15:37:29 2022 +0200
Commit:     hpoussin <[email protected]>
CommitDate: Sat May 14 21:29:12 2022 +0200

    [WIN32SS] mouse: use pointer flags in PDEVOBJ
    
    When changing pointer cursor:
    - use PDEV_HARDWARE_POINTER flag if using hardware pointer
    - use PDEV_SOFTWARE_POINTER flag if using software pointer
    - keep pfnMovePointer as an accelerator to driver function (if available) 
and never change it
    - fix bug (2 pointers) when switching between hardware and software pointer
    
    When moving pointer:
    - check PDEV_HARDWARE_POINTER flag to know if we need to call the driver
    - check PDEV_SOFTWARE_POINTER flag to know if we need to call EngMovePointer
---
 win32ss/gdi/eng/mouse.c | 50 ++++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 39 insertions(+), 11 deletions(-)

diff --git a/win32ss/gdi/eng/mouse.c b/win32ss/gdi/eng/mouse.c
index 677a0e68eee..21f67f7fdcc 100644
--- a/win32ss/gdi/eng/mouse.c
+++ b/win32ss/gdi/eng/mouse.c
@@ -618,6 +618,8 @@ IntEngSetPointerShape(
     ULONG ulResult = SPS_DECLINE;
     PFN_DrvSetPointerShape pfnSetPointerShape;
     PPDEVOBJ ppdev = GDIDEV(pso);
+    BOOL bHardwarePointer = FALSE;
+    BOOL bSoftwarePointer = TRUE;
 
     pfnSetPointerShape = GDIDEVFUNCS(pso).SetPointerShape;
 
@@ -638,15 +640,15 @@ IntEngSetPointerShape(
                                       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;
+        /* Check if the driver accepted it */
+        if (ulResult == SPS_ACCEPT_NOEXCLUDE)
+            bHardwarePointer = TRUE;
+
+        bSoftwarePointer = !bHardwarePointer;
     }
-    else
+
+    if (bSoftwarePointer)
     {
         /* Set software pointer */
         ulResult = EngSetPointerShape(pso,
@@ -659,10 +661,31 @@ IntEngSetPointerShape(
                                       y,
                                       prcl,
                                       fl);
-        /* Set MovePointer to the eng function */
-        ppdev->pfnMovePointer = EngMovePointer;
     }
 
+    if (!bSoftwarePointer && ppdev->flFlags & PDEV_SOFTWARE_POINTER)
+    {
+        /* Disable software pointer */
+        EngMovePointer(pso, -1, -1, NULL);
+    }
+
+    if (!bHardwarePointer && ppdev->flFlags & PDEV_HARDWARE_POINTER)
+    {
+        /* Disable hardware pointer */
+        ppdev->pfnMovePointer(pso, -1, -1, NULL);
+    }
+
+    /* Update flags */
+    if (bSoftwarePointer)
+        ppdev->flFlags |= PDEV_SOFTWARE_POINTER;
+    else
+        ppdev->flFlags &= ~PDEV_SOFTWARE_POINTER;
+
+    if (bHardwarePointer)
+        ppdev->flFlags |= PDEV_HARDWARE_POINTER;
+    else
+        ppdev->flFlags &= ~PDEV_HARDWARE_POINTER;
+
     return ulResult;
 }
 
@@ -787,11 +810,16 @@ GreMovePointer(
     /* Check if we need to move it */
     if(pdc->ppdev->SafetyRemoveLevel == 0)
     {
+        SURFOBJ* pso = &pdc->ppdev->pSurface->SurfObj;
+
         /* Store the cursor exclude position in the PDEV */
         prcl = &pdc->ppdev->Pointer.Exclude;
 
-        /* Call Eng/Drv function */
-        pdc->ppdev->pfnMovePointer(&pdc->ppdev->pSurface->SurfObj, x, y, prcl);
+        /* Send new position of the hot spot of the pointer (will likely 
redraw cursor) */
+        if (pdc->ppdev->flFlags & PDEV_HARDWARE_POINTER)
+            pdc->ppdev->pfnMovePointer(pso, x, y, prcl);
+        else if (pdc->ppdev->flFlags & PDEV_SOFTWARE_POINTER)
+            EngMovePointer(pso, x, y, prcl);
     }
 
     /* Release PDEV lock */

Reply via email to