fixed a bug that caused the mouse cursor drawing incorrectly

svn path=/trunk/; revision=5840
This commit is contained in:
Thomas Bluemel 2003-08-25 00:28:23 +00:00
parent 94b7020933
commit 862a1d3afe
5 changed files with 20 additions and 20 deletions

View file

@ -35,6 +35,7 @@ typedef struct _SYSTEM_CURSORINFO
UINT CurrentCursor; UINT CurrentCursor;
LONG x, y; LONG x, y;
BOOL SafetySwitch, SafetySwitch2; BOOL SafetySwitch, SafetySwitch2;
FAST_MUTEX CursorMutex;
CURSORCLIP_INFO CursorClipInfo; CURSORCLIP_INFO CursorClipInfo;
SYSCURSOR SystemCursors[SYSCURSORCOUNT]; SYSCURSOR SystemCursors[SYSCURSORCOUNT];
} SYSTEM_CURSORINFO, *PSYSTEM_CURSORINFO; } SYSTEM_CURSORINFO, *PSYSTEM_CURSORINFO;

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.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 * PROJECT: ReactOS kernel
* PURPOSE: Mouse * PURPOSE: Mouse
@ -30,6 +30,7 @@
#include <windows.h> #include <windows.h>
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <ddk/ntddmou.h> #include <ddk/ntddmou.h>
#include <win32k/win32k.h>
#include <win32k/dc.h> #include <win32k/dc.h>
#include "objects.h" #include "objects.h"
#include "include/msgqueue.h" #include "include/msgqueue.h"
@ -45,11 +46,6 @@
/* GLOBALS *******************************************************************/ /* 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 ULONG PointerStatus;
static UCHAR DefaultCursor[256] = { static UCHAR DefaultCursor[256] = {
@ -201,8 +197,10 @@ MouseSafetyOnDrawStart(PSURFOBJ SurfObj, PSURFGDI SurfGDI, LONG HazardX1,
((CurInfo->y + SysCursor->cy) >= HazardY1) && (CurInfo->y <= HazardY2)) ((CurInfo->y + SysCursor->cy) >= HazardY1) && (CurInfo->y <= HazardY2))
{ {
/* Mouse is not allowed to move if GDI is busy drawing */ /* Mouse is not allowed to move if GDI is busy drawing */
ExAcquireFastMutexUnsafe(&CurInfo->CursorMutex);
CurInfo->SafetySwitch = TRUE; CurInfo->SafetySwitch = TRUE;
SurfGDI->MovePointer(SurfObj, -1, -1, &MouseRect); SurfGDI->MovePointer(SurfObj, -1, -1, &MouseRect);
ExReleaseFastMutexUnsafe(&CurInfo->CursorMutex);
} }
ObDereferenceObject(InputWindowStation); ObDereferenceObject(InputWindowStation);
@ -254,8 +252,10 @@ MouseSafetyOnDrawEnd(PSURFOBJ SurfObj, PSURFGDI SurfGDI)
if (CurInfo->SafetySwitch) if (CurInfo->SafetySwitch)
{ {
ExAcquireFastMutexUnsafe(&CurInfo->CursorMutex);
SurfGDI->MovePointer(SurfObj, CurInfo->x, CurInfo->y, &MouseRect); SurfGDI->MovePointer(SurfObj, CurInfo->x, CurInfo->y, &MouseRect);
CurInfo->SafetySwitch = FALSE; CurInfo->SafetySwitch = FALSE;
ExReleaseFastMutexUnsafe(&CurInfo->CursorMutex);
} }
CurInfo->SafetySwitch2 = FALSE; CurInfo->SafetySwitch2 = FALSE;
@ -276,6 +276,7 @@ MouseMoveCursor(LONG X, LONG Y)
MSG Msg; MSG Msg;
LARGE_INTEGER LargeTickCount; LARGE_INTEGER LargeTickCount;
ULONG TickCount; ULONG TickCount;
static ULONG ButtonsDown = 0;
hDC = IntGetScreenDC(); hDC = IntGetScreenDC();
@ -289,13 +290,13 @@ MouseMoveCursor(LONG X, LONG Y)
SurfGDI = (PSURFGDI)AccessInternalObject((ULONG) dc->Surface); SurfGDI = (PSURFGDI)AccessInternalObject((ULONG) dc->Surface);
DC_UnlockDc( hDC ); DC_UnlockDc( hDC );
CurInfo = &InputWindowStation->SystemCursor; CurInfo = &InputWindowStation->SystemCursor;
CheckClipCursor(&X, &X, CurInfo); CheckClipCursor(&X, &Y, CurInfo);
if((X != CurInfo->x) || (Y != CurInfo->y)) if((X != CurInfo->x) || (Y != CurInfo->y))
{ {
/* send MOUSEMOVE message */ /* send MOUSEMOVE message */
KeQueryTickCount(&LargeTickCount); KeQueryTickCount(&LargeTickCount);
TickCount = LargeTickCount.u.LowPart; TickCount = LargeTickCount.u.LowPart;
Msg.wParam = 0; Msg.wParam = ButtonsDown;
Msg.lParam = MAKELPARAM(X, Y); Msg.lParam = MAKELPARAM(X, Y);
Msg.message = WM_MOUSEMOVE; Msg.message = WM_MOUSEMOVE;
Msg.time = TickCount; Msg.time = TickCount;
@ -307,7 +308,9 @@ MouseMoveCursor(LONG X, LONG Y)
CurInfo->y = Y; CurInfo->y = Y;
if(!CurInfo->SafetySwitch && !CurInfo->SafetySwitch2 && CurInfo->Enabled) if(!CurInfo->SafetySwitch && !CurInfo->SafetySwitch2 && CurInfo->Enabled)
{ {
ExAcquireFastMutexUnsafe(&CurInfo->CursorMutex);
SurfGDI->MovePointer(SurfObj, CurInfo->x, CurInfo->y, &MouseRect); SurfGDI->MovePointer(SurfObj, CurInfo->x, CurInfo->y, &MouseRect);
ExReleaseFastMutexUnsafe(&CurInfo->CursorMutex);
} }
res = TRUE; res = TRUE;
} }
@ -439,7 +442,9 @@ MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount)
if (!CurInfo->SafetySwitch && !CurInfo->SafetySwitch2 && if (!CurInfo->SafetySwitch && !CurInfo->SafetySwitch2 &&
((mouse_ox != CurInfo->x) || (mouse_oy != CurInfo->y))) ((mouse_ox != CurInfo->x) || (mouse_oy != CurInfo->y)))
{ {
ExAcquireFastMutexUnsafe(&CurInfo->CursorMutex);
SurfGDI->MovePointer(SurfObj, CurInfo->x, CurInfo->y, &MouseRect); SurfGDI->MovePointer(SurfObj, CurInfo->x, CurInfo->y, &MouseRect);
ExReleaseFastMutexUnsafe(&CurInfo->CursorMutex);
} }
} }
@ -466,6 +471,7 @@ EnableMouse(HDC hDisplayDC)
InputWindowStation->SystemCursor.Enabled = FALSE; InputWindowStation->SystemCursor.Enabled = FALSE;
return; return;
} }
CurInfo = &InputWindowStation->SystemCursor; CurInfo = &InputWindowStation->SystemCursor;
SysCursor = &CurInfo->SystemCursors[CurInfo->CurrentCursor]; SysCursor = &CurInfo->SystemCursors[CurInfo->CurrentCursor];

View file

@ -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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -166,7 +166,7 @@ NtUserCallTwoParam(
CurInfo = &WinStaObject->SystemCursor; CurInfo = &WinStaObject->SystemCursor;
/* FIXME - check if process has WINSTA_WRITEATTRIBUTES */ /* 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)) if((Pos->x != CurInfo->x) || (Pos->y != CurInfo->y))
{ {
MouseMoveCursor(Pos->x, Pos->y); MouseMoveCursor(Pos->x, Pos->y);

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.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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -352,6 +352,7 @@ NtUserCreateWindowStation(PUNICODE_STRING lpszWindowStationName,
return((HWINSTA)0); return((HWINSTA)0);
} }
ExInitializeFastMutex(&WinStaObject->SystemCursor.CursorMutex);
WinStaObject->SystemCursor.Enabled = FALSE; WinStaObject->SystemCursor.Enabled = FALSE;
WinStaObject->SystemCursor.CurrentCursor = 0; WinStaObject->SystemCursor.CurrentCursor = 0;
WinStaObject->SystemCursor.x = (LONG)0; WinStaObject->SystemCursor.x = (LONG)0;

View file

@ -235,7 +235,6 @@ NtUserClipCursor(
PWINSTATION_OBJECT WinStaObject; PWINSTATION_OBJECT WinStaObject;
PSYSTEM_CURSORINFO CurInfo; PSYSTEM_CURSORINFO CurInfo;
LONG newx, newy;
NTSTATUS Status = ValidateWindowStationHandle(PROCESS_WINDOW_STATION(), NTSTATUS Status = ValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
KernelMode, KernelMode,
@ -258,14 +257,7 @@ NtUserClipCursor(
CurInfo->CursorClipInfo.Right = lpRect->right; CurInfo->CursorClipInfo.Right = lpRect->right;
CurInfo->CursorClipInfo.Bottom = lpRect->bottom; CurInfo->CursorClipInfo.Bottom = lpRect->bottom;
newx = CurInfo->x; MouseMoveCursor(CurInfo->x, CurInfo->y);
newy = CurInfo->y;
CheckClipCursor(&newx, &newy, CurInfo);
if((newx != CurInfo->x) || (newy != CurInfo->y))
{
MouseMoveCursor(newx, newy);
}
} }
else else
WinStaObject->SystemCursor.CursorClipInfo.IsClipped = FALSE; WinStaObject->SystemCursor.CursorClipInfo.IsClipped = FALSE;