mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
use SendInput() to send mouse input data
svn path=/trunk/; revision=9255
This commit is contained in:
parent
d25a045798
commit
c2d319d2d2
5 changed files with 369 additions and 322 deletions
|
@ -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.66 2004/04/16 18:53:53 weiden Exp $
|
||||
/* $Id: mouse.c,v 1.67 2004/04/30 22:17:59 weiden Exp $
|
||||
*
|
||||
* PROJECT: ReactOS kernel
|
||||
* PURPOSE: Mouse
|
||||
|
@ -45,45 +45,65 @@
|
|||
#include "include/eng.h"
|
||||
#include "include/tags.h"
|
||||
#include <include/mouse.h>
|
||||
#include <include/input.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
#define GETSYSCURSOR(x) ((x) - OCR_NORMAL)
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
BOOL FASTCALL
|
||||
IntIsPrimarySurface(PSURFGDI SurfGDI);
|
||||
|
||||
|
||||
BOOL FASTCALL
|
||||
IntCheckClipCursor(LONG *x, LONG *y, PSYSTEM_CURSORINFO CurInfo)
|
||||
VOID FASTCALL
|
||||
EnableMouse(HDC hDisplayDC)
|
||||
{
|
||||
if(CurInfo->CursorClipInfo.IsClipped)
|
||||
PDC dc;
|
||||
SURFOBJ *SurfObj;
|
||||
PSURFGDI SurfGDI;
|
||||
|
||||
if( hDisplayDC && InputWindowStation)
|
||||
{
|
||||
if(*x > CurInfo->CursorClipInfo.Right)
|
||||
*x = CurInfo->CursorClipInfo.Right;
|
||||
if(*x < CurInfo->CursorClipInfo.Left)
|
||||
*x = CurInfo->CursorClipInfo.Left;
|
||||
if(*y > CurInfo->CursorClipInfo.Bottom)
|
||||
*y = CurInfo->CursorClipInfo.Bottom;
|
||||
if(*y < CurInfo->CursorClipInfo.Top)
|
||||
*y = CurInfo->CursorClipInfo.Top;
|
||||
return TRUE;
|
||||
if(!IntGetWindowStationObject(InputWindowStation))
|
||||
{
|
||||
InputWindowStation->SystemCursor.Enabled = FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
dc = DC_LockDc(hDisplayDC);
|
||||
SurfObj = (SURFOBJ*)AccessUserObject((ULONG) dc->Surface);
|
||||
SurfGDI = (PSURFGDI)AccessInternalObject((ULONG) dc->Surface);
|
||||
DC_UnlockDc( hDisplayDC );
|
||||
|
||||
IntSetCursor(InputWindowStation, NULL, TRUE);
|
||||
|
||||
InputWindowStation->SystemCursor.Enabled = (SPS_ACCEPT_EXCLUDE == SurfGDI->PointerStatus ||
|
||||
SPS_ACCEPT_NOEXCLUDE == SurfGDI->PointerStatus);
|
||||
|
||||
/* 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);
|
||||
#if 0
|
||||
ExAcquireFastMutex(&CurInfo->CursorMutex);
|
||||
MouseMoveCursor(SurfObj->sizlBitmap.cx / 2, SurfObj->sizlBitmap.cy / 2);
|
||||
ExReleaseFastMutex(&CurInfo->CursorMutex);
|
||||
#endif
|
||||
|
||||
ObDereferenceObject(InputWindowStation);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(IntGetWindowStationObject(InputWindowStation))
|
||||
{
|
||||
IntSetCursor(InputWindowStation, NULL, TRUE);
|
||||
InputWindowStation->SystemCursor.Enabled = FALSE;
|
||||
InputWindowStation->SystemCursor.CursorClipInfo.IsClipped = FALSE;
|
||||
ObDereferenceObject(InputWindowStation);
|
||||
return;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL FASTCALL
|
||||
IntSwapMouseButton(PWINSTATION_OBJECT WinStaObject, BOOL Swap)
|
||||
{
|
||||
BOOL res = WinStaObject->SystemCursor.SwapButtons;
|
||||
WinStaObject->SystemCursor.SwapButtons = Swap;
|
||||
return res;
|
||||
}
|
||||
|
||||
INT STDCALL
|
||||
INT FASTCALL
|
||||
MouseSafetyOnDrawStart(SURFOBJ *SurfObj, PSURFGDI SurfGDI, LONG HazardX1,
|
||||
LONG HazardY1, LONG HazardX2, LONG HazardY2)
|
||||
/*
|
||||
|
@ -166,7 +186,7 @@ MouseSafetyOnDrawStart(SURFOBJ *SurfObj, PSURFGDI SurfGDI, LONG HazardX1,
|
|||
return(TRUE);
|
||||
}
|
||||
|
||||
STATIC VOID FASTCALL
|
||||
VOID FASTCALL
|
||||
SetPointerRect(PSYSTEM_CURSORINFO CurInfo, PRECTL PointerRect)
|
||||
{
|
||||
CurInfo->PointerRectLeft = PointerRect->left;
|
||||
|
@ -237,306 +257,101 @@ MouseSafetyOnDrawEnd(SURFOBJ *SurfObj, SURFGDI *SurfGDI)
|
|||
return(TRUE);
|
||||
}
|
||||
|
||||
BOOL FASTCALL
|
||||
MouseMoveCursor(LONG X, LONG Y)
|
||||
{
|
||||
HDC hDC;
|
||||
PDC dc;
|
||||
BOOL res = FALSE;
|
||||
SURFOBJ *SurfObj;
|
||||
PSURFGDI SurfGDI;
|
||||
PSYSTEM_CURSORINFO CurInfo;
|
||||
MSG Msg;
|
||||
LARGE_INTEGER LargeTickCount;
|
||||
ULONG TickCount;
|
||||
RECTL PointerRect;
|
||||
|
||||
if(!InputWindowStation)
|
||||
return FALSE;
|
||||
|
||||
if(IntGetWindowStationObject(InputWindowStation))
|
||||
{
|
||||
CurInfo = &InputWindowStation->SystemCursor;
|
||||
if(!CurInfo->Enabled)
|
||||
{
|
||||
ObDereferenceObject(InputWindowStation);
|
||||
return FALSE;
|
||||
}
|
||||
hDC = IntGetScreenDC();
|
||||
if(!hDC)
|
||||
{
|
||||
ObDereferenceObject(InputWindowStation);
|
||||
return FALSE;
|
||||
}
|
||||
dc = DC_LockDc(hDC);
|
||||
SurfObj = (SURFOBJ*)AccessUserObject((ULONG) dc->Surface);
|
||||
SurfGDI = (PSURFGDI)AccessInternalObject((ULONG) dc->Surface);
|
||||
DC_UnlockDc( hDC );
|
||||
IntCheckClipCursor(&X, &Y, CurInfo);
|
||||
if((X != CurInfo->x) || (Y != CurInfo->y))
|
||||
{
|
||||
/* move cursor */
|
||||
CurInfo->x = X;
|
||||
CurInfo->y = Y;
|
||||
if(CurInfo->Enabled)
|
||||
{
|
||||
ExAcquireFastMutex(&CurInfo->CursorMutex);
|
||||
IntLockGDIDriver(SurfGDI);
|
||||
if (SurfGDI->MovePointer != NULL)
|
||||
SurfGDI->MovePointer(SurfObj, CurInfo->x, CurInfo->y, &PointerRect);
|
||||
IntUnLockGDIDriver(SurfGDI);
|
||||
SetPointerRect(CurInfo, &PointerRect);
|
||||
ExReleaseFastMutex(&CurInfo->CursorMutex);
|
||||
}
|
||||
/* send MOUSEMOVE message */
|
||||
KeQueryTickCount(&LargeTickCount);
|
||||
TickCount = LargeTickCount.u.LowPart;
|
||||
Msg.wParam = CurInfo->ButtonsDown;
|
||||
Msg.lParam = MAKELPARAM(X, Y);
|
||||
Msg.message = WM_MOUSEMOVE;
|
||||
Msg.time = TickCount;
|
||||
Msg.pt.x = X;
|
||||
Msg.pt.y = Y;
|
||||
MsqInsertSystemMessage(&Msg);
|
||||
res = TRUE;
|
||||
}
|
||||
|
||||
ObDereferenceObject(InputWindowStation);
|
||||
return res;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
#define ClearMouseInput(mi) \
|
||||
mi.dx = 0; \
|
||||
mi.dy = 0; \
|
||||
mi.mouseData = 0; \
|
||||
mi.dwFlags = 0;
|
||||
|
||||
#define SendMouseEvent(mi) \
|
||||
if(mi.dx != 0 || mi.dy != 0) \
|
||||
mi.dwFlags |= MOUSEEVENTF_MOVE; \
|
||||
if(mi.dwFlags) \
|
||||
IntMouseInput(&mi); \
|
||||
ClearMouseInput(mi);
|
||||
|
||||
VOID /* STDCALL */
|
||||
MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount)
|
||||
/*
|
||||
* FUNCTION: Call by the mouse driver when input events occur.
|
||||
*/
|
||||
{
|
||||
PMOUSE_INPUT_DATA mid;
|
||||
MOUSEINPUT mi;
|
||||
ULONG i;
|
||||
PSYSTEM_CURSORINFO CurInfo;
|
||||
BOOL MouseEnabled = FALSE;
|
||||
BOOL Moved = FALSE;
|
||||
LONG mouse_ox, mouse_oy;
|
||||
LONG mouse_cx = 0, mouse_cy = 0;
|
||||
LONG dScroll = 0;
|
||||
HDC hDC;
|
||||
PDC dc;
|
||||
SURFOBJ *SurfObj;
|
||||
PSURFGDI SurfGDI;
|
||||
MSG Msg;
|
||||
RECTL PointerRect;
|
||||
|
||||
hDC = IntGetScreenDC();
|
||||
|
||||
if(!hDC || !InputWindowStation)
|
||||
return;
|
||||
|
||||
if(IntGetWindowStationObject(InputWindowStation))
|
||||
ClearMouseInput(mi);
|
||||
mi.time = 0;
|
||||
mi.dwExtraInfo = 0;
|
||||
for(i = 0; i < InputCount; i++)
|
||||
{
|
||||
CurInfo = &InputWindowStation->SystemCursor;
|
||||
MouseEnabled = CurInfo->Enabled;
|
||||
if(!MouseEnabled)
|
||||
mid = (Data + i);
|
||||
mi.dx += mid->LastX;
|
||||
mi.dy += mid->LastY;
|
||||
|
||||
if(mid->ButtonFlags)
|
||||
{
|
||||
ObDereferenceObject(InputWindowStation);
|
||||
return;
|
||||
}
|
||||
mouse_ox = CurInfo->x;
|
||||
mouse_oy = CurInfo->y;
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
||||
dc = DC_LockDc(hDC);
|
||||
SurfObj = (SURFOBJ*)AccessUserObject((ULONG) dc->Surface);
|
||||
SurfGDI = (PSURFGDI)AccessInternalObject((ULONG) dc->Surface);
|
||||
DC_UnlockDc( hDC );
|
||||
|
||||
/* Compile the total mouse movement change and dispatch button events. */
|
||||
for (i = 0; i < InputCount; i++)
|
||||
{
|
||||
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 - 1);
|
||||
CurInfo->y = min(CurInfo->y, SurfObj->sizlBitmap.cy - 1);
|
||||
|
||||
IntCheckClipCursor(&CurInfo->x, &CurInfo->y, CurInfo);
|
||||
|
||||
Msg.wParam = CurInfo->ButtonsDown;
|
||||
Msg.lParam = MAKELPARAM(CurInfo->x, CurInfo->y);
|
||||
Msg.message = WM_MOUSEMOVE;
|
||||
Msg.pt.x = CurInfo->x;
|
||||
Msg.pt.y = CurInfo->y;
|
||||
|
||||
if (Data[i].ButtonFlags != 0)
|
||||
{
|
||||
if ((Data[i].ButtonFlags & MOUSE_LEFT_BUTTON_DOWN) > 0)
|
||||
if(mid->ButtonFlags & MOUSE_LEFT_BUTTON_DOWN)
|
||||
{
|
||||
CurInfo->ButtonsDown |= (CurInfo->SwapButtons ? MK_RBUTTON : MK_LBUTTON);
|
||||
Msg.message = (CurInfo->SwapButtons ? WM_RBUTTONDOWN : WM_LBUTTONDOWN);
|
||||
mi.dwFlags |= MOUSEEVENTF_LEFTDOWN;
|
||||
SendMouseEvent(mi);
|
||||
}
|
||||
if ((Data[i].ButtonFlags & MOUSE_MIDDLE_BUTTON_DOWN) > 0)
|
||||
if(mid->ButtonFlags & MOUSE_LEFT_BUTTON_UP)
|
||||
{
|
||||
CurInfo->ButtonsDown |= MK_MBUTTON;
|
||||
Msg.message = WM_MBUTTONDOWN;
|
||||
mi.dwFlags |= MOUSEEVENTF_LEFTUP;
|
||||
SendMouseEvent(mi);
|
||||
}
|
||||
if ((Data[i].ButtonFlags & MOUSE_RIGHT_BUTTON_DOWN) > 0)
|
||||
if(mid->ButtonFlags & MOUSE_MIDDLE_BUTTON_DOWN)
|
||||
{
|
||||
CurInfo->ButtonsDown |= (CurInfo->SwapButtons ? MK_LBUTTON : MK_RBUTTON);
|
||||
Msg.message = (CurInfo->SwapButtons ? WM_LBUTTONDOWN : WM_RBUTTONDOWN);
|
||||
mi.dwFlags |= MOUSEEVENTF_MIDDLEDOWN;
|
||||
SendMouseEvent(mi);
|
||||
}
|
||||
|
||||
if ((Data[i].ButtonFlags & MOUSE_BUTTON_4_DOWN) > 0)
|
||||
if(mid->ButtonFlags & MOUSE_MIDDLE_BUTTON_UP)
|
||||
{
|
||||
CurInfo->ButtonsDown |= MK_XBUTTON1;
|
||||
Msg.message = WM_XBUTTONDOWN;
|
||||
mi.dwFlags |= MOUSEEVENTF_MIDDLEUP;
|
||||
SendMouseEvent(mi);
|
||||
}
|
||||
if ((Data[i].ButtonFlags & MOUSE_BUTTON_5_DOWN) > 0)
|
||||
if(mid->ButtonFlags & MOUSE_RIGHT_BUTTON_DOWN)
|
||||
{
|
||||
CurInfo->ButtonsDown |= MK_XBUTTON2;
|
||||
Msg.message = WM_XBUTTONDOWN;
|
||||
mi.dwFlags |= MOUSEEVENTF_RIGHTDOWN;
|
||||
SendMouseEvent(mi);
|
||||
}
|
||||
|
||||
if ((Data[i].ButtonFlags & MOUSE_LEFT_BUTTON_UP) > 0)
|
||||
if(mid->ButtonFlags & MOUSE_RIGHT_BUTTON_UP)
|
||||
{
|
||||
CurInfo->ButtonsDown &= (CurInfo->SwapButtons ? ~MK_RBUTTON : ~MK_LBUTTON);
|
||||
Msg.message = (CurInfo->SwapButtons ? WM_RBUTTONUP : WM_LBUTTONUP);
|
||||
mi.dwFlags |= MOUSEEVENTF_RIGHTUP;
|
||||
SendMouseEvent(mi);
|
||||
}
|
||||
if ((Data[i].ButtonFlags & MOUSE_MIDDLE_BUTTON_UP) > 0)
|
||||
if(mid->ButtonFlags & MOUSE_BUTTON_4_DOWN)
|
||||
{
|
||||
CurInfo->ButtonsDown &= ~MK_MBUTTON;
|
||||
Msg.message = WM_MBUTTONUP;
|
||||
mi.mouseData |= XBUTTON1;
|
||||
mi.dwFlags |= MOUSEEVENTF_XDOWN;
|
||||
SendMouseEvent(mi);
|
||||
}
|
||||
if ((Data[i].ButtonFlags & MOUSE_RIGHT_BUTTON_UP) > 0)
|
||||
if(mid->ButtonFlags & MOUSE_BUTTON_4_UP)
|
||||
{
|
||||
CurInfo->ButtonsDown &= (CurInfo->SwapButtons ? ~MK_LBUTTON : ~MK_RBUTTON);
|
||||
Msg.message = (CurInfo->SwapButtons ? WM_LBUTTONUP : WM_RBUTTONUP);
|
||||
mi.mouseData |= XBUTTON1;
|
||||
mi.dwFlags |= MOUSEEVENTF_XUP;
|
||||
SendMouseEvent(mi);
|
||||
}
|
||||
if ((Data[i].ButtonFlags & MOUSE_BUTTON_4_UP) > 0)
|
||||
if(mid->ButtonFlags & MOUSE_BUTTON_5_DOWN)
|
||||
{
|
||||
CurInfo->ButtonsDown &= ~MK_XBUTTON1;
|
||||
Msg.message = WM_XBUTTONUP;
|
||||
mi.mouseData |= XBUTTON2;
|
||||
mi.dwFlags |= MOUSEEVENTF_XDOWN;
|
||||
SendMouseEvent(mi);
|
||||
}
|
||||
if ((Data[i].ButtonFlags & MOUSE_BUTTON_5_UP) > 0)
|
||||
if(mid->ButtonFlags & MOUSE_BUTTON_5_UP)
|
||||
{
|
||||
CurInfo->ButtonsDown &= ~MK_XBUTTON2;
|
||||
Msg.message = WM_XBUTTONUP;
|
||||
mi.mouseData |= XBUTTON2;
|
||||
mi.dwFlags |= MOUSEEVENTF_XUP;
|
||||
SendMouseEvent(mi);
|
||||
}
|
||||
if ((Data[i].ButtonFlags & MOUSE_WHEEL) > 0)
|
||||
if(mid->ButtonFlags & MOUSE_WHEEL)
|
||||
{
|
||||
dScroll += (LONG)Data[i].ButtonData;
|
||||
mi.mouseData = mid->ButtonData;
|
||||
mi.dwFlags |= MOUSEEVENTF_WHEEL;
|
||||
SendMouseEvent(mi);
|
||||
}
|
||||
|
||||
if (Data[i].ButtonFlags != MOUSE_WHEEL)
|
||||
{
|
||||
Moved = (0 != mouse_cx) || (0 != mouse_cy);
|
||||
if(Moved && MouseEnabled)
|
||||
{
|
||||
if (!CurInfo->SafetySwitch && 0 == CurInfo->SafetyRemoveCount &&
|
||||
((mouse_ox != CurInfo->x) || (mouse_oy != CurInfo->y)))
|
||||
{
|
||||
ExAcquireFastMutex(&CurInfo->CursorMutex);
|
||||
IntLockGDIDriver(SurfGDI);
|
||||
SurfGDI->MovePointer(SurfObj, CurInfo->x, CurInfo->y, &PointerRect);
|
||||
IntUnLockGDIDriver(SurfGDI);
|
||||
SetPointerRect(CurInfo, &PointerRect);
|
||||
ExReleaseFastMutex(&CurInfo->CursorMutex);
|
||||
mouse_cx = 0;
|
||||
mouse_cy = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Msg.wParam = CurInfo->ButtonsDown;
|
||||
MsqInsertSystemMessage(&Msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* If the mouse moved then move the pointer. */
|
||||
if ((mouse_cx != 0 || mouse_cy != 0) && MouseEnabled)
|
||||
{
|
||||
Msg.wParam = CurInfo->ButtonsDown;
|
||||
Msg.message = WM_MOUSEMOVE;
|
||||
Msg.pt.x = CurInfo->x;
|
||||
Msg.pt.y = CurInfo->y;
|
||||
Msg.lParam = MAKELPARAM(CurInfo->x, CurInfo->y);
|
||||
MsqInsertSystemMessage(&Msg);
|
||||
|
||||
if (!CurInfo->SafetySwitch && 0 == CurInfo->SafetyRemoveCount &&
|
||||
((mouse_ox != CurInfo->x) || (mouse_oy != CurInfo->y)))
|
||||
{
|
||||
ExAcquireFastMutex(&CurInfo->CursorMutex);
|
||||
IntLockGDIDriver(SurfGDI);
|
||||
SurfGDI->MovePointer(SurfObj, CurInfo->x, CurInfo->y, &PointerRect);
|
||||
IntUnLockGDIDriver(SurfGDI);
|
||||
SetPointerRect(CurInfo, &PointerRect);
|
||||
ExReleaseFastMutex(&CurInfo->CursorMutex);
|
||||
}
|
||||
}
|
||||
|
||||
/* send WM_MOUSEWHEEL message */
|
||||
if(dScroll && MouseEnabled)
|
||||
{
|
||||
Msg.message = WM_MOUSEWHEEL;
|
||||
Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, dScroll);
|
||||
Msg.lParam = MAKELPARAM(CurInfo->x, CurInfo->y);
|
||||
Msg.pt.x = CurInfo->x;
|
||||
Msg.pt.y = CurInfo->y;
|
||||
MsqInsertSystemMessage(&Msg);
|
||||
}
|
||||
|
||||
ObDereferenceObject(InputWindowStation);
|
||||
}
|
||||
|
||||
VOID FASTCALL
|
||||
EnableMouse(HDC hDisplayDC)
|
||||
{
|
||||
PDC dc;
|
||||
SURFOBJ *SurfObj;
|
||||
PSURFGDI SurfGDI;
|
||||
|
||||
if( hDisplayDC && InputWindowStation)
|
||||
{
|
||||
if(!IntGetWindowStationObject(InputWindowStation))
|
||||
{
|
||||
InputWindowStation->SystemCursor.Enabled = FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
dc = DC_LockDc(hDisplayDC);
|
||||
SurfObj = (SURFOBJ*)AccessUserObject((ULONG) dc->Surface);
|
||||
SurfGDI = (PSURFGDI)AccessInternalObject((ULONG) dc->Surface);
|
||||
DC_UnlockDc( hDisplayDC );
|
||||
|
||||
IntSetCursor(InputWindowStation, NULL, TRUE);
|
||||
|
||||
InputWindowStation->SystemCursor.Enabled = (SPS_ACCEPT_EXCLUDE == SurfGDI->PointerStatus ||
|
||||
SPS_ACCEPT_NOEXCLUDE == SurfGDI->PointerStatus);
|
||||
|
||||
/* 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);
|
||||
MouseMoveCursor(SurfObj->sizlBitmap.cx / 2, SurfObj->sizlBitmap.cy / 2);
|
||||
|
||||
ObDereferenceObject(InputWindowStation);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(IntGetWindowStationObject(InputWindowStation))
|
||||
{
|
||||
IntSetCursor(InputWindowStation, NULL, TRUE);
|
||||
InputWindowStation->SystemCursor.Enabled = FALSE;
|
||||
InputWindowStation->SystemCursor.CursorClipInfo.IsClipped = FALSE;
|
||||
ObDereferenceObject(InputWindowStation);
|
||||
return;
|
||||
}
|
||||
}
|
||||
SendMouseEvent(mi);
|
||||
}
|
||||
|
||||
/* SOFTWARE MOUSE POINTER IMPLEMENTATION **************************************/
|
||||
|
|
|
@ -7,11 +7,24 @@
|
|||
|
||||
BOOL FASTCALL IntCheckClipCursor(LONG *x, LONG *y, PSYSTEM_CURSORINFO CurInfo);
|
||||
BOOL FASTCALL IntSwapMouseButton(PWINSTATION_OBJECT WinStaObject, BOOL Swap);
|
||||
INT STDCALL MouseSafetyOnDrawStart(SURFOBJ *SurfObj, SURFGDI *SurfGDI, LONG HazardX1, LONG HazardY1, LONG HazardX2, LONG HazardY2);
|
||||
INT FASTCALL MouseSafetyOnDrawStart(SURFOBJ *SurfObj, SURFGDI *SurfGDI, LONG HazardX1, LONG HazardY1, LONG HazardX2, LONG HazardY2);
|
||||
INT FASTCALL MouseSafetyOnDrawEnd(SURFOBJ *SurfObj, SURFGDI *SurfGDI);
|
||||
BOOL FASTCALL MouseMoveCursor(LONG X, LONG Y);
|
||||
VOID FASTCALL EnableMouse(HDC hDisplayDC);
|
||||
VOID MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount);
|
||||
VOID FASTCALL SetPointerRect(PSYSTEM_CURSORINFO CurInfo, PRECTL PointerRect);
|
||||
|
||||
#ifndef XBUTTON1
|
||||
#define XBUTTON1 (0x01)
|
||||
#endif
|
||||
#ifndef XBUTTON2
|
||||
#define XBUTTON2 (0x02)
|
||||
#endif
|
||||
#ifndef MOUSEEVENTF_XDOWN
|
||||
#define MOUSEEVENTF_XDOWN (0x80)
|
||||
#endif
|
||||
#ifndef MOUSEEVENTF_XUP
|
||||
#define MOUSEEVENTF_XUP (0x100)
|
||||
#endif
|
||||
|
||||
#endif /* _WIN32K_MOUSE_H */
|
||||
|
|
|
@ -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: input.c,v 1.29 2004/04/29 20:41:03 weiden Exp $
|
||||
/* $Id: input.c,v 1.30 2004/04/30 22:18:00 weiden Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -41,6 +41,7 @@
|
|||
#include <include/mouse.h>
|
||||
#include <include/input.h>
|
||||
#include <include/hotkey.h>
|
||||
#include <include/eng.h>
|
||||
#include <rosrtl/string.h>
|
||||
|
||||
#define NDEBUG
|
||||
|
@ -522,10 +523,228 @@ NtUserBlockInput(
|
|||
return IntBlockInput(PsGetWin32Thread(), BlockIt);
|
||||
}
|
||||
|
||||
BOOL FASTCALL
|
||||
IntSwapMouseButton(PWINSTATION_OBJECT WinStaObject, BOOL Swap)
|
||||
{
|
||||
BOOL res = WinStaObject->SystemCursor.SwapButtons;
|
||||
WinStaObject->SystemCursor.SwapButtons = Swap;
|
||||
return res;
|
||||
}
|
||||
|
||||
BOOL FASTCALL
|
||||
IntMouseInput(MOUSEINPUT *mi)
|
||||
{
|
||||
return FALSE;
|
||||
const UINT SwapBtnMsg[2][2] = {{WM_LBUTTONDOWN, WM_RBUTTONDOWN},
|
||||
{WM_LBUTTONUP, WM_RBUTTONUP}};
|
||||
const WPARAM SwapBtn[2] = {MK_LBUTTON, MK_RBUTTON};
|
||||
POINT MousePos;
|
||||
PSYSTEM_CURSORINFO CurInfo;
|
||||
PWINSTATION_OBJECT WinSta;
|
||||
BOOL DoMove, SwapButtons;
|
||||
MSG Msg;
|
||||
SURFOBJ *SurfObj;
|
||||
PSURFGDI SurfGDI;
|
||||
PDC dc;
|
||||
RECTL PointerRect;
|
||||
|
||||
#if 1
|
||||
HDC hDC;
|
||||
|
||||
/* FIXME - get the screen dc from the window station or desktop */
|
||||
if(!(hDC = IntGetScreenDC()))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
ASSERT(mi);
|
||||
#if 0
|
||||
WinSta = PsGetWin32Process()->WindowStation;
|
||||
#else
|
||||
/* FIXME - ugly hack but as long as we're using this dumb callback from the
|
||||
mouse class driver, we can't access the window station from the calling
|
||||
process */
|
||||
WinSta = InputWindowStation;
|
||||
#endif
|
||||
ASSERT(WinSta);
|
||||
|
||||
CurInfo = &WinSta->SystemCursor;
|
||||
|
||||
dc = DC_LockDc(hDC);
|
||||
SurfObj = (SURFOBJ*)AccessUserObject((ULONG) dc->Surface);
|
||||
SurfGDI = (PSURFGDI)AccessInternalObject((ULONG) dc->Surface);
|
||||
DC_UnlockDc(hDC);
|
||||
ASSERT(SurfObj);
|
||||
ASSERT(SurfGDI);
|
||||
|
||||
if(!mi->time)
|
||||
{
|
||||
LARGE_INTEGER LargeTickCount;
|
||||
KeQueryTickCount(&LargeTickCount);
|
||||
mi->time = LargeTickCount.u.LowPart;
|
||||
}
|
||||
|
||||
SwapButtons = WinSta->SystemCursor.SwapButtons;
|
||||
DoMove = FALSE;
|
||||
ExAcquireFastMutex(&CurInfo->CursorMutex);
|
||||
MousePos.x = CurInfo->x;
|
||||
MousePos.y = CurInfo->y;
|
||||
if(mi->dwFlags & MOUSEEVENTF_MOVE)
|
||||
{
|
||||
if(mi->dwFlags & MOUSEEVENTF_ABSOLUTE)
|
||||
{
|
||||
MousePos.x = mi->dx;
|
||||
MousePos.y = mi->dy;
|
||||
}
|
||||
else
|
||||
{
|
||||
MousePos.x += mi->dx;
|
||||
MousePos.y += mi->dy;
|
||||
}
|
||||
|
||||
if(CurInfo->CursorClipInfo.IsClipped)
|
||||
{
|
||||
/* The mouse cursor needs to be clipped */
|
||||
|
||||
if(MousePos.x > CurInfo->CursorClipInfo.Right)
|
||||
MousePos.x = CurInfo->CursorClipInfo.Right;
|
||||
if(MousePos.x <= CurInfo->CursorClipInfo.Left)
|
||||
MousePos.x = CurInfo->CursorClipInfo.Left;
|
||||
if(MousePos.y > CurInfo->CursorClipInfo.Bottom)
|
||||
MousePos.y = CurInfo->CursorClipInfo.Bottom;
|
||||
if(MousePos.y <= CurInfo->CursorClipInfo.Top)
|
||||
MousePos.y = CurInfo->CursorClipInfo.Top;
|
||||
}
|
||||
|
||||
if(MousePos.x < 0)
|
||||
MousePos.x = 0;
|
||||
if(MousePos.y < 0)
|
||||
MousePos.y = 0;
|
||||
if(MousePos.x >= SurfObj->sizlBitmap.cx)
|
||||
MousePos.x = SurfObj->sizlBitmap.cx - 1;
|
||||
if(MousePos.y >= SurfObj->sizlBitmap.cy)
|
||||
MousePos.y = SurfObj->sizlBitmap.cy - 1;
|
||||
|
||||
if((DoMove = (MousePos.x != CurInfo->x || MousePos.y != CurInfo->y)))
|
||||
{
|
||||
CurInfo->x = MousePos.x;
|
||||
CurInfo->y = MousePos.y;
|
||||
if(SurfGDI->MovePointer)
|
||||
{
|
||||
IntLockGDIDriver(SurfGDI);
|
||||
SurfGDI->MovePointer(SurfObj, CurInfo->x, CurInfo->y, &PointerRect);
|
||||
IntUnLockGDIDriver(SurfGDI);
|
||||
}
|
||||
else
|
||||
{
|
||||
IntLockGDIDriver(SurfGDI);
|
||||
EngMovePointer(SurfObj, CurInfo->x, CurInfo->y, &PointerRect);
|
||||
IntUnLockGDIDriver(SurfGDI);
|
||||
}
|
||||
SetPointerRect(CurInfo, &PointerRect);
|
||||
}
|
||||
}
|
||||
|
||||
ExReleaseFastMutex(&CurInfo->CursorMutex);
|
||||
|
||||
/*
|
||||
* Insert the messages into the system queue
|
||||
*/
|
||||
|
||||
Msg.wParam = CurInfo->ButtonsDown;
|
||||
Msg.lParam = MAKELPARAM(MousePos.x, MousePos.y);
|
||||
Msg.pt = MousePos;
|
||||
if(DoMove)
|
||||
{
|
||||
Msg.message = WM_MOUSEMOVE;
|
||||
MsqInsertSystemMessage(&Msg);
|
||||
}
|
||||
|
||||
Msg.message = 0;
|
||||
if(mi->dwFlags & MOUSEEVENTF_LEFTDOWN)
|
||||
{
|
||||
Msg.message = SwapBtnMsg[0][SwapButtons];
|
||||
CurInfo->ButtonsDown |= SwapBtn[SwapButtons];
|
||||
MsqInsertSystemMessage(&Msg);
|
||||
}
|
||||
else if(mi->dwFlags & MOUSEEVENTF_LEFTUP)
|
||||
{
|
||||
Msg.message = SwapBtnMsg[1][SwapButtons];
|
||||
CurInfo->ButtonsDown &= ~SwapBtn[SwapButtons];
|
||||
MsqInsertSystemMessage(&Msg);
|
||||
}
|
||||
if(mi->dwFlags & MOUSEEVENTF_MIDDLEDOWN)
|
||||
{
|
||||
Msg.message = WM_MBUTTONDOWN;
|
||||
CurInfo->ButtonsDown |= MK_MBUTTON;
|
||||
MsqInsertSystemMessage(&Msg);
|
||||
}
|
||||
else if(mi->dwFlags & MOUSEEVENTF_MIDDLEUP)
|
||||
{
|
||||
Msg.message = WM_MBUTTONUP;
|
||||
CurInfo->ButtonsDown &= ~MK_MBUTTON;
|
||||
MsqInsertSystemMessage(&Msg);
|
||||
}
|
||||
if(mi->dwFlags & MOUSEEVENTF_RIGHTDOWN)
|
||||
{
|
||||
Msg.message = SwapBtnMsg[0][!SwapButtons];
|
||||
CurInfo->ButtonsDown |= SwapBtn[!SwapButtons];
|
||||
MsqInsertSystemMessage(&Msg);
|
||||
}
|
||||
else if(mi->dwFlags & MOUSEEVENTF_RIGHTUP)
|
||||
{
|
||||
Msg.message = SwapBtnMsg[1][!SwapButtons];
|
||||
CurInfo->ButtonsDown &= ~SwapBtn[!SwapButtons];
|
||||
MsqInsertSystemMessage(&Msg);
|
||||
}
|
||||
|
||||
if((mi->dwFlags & (MOUSEEVENTF_XDOWN | MOUSEEVENTF_XUP)) &&
|
||||
(mi->dwFlags & MOUSEEVENTF_WHEEL))
|
||||
{
|
||||
/* fail because both types of events use the mouseData field */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if(mi->dwFlags & MOUSEEVENTF_XDOWN)
|
||||
{
|
||||
Msg.message = WM_XBUTTONDOWN;
|
||||
if(mi->mouseData & XBUTTON1)
|
||||
{
|
||||
Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, XBUTTON1);
|
||||
CurInfo->ButtonsDown |= XBUTTON1;
|
||||
MsqInsertSystemMessage(&Msg);
|
||||
}
|
||||
if(mi->mouseData & XBUTTON2)
|
||||
{
|
||||
Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, XBUTTON2);
|
||||
CurInfo->ButtonsDown |= XBUTTON2;
|
||||
MsqInsertSystemMessage(&Msg);
|
||||
}
|
||||
}
|
||||
else if(mi->dwFlags & MOUSEEVENTF_XUP)
|
||||
{
|
||||
Msg.message = WM_XBUTTONUP;
|
||||
if(mi->mouseData & XBUTTON1)
|
||||
{
|
||||
Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, XBUTTON1);
|
||||
CurInfo->ButtonsDown &= ~XBUTTON1;
|
||||
MsqInsertSystemMessage(&Msg);
|
||||
}
|
||||
if(mi->mouseData & XBUTTON2)
|
||||
{
|
||||
Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, XBUTTON2);
|
||||
CurInfo->ButtonsDown &= ~XBUTTON2;
|
||||
MsqInsertSystemMessage(&Msg);
|
||||
}
|
||||
}
|
||||
if(mi->dwFlags & MOUSEEVENTF_WHEEL)
|
||||
{
|
||||
Msg.message = WM_MOUSEWHEEL;
|
||||
Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, mi->mouseData);
|
||||
MsqInsertSystemMessage(&Msg);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL FASTCALL
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: misc.c,v 1.63 2004/04/25 20:05:30 weiden Exp $
|
||||
/* $Id: misc.c,v 1.64 2004/04/30 22:18:00 weiden Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -19,6 +19,7 @@
|
|||
#include <include/painting.h>
|
||||
#include <include/dce.h>
|
||||
#include <include/inteng.h>
|
||||
#include <include/input.h>
|
||||
#include <include/intgdi.h>
|
||||
#include <include/mouse.h>
|
||||
#include <include/winsta.h>
|
||||
|
@ -204,7 +205,6 @@ NtUserCallTwoParam(
|
|||
{
|
||||
NTSTATUS Status;
|
||||
PWINDOW_OBJECT WindowObject;
|
||||
PSYSTEM_CURSORINFO CurInfo;
|
||||
PWINSTATION_OBJECT WinStaObject;
|
||||
POINT Pos;
|
||||
|
||||
|
@ -329,6 +329,7 @@ NtUserCallTwoParam(
|
|||
if(Param2)
|
||||
{
|
||||
/* set cursor position */
|
||||
MOUSEINPUT mi;
|
||||
|
||||
Status = MmCopyFromCaller(&Pos, (PPOINT)Param1, sizeof(POINT));
|
||||
if(!NT_SUCCESS(Status))
|
||||
|
@ -338,15 +339,13 @@ NtUserCallTwoParam(
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
CurInfo = &WinStaObject->SystemCursor;
|
||||
/* FIXME - check if process has WINSTA_WRITEATTRIBUTES */
|
||||
|
||||
//CheckClipCursor(&Pos->x, &Pos->y, CurInfo);
|
||||
if((Pos.x != CurInfo->x) || (Pos.y != CurInfo->y))
|
||||
{
|
||||
MouseMoveCursor(Pos.x, Pos.y);
|
||||
}
|
||||
|
||||
mi.dx = Pos.x;
|
||||
mi.dy = Pos.y;
|
||||
mi.mouseData = 0;
|
||||
mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
|
||||
mi.time = 0;
|
||||
mi.dwExtraInfo = 0;
|
||||
IntMouseInput(&mi);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -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: cursoricon.c,v 1.53 2004/04/09 20:03:20 navaraf Exp $ */
|
||||
/* $Id: cursoricon.c,v 1.54 2004/04/30 22:18:00 weiden Exp $ */
|
||||
|
||||
#undef WIN32_LEAN_AND_MEAN
|
||||
|
||||
|
@ -32,6 +32,7 @@
|
|||
#include <include/error.h>
|
||||
#include <include/mouse.h>
|
||||
#include <include/window.h>
|
||||
#include <include/input.h>
|
||||
#include <include/cursoricon.h>
|
||||
#include <include/inteng.h>
|
||||
#include <include/surface.h>
|
||||
|
@ -81,15 +82,6 @@ IntCopyBitmap(HBITMAP bmp)
|
|||
return ret;
|
||||
}
|
||||
|
||||
STATIC VOID FASTCALL
|
||||
SetPointerRect(PSYSTEM_CURSORINFO CurInfo, PRECTL PointerRect)
|
||||
{
|
||||
CurInfo->PointerRectLeft = PointerRect->left;
|
||||
CurInfo->PointerRectRight = PointerRect->right;
|
||||
CurInfo->PointerRectTop = PointerRect->top;
|
||||
CurInfo->PointerRectBottom = PointerRect->bottom;
|
||||
}
|
||||
|
||||
#define COLORCURSORS_ALLOWED FALSE
|
||||
HCURSOR FASTCALL
|
||||
IntSetCursor(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT NewCursor,
|
||||
|
@ -740,6 +732,8 @@ NtUserClipCursor(
|
|||
if((Rect.right > Rect.left) && (Rect.bottom > Rect.top)
|
||||
&& DesktopWindow)
|
||||
{
|
||||
MOUSEINPUT mi;
|
||||
|
||||
CurInfo->CursorClipInfo.IsClipped = TRUE;
|
||||
CurInfo->CursorClipInfo.Left = max(Rect.left, DesktopWindow->WindowRect.left);
|
||||
CurInfo->CursorClipInfo.Top = max(Rect.top, DesktopWindow->WindowRect.top);
|
||||
|
@ -747,11 +741,18 @@ NtUserClipCursor(
|
|||
CurInfo->CursorClipInfo.Bottom = min(Rect.bottom - 1, DesktopWindow->WindowRect.bottom - 1);
|
||||
IntReleaseWindowObject(DesktopWindow);
|
||||
|
||||
MouseMoveCursor(CurInfo->x, CurInfo->y);
|
||||
}
|
||||
else
|
||||
WinStaObject->SystemCursor.CursorClipInfo.IsClipped = FALSE;
|
||||
mi.dx = CurInfo->x;
|
||||
mi.dy = CurInfo->y;
|
||||
mi.mouseData = 0;
|
||||
mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
|
||||
mi.time = 0;
|
||||
mi.dwExtraInfo = 0;
|
||||
IntMouseInput(&mi);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WinStaObject->SystemCursor.CursorClipInfo.IsClipped = FALSE;
|
||||
ObDereferenceObject(WinStaObject);
|
||||
|
||||
return TRUE;
|
||||
|
|
Loading…
Reference in a new issue