changed cursors/icons to use the window station handle table

svn path=/trunk/; revision=9389
This commit is contained in:
Thomas Bluemel 2004-05-14 23:57:32 +00:00
parent 4b8fc8e4e4
commit b3b134ecfa
10 changed files with 173 additions and 133 deletions

View file

@ -8,41 +8,6 @@
#define NTOS_MODE_KERNEL #define NTOS_MODE_KERNEL
#include <ntos.h> #include <ntos.h>
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 typedef struct _WINSTATION_OBJECT
{ {
CSHORT Type; CSHORT Type;
@ -53,7 +18,7 @@ typedef struct _WINSTATION_OBJECT
PRTL_ATOM_TABLE AtomTable; PRTL_ATOM_TABLE AtomTable;
PVOID HandleTable; PVOID HandleTable;
HANDLE SystemMenuTemplate; HANDLE SystemMenuTemplate;
SYSTEM_CURSORINFO SystemCursor; PVOID SystemCursor;
UINT CaretBlinkRate; UINT CaretBlinkRate;
HANDLE ShellWindow; HANDLE ShellWindow;
HANDLE ShellListView; HANDLE ShellListView;

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 * PROJECT: ReactOS kernel
* PURPOSE: Mouse * PURPOSE: Mouse
@ -39,12 +39,13 @@ EnableMouse(HDC hDisplayDC)
PDC dc; PDC dc;
SURFOBJ *SurfObj; SURFOBJ *SurfObj;
PSURFGDI SurfGDI; PSURFGDI SurfGDI;
PSYSTEM_CURSORINFO CurInfo = IntGetSysCursorInfo(InputWindowStation);
if( hDisplayDC && InputWindowStation) if( hDisplayDC && InputWindowStation)
{ {
if(!IntGetWindowStationObject(InputWindowStation)) if(!IntGetWindowStationObject(InputWindowStation))
{ {
InputWindowStation->SystemCursor.Enabled = FALSE; CurInfo->Enabled = FALSE;
return; return;
} }
@ -55,14 +56,14 @@ EnableMouse(HDC hDisplayDC)
/* Move the cursor to the screen center */ /* 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); DPRINT("Setting Cursor up at 0x%x, 0x%x\n", SurfObj->sizlBitmap.cx / 2, SurfObj->sizlBitmap.cy / 2);
ExAcquireFastMutex(&InputWindowStation->SystemCursor.CursorMutex); ExAcquireFastMutex(&CurInfo->CursorMutex);
InputWindowStation->SystemCursor.x = SurfObj->sizlBitmap.cx / 2; CurInfo->x = SurfObj->sizlBitmap.cx / 2;
InputWindowStation->SystemCursor.y = SurfObj->sizlBitmap.cy / 2; CurInfo->y = SurfObj->sizlBitmap.cy / 2;
ExReleaseFastMutex(&InputWindowStation->SystemCursor.CursorMutex); ExReleaseFastMutex(&CurInfo->CursorMutex);
IntSetCursor(InputWindowStation, NULL, TRUE); IntSetCursor(InputWindowStation, NULL, TRUE);
InputWindowStation->SystemCursor.Enabled = (SPS_ACCEPT_EXCLUDE == SurfGDI->PointerStatus || CurInfo->Enabled = (SPS_ACCEPT_EXCLUDE == SurfGDI->PointerStatus ||
SPS_ACCEPT_NOEXCLUDE == SurfGDI->PointerStatus); SPS_ACCEPT_NOEXCLUDE == SurfGDI->PointerStatus);
ObDereferenceObject(InputWindowStation); ObDereferenceObject(InputWindowStation);
} }
@ -71,9 +72,9 @@ EnableMouse(HDC hDisplayDC)
if(IntGetWindowStationObject(InputWindowStation)) if(IntGetWindowStationObject(InputWindowStation))
{ {
IntSetCursor(InputWindowStation, NULL, TRUE); IntSetCursor(InputWindowStation, NULL, TRUE);
InputWindowStation->SystemCursor.Enabled = FALSE; CurInfo->Enabled = FALSE;
InputWindowStation->SystemCursor.CursorClipInfo.IsClipped = FALSE; CurInfo->CursorClipInfo.IsClipped = FALSE;
ObDereferenceObject(InputWindowStation); ObDereferenceObject(InputWindowStation);
return; return;
} }
} }
@ -97,7 +98,7 @@ MouseSafetyOnDrawStart(SURFOBJ *SurfObj, PSURFGDI SurfGDI, LONG HazardX1,
if(IntGetWindowStationObject(InputWindowStation)) if(IntGetWindowStationObject(InputWindowStation))
{ {
CurInfo = &InputWindowStation->SystemCursor; CurInfo = IntGetSysCursorInfo(InputWindowStation);
MouseEnabled = CurInfo->Enabled && CurInfo->ShowingCursor; MouseEnabled = CurInfo->Enabled && CurInfo->ShowingCursor;
} }
@ -183,7 +184,7 @@ MouseSafetyOnDrawEnd(SURFOBJ *SurfObj, SURFGDI *SurfGDI)
if(IntGetWindowStationObject(InputWindowStation)) if(IntGetWindowStationObject(InputWindowStation))
{ {
CurInfo = &InputWindowStation->SystemCursor; CurInfo = IntGetSysCursorInfo(InputWindowStation);
} }
else else
return FALSE; return FALSE;

View file

@ -16,12 +16,49 @@ typedef struct _CURICON_OBJECT
ICONINFO IconInfo; ICONINFO IconInfo;
} CURICON_OBJECT, *PCURICON_OBJECT; } 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); HCURSOR FASTCALL IntSetCursor(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT NewCursor, BOOL ForceChange);
BOOL FASTCALL IntSetupCurIconHandles(PWINSTATION_OBJECT WinStaObject); BOOL FASTCALL IntSetupCurIconHandles(PWINSTATION_OBJECT WinStaObject);
PCURICON_OBJECT FASTCALL IntGetCurIconObject(PWINSTATION_OBJECT WinStaObject, HANDLE Handle); PCURICON_OBJECT FASTCALL IntGetCurIconObject(PWINSTATION_OBJECT WinStaObject, HANDLE Handle);
PCURICON_OBJECT FASTCALL IntCreateCurIconHandle(PWINSTATION_OBJECT WinStaObject); PCURICON_OBJECT FASTCALL IntCreateCurIconHandle(PWINSTATION_OBJECT WinStaObject);
VOID FASTCALL IntCleanupCurIcons(struct _EPROCESS *Process, PW32PROCESS Win32Process); VOID FASTCALL IntCleanupCurIcons(struct _EPROCESS *Process, PW32PROCESS Win32Process);
#define IntGetSysCursorInfo(WinStaObj) \
(PSYSTEM_CURSORINFO)((WinStaObj)->SystemCursor)
#define IntReleaseCurIconObject(CurIconObj) \ #define IntReleaseCurIconObject(CurIconObj) \
ObmDereferenceObject(CurIconObj) ObmDereferenceObject(CurIconObj)

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -515,8 +515,12 @@ NtUserBlockInput(
BOOL FASTCALL BOOL FASTCALL
IntSwapMouseButton(PWINSTATION_OBJECT WinStaObject, BOOL Swap) IntSwapMouseButton(PWINSTATION_OBJECT WinStaObject, BOOL Swap)
{ {
BOOL res = WinStaObject->SystemCursor.SwapButtons; PSYSTEM_CURSORINFO CurInfo;
WinStaObject->SystemCursor.SwapButtons = Swap; BOOL res;
CurInfo = IntGetSysCursorInfo(WinStaObject);
res = CurInfo->SwapButtons;
CurInfo->SwapButtons = Swap;
return res; return res;
} }
@ -557,7 +561,7 @@ IntMouseInput(MOUSEINPUT *mi)
#endif #endif
ASSERT(WinSta); ASSERT(WinSta);
CurInfo = &WinSta->SystemCursor; CurInfo = IntGetSysCursorInfo(WinSta);
dc = DC_LockDc(hDC); dc = DC_LockDc(hDC);
SurfObj = (SURFOBJ*)AccessUserObject((ULONG) dc->Surface); SurfObj = (SURFOBJ*)AccessUserObject((ULONG) dc->Surface);
@ -573,7 +577,7 @@ IntMouseInput(MOUSEINPUT *mi)
mi->time = LargeTickCount.u.LowPart; mi->time = LargeTickCount.u.LowPart;
} }
SwapButtons = WinSta->SystemCursor.SwapButtons; SwapButtons = CurInfo->SwapButtons;
DoMove = FALSE; DoMove = FALSE;
ExAcquireFastMutex(&CurInfo->CursorMutex); ExAcquireFastMutex(&CurInfo->CursorMutex);
MousePos.x = CurInfo->x; MousePos.x = CurInfo->x;

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -342,12 +342,14 @@ IntSendHitTestMessages(PUSER_MESSAGE_QUEUE ThreadQueue, LPMSG Msg)
case WM_XBUTTONDBLCLK: case WM_XBUTTONDBLCLK:
{ {
WPARAM wParam; WPARAM wParam;
PSYSTEM_CURSORINFO CurInfo;
if(!IntGetWindowStationObject(InputWindowStation)) if(!IntGetWindowStationObject(InputWindowStation))
{ {
break; break;
} }
wParam = (WPARAM)InputWindowStation->SystemCursor.ButtonsDown; CurInfo = IntGetSysCursorInfo(InputWindowStation);
wParam = (WPARAM)(CurInfo->ButtonsDown);
ObDereferenceObject(InputWindowStation); ObDereferenceObject(InputWindowStation);
IntSendMessage(Msg->hwnd, WM_MOUSEMOVE, wParam, Msg->lParam); IntSendMessage(Msg->hwnd, WM_MOUSEMOVE, wParam, Msg->lParam);
@ -1025,6 +1027,7 @@ NtUserPostMessage(HWND Wnd,
} }
else else
{ {
PSYSTEM_CURSORINFO CurInfo;
Window = IntGetWindowObject(Wnd); Window = IntGetWindowObject(Wnd);
if (NULL == Window) if (NULL == Window)
{ {
@ -1043,8 +1046,9 @@ NtUserPostMessage(HWND Wnd,
SetLastWin32Error(ERROR_INVALID_PARAMETER); SetLastWin32Error(ERROR_INVALID_PARAMETER);
return FALSE; return FALSE;
} }
KernelModeMsg.pt.x = PsGetWin32Process()->WindowStation->SystemCursor.x; CurInfo = IntGetSysCursorInfo(PsGetWin32Process()->WindowStation);
KernelModeMsg.pt.y = PsGetWin32Process()->WindowStation->SystemCursor.y; KernelModeMsg.pt.x = CurInfo->x;
KernelModeMsg.pt.y = CurInfo->y;
KeQueryTickCount(&LargeTickCount); KeQueryTickCount(&LargeTickCount);
KernelModeMsg.time = LargeTickCount.u.LowPart; KernelModeMsg.time = LargeTickCount.u.LowPart;
MsqPostMessage(Window->MessageQueue, &KernelModeMsg, MsqPostMessage(Window->MessageQueue, &KernelModeMsg,

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -66,6 +66,8 @@ NtUserGetSystemMetrics(ULONG Index)
case SM_CXDOUBLECLK: case SM_CXDOUBLECLK:
case SM_CYDOUBLECLK: case SM_CYDOUBLECLK:
case SM_SWAPBUTTON: case SM_SWAPBUTTON:
{
PSYSTEM_CURSORINFO CurInfo;
Status = IntValidateWindowStationHandle(PROCESS_WINDOW_STATION(), Status = IntValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
KernelMode, KernelMode,
0, 0,
@ -73,22 +75,24 @@ NtUserGetSystemMetrics(ULONG Index)
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
return 0xFFFFFFFF; return 0xFFFFFFFF;
CurInfo = IntGetSysCursorInfo(WinStaObject);
switch(Index) switch(Index)
{ {
case SM_CXDOUBLECLK: case SM_CXDOUBLECLK:
Result = WinStaObject->SystemCursor.DblClickWidth; Result = CurInfo->DblClickWidth;
break; break;
case SM_CYDOUBLECLK: case SM_CYDOUBLECLK:
Result = WinStaObject->SystemCursor.DblClickWidth; Result = CurInfo->DblClickWidth;
break; break;
case SM_SWAPBUTTON: case SM_SWAPBUTTON:
Result = (UINT)WinStaObject->SystemCursor.SwapButtons; Result = (UINT)CurInfo->SwapButtons;
break; break;
} }
ObDereferenceObject(WinStaObject); ObDereferenceObject(WinStaObject);
return Result; return Result;
}
case SM_CXDRAG: case SM_CXDRAG:
case SM_CYDRAG: case SM_CYDRAG:
return(2); return(2);

View file

@ -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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -238,6 +238,7 @@ NtUserCallOneParam(
case ONEPARAM_ROUTINE_GETCURSORPOSITION: case ONEPARAM_ROUTINE_GETCURSORPOSITION:
{ {
PSYSTEM_CURSORINFO CurInfo;
PWINSTATION_OBJECT WinStaObject; PWINSTATION_OBJECT WinStaObject;
NTSTATUS Status; NTSTATUS Status;
POINT Pos; POINT Pos;
@ -251,9 +252,10 @@ NtUserCallOneParam(
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
return (DWORD)FALSE; return (DWORD)FALSE;
CurInfo = IntGetSysCursorInfo(WinStaObject);
/* FIXME - check if process has WINSTA_READATTRIBUTES */ /* FIXME - check if process has WINSTA_READATTRIBUTES */
Pos.x = WinStaObject->SystemCursor.x; Pos.x = CurInfo->x;
Pos.y = WinStaObject->SystemCursor.y; Pos.y = CurInfo->y;
Status = MmCopyToCaller((PPOINT)Param, &Pos, sizeof(POINT)); Status = MmCopyToCaller((PPOINT)Param, &Pos, sizeof(POINT));
if(!NT_SUCCESS(Status)) if(!NT_SUCCESS(Status))
@ -636,6 +638,8 @@ IntSystemParametersInfo(
case SPI_SETDOUBLECLKHEIGHT: case SPI_SETDOUBLECLKHEIGHT:
case SPI_SETDOUBLECLICKTIME: case SPI_SETDOUBLECLICKTIME:
{ {
PSYSTEM_CURSORINFO CurInfo;
Status = IntValidateWindowStationHandle(PROCESS_WINDOW_STATION(), Status = IntValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
KernelMode, KernelMode,
0, 0,
@ -646,19 +650,20 @@ IntSystemParametersInfo(
return (DWORD)FALSE; return (DWORD)FALSE;
} }
CurInfo = IntGetSysCursorInfo(WinStaObject);
switch(uiAction) switch(uiAction)
{ {
case SPI_SETDOUBLECLKWIDTH: case SPI_SETDOUBLECLKWIDTH:
/* FIXME limit the maximum value? */ /* FIXME limit the maximum value? */
WinStaObject->SystemCursor.DblClickWidth = uiParam; CurInfo->DblClickWidth = uiParam;
break; break;
case SPI_SETDOUBLECLKHEIGHT: case SPI_SETDOUBLECLKHEIGHT:
/* FIXME limit the maximum value? */ /* FIXME limit the maximum value? */
WinStaObject->SystemCursor.DblClickHeight = uiParam; CurInfo->DblClickHeight = uiParam;
break; break;
case SPI_SETDOUBLECLICKTIME: case SPI_SETDOUBLECLICKTIME:
/* FIXME limit the maximum time to 1000 ms? */ /* FIXME limit the maximum time to 1000 ms? */
WinStaObject->SystemCursor.DblClickSpeed = uiParam; CurInfo->DblClickSpeed = uiParam;
break; break;
} }
@ -914,6 +919,7 @@ NtUserGetDoubleClickTime(VOID)
UINT Result; UINT Result;
NTSTATUS Status; NTSTATUS Status;
PWINSTATION_OBJECT WinStaObject; PWINSTATION_OBJECT WinStaObject;
PSYSTEM_CURSORINFO CurInfo;
Status = IntValidateWindowStationHandle(PROCESS_WINDOW_STATION(), Status = IntValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
KernelMode, KernelMode,
@ -922,7 +928,8 @@ NtUserGetDoubleClickTime(VOID)
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
return (DWORD)FALSE; return (DWORD)FALSE;
Result = WinStaObject->SystemCursor.DblClickSpeed; CurInfo = IntGetSysCursorInfo(WinStaObject);
Result = CurInfo->DblClickSpeed;
ObDereferenceObject(WinStaObject); ObDereferenceObject(WinStaObject);
return Result; return Result;

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -187,7 +187,7 @@ MsqIsDblClk(LPMSG Msg, BOOL Remove)
{ {
return FALSE; return FALSE;
} }
CurInfo = &WinStaObject->SystemCursor; CurInfo = IntGetSysCursorInfo(WinStaObject);
Res = (Msg->hwnd == (HWND)CurInfo->LastClkWnd) && Res = (Msg->hwnd == (HWND)CurInfo->LastClkWnd) &&
((Msg->time - CurInfo->LastBtnDown) < CurInfo->DblClickSpeed); ((Msg->time - CurInfo->LastBtnDown) < CurInfo->DblClickSpeed);
if(Res) if(Res)

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -274,6 +274,7 @@ NtUserCreateWindowStation(
DWORD Unknown4, DWORD Unknown4,
DWORD Unknown5) DWORD Unknown5)
{ {
PSYSTEM_CURSORINFO CurInfo;
UNICODE_STRING WindowStationName; UNICODE_STRING WindowStationName;
PWINSTATION_OBJECT WindowStationObject; PWINSTATION_OBJECT WindowStationObject;
HWINSTA WindowStation; HWINSTA WindowStation;
@ -367,11 +368,22 @@ NtUserCreateWindowStation(
* Initialize the new window station object * 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(); WindowStationObject->HandleTable = ObmCreateHandleTable();
if (!WindowStationObject->HandleTable) if (!WindowStationObject->HandleTable)
{ {
DPRINT("Failed creating handle table\n"); DPRINT("Failed creating handle table\n");
ExFreePool(CurInfo);
ExFreePool(WindowStationName.Buffer); ExFreePool(WindowStationName.Buffer);
/* FIXME - Delete window station object */
ObDereferenceObject(WindowStationObject); ObDereferenceObject(WindowStationObject);
SetLastNtError(STATUS_INSUFFICIENT_RESOURCES); SetLastNtError(STATUS_INSUFFICIENT_RESOURCES);
return 0; return 0;
@ -379,23 +391,25 @@ NtUserCreateWindowStation(
InitHotKeys(WindowStationObject); InitHotKeys(WindowStationObject);
ExInitializeFastMutex(&WindowStationObject->SystemCursor.CursorMutex); ExInitializeFastMutex(&CurInfo->CursorMutex);
WindowStationObject->SystemCursor.Enabled = FALSE; CurInfo->Enabled = FALSE;
WindowStationObject->SystemCursor.ButtonsDown = 0; CurInfo->ButtonsDown = 0;
WindowStationObject->SystemCursor.x = (LONG)0; CurInfo->x = (LONG)0;
WindowStationObject->SystemCursor.y = (LONG)0; CurInfo->y = (LONG)0;
WindowStationObject->SystemCursor.CursorClipInfo.IsClipped = FALSE; CurInfo->CursorClipInfo.IsClipped = FALSE;
WindowStationObject->SystemCursor.LastBtnDown = 0; CurInfo->LastBtnDown = 0;
WindowStationObject->SystemCursor.CurrentCursorObject = NULL; CurInfo->CurrentCursorObject = NULL;
WindowStationObject->SystemCursor.ShowingCursor = 0; CurInfo->ShowingCursor = 0;
/* FIXME: Obtain the following information from the registry */ /* FIXME: Obtain the following information from the registry */
WindowStationObject->SystemCursor.SwapButtons = FALSE; CurInfo->SwapButtons = FALSE;
WindowStationObject->SystemCursor.SafetySwitch = FALSE; CurInfo->SafetySwitch = FALSE;
WindowStationObject->SystemCursor.SafetyRemoveCount = 0; CurInfo->SafetyRemoveCount = 0;
WindowStationObject->SystemCursor.DblClickSpeed = 500; CurInfo->DblClickSpeed = 500;
WindowStationObject->SystemCursor.DblClickWidth = 4; CurInfo->DblClickWidth = 4;
WindowStationObject->SystemCursor.DblClickHeight = 4; CurInfo->DblClickHeight = 4;
WindowStationObject->SystemCursor = CurInfo;
if (!IntSetupCurIconHandles(WindowStationObject)) if (!IntSetupCurIconHandles(WindowStationObject))
{ {
@ -529,6 +543,12 @@ NtUserCloseWindowStation(
return FALSE; return FALSE;
} }
#if 0
/* FIXME - free the cursor information when actually deleting the object!! */
ASSERT(Object->SystemCursor);
ExFreePool(Object->SystemCursor);
#endif
ObDereferenceObject(Object); ObDereferenceObject(Object);
DPRINT("Closing window station handle (0x%X)\n", hWinSta); DPRINT("Closing window station handle (0x%X)\n", hWinSta);

View file

@ -16,23 +16,22 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 <w32k.h> #include <w32k.h>
PCURICON_OBJECT FASTCALL PCURICON_OBJECT FASTCALL
IntGetCurIconObject(PWINSTATION_OBJECT WinStaObject, HANDLE Handle) IntGetCurIconObject(PWINSTATION_OBJECT WinStaObject, HANDLE Handle)
{ {
PCURICON_OBJECT Object; PCURICON_OBJECT Object;
PUSER_HANDLE_TABLE HandleTable; NTSTATUS Status;
HandleTable = (PUSER_HANDLE_TABLE)WinStaObject->SystemCursor.CurIconHandleTable; Status = ObmReferenceObjectByHandle(WinStaObject->HandleTable,
if(!NT_SUCCESS(ObmReferenceObjectByHandle(HandleTable, Handle, otCursorIcon, Handle, otCursorIcon, (PVOID*)&Object);
(PVOID*)&Object))) if (!NT_SUCCESS(Status))
{ {
return FALSE; return NULL;
} }
return Object;
return Object;
} }
HBITMAP FASTCALL HBITMAP FASTCALL
@ -74,7 +73,7 @@ IntSetCursor(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT NewCursor,
RECTL PointerRect; RECTL PointerRect;
HDC Screen; HDC Screen;
CurInfo = &WinStaObject->SystemCursor; CurInfo = IntGetSysCursorInfo(WinStaObject);
OldCursor = CurInfo->CurrentCursorObject; OldCursor = CurInfo->CurrentCursorObject;
if (OldCursor) if (OldCursor)
{ {
@ -241,11 +240,7 @@ IntSetCursor(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT NewCursor,
BOOL FASTCALL BOOL FASTCALL
IntSetupCurIconHandles(PWINSTATION_OBJECT WinStaObject) IntSetupCurIconHandles(PWINSTATION_OBJECT WinStaObject)
{ {
if((WinStaObject->SystemCursor.CurIconHandleTable = (PVOID)ObmCreateHandleTable())) return TRUE;
{
ObmInitializeHandleTable((PUSER_HANDLE_TABLE)WinStaObject->SystemCursor.CurIconHandleTable);
}
return (WinStaObject->SystemCursor.CurIconHandleTable != NULL);
} }
PCURICON_OBJECT FASTCALL PCURICON_OBJECT FASTCALL
@ -258,7 +253,7 @@ IntFindExistingCurIconObject(PWINSTATION_OBJECT WinStaObject, HMODULE hModule,
PCURICON_OBJECT Object; PCURICON_OBJECT Object;
ULONG i; ULONG i;
HandleTable = (PUSER_HANDLE_TABLE)WinStaObject->SystemCursor.CurIconHandleTable; HandleTable = (PUSER_HANDLE_TABLE)WinStaObject->HandleTable;
ObmpLockHandleTable(HandleTable); ObmpLockHandleTable(HandleTable);
CurrentEntry = HandleTable->ListHead.Flink; CurrentEntry = HandleTable->ListHead.Flink;
@ -268,15 +263,19 @@ IntFindExistingCurIconObject(PWINSTATION_OBJECT WinStaObject, HMODULE hModule,
for(i = 0; i < HANDLE_BLOCK_ENTRIES; i++) for(i = 0; i < HANDLE_BLOCK_ENTRIES; i++)
{ {
Object = (PCURICON_OBJECT)Current->Handles[i].ObjectBody; 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); ObmDereferenceObject(Object);
ObmpUnlockHandleTable(HandleTable);
return Object;
} }
} }
CurrentEntry = CurrentEntry->Flink; CurrentEntry = CurrentEntry->Flink;
@ -289,14 +288,11 @@ IntFindExistingCurIconObject(PWINSTATION_OBJECT WinStaObject, HMODULE hModule,
PCURICON_OBJECT FASTCALL PCURICON_OBJECT FASTCALL
IntCreateCurIconHandle(PWINSTATION_OBJECT WinStaObject) IntCreateCurIconHandle(PWINSTATION_OBJECT WinStaObject)
{ {
PUSER_HANDLE_TABLE HandleTable;
PCURICON_OBJECT Object; PCURICON_OBJECT Object;
HANDLE Handle; HANDLE Handle;
PW32PROCESS Win32Process; PW32PROCESS Win32Process;
HandleTable = (PUSER_HANDLE_TABLE)WinStaObject->SystemCursor.CurIconHandleTable; Object = ObmCreateObject(WinStaObject->HandleTable, &Handle, otCursorIcon, sizeof(CURICON_OBJECT));
Object = ObmCreateObject(HandleTable, &Handle, otCursorIcon, sizeof(CURICON_OBJECT));
if(!Object) if(!Object)
{ {
@ -319,15 +315,13 @@ IntCreateCurIconHandle(PWINSTATION_OBJECT WinStaObject)
BOOL FASTCALL BOOL FASTCALL
IntDestroyCurIconObject(PWINSTATION_OBJECT WinStaObject, HANDLE Handle, BOOL RemoveFromProcess) IntDestroyCurIconObject(PWINSTATION_OBJECT WinStaObject, HANDLE Handle, BOOL RemoveFromProcess)
{ {
PUSER_HANDLE_TABLE HandleTable; PSYSTEM_CURSORINFO CurInfo;
PCURICON_OBJECT Object; PCURICON_OBJECT Object;
HBITMAP bmpMask, bmpColor; HBITMAP bmpMask, bmpColor;
NTSTATUS Status; NTSTATUS Status;
BOOL Ret; BOOL Ret;
HandleTable = (PUSER_HANDLE_TABLE)WinStaObject->SystemCursor.CurIconHandleTable; Status = ObmReferenceObjectByHandle(WinStaObject->HandleTable, Handle, otCursorIcon, (PVOID*)&Object);
Status = ObmReferenceObjectByHandle(HandleTable, Handle, otCursorIcon, (PVOID*)&Object);
if(!NT_SUCCESS(Status)) if(!NT_SUCCESS(Status))
{ {
return FALSE; return FALSE;
@ -335,10 +329,13 @@ IntDestroyCurIconObject(PWINSTATION_OBJECT WinStaObject, HANDLE Handle, BOOL Rem
if (Object->Process != PsGetWin32Process()) if (Object->Process != PsGetWin32Process())
{ {
ObmDereferenceObject(Object);
return FALSE; return FALSE;
} }
if (WinStaObject->SystemCursor.CurrentCursorObject == Object) CurInfo = IntGetSysCursorInfo(WinStaObject);
if (CurInfo->CurrentCursorObject == Object)
{ {
/* Hide the cursor if we're destroying the current cursor */ /* Hide the cursor if we're destroying the current cursor */
IntSetCursor(WinStaObject, NULL, TRUE); IntSetCursor(WinStaObject, NULL, TRUE);
@ -354,7 +351,7 @@ IntDestroyCurIconObject(PWINSTATION_OBJECT WinStaObject, HANDLE Handle, BOOL Rem
IntUnLockProcessCursorIcons(Object->Process); IntUnLockProcessCursorIcons(Object->Process);
} }
Ret = NT_SUCCESS(ObmCloseHandle(HandleTable, Handle)); Ret = NT_SUCCESS(ObmCloseHandle(WinStaObject->HandleTable, Handle));
/* delete bitmaps */ /* delete bitmaps */
if(bmpMask) if(bmpMask)
@ -362,7 +359,7 @@ IntDestroyCurIconObject(PWINSTATION_OBJECT WinStaObject, HANDLE Handle, BOOL Rem
if(bmpColor) if(bmpColor)
NtGdiDeleteObject(bmpColor); NtGdiDeleteObject(bmpColor);
/* ObmDereferenceObject(Object);*/ ObmDereferenceObject(Object);
return Ret; return Ret;
} }
@ -643,7 +640,7 @@ NtUserGetCursorInfo(
return FALSE; return FALSE;
} }
CurInfo = &WinStaObject->SystemCursor; CurInfo = IntGetSysCursorInfo(WinStaObject);
CursorObject = (PCURICON_OBJECT)CurInfo->CurrentCursorObject; CursorObject = (PCURICON_OBJECT)CurInfo->CurrentCursorObject;
SafeCi.flags = ((CurInfo->ShowingCursor && CursorObject) ? CURSOR_SHOWING : 0); SafeCi.flags = ((CurInfo->ShowingCursor && CursorObject) ? CURSOR_SHOWING : 0);
@ -698,7 +695,7 @@ NtUserClipCursor(
return FALSE; return FALSE;
} }
CurInfo = &WinStaObject->SystemCursor; CurInfo = IntGetSysCursorInfo(WinStaObject);
if(WinStaObject->ActiveDesktop) if(WinStaObject->ActiveDesktop)
DesktopWindow = IntGetWindowObject(WinStaObject->ActiveDesktop->DesktopWindow); DesktopWindow = IntGetWindowObject(WinStaObject->ActiveDesktop->DesktopWindow);
@ -725,7 +722,7 @@ NtUserClipCursor(
return TRUE; return TRUE;
} }
WinStaObject->SystemCursor.CursorClipInfo.IsClipped = FALSE; CurInfo->CursorClipInfo.IsClipped = FALSE;
ObDereferenceObject(WinStaObject); ObDereferenceObject(WinStaObject);
return TRUE; return TRUE;
@ -819,7 +816,7 @@ NtUserGetClipCursor(
RECT *lpRect) RECT *lpRect)
{ {
/* FIXME - check if process has WINSTA_READATTRIBUTES */ /* FIXME - check if process has WINSTA_READATTRIBUTES */
PSYSTEM_CURSORINFO CurInfo;
PWINSTATION_OBJECT WinStaObject; PWINSTATION_OBJECT WinStaObject;
RECT Rect; RECT Rect;
NTSTATUS Status; NTSTATUS Status;
@ -839,12 +836,13 @@ NtUserGetClipCursor(
return FALSE; return FALSE;
} }
if(WinStaObject->SystemCursor.CursorClipInfo.IsClipped) CurInfo = IntGetSysCursorInfo(WinStaObject);
if(CurInfo->CursorClipInfo.IsClipped)
{ {
Rect.left = WinStaObject->SystemCursor.CursorClipInfo.Left; Rect.left = CurInfo->CursorClipInfo.Left;
Rect.top = WinStaObject->SystemCursor.CursorClipInfo.Top; Rect.top = CurInfo->CursorClipInfo.Top;
Rect.right = WinStaObject->SystemCursor.CursorClipInfo.Right; Rect.right = CurInfo->CursorClipInfo.Right;
Rect.bottom = WinStaObject->SystemCursor.CursorClipInfo.Bottom; Rect.bottom = CurInfo->CursorClipInfo.Bottom;
} }
else else
{ {