fixed a few bugs in MsqInsertSystemMessage() and improved moving mouse cursor

svn path=/trunk/; revision=5862
This commit is contained in:
Thomas Bluemel 2003-08-25 23:55:46 +00:00
parent 877b6f0c22
commit 044494cbcd
2 changed files with 72 additions and 36 deletions

View file

@ -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.33 2003/08/25 00:28:22 weiden Exp $
/* $Id: mouse.c,v 1.34 2003/08/25 23:55:45 weiden Exp $
*
* PROJECT: ReactOS kernel
* PURPOSE: Mouse
@ -306,7 +306,7 @@ MouseMoveCursor(LONG X, LONG Y)
/* move cursor */
CurInfo->x = X;
CurInfo->y = Y;
if(!CurInfo->SafetySwitch && !CurInfo->SafetySwitch2 && CurInfo->Enabled)
if(CurInfo->Enabled)
{
ExAcquireFastMutexUnsafe(&CurInfo->CursorMutex);
SurfGDI->MovePointer(SurfObj, CurInfo->x, CurInfo->y, &MouseRect);
@ -332,6 +332,7 @@ MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount)
PSYSTEM_CURSORINFO CurInfo;
PSYSCURSOR SysCursor;
BOOL MouseEnabled = FALSE;
BOOL MouseMoveAdded = FALSE;
LONG mouse_ox, mouse_oy;
LONG mouse_cx = 0, mouse_cy = 0;
HDC hDC;
@ -360,9 +361,6 @@ MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount)
else
return;
KeQueryTickCount(&LargeTickCount);
TickCount = LargeTickCount.u.LowPart;
dc = DC_LockDc(hDC);
SurfObj = (PSURFOBJ)AccessUserObject((ULONG) dc->Surface);
SurfGDI = (PSURFGDI)AccessInternalObject((ULONG) dc->Surface);
@ -373,23 +371,38 @@ MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount)
{
mouse_cx += Data[i].LastX;
mouse_cy += Data[i].LastY;
CurInfo->x += Data[i].LastX;
CurInfo->y += Data[i].LastY;
CurInfo->x = max(CurInfo->x, 0);
CurInfo->y = max(CurInfo->y, 0);
CurInfo->x = min(CurInfo->x, SurfObj->sizlBitmap.cx - 20);
CurInfo->y = min(CurInfo->y, SurfObj->sizlBitmap.cy - 20);
CheckClipCursor(&CurInfo->x, &CurInfo->y, CurInfo);
KeQueryTickCount(&LargeTickCount);
TickCount = LargeTickCount.u.LowPart;
Msg.wParam = ButtonsDown;
Msg.lParam = MAKELPARAM(CurInfo->x + mouse_cx, CurInfo->y + mouse_cy);
Msg.lParam = MAKELPARAM(CurInfo->x, CurInfo->y);
Msg.message = WM_MOUSEMOVE;
Msg.time = TickCount;
Msg.pt.x = CurInfo->x + mouse_cx;
Msg.pt.y = CurInfo->y + mouse_cy;
Msg.pt.x = CurInfo->x;
Msg.pt.y = CurInfo->y;
CheckClipCursor(&Msg.pt.x, &Msg.pt.y, CurInfo);
MouseMoveAdded = FALSE;
if ((0 != Data[i].LastX) || (0 != Data[i].LastY))
{
MsqInsertSystemMessage(&Msg);
}
if (Data[i].ButtonFlags != 0)
{
if ((0 != Data[i].LastX) || (0 != Data[i].LastY))
{
MsqInsertSystemMessage(&Msg);
MouseMoveAdded = TRUE;
}
if ((Data[i].ButtonFlags & MOUSE_LEFT_BUTTON_DOWN) > 0)
{
Msg.wParam = MK_LBUTTON;
@ -429,15 +442,19 @@ MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount)
/* If the mouse moved then move the pointer. */
if ((mouse_cx != 0 || mouse_cy != 0) && MouseEnabled)
{
CurInfo->x += mouse_cx;
CurInfo->y += mouse_cy;
CurInfo->x = max(CurInfo->x, 0);
CurInfo->y = max(CurInfo->y, 0);
CurInfo->x = min(CurInfo->x, SurfObj->sizlBitmap.cx - 20);
CurInfo->y = min(CurInfo->y, SurfObj->sizlBitmap.cy - 20);
CheckClipCursor(&CurInfo->x, &CurInfo->y, CurInfo);
if(!MouseMoveAdded)
{
KeQueryTickCount(&LargeTickCount);
TickCount = LargeTickCount.u.LowPart;
Msg.wParam = ButtonsDown;
Msg.message = WM_MOUSEMOVE;
Msg.pt.x = CurInfo->x;
Msg.pt.y = CurInfo->y;
Msg.time = TickCount;
Msg.lParam = MAKELPARAM(CurInfo->x, CurInfo->y);
MsqInsertSystemMessage(&Msg);
}
if (!CurInfo->SafetySwitch && !CurInfo->SafetySwitch2 &&
((mouse_ox != CurInfo->x) || (mouse_oy != CurInfo->y)))

View file

@ -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.17 2003/08/25 14:54:06 weiden Exp $
/* $Id: msgqueue.c,v 1.18 2003/08/25 23:55:46 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -125,27 +125,47 @@ MsqInitializeImpl(VOID)
}
ULONG FASTCALL
MsgFindSystemMessage(UINT message)
MsgFindSystemMouseMoveMessage()
{
MSG Msg;
ULONG QueuePos, Result = (ULONG)-1;
LPMSG Msg, Msg2;
ULONG QueuePos;
if(SystemMessageQueueCount > 0)
{
QueuePos = SystemMessageQueueTail;
while(QueuePos >= SystemMessageQueueHead)
{
Msg = SystemMessageQueue[QueuePos];
if(Msg.message == message)
Msg = &SystemMessageQueue[QueuePos];
if(Msg->message == WM_MOUSEMOVE)
{
Result = QueuePos;
break;
if(SystemMessageQueueHead == QueuePos)
return QueuePos;
/* if there is one of the following messages after a
WM_MOUSEMOVE message then skip it */
Msg2 = &SystemMessageQueue[QueuePos - 1];
switch(Msg2->message)
{
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
case WM_RBUTTONDOWN:
case WM_RBUTTONUP:
case WM_MBUTTONDOWN:
case WM_MBUTTONUP:
#if 0
case WM_XBUTTONDOWN:
case WM_XBUTTONUP:
#endif
break;
default:
return QueuePos;
}
}
QueuePos--;
}
}
return Result;
return (ULONG)-1;
}
VOID FASTCALL
@ -158,15 +178,14 @@ MsqInsertSystemMessage(MSG* Msg)
/* only insert WM_MOUSEMOVE messages if not already in system message queue */
if(Msg->message == WM_MOUSEMOVE)
mmov = MsgFindSystemMessage(WM_MOUSEMOVE);
mmov = MsgFindSystemMouseMoveMessage();
if(mmov != (ULONG)-1)
{
/* remove old WM_MOUSEMOVE message, move previous messages and insert
new WM_MOUSEMOVE message at the queue head */
/* insert message at the queue head */
while(mmov > SystemMessageQueueHead)
{
SystemMessageQueue[mmov - 1] = SystemMessageQueue[mmov];
SystemMessageQueue[mmov] = SystemMessageQueue[mmov - 1];
mmov--;
}
SystemMessageQueue[SystemMessageQueueHead] = *Msg;