fixed bugs and completed SetCursorPos() and ClipCursor()
authorThomas Bluemel <thomas@reactsoft.com>
Sun, 24 Aug 2003 23:52:29 +0000 (23:52 +0000)
committerThomas Bluemel <thomas@reactsoft.com>
Sun, 24 Aug 2003 23:52:29 +0000 (23:52 +0000)
svn path=/trunk/; revision=5839

reactos/subsys/win32k/eng/mouse.c
reactos/subsys/win32k/include/mouse.h
reactos/subsys/win32k/ntuser/misc.c
reactos/subsys/win32k/ntuser/winsta.c
reactos/subsys/win32k/objects/cursoricon.c

index 89d4378..735c929 100644 (file)
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: mouse.c,v 1.31 2003/08/24 18:52:18 weiden Exp $
+/* $Id: mouse.c,v 1.32 2003/08/24 23:52:29 weiden Exp $
  *
  * PROJECT:          ReactOS kernel
  * PURPOSE:          Mouse
@@ -263,6 +263,62 @@ MouseSafetyOnDrawEnd(PSURFOBJ SurfObj, PSURFGDI SurfGDI)
   return(TRUE);
 }
 
+BOOL FASTCALL
+MouseMoveCursor(LONG X, LONG Y)
+{
+  HDC hDC;
+  PDC dc;
+  RECTL MouseRect;
+  BOOL res = FALSE;
+  PSURFOBJ SurfObj;
+  PSURFGDI SurfGDI;
+  PSYSTEM_CURSORINFO CurInfo;
+  MSG Msg;
+  LARGE_INTEGER LargeTickCount;
+  ULONG TickCount;
+  
+  hDC = IntGetScreenDC();
+  
+  if(!hDC || !InputWindowStation)
+    return FALSE;
+  
+  if(IntGetWindowStationObject(InputWindowStation))
+  {
+    dc = DC_LockDc(hDC);
+    SurfObj = (PSURFOBJ)AccessUserObject((ULONG) dc->Surface);
+    SurfGDI = (PSURFGDI)AccessInternalObject((ULONG) dc->Surface);
+    DC_UnlockDc( hDC );
+    CurInfo = &InputWindowStation->SystemCursor;
+    CheckClipCursor(&X, &X, CurInfo);
+    if((X != CurInfo->x) || (Y != CurInfo->y))
+    {
+      /* send MOUSEMOVE message */
+      KeQueryTickCount(&LargeTickCount);
+      TickCount = LargeTickCount.u.LowPart;
+      Msg.wParam = 0;
+      Msg.lParam = MAKELPARAM(X, Y);
+      Msg.message = WM_MOUSEMOVE;
+      Msg.time = TickCount;
+      Msg.pt.x = X;
+      Msg.pt.y = Y;
+      MsqInsertSystemMessage(&Msg);
+      /* move cursor */
+      CurInfo->x = X;
+      CurInfo->y = Y;
+      if(!CurInfo->SafetySwitch && !CurInfo->SafetySwitch2 && CurInfo->Enabled)
+      {
+        SurfGDI->MovePointer(SurfObj, CurInfo->x, CurInfo->y, &MouseRect);
+      }
+      res = TRUE;
+    }
+        
+    ObDereferenceObject(InputWindowStation);
+    return res;
+  }
+  else
+    return FALSE;
+}
+
 VOID /* STDCALL */
 MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount)
 /*
@@ -380,7 +436,7 @@ MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount)
     
     CheckClipCursor(&CurInfo->x, &CurInfo->y, CurInfo);
     
-    if (SysCursor->hCursor && !CurInfo->SafetySwitch && !CurInfo->SafetySwitch2 &&
+    if (!CurInfo->SafetySwitch && !CurInfo->SafetySwitch2 &&
         ((mouse_ox != CurInfo->x) || (mouse_oy != CurInfo->y)))
     {
       SurfGDI->MovePointer(SurfObj, CurInfo->x, CurInfo->y, &MouseRect);
@@ -404,7 +460,7 @@ EnableMouse(HDC hDisplayDC)
   PSYSCURSOR SysCursor;
 
   if( hDisplayDC && InputWindowStation)
-  {DbgPrint("EnableMouse(TRUE)\n");
+  {
     if(!IntGetWindowStationObject(InputWindowStation))
     {
        InputWindowStation->SystemCursor.Enabled = FALSE;
@@ -457,6 +513,7 @@ EnableMouse(HDC hDisplayDC)
     if(IntGetWindowStationObject(InputWindowStation))
     {
        InputWindowStation->SystemCursor.Enabled = FALSE;
+       InputWindowStation->SystemCursor.CursorClipInfo.IsClipped = FALSE;
           ObDereferenceObject(InputWindowStation);
        return;
     }
index 0c2d3ae..a50f00f 100644 (file)
@@ -5,8 +5,10 @@
 #include <include/winsta.h>
 //#include <ddk/ntddmou.h>
 
+BOOL FASTCALL CheckClipCursor(LONG *x, LONG *y, PSYSTEM_CURSORINFO CurInfo);
 INT  STDCALL  MouseSafetyOnDrawStart(PSURFOBJ SurfObj, PSURFGDI SurfGDI, LONG HazardX1, LONG HazardY1, LONG HazardX2, LONG HazardY2);
 INT  FASTCALL MouseSafetyOnDrawEnd(PSURFOBJ SurfObj, PSURFGDI SurfGDI);
+BOOL FASTCALL MouseMoveCursor(LONG X, LONG Y);
 VOID FASTCALL EnableMouse(HDC hDisplayDC);
 VOID          MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount);
 
index e54f205..f07e624 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: misc.c,v 1.10 2003/08/24 18:52:18 weiden Exp $
+/* $Id: misc.c,v 1.11 2003/08/24 23:52:29 weiden Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -9,11 +9,14 @@
  *       2003/05/22  Created
  */
 #include <ddk/ntddk.h>
+#include <ddk/ntddmou.h>
 #include <win32k/win32k.h>
+#include <win32k/dc.h>
 #include <include/error.h>
 #include <include/window.h>
 #include <include/painting.h>
 #include <include/dce.h>
+#include <include/mouse.h>
 #include <include/winsta.h>
 
 #define NDEBUG
@@ -106,6 +109,7 @@ NtUserCallTwoParam(
 {
   NTSTATUS Status;
   PWINDOW_OBJECT WindowObject;
+  PSYSTEM_CURSORINFO CurInfo;
   PWINSTATION_OBJECT WinStaObject;
   PPOINT Pos;
   
@@ -158,11 +162,16 @@ NtUserCallTwoParam(
       if(Param2)
       {
         /* set cursor position */
+        
+        CurInfo = &WinStaObject->SystemCursor;
         /* FIXME - check if process has WINSTA_WRITEATTRIBUTES */
-        WinStaObject->SystemCursor.x = Pos->x;
-        WinStaObject->SystemCursor.y = Pos->y;
         
-        /* FIXME move cursor */
+        CheckClipCursor(&Pos->x, &Pos->y, CurInfo);  
+        if((Pos->x != CurInfo->x) || (Pos->y != CurInfo->y))
+        {
+          MouseMoveCursor(Pos->x, Pos->y);
+        }
+
       }
       else
       {
index e1118a4..9309109 100644 (file)
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: winsta.c,v 1.28 2003/08/24 18:52:18 weiden Exp $
+/* $Id: winsta.c,v 1.29 2003/08/24 23:52:29 weiden Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -352,12 +352,12 @@ NtUserCreateWindowStation(PUNICODE_STRING lpszWindowStationName,
       return((HWINSTA)0);
     }
     
-  WinStaObject->SystemCursor.Enabled = TRUE;
+  WinStaObject->SystemCursor.Enabled = FALSE;
   WinStaObject->SystemCursor.CurrentCursor = 0;
-  WinStaObject->SystemCursor.x = (LONG)-1;
-  WinStaObject->SystemCursor.y = (LONG)-1;
+  WinStaObject->SystemCursor.x = (LONG)0;
+  WinStaObject->SystemCursor.y = (LONG)0;
   WinStaObject->SystemCursor.SafetySwitch = FALSE;
-  WinStaObject->SystemCursor.SafetySwitch2 = FALSE;
+  WinStaObject->SystemCursor.SafetySwitch2 = TRUE;
   WinStaObject->SystemCursor.CursorClipInfo.IsClipped = FALSE;
   
   WinStaObject->SystemCursor.SystemCursors[0].hCursor = (HANDLE)1;
index 388e529..39f9e98 100644 (file)
@@ -1,4 +1,6 @@
 #undef WIN32_LEAN_AND_MEAN
+#include <ddk/ntddk.h>
+#include <ddk/ntddmou.h>
 #include <win32k/win32k.h>
 #include <windows.h>
 #include <stdlib.h>
@@ -6,6 +8,7 @@
 #include <win32k/bitmaps.h>
 #include <include/winsta.h>
 #include <include/error.h>
+#include <include/mouse.h>
 
 #define NDEBUG
 #include <win32k/debug1.h>
@@ -231,6 +234,8 @@ NtUserClipCursor(
   /* FIXME - check if process has WINSTA_WRITEATTRIBUTES */
   
   PWINSTATION_OBJECT WinStaObject;
+  PSYSTEM_CURSORINFO CurInfo;
+  LONG newx, newy;
 
   NTSTATUS Status = ValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
                                       KernelMode,
@@ -243,15 +248,24 @@ NtUserClipCursor(
     SetLastWin32Error(Status);
     return FALSE;
   }
+  
+  CurInfo = &WinStaObject->SystemCursor;
   if(lpRect)
   {
-    WinStaObject->SystemCursor.CursorClipInfo.IsClipped = TRUE;
-    WinStaObject->SystemCursor.CursorClipInfo.Left = lpRect->left;
-    WinStaObject->SystemCursor.CursorClipInfo.Top = lpRect->top;
-    WinStaObject->SystemCursor.CursorClipInfo.Right = lpRect->right;
-    WinStaObject->SystemCursor.CursorClipInfo.Bottom = lpRect->bottom;
+    CurInfo->CursorClipInfo.IsClipped = TRUE;
+    CurInfo->CursorClipInfo.Left = lpRect->left;
+    CurInfo->CursorClipInfo.Top = lpRect->top;
+    CurInfo->CursorClipInfo.Right = lpRect->right;
+    CurInfo->CursorClipInfo.Bottom = lpRect->bottom;
+    
+    newx = CurInfo->x;
+    newy = CurInfo->y;
+    CheckClipCursor(&newx, &newy, CurInfo);  
+    if((newx != CurInfo->x) || (newy != CurInfo->y))
+    {
+      MouseMoveCursor(newx, newy);
+    }
     
-    /* FIXME - update cursor position in case the cursor is not within the rectangle */
   }
   else
     WinStaObject->SystemCursor.CursorClipInfo.IsClipped = FALSE;