From b3b134ecfad6f6198f122734e8fd69edb93c9761 Mon Sep 17 00:00:00 2001 From: Thomas Bluemel Date: Fri, 14 May 2004 23:57:32 +0000 Subject: [PATCH] changed cursors/icons to use the window station handle table svn path=/trunk/; revision=9389 --- reactos/ntoskrnl/include/internal/ex.h | 37 +-------- reactos/subsys/win32k/eng/mouse.c | 27 +++---- reactos/subsys/win32k/include/cursoricon.h | 37 +++++++++ reactos/subsys/win32k/ntuser/input.c | 14 ++-- reactos/subsys/win32k/ntuser/message.c | 12 ++- reactos/subsys/win32k/ntuser/metric.c | 14 ++-- reactos/subsys/win32k/ntuser/misc.c | 21 ++++-- reactos/subsys/win32k/ntuser/msgqueue.c | 4 +- reactos/subsys/win32k/ntuser/winsta.c | 52 +++++++++---- reactos/subsys/win32k/objects/cursoricon.c | 88 +++++++++++----------- 10 files changed, 173 insertions(+), 133 deletions(-) diff --git a/reactos/ntoskrnl/include/internal/ex.h b/reactos/ntoskrnl/include/internal/ex.h index 70e3ed05d15..be5d814c869 100644 --- a/reactos/ntoskrnl/include/internal/ex.h +++ b/reactos/ntoskrnl/include/internal/ex.h @@ -8,41 +8,6 @@ #define NTOS_MODE_KERNEL #include -typedef struct _CURSORCLIP_INFO -{ - BOOL IsClipped; - UINT Left; - UINT Top; - UINT Right; - UINT Bottom; -} CURSORCLIP_INFO, *PCURSORCLIP_INFO; - -typedef struct _SYSTEM_CURSORINFO -{ - BOOL Enabled; - BOOL SwapButtons; - UINT ButtonsDown; - LONG x, y; - BOOL SafetySwitch; - UINT SafetyRemoveCount; - LONG PointerRectLeft; - LONG PointerRectTop; - LONG PointerRectRight; - LONG PointerRectBottom; - FAST_MUTEX CursorMutex; - CURSORCLIP_INFO CursorClipInfo; - PVOID CurIconHandleTable; - PVOID CurrentCursorObject; - BYTE ShowingCursor; - UINT DblClickSpeed; - UINT DblClickWidth; - UINT DblClickHeight; - DWORD LastBtnDown; - LONG LastBtnDownX; - LONG LastBtnDownY; - HANDLE LastClkWnd; -} SYSTEM_CURSORINFO, *PSYSTEM_CURSORINFO; - typedef struct _WINSTATION_OBJECT { CSHORT Type; @@ -53,7 +18,7 @@ typedef struct _WINSTATION_OBJECT PRTL_ATOM_TABLE AtomTable; PVOID HandleTable; HANDLE SystemMenuTemplate; - SYSTEM_CURSORINFO SystemCursor; + PVOID SystemCursor; UINT CaretBlinkRate; HANDLE ShellWindow; HANDLE ShellListView; diff --git a/reactos/subsys/win32k/eng/mouse.c b/reactos/subsys/win32k/eng/mouse.c index 94377ed8003..02a19ae57e2 100644 --- a/reactos/subsys/win32k/eng/mouse.c +++ b/reactos/subsys/win32k/eng/mouse.c @@ -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.69 2004/05/10 17:07:17 weiden Exp $ +/* $Id: mouse.c,v 1.70 2004/05/14 23:57:32 weiden Exp $ * * PROJECT: ReactOS kernel * PURPOSE: Mouse @@ -39,12 +39,13 @@ EnableMouse(HDC hDisplayDC) PDC dc; SURFOBJ *SurfObj; PSURFGDI SurfGDI; + PSYSTEM_CURSORINFO CurInfo = IntGetSysCursorInfo(InputWindowStation); if( hDisplayDC && InputWindowStation) { if(!IntGetWindowStationObject(InputWindowStation)) { - InputWindowStation->SystemCursor.Enabled = FALSE; + CurInfo->Enabled = FALSE; return; } @@ -55,14 +56,14 @@ EnableMouse(HDC hDisplayDC) /* Move the cursor to the screen center */ DPRINT("Setting Cursor up at 0x%x, 0x%x\n", SurfObj->sizlBitmap.cx / 2, SurfObj->sizlBitmap.cy / 2); - ExAcquireFastMutex(&InputWindowStation->SystemCursor.CursorMutex); - InputWindowStation->SystemCursor.x = SurfObj->sizlBitmap.cx / 2; - InputWindowStation->SystemCursor.y = SurfObj->sizlBitmap.cy / 2; - ExReleaseFastMutex(&InputWindowStation->SystemCursor.CursorMutex); + ExAcquireFastMutex(&CurInfo->CursorMutex); + CurInfo->x = SurfObj->sizlBitmap.cx / 2; + CurInfo->y = SurfObj->sizlBitmap.cy / 2; + ExReleaseFastMutex(&CurInfo->CursorMutex); IntSetCursor(InputWindowStation, NULL, TRUE); - InputWindowStation->SystemCursor.Enabled = (SPS_ACCEPT_EXCLUDE == SurfGDI->PointerStatus || - SPS_ACCEPT_NOEXCLUDE == SurfGDI->PointerStatus); + CurInfo->Enabled = (SPS_ACCEPT_EXCLUDE == SurfGDI->PointerStatus || + SPS_ACCEPT_NOEXCLUDE == SurfGDI->PointerStatus); ObDereferenceObject(InputWindowStation); } @@ -71,9 +72,9 @@ EnableMouse(HDC hDisplayDC) if(IntGetWindowStationObject(InputWindowStation)) { IntSetCursor(InputWindowStation, NULL, TRUE); - InputWindowStation->SystemCursor.Enabled = FALSE; - InputWindowStation->SystemCursor.CursorClipInfo.IsClipped = FALSE; - ObDereferenceObject(InputWindowStation); + CurInfo->Enabled = FALSE; + CurInfo->CursorClipInfo.IsClipped = FALSE; + ObDereferenceObject(InputWindowStation); return; } } @@ -97,7 +98,7 @@ MouseSafetyOnDrawStart(SURFOBJ *SurfObj, PSURFGDI SurfGDI, LONG HazardX1, if(IntGetWindowStationObject(InputWindowStation)) { - CurInfo = &InputWindowStation->SystemCursor; + CurInfo = IntGetSysCursorInfo(InputWindowStation); MouseEnabled = CurInfo->Enabled && CurInfo->ShowingCursor; } @@ -183,7 +184,7 @@ MouseSafetyOnDrawEnd(SURFOBJ *SurfObj, SURFGDI *SurfGDI) if(IntGetWindowStationObject(InputWindowStation)) { - CurInfo = &InputWindowStation->SystemCursor; + CurInfo = IntGetSysCursorInfo(InputWindowStation); } else return FALSE; diff --git a/reactos/subsys/win32k/include/cursoricon.h b/reactos/subsys/win32k/include/cursoricon.h index 412b60c782a..52121543015 100644 --- a/reactos/subsys/win32k/include/cursoricon.h +++ b/reactos/subsys/win32k/include/cursoricon.h @@ -16,12 +16,49 @@ typedef struct _CURICON_OBJECT ICONINFO IconInfo; } CURICON_OBJECT, *PCURICON_OBJECT; +typedef struct _CURSORCLIP_INFO +{ + BOOL IsClipped; + UINT Left; + UINT Top; + UINT Right; + UINT Bottom; +} CURSORCLIP_INFO, *PCURSORCLIP_INFO; + +typedef struct _SYSTEM_CURSORINFO +{ + BOOL Enabled; + BOOL SwapButtons; + UINT ButtonsDown; + LONG x, y; + BOOL SafetySwitch; + UINT SafetyRemoveCount; + LONG PointerRectLeft; + LONG PointerRectTop; + LONG PointerRectRight; + LONG PointerRectBottom; + FAST_MUTEX CursorMutex; + CURSORCLIP_INFO CursorClipInfo; + PCURICON_OBJECT CurrentCursorObject; + BYTE ShowingCursor; + UINT DblClickSpeed; + UINT DblClickWidth; + UINT DblClickHeight; + DWORD LastBtnDown; + LONG LastBtnDownX; + LONG LastBtnDownY; + HANDLE LastClkWnd; +} SYSTEM_CURSORINFO, *PSYSTEM_CURSORINFO; + HCURSOR FASTCALL IntSetCursor(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT NewCursor, BOOL ForceChange); BOOL FASTCALL IntSetupCurIconHandles(PWINSTATION_OBJECT WinStaObject); PCURICON_OBJECT FASTCALL IntGetCurIconObject(PWINSTATION_OBJECT WinStaObject, HANDLE Handle); PCURICON_OBJECT FASTCALL IntCreateCurIconHandle(PWINSTATION_OBJECT WinStaObject); VOID FASTCALL IntCleanupCurIcons(struct _EPROCESS *Process, PW32PROCESS Win32Process); +#define IntGetSysCursorInfo(WinStaObj) \ + (PSYSTEM_CURSORINFO)((WinStaObj)->SystemCursor) + #define IntReleaseCurIconObject(CurIconObj) \ ObmDereferenceObject(CurIconObj) diff --git a/reactos/subsys/win32k/ntuser/input.c b/reactos/subsys/win32k/ntuser/input.c index aad68601537..f2ff2a0fb25 100644 --- a/reactos/subsys/win32k/ntuser/input.c +++ b/reactos/subsys/win32k/ntuser/input.c @@ -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: input.c,v 1.32 2004/05/10 17:07:18 weiden Exp $ +/* $Id: input.c,v 1.33 2004/05/14 23:57:32 weiden Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -515,8 +515,12 @@ NtUserBlockInput( BOOL FASTCALL IntSwapMouseButton(PWINSTATION_OBJECT WinStaObject, BOOL Swap) { - BOOL res = WinStaObject->SystemCursor.SwapButtons; - WinStaObject->SystemCursor.SwapButtons = Swap; + PSYSTEM_CURSORINFO CurInfo; + BOOL res; + + CurInfo = IntGetSysCursorInfo(WinStaObject); + res = CurInfo->SwapButtons; + CurInfo->SwapButtons = Swap; return res; } @@ -557,7 +561,7 @@ IntMouseInput(MOUSEINPUT *mi) #endif ASSERT(WinSta); - CurInfo = &WinSta->SystemCursor; + CurInfo = IntGetSysCursorInfo(WinSta); dc = DC_LockDc(hDC); SurfObj = (SURFOBJ*)AccessUserObject((ULONG) dc->Surface); @@ -573,7 +577,7 @@ IntMouseInput(MOUSEINPUT *mi) mi->time = LargeTickCount.u.LowPart; } - SwapButtons = WinSta->SystemCursor.SwapButtons; + SwapButtons = CurInfo->SwapButtons; DoMove = FALSE; ExAcquireFastMutex(&CurInfo->CursorMutex); MousePos.x = CurInfo->x; diff --git a/reactos/subsys/win32k/ntuser/message.c b/reactos/subsys/win32k/ntuser/message.c index edc4d54a341..a628e4cfe9c 100644 --- a/reactos/subsys/win32k/ntuser/message.c +++ b/reactos/subsys/win32k/ntuser/message.c @@ -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: message.c,v 1.64 2004/05/14 16:48:04 navaraf Exp $ +/* $Id: message.c,v 1.65 2004/05/14 23:57:32 weiden Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -342,12 +342,14 @@ IntSendHitTestMessages(PUSER_MESSAGE_QUEUE ThreadQueue, LPMSG Msg) case WM_XBUTTONDBLCLK: { WPARAM wParam; + PSYSTEM_CURSORINFO CurInfo; if(!IntGetWindowStationObject(InputWindowStation)) { break; } - wParam = (WPARAM)InputWindowStation->SystemCursor.ButtonsDown; + CurInfo = IntGetSysCursorInfo(InputWindowStation); + wParam = (WPARAM)(CurInfo->ButtonsDown); ObDereferenceObject(InputWindowStation); IntSendMessage(Msg->hwnd, WM_MOUSEMOVE, wParam, Msg->lParam); @@ -1025,6 +1027,7 @@ NtUserPostMessage(HWND Wnd, } else { + PSYSTEM_CURSORINFO CurInfo; Window = IntGetWindowObject(Wnd); if (NULL == Window) { @@ -1043,8 +1046,9 @@ NtUserPostMessage(HWND Wnd, SetLastWin32Error(ERROR_INVALID_PARAMETER); return FALSE; } - KernelModeMsg.pt.x = PsGetWin32Process()->WindowStation->SystemCursor.x; - KernelModeMsg.pt.y = PsGetWin32Process()->WindowStation->SystemCursor.y; + CurInfo = IntGetSysCursorInfo(PsGetWin32Process()->WindowStation); + KernelModeMsg.pt.x = CurInfo->x; + KernelModeMsg.pt.y = CurInfo->y; KeQueryTickCount(&LargeTickCount); KernelModeMsg.time = LargeTickCount.u.LowPart; MsqPostMessage(Window->MessageQueue, &KernelModeMsg, diff --git a/reactos/subsys/win32k/ntuser/metric.c b/reactos/subsys/win32k/ntuser/metric.c index ba332f54e77..7522e61f8a5 100644 --- a/reactos/subsys/win32k/ntuser/metric.c +++ b/reactos/subsys/win32k/ntuser/metric.c @@ -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: metric.c,v 1.20 2004/05/10 17:07:18 weiden Exp $ +/* $Id: metric.c,v 1.21 2004/05/14 23:57:32 weiden Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -66,6 +66,8 @@ NtUserGetSystemMetrics(ULONG Index) case SM_CXDOUBLECLK: case SM_CYDOUBLECLK: case SM_SWAPBUTTON: + { + PSYSTEM_CURSORINFO CurInfo; Status = IntValidateWindowStationHandle(PROCESS_WINDOW_STATION(), KernelMode, 0, @@ -73,22 +75,24 @@ NtUserGetSystemMetrics(ULONG Index) if (!NT_SUCCESS(Status)) return 0xFFFFFFFF; + CurInfo = IntGetSysCursorInfo(WinStaObject); switch(Index) { case SM_CXDOUBLECLK: - Result = WinStaObject->SystemCursor.DblClickWidth; + Result = CurInfo->DblClickWidth; break; case SM_CYDOUBLECLK: - Result = WinStaObject->SystemCursor.DblClickWidth; + Result = CurInfo->DblClickWidth; break; case SM_SWAPBUTTON: - Result = (UINT)WinStaObject->SystemCursor.SwapButtons; + Result = (UINT)CurInfo->SwapButtons; break; } ObDereferenceObject(WinStaObject); return Result; - + } + case SM_CXDRAG: case SM_CYDRAG: return(2); diff --git a/reactos/subsys/win32k/ntuser/misc.c b/reactos/subsys/win32k/ntuser/misc.c index ce205675f36..426b302528d 100644 --- a/reactos/subsys/win32k/ntuser/misc.c +++ b/reactos/subsys/win32k/ntuser/misc.c @@ -1,4 +1,4 @@ -/* $Id: misc.c,v 1.72 2004/05/12 15:28:01 weiden Exp $ +/* $Id: misc.c,v 1.73 2004/05/14 23:57:32 weiden Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -238,6 +238,7 @@ NtUserCallOneParam( case ONEPARAM_ROUTINE_GETCURSORPOSITION: { + PSYSTEM_CURSORINFO CurInfo; PWINSTATION_OBJECT WinStaObject; NTSTATUS Status; POINT Pos; @@ -251,9 +252,10 @@ NtUserCallOneParam( if (!NT_SUCCESS(Status)) return (DWORD)FALSE; + CurInfo = IntGetSysCursorInfo(WinStaObject); /* FIXME - check if process has WINSTA_READATTRIBUTES */ - Pos.x = WinStaObject->SystemCursor.x; - Pos.y = WinStaObject->SystemCursor.y; + Pos.x = CurInfo->x; + Pos.y = CurInfo->y; Status = MmCopyToCaller((PPOINT)Param, &Pos, sizeof(POINT)); if(!NT_SUCCESS(Status)) @@ -636,6 +638,8 @@ IntSystemParametersInfo( case SPI_SETDOUBLECLKHEIGHT: case SPI_SETDOUBLECLICKTIME: { + PSYSTEM_CURSORINFO CurInfo; + Status = IntValidateWindowStationHandle(PROCESS_WINDOW_STATION(), KernelMode, 0, @@ -646,19 +650,20 @@ IntSystemParametersInfo( return (DWORD)FALSE; } + CurInfo = IntGetSysCursorInfo(WinStaObject); switch(uiAction) { case SPI_SETDOUBLECLKWIDTH: /* FIXME limit the maximum value? */ - WinStaObject->SystemCursor.DblClickWidth = uiParam; + CurInfo->DblClickWidth = uiParam; break; case SPI_SETDOUBLECLKHEIGHT: /* FIXME limit the maximum value? */ - WinStaObject->SystemCursor.DblClickHeight = uiParam; + CurInfo->DblClickHeight = uiParam; break; case SPI_SETDOUBLECLICKTIME: /* FIXME limit the maximum time to 1000 ms? */ - WinStaObject->SystemCursor.DblClickSpeed = uiParam; + CurInfo->DblClickSpeed = uiParam; break; } @@ -914,6 +919,7 @@ NtUserGetDoubleClickTime(VOID) UINT Result; NTSTATUS Status; PWINSTATION_OBJECT WinStaObject; + PSYSTEM_CURSORINFO CurInfo; Status = IntValidateWindowStationHandle(PROCESS_WINDOW_STATION(), KernelMode, @@ -922,7 +928,8 @@ NtUserGetDoubleClickTime(VOID) if (!NT_SUCCESS(Status)) return (DWORD)FALSE; - Result = WinStaObject->SystemCursor.DblClickSpeed; + CurInfo = IntGetSysCursorInfo(WinStaObject); + Result = CurInfo->DblClickSpeed; ObDereferenceObject(WinStaObject); return Result; diff --git a/reactos/subsys/win32k/ntuser/msgqueue.c b/reactos/subsys/win32k/ntuser/msgqueue.c index 34479839c8c..5f9b8d8a065 100644 --- a/reactos/subsys/win32k/ntuser/msgqueue.c +++ b/reactos/subsys/win32k/ntuser/msgqueue.c @@ -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: msgqueue.c,v 1.94 2004/05/10 17:07:18 weiden Exp $ +/* $Id: msgqueue.c,v 1.95 2004/05/14 23:57:32 weiden Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -187,7 +187,7 @@ MsqIsDblClk(LPMSG Msg, BOOL Remove) { return FALSE; } - CurInfo = &WinStaObject->SystemCursor; + CurInfo = IntGetSysCursorInfo(WinStaObject); Res = (Msg->hwnd == (HWND)CurInfo->LastClkWnd) && ((Msg->time - CurInfo->LastBtnDown) < CurInfo->DblClickSpeed); if(Res) diff --git a/reactos/subsys/win32k/ntuser/winsta.c b/reactos/subsys/win32k/ntuser/winsta.c index 7fc4a3c8b63..ee852053093 100644 --- a/reactos/subsys/win32k/ntuser/winsta.c +++ b/reactos/subsys/win32k/ntuser/winsta.c @@ -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.59 2004/05/10 17:07:18 weiden Exp $ + * $Id: winsta.c,v 1.60 2004/05/14 23:57:32 weiden Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -274,6 +274,7 @@ NtUserCreateWindowStation( DWORD Unknown4, DWORD Unknown5) { + PSYSTEM_CURSORINFO CurInfo; UNICODE_STRING WindowStationName; PWINSTATION_OBJECT WindowStationObject; HWINSTA WindowStation; @@ -367,11 +368,22 @@ NtUserCreateWindowStation( * Initialize the new window station object */ + if(!(CurInfo = ExAllocatePool(PagedPool, sizeof(SYSTEM_CURSORINFO)))) + { + ExFreePool(WindowStationName.Buffer); + /* FIXME - Delete window station object */ + ObDereferenceObject(WindowStationObject); + SetLastNtError(STATUS_INSUFFICIENT_RESOURCES); + return 0; + } + WindowStationObject->HandleTable = ObmCreateHandleTable(); if (!WindowStationObject->HandleTable) { DPRINT("Failed creating handle table\n"); + ExFreePool(CurInfo); ExFreePool(WindowStationName.Buffer); + /* FIXME - Delete window station object */ ObDereferenceObject(WindowStationObject); SetLastNtError(STATUS_INSUFFICIENT_RESOURCES); return 0; @@ -379,23 +391,25 @@ NtUserCreateWindowStation( InitHotKeys(WindowStationObject); - ExInitializeFastMutex(&WindowStationObject->SystemCursor.CursorMutex); - WindowStationObject->SystemCursor.Enabled = FALSE; - WindowStationObject->SystemCursor.ButtonsDown = 0; - WindowStationObject->SystemCursor.x = (LONG)0; - WindowStationObject->SystemCursor.y = (LONG)0; - WindowStationObject->SystemCursor.CursorClipInfo.IsClipped = FALSE; - WindowStationObject->SystemCursor.LastBtnDown = 0; - WindowStationObject->SystemCursor.CurrentCursorObject = NULL; - WindowStationObject->SystemCursor.ShowingCursor = 0; + ExInitializeFastMutex(&CurInfo->CursorMutex); + CurInfo->Enabled = FALSE; + CurInfo->ButtonsDown = 0; + CurInfo->x = (LONG)0; + CurInfo->y = (LONG)0; + CurInfo->CursorClipInfo.IsClipped = FALSE; + CurInfo->LastBtnDown = 0; + CurInfo->CurrentCursorObject = NULL; + CurInfo->ShowingCursor = 0; /* FIXME: Obtain the following information from the registry */ - WindowStationObject->SystemCursor.SwapButtons = FALSE; - WindowStationObject->SystemCursor.SafetySwitch = FALSE; - WindowStationObject->SystemCursor.SafetyRemoveCount = 0; - WindowStationObject->SystemCursor.DblClickSpeed = 500; - WindowStationObject->SystemCursor.DblClickWidth = 4; - WindowStationObject->SystemCursor.DblClickHeight = 4; + CurInfo->SwapButtons = FALSE; + CurInfo->SafetySwitch = FALSE; + CurInfo->SafetyRemoveCount = 0; + CurInfo->DblClickSpeed = 500; + CurInfo->DblClickWidth = 4; + CurInfo->DblClickHeight = 4; + + WindowStationObject->SystemCursor = CurInfo; if (!IntSetupCurIconHandles(WindowStationObject)) { @@ -529,6 +543,12 @@ 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); diff --git a/reactos/subsys/win32k/objects/cursoricon.c b/reactos/subsys/win32k/objects/cursoricon.c index cbc773df92a..55c7fb45e5d 100644 --- a/reactos/subsys/win32k/objects/cursoricon.c +++ b/reactos/subsys/win32k/objects/cursoricon.c @@ -16,23 +16,22 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: cursoricon.c,v 1.55 2004/05/10 17:07:20 weiden Exp $ */ +/* $Id: cursoricon.c,v 1.56 2004/05/14 23:57:32 weiden Exp $ */ #include PCURICON_OBJECT FASTCALL IntGetCurIconObject(PWINSTATION_OBJECT WinStaObject, HANDLE Handle) { - PCURICON_OBJECT Object; - PUSER_HANDLE_TABLE HandleTable; - - HandleTable = (PUSER_HANDLE_TABLE)WinStaObject->SystemCursor.CurIconHandleTable; - if(!NT_SUCCESS(ObmReferenceObjectByHandle(HandleTable, Handle, otCursorIcon, - (PVOID*)&Object))) - { - return FALSE; - } - - return Object; + PCURICON_OBJECT Object; + NTSTATUS Status; + + Status = ObmReferenceObjectByHandle(WinStaObject->HandleTable, + Handle, otCursorIcon, (PVOID*)&Object); + if (!NT_SUCCESS(Status)) + { + return NULL; + } + return Object; } HBITMAP FASTCALL @@ -74,7 +73,7 @@ IntSetCursor(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT NewCursor, RECTL PointerRect; HDC Screen; - CurInfo = &WinStaObject->SystemCursor; + CurInfo = IntGetSysCursorInfo(WinStaObject); OldCursor = CurInfo->CurrentCursorObject; if (OldCursor) { @@ -241,11 +240,7 @@ IntSetCursor(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT NewCursor, BOOL FASTCALL IntSetupCurIconHandles(PWINSTATION_OBJECT WinStaObject) { - if((WinStaObject->SystemCursor.CurIconHandleTable = (PVOID)ObmCreateHandleTable())) - { - ObmInitializeHandleTable((PUSER_HANDLE_TABLE)WinStaObject->SystemCursor.CurIconHandleTable); - } - return (WinStaObject->SystemCursor.CurIconHandleTable != NULL); + return TRUE; } PCURICON_OBJECT FASTCALL @@ -258,7 +253,7 @@ IntFindExistingCurIconObject(PWINSTATION_OBJECT WinStaObject, HMODULE hModule, PCURICON_OBJECT Object; ULONG i; - HandleTable = (PUSER_HANDLE_TABLE)WinStaObject->SystemCursor.CurIconHandleTable; + HandleTable = (PUSER_HANDLE_TABLE)WinStaObject->HandleTable; ObmpLockHandleTable(HandleTable); CurrentEntry = HandleTable->ListHead.Flink; @@ -268,15 +263,19 @@ IntFindExistingCurIconObject(PWINSTATION_OBJECT WinStaObject, HMODULE hModule, for(i = 0; i < HANDLE_BLOCK_ENTRIES; i++) { Object = (PCURICON_OBJECT)Current->Handles[i].ObjectBody; - if(Object && (Object->hModule == hModule) && (Object->hRsrc == hRsrc)) + if(Object && (ObmReferenceObjectByPointer(Object, otCursorIcon) == STATUS_SUCCESS)) { - if(cx && ((cx != Object->Size.cx) || (cy != Object->Size.cy))) + if((Object->hModule == hModule) && (Object->hRsrc == hRsrc)) { - continue; + if(cx && ((cx != Object->Size.cx) || (cy != Object->Size.cy))) + { + ObmDereferenceObject(Object); + continue; + } + ObmpUnlockHandleTable(HandleTable); + return Object; } - ObmReferenceObject(Object); - ObmpUnlockHandleTable(HandleTable); - return Object; + ObmDereferenceObject(Object); } } CurrentEntry = CurrentEntry->Flink; @@ -289,14 +288,11 @@ IntFindExistingCurIconObject(PWINSTATION_OBJECT WinStaObject, HMODULE hModule, PCURICON_OBJECT FASTCALL IntCreateCurIconHandle(PWINSTATION_OBJECT WinStaObject) { - PUSER_HANDLE_TABLE HandleTable; PCURICON_OBJECT Object; HANDLE Handle; PW32PROCESS Win32Process; - HandleTable = (PUSER_HANDLE_TABLE)WinStaObject->SystemCursor.CurIconHandleTable; - - Object = ObmCreateObject(HandleTable, &Handle, otCursorIcon, sizeof(CURICON_OBJECT)); + Object = ObmCreateObject(WinStaObject->HandleTable, &Handle, otCursorIcon, sizeof(CURICON_OBJECT)); if(!Object) { @@ -319,15 +315,13 @@ IntCreateCurIconHandle(PWINSTATION_OBJECT WinStaObject) BOOL FASTCALL IntDestroyCurIconObject(PWINSTATION_OBJECT WinStaObject, HANDLE Handle, BOOL RemoveFromProcess) { - PUSER_HANDLE_TABLE HandleTable; + PSYSTEM_CURSORINFO CurInfo; PCURICON_OBJECT Object; HBITMAP bmpMask, bmpColor; NTSTATUS Status; BOOL Ret; - HandleTable = (PUSER_HANDLE_TABLE)WinStaObject->SystemCursor.CurIconHandleTable; - - Status = ObmReferenceObjectByHandle(HandleTable, Handle, otCursorIcon, (PVOID*)&Object); + Status = ObmReferenceObjectByHandle(WinStaObject->HandleTable, Handle, otCursorIcon, (PVOID*)&Object); if(!NT_SUCCESS(Status)) { return FALSE; @@ -335,10 +329,13 @@ IntDestroyCurIconObject(PWINSTATION_OBJECT WinStaObject, HANDLE Handle, BOOL Rem if (Object->Process != PsGetWin32Process()) { + ObmDereferenceObject(Object); return FALSE; } - if (WinStaObject->SystemCursor.CurrentCursorObject == Object) + CurInfo = IntGetSysCursorInfo(WinStaObject); + + if (CurInfo->CurrentCursorObject == Object) { /* Hide the cursor if we're destroying the current cursor */ IntSetCursor(WinStaObject, NULL, TRUE); @@ -354,7 +351,7 @@ IntDestroyCurIconObject(PWINSTATION_OBJECT WinStaObject, HANDLE Handle, BOOL Rem IntUnLockProcessCursorIcons(Object->Process); } - Ret = NT_SUCCESS(ObmCloseHandle(HandleTable, Handle)); + Ret = NT_SUCCESS(ObmCloseHandle(WinStaObject->HandleTable, Handle)); /* delete bitmaps */ if(bmpMask) @@ -362,7 +359,7 @@ IntDestroyCurIconObject(PWINSTATION_OBJECT WinStaObject, HANDLE Handle, BOOL Rem if(bmpColor) NtGdiDeleteObject(bmpColor); -/* ObmDereferenceObject(Object);*/ + ObmDereferenceObject(Object); return Ret; } @@ -643,7 +640,7 @@ NtUserGetCursorInfo( return FALSE; } - CurInfo = &WinStaObject->SystemCursor; + CurInfo = IntGetSysCursorInfo(WinStaObject); CursorObject = (PCURICON_OBJECT)CurInfo->CurrentCursorObject; SafeCi.flags = ((CurInfo->ShowingCursor && CursorObject) ? CURSOR_SHOWING : 0); @@ -698,7 +695,7 @@ NtUserClipCursor( return FALSE; } - CurInfo = &WinStaObject->SystemCursor; + CurInfo = IntGetSysCursorInfo(WinStaObject); if(WinStaObject->ActiveDesktop) DesktopWindow = IntGetWindowObject(WinStaObject->ActiveDesktop->DesktopWindow); @@ -725,7 +722,7 @@ NtUserClipCursor( return TRUE; } - WinStaObject->SystemCursor.CursorClipInfo.IsClipped = FALSE; + CurInfo->CursorClipInfo.IsClipped = FALSE; ObDereferenceObject(WinStaObject); return TRUE; @@ -819,7 +816,7 @@ NtUserGetClipCursor( RECT *lpRect) { /* FIXME - check if process has WINSTA_READATTRIBUTES */ - + PSYSTEM_CURSORINFO CurInfo; PWINSTATION_OBJECT WinStaObject; RECT Rect; NTSTATUS Status; @@ -839,12 +836,13 @@ NtUserGetClipCursor( return FALSE; } - if(WinStaObject->SystemCursor.CursorClipInfo.IsClipped) + CurInfo = IntGetSysCursorInfo(WinStaObject); + if(CurInfo->CursorClipInfo.IsClipped) { - Rect.left = WinStaObject->SystemCursor.CursorClipInfo.Left; - Rect.top = WinStaObject->SystemCursor.CursorClipInfo.Top; - Rect.right = WinStaObject->SystemCursor.CursorClipInfo.Right; - Rect.bottom = WinStaObject->SystemCursor.CursorClipInfo.Bottom; + Rect.left = CurInfo->CursorClipInfo.Left; + Rect.top = CurInfo->CursorClipInfo.Top; + Rect.right = CurInfo->CursorClipInfo.Right; + Rect.bottom = CurInfo->CursorClipInfo.Bottom; } else {