mirror of
https://github.com/reactos/reactos.git
synced 2024-08-04 18:40:59 +00:00
fixed a few bugs in MsqInsertSystemMessage() and improved moving mouse cursor
svn path=/trunk/; revision=5862
This commit is contained in:
parent
877b6f0c22
commit
044494cbcd
|
@ -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.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
|
* PROJECT: ReactOS kernel
|
||||||
* PURPOSE: Mouse
|
* PURPOSE: Mouse
|
||||||
|
@ -306,7 +306,7 @@ MouseMoveCursor(LONG X, LONG Y)
|
||||||
/* move cursor */
|
/* move cursor */
|
||||||
CurInfo->x = X;
|
CurInfo->x = X;
|
||||||
CurInfo->y = Y;
|
CurInfo->y = Y;
|
||||||
if(!CurInfo->SafetySwitch && !CurInfo->SafetySwitch2 && CurInfo->Enabled)
|
if(CurInfo->Enabled)
|
||||||
{
|
{
|
||||||
ExAcquireFastMutexUnsafe(&CurInfo->CursorMutex);
|
ExAcquireFastMutexUnsafe(&CurInfo->CursorMutex);
|
||||||
SurfGDI->MovePointer(SurfObj, CurInfo->x, CurInfo->y, &MouseRect);
|
SurfGDI->MovePointer(SurfObj, CurInfo->x, CurInfo->y, &MouseRect);
|
||||||
|
@ -332,6 +332,7 @@ MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount)
|
||||||
PSYSTEM_CURSORINFO CurInfo;
|
PSYSTEM_CURSORINFO CurInfo;
|
||||||
PSYSCURSOR SysCursor;
|
PSYSCURSOR SysCursor;
|
||||||
BOOL MouseEnabled = FALSE;
|
BOOL MouseEnabled = FALSE;
|
||||||
|
BOOL MouseMoveAdded = FALSE;
|
||||||
LONG mouse_ox, mouse_oy;
|
LONG mouse_ox, mouse_oy;
|
||||||
LONG mouse_cx = 0, mouse_cy = 0;
|
LONG mouse_cx = 0, mouse_cy = 0;
|
||||||
HDC hDC;
|
HDC hDC;
|
||||||
|
@ -360,9 +361,6 @@ MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount)
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
|
|
||||||
KeQueryTickCount(&LargeTickCount);
|
|
||||||
TickCount = LargeTickCount.u.LowPart;
|
|
||||||
|
|
||||||
dc = DC_LockDc(hDC);
|
dc = DC_LockDc(hDC);
|
||||||
SurfObj = (PSURFOBJ)AccessUserObject((ULONG) dc->Surface);
|
SurfObj = (PSURFOBJ)AccessUserObject((ULONG) dc->Surface);
|
||||||
SurfGDI = (PSURFGDI)AccessInternalObject((ULONG) dc->Surface);
|
SurfGDI = (PSURFGDI)AccessInternalObject((ULONG) dc->Surface);
|
||||||
|
@ -374,22 +372,37 @@ MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount)
|
||||||
mouse_cx += Data[i].LastX;
|
mouse_cx += Data[i].LastX;
|
||||||
mouse_cy += Data[i].LastY;
|
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.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.message = WM_MOUSEMOVE;
|
||||||
Msg.time = TickCount;
|
Msg.time = TickCount;
|
||||||
Msg.pt.x = CurInfo->x + mouse_cx;
|
Msg.pt.x = CurInfo->x;
|
||||||
Msg.pt.y = CurInfo->y + mouse_cy;
|
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 (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)
|
if ((Data[i].ButtonFlags & MOUSE_LEFT_BUTTON_DOWN) > 0)
|
||||||
{
|
{
|
||||||
Msg.wParam = MK_LBUTTON;
|
Msg.wParam = MK_LBUTTON;
|
||||||
|
@ -429,15 +442,19 @@ MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount)
|
||||||
/* If the mouse moved then move the pointer. */
|
/* If the mouse moved then move the pointer. */
|
||||||
if ((mouse_cx != 0 || mouse_cy != 0) && MouseEnabled)
|
if ((mouse_cx != 0 || mouse_cy != 0) && MouseEnabled)
|
||||||
{
|
{
|
||||||
CurInfo->x += mouse_cx;
|
|
||||||
CurInfo->y += mouse_cy;
|
|
||||||
|
|
||||||
CurInfo->x = max(CurInfo->x, 0);
|
if(!MouseMoveAdded)
|
||||||
CurInfo->y = max(CurInfo->y, 0);
|
{
|
||||||
CurInfo->x = min(CurInfo->x, SurfObj->sizlBitmap.cx - 20);
|
KeQueryTickCount(&LargeTickCount);
|
||||||
CurInfo->y = min(CurInfo->y, SurfObj->sizlBitmap.cy - 20);
|
TickCount = LargeTickCount.u.LowPart;
|
||||||
|
Msg.wParam = ButtonsDown;
|
||||||
CheckClipCursor(&CurInfo->x, &CurInfo->y, CurInfo);
|
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 &&
|
if (!CurInfo->SafetySwitch && !CurInfo->SafetySwitch2 &&
|
||||||
((mouse_ox != CurInfo->x) || (mouse_oy != CurInfo->y)))
|
((mouse_ox != CurInfo->x) || (mouse_oy != CurInfo->y)))
|
||||||
|
|
|
@ -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.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
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -125,27 +125,47 @@ MsqInitializeImpl(VOID)
|
||||||
}
|
}
|
||||||
|
|
||||||
ULONG FASTCALL
|
ULONG FASTCALL
|
||||||
MsgFindSystemMessage(UINT message)
|
MsgFindSystemMouseMoveMessage()
|
||||||
{
|
{
|
||||||
MSG Msg;
|
LPMSG Msg, Msg2;
|
||||||
ULONG QueuePos, Result = (ULONG)-1;
|
ULONG QueuePos;
|
||||||
|
|
||||||
if(SystemMessageQueueCount > 0)
|
if(SystemMessageQueueCount > 0)
|
||||||
{
|
{
|
||||||
QueuePos = SystemMessageQueueTail;
|
QueuePos = SystemMessageQueueTail;
|
||||||
while(QueuePos >= SystemMessageQueueHead)
|
while(QueuePos >= SystemMessageQueueHead)
|
||||||
{
|
{
|
||||||
Msg = SystemMessageQueue[QueuePos];
|
Msg = &SystemMessageQueue[QueuePos];
|
||||||
if(Msg.message == message)
|
if(Msg->message == WM_MOUSEMOVE)
|
||||||
{
|
{
|
||||||
Result = QueuePos;
|
if(SystemMessageQueueHead == QueuePos)
|
||||||
break;
|
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--;
|
QueuePos--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result;
|
return (ULONG)-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID FASTCALL
|
VOID FASTCALL
|
||||||
|
@ -158,15 +178,14 @@ MsqInsertSystemMessage(MSG* Msg)
|
||||||
|
|
||||||
/* only insert WM_MOUSEMOVE messages if not already in system message queue */
|
/* only insert WM_MOUSEMOVE messages if not already in system message queue */
|
||||||
if(Msg->message == WM_MOUSEMOVE)
|
if(Msg->message == WM_MOUSEMOVE)
|
||||||
mmov = MsgFindSystemMessage(WM_MOUSEMOVE);
|
mmov = MsgFindSystemMouseMoveMessage();
|
||||||
|
|
||||||
if(mmov != (ULONG)-1)
|
if(mmov != (ULONG)-1)
|
||||||
{
|
{
|
||||||
/* remove old WM_MOUSEMOVE message, move previous messages and insert
|
/* insert message at the queue head */
|
||||||
new WM_MOUSEMOVE message at the queue head */
|
|
||||||
while(mmov > SystemMessageQueueHead)
|
while(mmov > SystemMessageQueueHead)
|
||||||
{
|
{
|
||||||
SystemMessageQueue[mmov - 1] = SystemMessageQueue[mmov];
|
SystemMessageQueue[mmov] = SystemMessageQueue[mmov - 1];
|
||||||
mmov--;
|
mmov--;
|
||||||
}
|
}
|
||||||
SystemMessageQueue[SystemMessageQueueHead] = *Msg;
|
SystemMessageQueue[SystemMessageQueueHead] = *Msg;
|
||||||
|
|
Loading…
Reference in a new issue