diff --git a/reactos/ntoskrnl/include/internal/ex.h b/reactos/ntoskrnl/include/internal/ex.h index 63314c09544..f3973176c0c 100644 --- a/reactos/ntoskrnl/include/internal/ex.h +++ b/reactos/ntoskrnl/include/internal/ex.h @@ -35,6 +35,7 @@ typedef struct _SYSTEM_CURSORINFO UINT CurrentCursor; LONG x, y; BOOL SafetySwitch, SafetySwitch2; + FAST_MUTEX CursorMutex; CURSORCLIP_INFO CursorClipInfo; SYSCURSOR SystemCursors[SYSCURSORCOUNT]; } SYSTEM_CURSORINFO, *PSYSTEM_CURSORINFO; diff --git a/reactos/subsys/win32k/eng/mouse.c b/reactos/subsys/win32k/eng/mouse.c index 735c929453e..f53c61c3823 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.32 2003/08/24 23:52:29 weiden Exp $ +/* $Id: mouse.c,v 1.33 2003/08/25 00:28:22 weiden Exp $ * * PROJECT: ReactOS kernel * PURPOSE: Mouse @@ -30,6 +30,7 @@ #include #include #include +#include #include #include "objects.h" #include "include/msgqueue.h" @@ -45,11 +46,6 @@ /* GLOBALS *******************************************************************/ -//static BOOLEAN SafetySwitch = FALSE; -//static BOOLEAN SafetySwitch2 = FALSE; -//static BOOLEAN MouseEnabled = FALSE; -//static LONG mouse_x, mouse_y; -//static LONG mouse_width = 0, mouse_height = 0; static ULONG PointerStatus; static UCHAR DefaultCursor[256] = { @@ -201,8 +197,10 @@ MouseSafetyOnDrawStart(PSURFOBJ SurfObj, PSURFGDI SurfGDI, LONG HazardX1, ((CurInfo->y + SysCursor->cy) >= HazardY1) && (CurInfo->y <= HazardY2)) { /* Mouse is not allowed to move if GDI is busy drawing */ + ExAcquireFastMutexUnsafe(&CurInfo->CursorMutex); CurInfo->SafetySwitch = TRUE; SurfGDI->MovePointer(SurfObj, -1, -1, &MouseRect); + ExReleaseFastMutexUnsafe(&CurInfo->CursorMutex); } ObDereferenceObject(InputWindowStation); @@ -254,8 +252,10 @@ MouseSafetyOnDrawEnd(PSURFOBJ SurfObj, PSURFGDI SurfGDI) if (CurInfo->SafetySwitch) { + ExAcquireFastMutexUnsafe(&CurInfo->CursorMutex); SurfGDI->MovePointer(SurfObj, CurInfo->x, CurInfo->y, &MouseRect); CurInfo->SafetySwitch = FALSE; + ExReleaseFastMutexUnsafe(&CurInfo->CursorMutex); } CurInfo->SafetySwitch2 = FALSE; @@ -276,6 +276,7 @@ MouseMoveCursor(LONG X, LONG Y) MSG Msg; LARGE_INTEGER LargeTickCount; ULONG TickCount; + static ULONG ButtonsDown = 0; hDC = IntGetScreenDC(); @@ -289,13 +290,13 @@ MouseMoveCursor(LONG X, LONG Y) SurfGDI = (PSURFGDI)AccessInternalObject((ULONG) dc->Surface); DC_UnlockDc( hDC ); CurInfo = &InputWindowStation->SystemCursor; - CheckClipCursor(&X, &X, CurInfo); + CheckClipCursor(&X, &Y, CurInfo); if((X != CurInfo->x) || (Y != CurInfo->y)) { /* send MOUSEMOVE message */ KeQueryTickCount(&LargeTickCount); TickCount = LargeTickCount.u.LowPart; - Msg.wParam = 0; + Msg.wParam = ButtonsDown; Msg.lParam = MAKELPARAM(X, Y); Msg.message = WM_MOUSEMOVE; Msg.time = TickCount; @@ -307,7 +308,9 @@ MouseMoveCursor(LONG X, LONG Y) CurInfo->y = Y; if(!CurInfo->SafetySwitch && !CurInfo->SafetySwitch2 && CurInfo->Enabled) { + ExAcquireFastMutexUnsafe(&CurInfo->CursorMutex); SurfGDI->MovePointer(SurfObj, CurInfo->x, CurInfo->y, &MouseRect); + ExReleaseFastMutexUnsafe(&CurInfo->CursorMutex); } res = TRUE; } @@ -439,7 +442,9 @@ MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount) if (!CurInfo->SafetySwitch && !CurInfo->SafetySwitch2 && ((mouse_ox != CurInfo->x) || (mouse_oy != CurInfo->y))) { + ExAcquireFastMutexUnsafe(&CurInfo->CursorMutex); SurfGDI->MovePointer(SurfObj, CurInfo->x, CurInfo->y, &MouseRect); + ExReleaseFastMutexUnsafe(&CurInfo->CursorMutex); } } @@ -466,6 +471,7 @@ EnableMouse(HDC hDisplayDC) InputWindowStation->SystemCursor.Enabled = FALSE; return; } + CurInfo = &InputWindowStation->SystemCursor; SysCursor = &CurInfo->SystemCursors[CurInfo->CurrentCursor]; diff --git a/reactos/subsys/win32k/ntuser/misc.c b/reactos/subsys/win32k/ntuser/misc.c index f07e624b5f6..5bfb970115e 100644 --- a/reactos/subsys/win32k/ntuser/misc.c +++ b/reactos/subsys/win32k/ntuser/misc.c @@ -1,4 +1,4 @@ -/* $Id: misc.c,v 1.11 2003/08/24 23:52:29 weiden Exp $ +/* $Id: misc.c,v 1.12 2003/08/25 00:28:23 weiden Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -166,7 +166,7 @@ NtUserCallTwoParam( CurInfo = &WinStaObject->SystemCursor; /* FIXME - check if process has WINSTA_WRITEATTRIBUTES */ - CheckClipCursor(&Pos->x, &Pos->y, CurInfo); + //CheckClipCursor(&Pos->x, &Pos->y, CurInfo); if((Pos->x != CurInfo->x) || (Pos->y != CurInfo->y)) { MouseMoveCursor(Pos->x, Pos->y); diff --git a/reactos/subsys/win32k/ntuser/winsta.c b/reactos/subsys/win32k/ntuser/winsta.c index 93091097405..1bd0258a495 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.29 2003/08/24 23:52:29 weiden Exp $ +/* $Id: winsta.c,v 1.30 2003/08/25 00:28:23 weiden Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -352,6 +352,7 @@ NtUserCreateWindowStation(PUNICODE_STRING lpszWindowStationName, return((HWINSTA)0); } + ExInitializeFastMutex(&WinStaObject->SystemCursor.CursorMutex); WinStaObject->SystemCursor.Enabled = FALSE; WinStaObject->SystemCursor.CurrentCursor = 0; WinStaObject->SystemCursor.x = (LONG)0; diff --git a/reactos/subsys/win32k/objects/cursoricon.c b/reactos/subsys/win32k/objects/cursoricon.c index 39f9e982b79..d4e058a0fd5 100644 --- a/reactos/subsys/win32k/objects/cursoricon.c +++ b/reactos/subsys/win32k/objects/cursoricon.c @@ -235,7 +235,6 @@ NtUserClipCursor( PWINSTATION_OBJECT WinStaObject; PSYSTEM_CURSORINFO CurInfo; - LONG newx, newy; NTSTATUS Status = ValidateWindowStationHandle(PROCESS_WINDOW_STATION(), KernelMode, @@ -258,14 +257,7 @@ NtUserClipCursor( 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); - } - + MouseMoveCursor(CurInfo->x, CurInfo->y); } else WinStaObject->SystemCursor.CursorClipInfo.IsClipped = FALSE;