[win32k]
authorGiannis Adamopoulos <gadamopoulos@reactos.org>
Sat, 19 Dec 2009 16:23:05 +0000 (16:23 +0000)
committerGiannis Adamopoulos <gadamopoulos@reactos.org>
Sat, 19 Dec 2009 16:23:05 +0000 (16:23 +0000)
- Don't store SYSTEM_CURSORINFO inside WINSTATION_OBJECT. Use a global variable instead
- Remove IntGetCursorLocation. Use directly gpsi->ptCursor

svn path=/trunk/; revision=44655

reactos/subsystems/win32/win32k/include/cursoricon.h
reactos/subsystems/win32/win32k/include/winsta.h
reactos/subsystems/win32/win32k/ntuser/cursoricon.c
reactos/subsystems/win32/win32k/ntuser/desktop.c
reactos/subsystems/win32/win32k/ntuser/input.c
reactos/subsystems/win32/win32k/ntuser/keyboard.c
reactos/subsystems/win32/win32k/ntuser/message.c
reactos/subsystems/win32/win32k/ntuser/metric.c
reactos/subsystems/win32/win32k/ntuser/msgqueue.c
reactos/subsystems/win32/win32k/ntuser/simplecall.c
reactos/subsystems/win32/win32k/ntuser/winsta.c

index e46e408..12bf5b1 100644 (file)
@@ -69,21 +69,20 @@ typedef struct _SYSTEM_CURSORINFO
   BOOL ScreenSaverRunning;
 } SYSTEM_CURSORINFO, *PSYSTEM_CURSORINFO;
 
-HCURSOR FASTCALL IntSetCursor(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT NewCursor, BOOL ForceChange);
-BOOL FASTCALL IntSetupCurIconHandles(PWINSTATION_OBJECT WinStaObject);
-PCURICON_OBJECT FASTCALL IntCreateCurIconHandle(PWINSTATION_OBJECT WinStaObject);
+BOOL FASTCALL InitCursorImpl();
+PCURICON_OBJECT FASTCALL IntCreateCurIconHandle();
 VOID FASTCALL IntCleanupCurIcons(struct _EPROCESS *Process, PPROCESSINFO Win32Process);
 
-BOOL FASTCALL IntGetCursorLocation(PWINSTATION_OBJECT WinStaObject, POINT *loc);
-
 BOOL UserDrawIconEx(HDC hDc, INT xLeft, INT yTop, PCURICON_OBJECT pIcon, INT cxWidth,
    INT cyHeight, UINT istepIfAniCur, HBRUSH hbrFlickerFreeDraw, UINT diFlags);
 PCURICON_OBJECT FASTCALL UserGetCurIconObject(HCURSOR hCurIcon);
 
+BOOL FASTCALL UserSetCursorPos( INT x, INT y);
+
 int APIENTRY UserShowCursor(BOOL bShow);
 
-#define IntGetSysCursorInfo(WinStaObj) \
-  (PSYSTEM_CURSORINFO)((WinStaObj)->SystemCursor)
+PSYSTEM_CURSORINFO FASTCALL
+IntGetSysCursorInfo();
 
 #define IntReleaseCurIconObject(CurIconObj) \
   UserDereferenceObject(CurIconObj)
index 4dda92a..dfbe717 100644 (file)
@@ -29,7 +29,6 @@ typedef struct _WINSTATION_OBJECT
     LIST_ENTRY DesktopListHead;
     PRTL_ATOM_TABLE AtomTable;
     HANDLE SystemMenuTemplate;
-    PVOID SystemCursor;
     UINT CaretBlinkRate;
     HANDLE ShellWindow;
     HANDLE ShellListView;
index ddc72ca..b937259 100644 (file)
 static PAGED_LOOKASIDE_LIST gProcessLookasideList;
 static LIST_ENTRY gCurIconList;
 
+SYSTEM_CURSORINFO gSysCursorInfo;
+
 BOOL FASTCALL
-IntGetCursorLocation(PWINSTATION_OBJECT WinSta, POINT *loc)
+InitCursorImpl()
 {
-    loc->x = gpsi->ptCursor.x;
-    loc->y = gpsi->ptCursor.y;
+    ExInitializePagedLookasideList(&gProcessLookasideList,
+                                   NULL,
+                                   NULL,
+                                   0,
+                                   sizeof(CURICON_PROCESS),
+                                   TAG_DIB,
+                                   128);
+    InitializeListHead(&gCurIconList);
+
+     gSysCursorInfo.Enabled = FALSE;
+     gSysCursorInfo.ButtonsDown = 0;
+     gSysCursorInfo.CursorClipInfo.IsClipped = FALSE;
+     gSysCursorInfo.LastBtnDown = 0;
+     gSysCursorInfo.CurrentCursorObject = NULL;
+     gSysCursorInfo.ShowingCursor = 0;
+     gSysCursorInfo.ClickLockActive = FALSE;
+     gSysCursorInfo.ClickLockTime = 0;
 
     return TRUE;
 }
 
+PSYSTEM_CURSORINFO FASTCALL
+IntGetSysCursorInfo()
+{
+    return &gSysCursorInfo;
+}
+
 /* This function creates a reference for the object! */
 PCURICON_OBJECT FASTCALL UserGetCurIconObject(HCURSOR hCurIcon)
 {
@@ -78,8 +101,7 @@ PCURICON_OBJECT FASTCALL UserGetCurIconObject(HCURSOR hCurIcon)
 
 HCURSOR
 FASTCALL
-IntSetCursor(
-    PWINSTATION_OBJECT WinSta,
+UserSetCursor(
     PCURICON_OBJECT NewCursor,
     BOOL ForceChange)
 {
@@ -88,8 +110,9 @@ IntSetCursor(
     HCURSOR hOldCursor = (HCURSOR)0;
     HDC hdcScreen;
     BOOL bResult;
+       
+       CurInfo = IntGetSysCursorInfo();
 
-    CurInfo = IntGetSysCursorInfo(WinSta);
     OldCursor = CurInfo->CurrentCursorObject;
     if (OldCursor)
     {
@@ -152,22 +175,6 @@ IntSetCursor(
     return hOldCursor;
 }
 
-
-BOOL FASTCALL
-IntSetupCurIconHandles(PWINSTATION_OBJECT WinSta)
-{
-    ExInitializePagedLookasideList(&gProcessLookasideList,
-                                   NULL,
-                                   NULL,
-                                   0,
-                                   sizeof(CURICON_PROCESS),
-                                   TAG_DIB,
-                                   128);
-    InitializeListHead(&gCurIconList);
-
-    return TRUE;
-}
-
 /*
  * We have to register that this object is in use by the current
  * process. The only way to do that seems to be to walk the list
@@ -207,7 +214,7 @@ ReferenceCurIconByProcess(PCURICON_OBJECT CurIcon)
 }
 
 PCURICON_OBJECT FASTCALL
-IntFindExistingCurIconObject(PWINSTATION_OBJECT WinSta, HMODULE hModule,
+IntFindExistingCurIconObject(HMODULE hModule,
                              HRSRC hRsrc, LONG cx, LONG cy)
 {
     PCURICON_OBJECT CurIcon;
@@ -241,7 +248,7 @@ IntFindExistingCurIconObject(PWINSTATION_OBJECT WinSta, HMODULE hModule,
 }
 
 PCURICON_OBJECT FASTCALL
-IntCreateCurIconHandle(PWINSTATION_OBJECT WinSta)
+IntCreateCurIconHandle()
 {
     PCURICON_OBJECT CurIcon;
     HANDLE hCurIcon;
@@ -271,7 +278,7 @@ IntCreateCurIconHandle(PWINSTATION_OBJECT WinSta)
 }
 
 BOOLEAN FASTCALL
-IntDestroyCurIconObject(PWINSTATION_OBJECT WinSta, PCURICON_OBJECT CurIcon, BOOL ProcessCleanup)
+IntDestroyCurIconObject(PCURICON_OBJECT CurIcon, BOOL ProcessCleanup)
 {
     PSYSTEM_CURSORINFO CurInfo;
     HBITMAP bmpMask, bmpColor;
@@ -321,12 +328,12 @@ IntDestroyCurIconObject(PWINSTATION_OBJECT WinSta, PCURICON_OBJECT CurIcon, BOOL
         RemoveEntryList(&CurIcon->ListEntry);
     }
 
-    CurInfo = IntGetSysCursorInfo(WinSta);
+    CurInfo = IntGetSysCursorInfo();
 
     if (CurInfo->CurrentCursorObject == CurIcon)
     {
         /* Hide the cursor if we're destroying the current cursor */
-        IntSetCursor(WinSta, NULL, TRUE);
+        UserSetCursor(NULL, TRUE);
     }
 
     bmpMask = CurIcon->IconInfo.hbmMask;
@@ -356,16 +363,9 @@ IntDestroyCurIconObject(PWINSTATION_OBJECT WinSta, PCURICON_OBJECT CurIcon, BOOL
 VOID FASTCALL
 IntCleanupCurIcons(struct _EPROCESS *Process, PPROCESSINFO Win32Process)
 {
-    PWINSTATION_OBJECT WinSta;
     PCURICON_OBJECT CurIcon, tmp;
     PCURICON_PROCESS ProcessData;
 
-    WinSta = IntGetWinStaObj();
-    if (WinSta == NULL)
-    {
-        return;
-    }
-
     LIST_FOR_EACH_SAFE(CurIcon, tmp, &gCurIconList, CURICON_OBJECT, ListEntry)
     {
         UserReferenceObject(CurIcon);
@@ -376,7 +376,7 @@ IntCleanupCurIcons(struct _EPROCESS *Process, PPROCESSINFO Win32Process)
                 if (Win32Process == ProcessData->Process)
                 {
                     RemoveEntryList(&CurIcon->ListEntry);
-                    IntDestroyCurIconObject(WinSta, CurIcon, TRUE);
+                    IntDestroyCurIconObject(CurIcon, TRUE);
                     CurIcon = NULL;
                     break;
                 }
@@ -391,7 +391,6 @@ IntCleanupCurIcons(struct _EPROCESS *Process, PPROCESSINFO Win32Process)
         }
     }
 
-    ObDereferenceObject(WinSta);
 }
 
 /*
@@ -402,7 +401,6 @@ APIENTRY
 NtUserCreateCursorIconHandle(PICONINFO IconInfo OPTIONAL, BOOL Indirect)
 {
     PCURICON_OBJECT CurIcon;
-    PWINSTATION_OBJECT WinSta;
     PSURFACE psurfBmp;
     NTSTATUS Status;
     HANDLE Ret;
@@ -411,16 +409,9 @@ NtUserCreateCursorIconHandle(PICONINFO IconInfo OPTIONAL, BOOL Indirect)
     DPRINT("Enter NtUserCreateCursorIconHandle\n");
     UserEnterExclusive();
 
-    WinSta = IntGetWinStaObj();
-    if (WinSta == NULL)
-    {
-        RETURN((HANDLE)0);
-    }
-
-    if (!(CurIcon = IntCreateCurIconHandle(WinSta)))
+    if (!(CurIcon = IntCreateCurIconHandle()))
     {
         SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
-        ObDereferenceObject(WinSta);
         RETURN((HANDLE)0);
     }
 
@@ -473,7 +464,6 @@ NtUserCreateCursorIconHandle(PICONINFO IconInfo OPTIONAL, BOOL Indirect)
     }
 
     UserDereferenceObject(CurIcon);
-    ObDereferenceObject(WinSta);
     RETURN(Ret);
 
 CLEANUP:
@@ -643,7 +633,6 @@ NtUserGetCursorInfo(
 {
     CURSORINFO SafeCi;
     PSYSTEM_CURSORINFO CurInfo;
-    PWINSTATION_OBJECT WinSta;
     NTSTATUS Status = STATUS_SUCCESS;
     PCURICON_OBJECT CurIcon;
     BOOL Ret = FALSE;
@@ -652,20 +641,14 @@ NtUserGetCursorInfo(
     DPRINT("Enter NtUserGetCursorInfo\n");
     UserEnterExclusive();
 
-    WinSta = IntGetWinStaObj();
-    if (WinSta == NULL)
-    {
-        RETURN(FALSE);
-    }
-
-    CurInfo = IntGetSysCursorInfo(WinSta);
+    CurInfo = IntGetSysCursorInfo();
     CurIcon = (PCURICON_OBJECT)CurInfo->CurrentCursorObject;
 
     SafeCi.cbSize = sizeof(CURSORINFO);
     SafeCi.flags = ((CurInfo->ShowingCursor && CurIcon) ? CURSOR_SHOWING : 0);
     SafeCi.hCursor = (CurIcon ? (HCURSOR)CurIcon->Self : (HCURSOR)0);
 
-    IntGetCursorLocation(WinSta, &SafeCi.ptScreenPos);
+    SafeCi.ptScreenPos = gpsi->ptCursor;
 
     _SEH2_TRY
     {
@@ -690,7 +673,6 @@ NtUserGetCursorInfo(
         SetLastNtError(Status);
     }
 
-    ObDereferenceObject(WinSta);
     RETURN(Ret);
 
 CLEANUP:
@@ -709,35 +691,23 @@ NtUserClipCursor(
     RECTL *UnsafeRect)
 {
     /* FIXME - check if process has WINSTA_WRITEATTRIBUTES */
-
-    PWINSTATION_OBJECT WinSta;
     PSYSTEM_CURSORINFO CurInfo;
     RECTL Rect;
     PWINDOW_OBJECT DesktopWindow = NULL;
-    POINT MousePos = {0};
     DECLARE_RETURN(BOOL);
 
     DPRINT("Enter NtUserClipCursor\n");
     UserEnterExclusive();
 
-    WinSta = IntGetWinStaObj();
-    if (WinSta == NULL)
-    {
-        RETURN(FALSE);
-    }
-
     if (NULL != UnsafeRect && ! NT_SUCCESS(MmCopyFromCaller(&Rect, UnsafeRect, sizeof(RECT))))
     {
-        ObDereferenceObject(WinSta);
         SetLastWin32Error(ERROR_INVALID_PARAMETER);
         RETURN(FALSE);
     }
 
-    CurInfo = IntGetSysCursorInfo(WinSta);
-    IntGetCursorLocation(WinSta, &MousePos);
+    CurInfo = IntGetSysCursorInfo();
 
-    if (WinSta->ActiveDesktop)
-        DesktopWindow = UserGetWindowObject(WinSta->ActiveDesktop->DesktopWindow);
+    DesktopWindow = UserGetDesktopWindow();
 
     if ((Rect.right > Rect.left) && (Rect.bottom > Rect.top)
             && DesktopWindow && UnsafeRect != NULL)
@@ -750,8 +720,8 @@ NtUserClipCursor(
         CurInfo->CursorClipInfo.Right = min(Rect.right - 1, DesktopWindow->Wnd->rcWindow.right - 1);
         CurInfo->CursorClipInfo.Bottom = min(Rect.bottom - 1, DesktopWindow->Wnd->rcWindow.bottom - 1);
 
-        mi.dx = MousePos.x;
-        mi.dy = MousePos.y;
+        mi.dx = gpsi->ptCursor.x;
+        mi.dy = gpsi->ptCursor.y;
         mi.mouseData = 0;
         mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
         mi.time = 0;
@@ -762,8 +732,6 @@ NtUserClipCursor(
     }
 
     CurInfo->CursorClipInfo.IsClipped = FALSE;
-    ObDereferenceObject(WinSta);
-
     RETURN(TRUE);
 
 CLEANUP:
@@ -782,7 +750,6 @@ NtUserDestroyCursor(
     HANDLE hCurIcon,
     DWORD Unknown)
 {
-    PWINSTATION_OBJECT WinSta;
     PCURICON_OBJECT CurIcon;
     BOOL ret;
     DECLARE_RETURN(BOOL);
@@ -790,22 +757,14 @@ NtUserDestroyCursor(
     DPRINT("Enter NtUserDestroyCursorIcon\n");
     UserEnterExclusive();
 
-    WinSta = IntGetWinStaObj();
-    if (WinSta == NULL)
-    {
-        RETURN(FALSE);
-    }
-
     if (!(CurIcon = UserGetCurIconObject(hCurIcon)))
     {
-        ObDereferenceObject(WinSta);
         RETURN(FALSE);
     }
 
-    ret = IntDestroyCurIconObject(WinSta, CurIcon, FALSE);
+    ret = IntDestroyCurIconObject(CurIcon, FALSE);
     /* Note: IntDestroyCurIconObject will remove our reference for us! */
 
-    ObDereferenceObject(WinSta);
     RETURN(ret);
 
 CLEANUP:
@@ -827,31 +786,22 @@ NtUserFindExistingCursorIcon(
     LONG cy)
 {
     PCURICON_OBJECT CurIcon;
-    PWINSTATION_OBJECT WinSta;
     HANDLE Ret = (HANDLE)0;
     DECLARE_RETURN(HICON);
 
     DPRINT("Enter NtUserFindExistingCursorIcon\n");
     UserEnterExclusive();
 
-    WinSta = IntGetWinStaObj();
-    if (WinSta == NULL)
-    {
-        RETURN(Ret);
-    }
-
-    CurIcon = IntFindExistingCurIconObject(WinSta, hModule, hRsrc, cx, cy);
+    CurIcon = IntFindExistingCurIconObject(hModule, hRsrc, cx, cy);
     if (CurIcon)
     {
         Ret = CurIcon->Self;
 
 //      IntReleaseCurIconObject(CurIcon);//faxme: is this correct? does IntFindExistingCurIconObject add a ref?
-        ObDereferenceObject(WinSta);
         RETURN(Ret);
     }
 
     SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE);
-    ObDereferenceObject(WinSta);
     RETURN((HANDLE)0);
 
 CLEANUP:
@@ -871,7 +821,6 @@ NtUserGetClipCursor(
 {
     /* FIXME - check if process has WINSTA_READATTRIBUTES */
     PSYSTEM_CURSORINFO CurInfo;
-    PWINSTATION_OBJECT WinSta;
     RECTL Rect;
     NTSTATUS Status;
     DECLARE_RETURN(BOOL);
@@ -882,13 +831,7 @@ NtUserGetClipCursor(
     if (!lpRect)
         RETURN(FALSE);
 
-    WinSta = IntGetWinStaObj();
-    if (WinSta == NULL)
-    {
-        RETURN(FALSE);
-    }
-
-    CurInfo = IntGetSysCursorInfo(WinSta);
+    CurInfo = IntGetSysCursorInfo();
     if (CurInfo->CursorClipInfo.IsClipped)
     {
         Rect.left = CurInfo->CursorClipInfo.Left;
@@ -907,13 +850,10 @@ NtUserGetClipCursor(
     Status = MmCopyToCaller(lpRect, &Rect, sizeof(RECT));
     if (!NT_SUCCESS(Status))
     {
-        ObDereferenceObject(WinSta);
         SetLastNtError(Status);
         RETURN(FALSE);
     }
 
-    ObDereferenceObject(WinSta);
-
     RETURN(TRUE);
 
 CLEANUP:
@@ -933,23 +873,15 @@ NtUserSetCursor(
 {
     PCURICON_OBJECT CurIcon;
     HICON OldCursor;
-    PWINSTATION_OBJECT WinSta;
     DECLARE_RETURN(HCURSOR);
 
     DPRINT("Enter NtUserSetCursor\n");
     UserEnterExclusive();
 
-    WinSta = IntGetWinStaObj();
-    if (WinSta == NULL)
-    {
-        RETURN(NULL);
-    }
-
     if (hCursor)
     {
         if (!(CurIcon = UserGetCurIconObject(hCursor)))
         {
-            ObDereferenceObject(WinSta);
             RETURN(NULL);
         }
     }
@@ -958,13 +890,12 @@ NtUserSetCursor(
         CurIcon = NULL;
     }
 
-    OldCursor = IntSetCursor(WinSta, CurIcon, FALSE);
+    OldCursor = UserSetCursor(CurIcon, FALSE);
 
     if (CurIcon)
     {
         UserDereferenceObject(CurIcon);
     }
-    ObDereferenceObject(WinSta);
 
     RETURN(OldCursor);
 
@@ -987,7 +918,6 @@ NtUserSetCursorContents(
     PCURICON_OBJECT CurIcon;
     ICONINFO IconInfo;
     PSURFACE psurfBmp;
-    PWINSTATION_OBJECT WinSta;
     NTSTATUS Status;
     BOOL Ret = FALSE;
     DECLARE_RETURN(BOOL);
@@ -995,15 +925,8 @@ NtUserSetCursorContents(
     DPRINT("Enter NtUserSetCursorContents\n");
     UserEnterExclusive();
 
-    WinSta = IntGetWinStaObj();
-    if (WinSta == NULL)
-    {
-        RETURN(FALSE);
-    }
-
     if (!(CurIcon = UserGetCurIconObject(hCurIcon)))
     {
-        ObDereferenceObject(WinSta);
         RETURN(FALSE);
     }
 
@@ -1057,7 +980,6 @@ done:
     {
         UserDereferenceObject(CurIcon);
     }
-    ObDereferenceObject(WinSta);
     RETURN(Ret);
 
 CLEANUP:
@@ -1080,7 +1002,6 @@ NtUserSetCursorIconData(
     PICONINFO pIconInfo)
 {
     PCURICON_OBJECT CurIcon;
-    PWINSTATION_OBJECT WinSta;
     PSURFACE psurfBmp;
     NTSTATUS Status = STATUS_SUCCESS;
     BOOL Ret = FALSE;
@@ -1089,15 +1010,8 @@ NtUserSetCursorIconData(
     DPRINT("Enter NtUserSetCursorIconData\n");
     UserEnterExclusive();
 
-    WinSta = IntGetWinStaObj();
-    if (WinSta == NULL)
-    {
-        RETURN(FALSE);
-    }
-
     if (!(CurIcon = UserGetCurIconObject(Handle)))
     {
-        ObDereferenceObject(WinSta);
         RETURN(FALSE);
     }
 
@@ -1149,7 +1063,6 @@ NtUserSetCursorIconData(
         Ret = TRUE;
 
     UserDereferenceObject(CurIcon);
-    ObDereferenceObject(WinSta);
     RETURN(Ret);
 
 CLEANUP:
@@ -1169,7 +1082,6 @@ NtUserSetCursorIconData(
     HRSRC hGroupRsrc)
 {
     PCURICON_OBJECT CurIcon;
-    PWINSTATION_OBJECT WinSta;
     NTSTATUS Status;
     POINT SafeHotspot;
     BOOL Ret = FALSE;
@@ -1178,15 +1090,8 @@ NtUserSetCursorIconData(
     DPRINT("Enter NtUserSetCursorIconData\n");
     UserEnterExclusive();
 
-    WinSta = IntGetWinStaObj();
-    if (WinSta == NULL)
-    {
-        RETURN(FALSE);
-    }
-
     if (!(CurIcon = UserGetCurIconObject(hCurIcon)))
     {
-        ObDereferenceObject(WinSta);
         RETURN(FALSE);
     }
 
@@ -1231,7 +1136,6 @@ NtUserSetCursorIconData(
 
 done:
     UserDereferenceObject(CurIcon);
-    ObDereferenceObject(WinSta);
     RETURN(Ret);
 
 
@@ -1608,10 +1512,7 @@ int
 APIENTRY
 UserShowCursor(BOOL bShow)
 {
-    PTHREADINFO pti = PsGetCurrentThreadWin32Thread();
-    PWINSTATION_OBJECT WinSta = pti->Desktop->WindowStation;
     PSYSTEM_CURSORINFO CurInfo;
-
     HDC Screen;
     PDC dc;
     SURFOBJ *SurfObj;
@@ -1619,6 +1520,8 @@ UserShowCursor(BOOL bShow)
     PDEVOBJ *ppdev;
     GDIPOINTER *pgp;
     int showpointer=0;
+       
+    CurInfo = IntGetSysCursorInfo();
 
     if (!(Screen = IntGetScreenDC()))
     {
@@ -1657,8 +1560,6 @@ UserShowCursor(BOOL bShow)
 
     pgp = &ppdev->Pointer;
 
-    CurInfo = IntGetSysCursorInfo(WinSta);
-
     if (bShow == FALSE)
     {
         pgp->ShowPointer--;
index 772327f..cb3a64f 100644 (file)
@@ -1684,18 +1684,23 @@ NtUserSwitchDesktop(HDESK hDesktop)
       RETURN(FALSE);
    }
 
-   /* FIXME: Fail if the desktop belong to an invisible window station */
+   if(DesktopObject->WindowStation != InputWindowStation)
+   {
+      ObDereferenceObject(DesktopObject);
+      DPRINT1("Switching desktop 0x%x denied because desktop doesn't belong to the interactive winsta!\n", hDesktop);
+      RETURN(FALSE);
+   }
+
    /* FIXME: Fail if the process is associated with a secured
              desktop such as Winlogon or Screen-Saver */
    /* FIXME: Connect to input device */
 
    /* Set the active desktop in the desktop's window station. */
-   DesktopObject->WindowStation->ActiveDesktop = DesktopObject;
+   InputWindowStation->ActiveDesktop = DesktopObject;
 
    /* Set the global state. */
    InputDesktop = DesktopObject;
    InputDesktopHandle = hDesktop;
-   InputWindowStation = DesktopObject->WindowStation;
 
    ObDereferenceObject(DesktopObject);
 
index f5bcfe3..521fd15 100644 (file)
@@ -1095,7 +1095,7 @@ IntMouseInput(MOUSEINPUT *mi)
 
    ASSERT(WinSta);
 
-   CurInfo = IntGetSysCursorInfo(WinSta);
+   CurInfo = IntGetSysCursorInfo();
 
    if(!mi->time)
    {
@@ -1107,9 +1107,7 @@ IntMouseInput(MOUSEINPUT *mi)
    SwapButtons = gspv.bMouseBtnSwap;
    DoMove = FALSE;
 
-   IntGetCursorLocation(WinSta, &MousePos);
-   OrgPos.x = MousePos.x;
-   OrgPos.y = MousePos.y;
+   OrgPos = MousePos = gpsi->ptCursor;
 
    if(mi->dwFlags & MOUSEEVENTF_MOVE)
    {
@@ -1410,8 +1408,7 @@ IntKeyboardInput(KEYBDINPUT *ki)
 
    /* All messages have to contain the cursor point. */
    pti = PsGetCurrentThreadWin32Thread();
-   IntGetCursorLocation(pti->Desktop->WindowStation,
-                        &Msg.pt);
+   Msg.pt = gpsi->ptCursor;
 
     DPRINT1("Kbd Hook msg %d wParam %d lParam 0x%08x dropped by WH_KEYBOARD_LL hook\n",
              Msg.message, vk_hook, Msg.lParam);
@@ -1464,8 +1461,8 @@ IntKeyboardInput(KEYBDINPUT *ki)
 
          FocusMessageQueue->Desktop->pDeskInfo->LastInputWasKbd = TRUE;
 
-         IntGetCursorLocation(FocusMessageQueue->Desktop->WindowStation,
-                              &Msg.pt);
+         Msg.pt = gpsi->ptCursor;
+
          MsqPostMessage(FocusMessageQueue, &Msg, FALSE, QS_KEY);
    }
    else
index 40372a6..443919c 100644 (file)
@@ -441,8 +441,7 @@ IntTranslateKbdMessage(LPMSG lpMsg,
       return FALSE;
 
    /* All messages have to contain the cursor point. */
-   IntGetCursorLocation(pti->Desktop->WindowStation,
-                        &NewMsg.pt);
+   NewMsg.pt = gpsi->ptCursor;
 
     switch (lpMsg->wParam)
     {
index 0bcb3fd..d137ead 100644 (file)
@@ -454,14 +454,9 @@ co_IntSendHitTestMessages(PUSER_MESSAGE_QUEUE ThreadQueue, LPMSG Msg)
          {
             WPARAM wParam;
             PSYSTEM_CURSORINFO CurInfo;
+                       CurInfo = IntGetSysCursorInfo();
 
-            if(!IntGetWindowStationObject(InputWindowStation))
-            {
-               break;
-            }
-            CurInfo = IntGetSysCursorInfo(InputWindowStation);
             wParam = (WPARAM)(CurInfo->ButtonsDown);
-            ObDereferenceObject(InputWindowStation);
 
             co_IntSendMessage(Msg->hwnd, WM_MOUSEMOVE, wParam, Msg->lParam);
             co_IntSendMessage(Msg->hwnd, WM_SETCURSOR, (WPARAM)Msg->hwnd, MAKELPARAM(HTCLIENT, Msg->message));
@@ -1094,7 +1089,8 @@ UserPostThreadMessage( DWORD idThread,
       Message.message = Msg;
       Message.wParam = wParam;
       Message.lParam = lParam;
-      IntGetCursorLocation(pThread->Desktop->WindowStation, &Message.pt);
+      Message.pt = gpsi->ptCursor;
+
       KeQueryTickCount(&LargeTickCount);
       pThread->timeLast = Message.time = MsqCalculateMessageTime(&LargeTickCount);
       MsqPostMessage(pThread->MessageQueue, &Message, FALSE, QS_POSTMESSAGE);
@@ -1180,7 +1176,7 @@ UserPostMessage( HWND Wnd,
          Message.message = Msg;
          Message.wParam = wParam;
          Message.lParam = lParam;
-         IntGetCursorLocation(pti->Desktop->WindowStation, &Message.pt);
+         Message.pt = gpsi->ptCursor;
          KeQueryTickCount(&LargeTickCount);
          pti->timeLast = Message.time = MsqCalculateMessageTime(&LargeTickCount);
          MsqPostMessage(Window->MessageQueue, &Message, FALSE, QS_POSTMESSAGE);
index daf547d..4519ff8 100644 (file)
@@ -23,27 +23,10 @@ BOOL
 FASTCALL
 InitMetrics(VOID)
 {
-    NTSTATUS Status;
-    PWINSTATION_OBJECT WinStaObject;
-    ULONG Width = 640, Height = 480;
-    PSYSTEM_CURSORINFO CurInfo;
     INT *piSysMet;
 
-    Width = pPrimarySurface->gdiinfo.ulHorzRes;
-    Height = pPrimarySurface->gdiinfo.ulVertRes;
-
-    Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
-                                            KernelMode,
-                                            0,
-                                            &WinStaObject);
-    if (NT_SUCCESS(Status))
-    {
-        CurInfo = IntGetSysCursorInfo(WinStaObject);
-    }
-    else
-    {
-        CurInfo = NULL;
-    }
+    ULONG Width = pPrimarySurface->gdiinfo.ulHorzRes;
+    ULONG Height = pPrimarySurface->gdiinfo.ulVertRes;
 
     piSysMet = gpsi->aiSysMet;
 
@@ -175,11 +158,6 @@ InitMetrics(VOID)
     gpsi->dwSRVIFlags |= SRVINFO_METRICS;
     Setup = TRUE;
 
-    if (NT_SUCCESS(Status))
-    {
-        ObDereferenceObject(WinStaObject);
-    }
-
     return TRUE;
 }
 
index 4659ffb..27e029a 100644 (file)
@@ -236,7 +236,6 @@ BOOL FASTCALL
 MsqIsClkLck(LPMSG Msg, BOOL Remove)
 {
    PTHREADINFO pti;
-   PWINSTATION_OBJECT WinStaObject;
    PSYSTEM_CURSORINFO CurInfo;
    BOOL Res = FALSE;
 
@@ -246,9 +245,7 @@ MsqIsClkLck(LPMSG Msg, BOOL Remove)
       return FALSE;
    }
 
-   WinStaObject = pti->Desktop->WindowStation;
-
-   CurInfo = IntGetSysCursorInfo(WinStaObject);
+   CurInfo = IntGetSysCursorInfo();
 
    switch (Msg->message)
    {
@@ -279,7 +276,6 @@ BOOL FASTCALL
 MsqIsDblClk(LPMSG Msg, BOOL Remove)
 {
    PTHREADINFO pti;
-   PWINSTATION_OBJECT WinStaObject;
    PSYSTEM_CURSORINFO CurInfo;
    LONG dX, dY;
    BOOL Res;
@@ -290,9 +286,7 @@ MsqIsDblClk(LPMSG Msg, BOOL Remove)
       return FALSE;
    }
 
-   WinStaObject = pti->Desktop->WindowStation;
-
-   CurInfo = IntGetSysCursorInfo(WinStaObject);
+   CurInfo = IntGetSysCursorInfo();
    Res = (Msg->hwnd == (HWND)CurInfo->LastClkWnd) &&
          ((Msg->time - CurInfo->LastBtnDown) < gspv.iDblClickTime);
    if(Res)
@@ -841,8 +835,7 @@ co_MsqPostKeyboardMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
 
          FocusMessageQueue->Desktop->pDeskInfo->LastInputWasKbd = TRUE;
 
-         IntGetCursorLocation(FocusMessageQueue->Desktop->WindowStation,
-                              &Msg.pt);
+         Msg.pt = gpsi->ptCursor;
          MsqPostMessage(FocusMessageQueue, &Msg, FALSE, QS_KEY);
    }
    else
@@ -859,7 +852,6 @@ MsqPostHotKeyMessage(PVOID Thread, HWND hWnd, WPARAM wParam, LPARAM lParam)
 {
    PWINDOW_OBJECT Window;
    PTHREADINFO Win32Thread;
-   PWINSTATION_OBJECT WinSta;
    MSG Mesg;
    LARGE_INTEGER LargeTickCount;
    NTSTATUS Status;
@@ -878,7 +870,6 @@ MsqPostHotKeyMessage(PVOID Thread, HWND hWnd, WPARAM wParam, LPARAM lParam)
       return;
    }
 
-   WinSta = Win32Thread->Desktop->WindowStation;
    Window = IntGetWindowObject(hWnd);
    if (!Window)
    {
@@ -892,7 +883,7 @@ MsqPostHotKeyMessage(PVOID Thread, HWND hWnd, WPARAM wParam, LPARAM lParam)
    Mesg.lParam = lParam;
    KeQueryTickCount(&LargeTickCount);
    Mesg.time = MsqCalculateMessageTime(&LargeTickCount);
-   IntGetCursorLocation(WinSta, &Mesg.pt);
+   Mesg.pt = gpsi->ptCursor;
    MsqPostMessage(Window->MessageQueue, &Mesg, FALSE, QS_HOTKEY);
    UserDereferenceObject(Window);
    ObDereferenceObject (Thread);
@@ -1876,7 +1867,6 @@ MsqGetTimerMessage(PUSER_MESSAGE_QUEUE MessageQueue,
    LARGE_INTEGER LargeTickCount;
    PLIST_ENTRY EnumEntry;
    BOOLEAN GotMessage;
-   PTHREADINFO pti;
 
    DPRINT("MsqGetTimerMessage queue %p msg %p restart %s\n",
           MessageQueue, Msg, Restart ? "TRUE" : "FALSE");
@@ -1928,9 +1918,7 @@ MsqGetTimerMessage(PUSER_MESSAGE_QUEUE MessageQueue,
    Msg->lParam = (LPARAM) Timer->TimerFunc;
    KeQueryTickCount(&LargeTickCount);
    Msg->time = MsqCalculateMessageTime(&LargeTickCount);
-   pti = PsGetCurrentThreadWin32Thread();
-   IntGetCursorLocation(pti->Desktop->WindowStation,
-                        &Msg->pt);
+   Msg->pt = gpsi->ptCursor;
 
    if (Restart)
    {
index 53ee983..91d58db 100644 (file)
@@ -203,54 +203,34 @@ NtUserCallOneParam(
       case ONEPARAM_ROUTINE_CREATECURICONHANDLE:
          {
             PCURICON_OBJECT CurIcon;
-            PWINSTATION_OBJECT WinSta;
 
-            WinSta = IntGetWinStaObj();
-            if(WinSta == NULL)
-            {
-               RETURN(0);
-            }
-
-            if (!(CurIcon = IntCreateCurIconHandle(WinSta)))
+            if (!(CurIcon = IntCreateCurIconHandle()))
             {
                SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
-               ObDereferenceObject(WinSta);
                RETURN(0);
             }
 
-            ObDereferenceObject(WinSta);
             RETURN((DWORD)CurIcon->Self);
          }
 
       case ONEPARAM_ROUTINE_GETCURSORPOSITION:
          {
-            PWINSTATION_OBJECT WinSta;
-            NTSTATUS Status;
-            POINT Pos;
-
-            if(!Param)
-               RETURN( (DWORD)FALSE);
-            Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
-                                                    KernelMode,
-                                                    0,
-                                                    &WinSta);
-            if (!NT_SUCCESS(Status))
-               RETURN( (DWORD)FALSE);
-
-            /* FIXME - check if process has WINSTA_READATTRIBUTES */
-            IntGetCursorLocation(WinSta, &Pos);
-
-            Status = MmCopyToCaller((PPOINT)Param, &Pos, sizeof(POINT));
-            if(!NT_SUCCESS(Status))
+             BOOL ret = TRUE;
+
+
+            _SEH2_TRY
             {
-               ObDereferenceObject(WinSta);
-               SetLastNtError(Status);
-               RETURN( FALSE);
+               ProbeForWrite((POINT*)Param,sizeof(POINT),1);
+               RtlCopyMemory((POINT*)Param,&gpsi->ptCursor,sizeof(POINT));
             }
+            _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+            {
+                SetLastNtError(_SEH2_GetExceptionCode());
+                ret = FALSE;
+            }
+            _SEH2_END;
 
-            ObDereferenceObject(WinSta);
-
-            RETURN( (DWORD)TRUE);
+            RETURN (ret);
          }
 
       case ONEPARAM_ROUTINE_ISWINDOWINDESTROY:
index 5cfc833..3036b20 100644 (file)
@@ -395,7 +395,6 @@ NtUserCreateWindowStation(
    DWORD Unknown5,
    DWORD Unknown6)
 {
-   PSYSTEM_CURSORINFO CurInfo;
    UNICODE_STRING WindowStationName;
    UNICODE_STRING FullWindowStationName;
    PWINSTATION_OBJECT WindowStationObject;
@@ -522,61 +521,16 @@ NtUserCreateWindowStation(
 
    WindowStationObject->FlatMenu = FALSE;
 
-   if(!(CurInfo = ExAllocatePool(PagedPool, sizeof(SYSTEM_CURSORINFO))))
-   {
-      ExFreePool(FullWindowStationName.Buffer);
-      /* FIXME - Delete window station object */
-      ObDereferenceObject(WindowStationObject);
-      SetLastNtError(STATUS_INSUFFICIENT_RESOURCES);
-      return 0;
-   }
-
-   CurInfo->Enabled = FALSE;
-   CurInfo->ButtonsDown = 0;
-   CurInfo->CursorClipInfo.IsClipped = FALSE;
-   CurInfo->LastBtnDown = 0;
-   CurInfo->CurrentCursorObject = NULL;
-   CurInfo->ShowingCursor = 0;
-   CurInfo->ClickLockActive = FALSE;
-   CurInfo->ClickLockTime = 0;
-
-/*
-   // not used anymore
-   CurInfo->WheelScroLines = gspv.iWheelScrollLines;
-#if (_WIN32_WINNT >= 0x0600)
-   CurInfo->WheelScroChars = gspv.iWheelScrollChars;
-#endif
-   CurInfo->SwapButtons = gspv.bMouseBtnSwap;
-   CurInfo->DblClickSpeed = gspv.iDblClickTime;
-   CurInfo->DblClickWidth = gspv.iDblClickWidth;
-   CurInfo->DblClickHeight = gspv.iDblClickHeight;
-
-   CurInfo->MouseSpeed = gspv.iMouseSpeed;
-   CurInfo->CursorAccelerationInfo.FirstThreshold  = gspv.caiMouse.FirstThreshold;
-   CurInfo->CursorAccelerationInfo.SecondThreshold = gspv.caiMouse.SecondThreshold;
-   CurInfo->CursorAccelerationInfo.Acceleration = gspv.caiMouse.Acceleration;
-
-   CurInfo->MouseHoverTime = gspv.iMouseHoverTime;
-   CurInfo->MouseHoverWidth = gspv.iMouseHoverWidth;
-   CurInfo->MouseHoverHeight = gspv.iMouseHoverHeight;
-*/
-
-//   WindowStationObject->ScreenSaverActive = FALSE;
-//   WindowStationObject->ScreenSaverTimeOut = 10;
-   WindowStationObject->SystemCursor = CurInfo;
-
-   /* END FIXME loading from register */
-
    if (!IntSetupClipboard(WindowStationObject))
    {
        DPRINT1("WindowStation: Error Setting up the clipboard!!!\n");
    }
 
-   if (!IntSetupCurIconHandles(WindowStationObject))
+   if (InputWindowStation == NULL)
    {
-      DPRINT1("Setting up the Cursor/Icon Handle table failed!\n");
-      /* FIXME: Complain more loudly? */
-      ExFreePool(FullWindowStationName.Buffer);
+      InputWindowStation = WindowStationObject;
+
+      InitCursorImpl();
    }
 
    DPRINT("Window station successfully created (%wZ)\n", &FullWindowStationName);
@@ -709,12 +663,6 @@ NtUserCloseWindowStation(
       return FALSE;
    }
 
-#if 0
-   /* FIXME - free the cursor information when actually deleting the object!! */
-   ASSERT(Object->SystemCursor);
-   ExFreePool(Object->SystemCursor);
-#endif
-
    ObDereferenceObject(Object);
 
    DPRINT("Closing window station handle (0x%X)\n", hWinSta);