Author: rharabien
Date: Fri Oct 21 21:23:51 2011
New Revision: 54227
URL:
http://svn.reactos.org/svn/reactos?rev=54227&view=rev
Log:
[WIN32K]
- Mouse code cleanup
- Support MOUSEEVENTF_VIRTUALDESK flag in MOUSEINPUT properly
- Support MOUSE_VIRTUAL_DESKTOP flag in MOUSE_INPUT_DATA properly
- Do not ignore MK_SHIFT and MK_CONTROL flags in some mouse messages
Modified:
trunk/reactos/include/psdk/winuser.h
trunk/reactos/subsystems/win32/win32k/include/input.h
trunk/reactos/subsystems/win32/win32k/ntuser/cursoricon.c
trunk/reactos/subsystems/win32/win32k/ntuser/focus.c
trunk/reactos/subsystems/win32/win32k/ntuser/input.c
trunk/reactos/subsystems/win32/win32k/ntuser/keyboard.c
trunk/reactos/subsystems/win32/win32k/ntuser/mouse.c
trunk/reactos/subsystems/win32/win32k/ntuser/timer.c
trunk/reactos/subsystems/win32/win32k/ntuser/window.c
trunk/reactos/subsystems/win32/win32k/ntuser/winpos.c
Modified: trunk/reactos/include/psdk/winuser.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/winuser.h?rev…
==============================================================================
--- trunk/reactos/include/psdk/winuser.h [iso-8859-1] (original)
+++ trunk/reactos/include/psdk/winuser.h [iso-8859-1] Fri Oct 21 21:23:51 2011
@@ -1139,17 +1139,18 @@
#define MSGF_MAINLOOP 8
#define MSGF_USER 4096
#define MSGF_MAX 8
-#define MOUSEEVENTF_MOVE 1
-#define MOUSEEVENTF_LEFTDOWN 2
-#define MOUSEEVENTF_LEFTUP 4
-#define MOUSEEVENTF_RIGHTDOWN 8
-#define MOUSEEVENTF_RIGHTUP 16
-#define MOUSEEVENTF_MIDDLEDOWN 32
-#define MOUSEEVENTF_MIDDLEUP 64
-#define MOUSEEVENTF_XDOWN 128
-#define MOUSEEVENTF_XUP 256
-#define MOUSEEVENTF_WHEEL 0x0800
-#define MOUSEEVENTF_ABSOLUTE 32768
+#define MOUSEEVENTF_MOVE 0x0001
+#define MOUSEEVENTF_LEFTDOWN 0x0002
+#define MOUSEEVENTF_LEFTUP 0x0004
+#define MOUSEEVENTF_RIGHTDOWN 0x0008
+#define MOUSEEVENTF_RIGHTUP 0x0010
+#define MOUSEEVENTF_MIDDLEDOWN 0x0020
+#define MOUSEEVENTF_MIDDLEUP 0x0040
+#define MOUSEEVENTF_XDOWN 0x0080
+#define MOUSEEVENTF_XUP 0x0100
+#define MOUSEEVENTF_WHEEL 0x0800
+#define MOUSEEVENTF_VIRTUALDESK 0x4000
+#define MOUSEEVENTF_ABSOLUTE 0x8000
#define PM_NOREMOVE 0
#define PM_REMOVE 1
#define PM_NOYIELD 2
Modified: trunk/reactos/subsystems/win32/win32k/include/input.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/in…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/input.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/include/input.h [iso-8859-1] Fri Oct 21 21:23:51
2011
@@ -58,23 +58,27 @@
/* lParam bits */
#define LP_DO_NOT_CARE_BIT (1<<25) // for GetKeyNameText
+/* General */
+INIT_FUNCTION NTSTATUS NTAPI InitInputImpl(VOID);
+BOOL FASTCALL IntBlockInput(PTHREADINFO W32Thread, BOOL BlockIt);
+DWORD NTAPI CreateSystemThreads(UINT Type);
+BOOL FASTCALL UserAttachThreadInput(PTHREADINFO,PTHREADINFO,BOOL);
+VOID FASTCALL DoTheScreenSaver(VOID);
+#define ThreadHasInputAccess(W32Thread) (TRUE)
-INIT_FUNCTION NTSTATUS NTAPI InitInputImpl(VOID);
+/* Keyboard */
INIT_FUNCTION NTSTATUS NTAPI InitKeyboardImpl(VOID);
VOID NTAPI UserInitKeyboard(HANDLE hKeyboardDevice);
PKL W32kGetDefaultKeyLayout(VOID);
VOID NTAPI UserProcessKeyboardInput(PKEYBOARD_INPUT_DATA pKeyInput);
BOOL NTAPI UserSendKeyboardInput(KEYBDINPUT *pKbdInput, BOOL bInjected);
-VOID NTAPI UserProcessMouseInput(PMOUSE_INPUT_DATA Data, ULONG InputCount);
-BOOL FASTCALL IntBlockInput(PTHREADINFO W32Thread, BOOL BlockIt);
-BOOL FASTCALL IntMouseInput(MOUSEINPUT *mi, BOOL Injected);
PKL NTAPI UserHklToKbl(HKL hKl);
BOOL NTAPI UserSetDefaultInputLang(HKL hKl);
-VOID NTAPI KeyboardThreadMain(PVOID StartContext);
-DWORD NTAPI CreateSystemThreads(UINT Type);
-BOOL FASTCALL UserAttachThreadInput(PTHREADINFO,PTHREADINFO,BOOL);
-VOID FASTCALL DoTheScreenSaver(VOID);
-#define ThreadHasInputAccess(W32Thread) (TRUE)
+
+/* Mouse */
+WORD FASTCALL UserGetMouseButtonsState(VOID);
+VOID NTAPI UserProcessMouseInput(PMOUSE_INPUT_DATA pMouseInputData);
+BOOL NTAPI UserSendMouseInput(MOUSEINPUT *pMouseInput, BOOL bInjected);
extern HANDLE ghKeyboardDevice;
extern PTHREADINFO ptiRawInput;
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/cursoricon.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/cursoricon.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/cursoricon.c [iso-8859-1] Fri Oct 21
21:23:51 2011
@@ -116,7 +116,7 @@
/* 1. Generate a mouse move message, this sets the htEx and Track Window too. */
Msg.message = WM_MOUSEMOVE;
- Msg.wParam = CurInfo->ButtonsDown;
+ Msg.wParam = UserGetMouseButtonsState();
Msg.lParam = MAKELPARAM(x, y);
Msg.pt = pt;
co_MsqInsertMouseMessage(&Msg, flags, dwExtraInfo, Hook);
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/focus.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/focus.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/focus.c [iso-8859-1] Fri Oct 21 21:23:51
2011
@@ -581,8 +581,8 @@
mi.mouseData = 0;
mi.dwFlags = MOUSEEVENTF_MOVE;
mi.time = 0;
- mi.dwExtraInfo = 0;
- IntMouseInput(&mi,FALSE);
+ mi.dwExtraInfo = 0;
+ UserSendMouseInput(&mi, FALSE);
}
return hWndPrev;
}
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/input.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/input.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/input.c [iso-8859-1] Fri Oct 21 21:23:51
2011
@@ -261,7 +261,7 @@
/* Process data */
UserEnterExclusive();
- UserProcessMouseInput(&MouseInput, MouIosb.Information /
sizeof(MOUSE_INPUT_DATA));
+ UserProcessMouseInput(&MouseInput);
UserLeave();
}
else if (MouStatus != STATUS_PENDING)
@@ -513,7 +513,7 @@
switch (SafeInput.type)
{
case INPUT_MOUSE:
- if (IntMouseInput(&SafeInput.mi, TRUE))
+ if (UserSendMouseInput(&SafeInput.mi, TRUE))
uRet++;
break;
case INPUT_KEYBOARD:
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/keyboard.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/keyboard.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/keyboard.c [iso-8859-1] Fri Oct 21
21:23:51 2011
@@ -1502,32 +1502,4 @@
return Ret;
}
-/*
- * UserGetMouseButtonsState
- *
- * Returns bitfield used in mouse messages
- */
-WORD FASTCALL
-UserGetMouseButtonsState(VOID)
-{
- WORD wRet = 0;
-
- if (gpsi->aiSysMet[SM_SWAPBUTTON])
- {
- if (IS_KEY_DOWN(gafAsyncKeyState, VK_RBUTTON)) wRet |= MK_LBUTTON;
- if (IS_KEY_DOWN(gafAsyncKeyState, VK_LBUTTON)) wRet |= MK_RBUTTON;
- }
- else
- {
- if (IS_KEY_DOWN(gafAsyncKeyState, VK_LBUTTON)) wRet |= MK_LBUTTON;
- if (IS_KEY_DOWN(gafAsyncKeyState, VK_RBUTTON)) wRet |= MK_RBUTTON;
- }
- if (IS_KEY_DOWN(gafAsyncKeyState, VK_MBUTTON)) wRet |= MK_MBUTTON;
- if (IS_KEY_DOWN(gafAsyncKeyState, VK_SHIFT)) wRet |= MK_SHIFT;
- if (IS_KEY_DOWN(gafAsyncKeyState, VK_CONTROL)) wRet |= MK_CONTROL;
- if (IS_KEY_DOWN(gafAsyncKeyState, VK_XBUTTON1)) wRet |= MK_XBUTTON1;
- if (IS_KEY_DOWN(gafAsyncKeyState, VK_XBUTTON2)) wRet |= MK_XBUTTON2;
- return wRet;
-}
-
/* EOF */
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/mouse.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/mouse.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/mouse.c [iso-8859-1] Fri Oct 21 21:23:51
2011
@@ -10,285 +10,331 @@
#include <win32k.h>
DBG_DEFAULT_CHANNEL(UserInput);
-MOUSEMOVEPOINT MouseHistoryOfMoves[64];
-INT gcur_count = 0;
-
-#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,FALSE); \
- ClearMouseInput(mi);
-
+MOUSEMOVEPOINT gMouseHistoryOfMoves[64];
+INT gcMouseHistoryOfMoves = 0;
+
+/*
+ * UserGetMouseButtonsState
+ *
+ * Returns bitfield of MK_* flags used in mouse messages
+ */
+WORD FASTCALL
+UserGetMouseButtonsState(VOID)
+{
+ WORD wRet = 0;
+
+ wRet = IntGetSysCursorInfo()->ButtonsDown;
+
+ if (IS_KEY_DOWN(gafAsyncKeyState, VK_SHIFT)) wRet |= MK_SHIFT;
+ if (IS_KEY_DOWN(gafAsyncKeyState, VK_CONTROL)) wRet |= MK_CONTROL;
+
+ return wRet;
+}
+
+/*
+ * UserProcessMouseInput
+ *
+ * Process raw mouse input data
+ */
VOID NTAPI
-UserProcessMouseInput(PMOUSE_INPUT_DATA Data, ULONG InputCount)
-{
- PMOUSE_INPUT_DATA mid;
+UserProcessMouseInput(PMOUSE_INPUT_DATA mid)
+{
MOUSEINPUT mi;
- ULONG i;
-
- ClearMouseInput(mi);
+
+ /* Convert MOUSE_INPUT_DATA to MOUSEINPUT. First init all fields. */
+ mi.dx = mid->LastX;
+ mi.dy = mid->LastY;
+ mi.mouseData = 0;
+ mi.dwFlags = 0;
mi.time = 0;
- mi.dwExtraInfo = 0;
- for(i = 0; i < InputCount; i++)
- {
- mid = (Data + i);
- mi.dx += mid->LastX;
- mi.dy += mid->LastY;
-
- /* Check if the mouse move is absolute */
- if (mid->Flags == MOUSE_MOVE_ABSOLUTE)
- {
- /* Set flag to convert to screen location */
- mi.dwFlags |= MOUSEEVENTF_ABSOLUTE;
- }
-
- if(mid->ButtonFlags)
- {
- if(mid->ButtonFlags & MOUSE_LEFT_BUTTON_DOWN)
- {
- mi.dwFlags |= MOUSEEVENTF_LEFTDOWN;
- SendMouseEvent(mi);
- }
- if(mid->ButtonFlags & MOUSE_LEFT_BUTTON_UP)
- {
- mi.dwFlags |= MOUSEEVENTF_LEFTUP;
- SendMouseEvent(mi);
- }
- if(mid->ButtonFlags & MOUSE_MIDDLE_BUTTON_DOWN)
- {
- mi.dwFlags |= MOUSEEVENTF_MIDDLEDOWN;
- SendMouseEvent(mi);
- }
- if(mid->ButtonFlags & MOUSE_MIDDLE_BUTTON_UP)
- {
- mi.dwFlags |= MOUSEEVENTF_MIDDLEUP;
- SendMouseEvent(mi);
- }
- if(mid->ButtonFlags & MOUSE_RIGHT_BUTTON_DOWN)
- {
- mi.dwFlags |= MOUSEEVENTF_RIGHTDOWN;
- SendMouseEvent(mi);
- }
- if(mid->ButtonFlags & MOUSE_RIGHT_BUTTON_UP)
- {
- mi.dwFlags |= MOUSEEVENTF_RIGHTUP;
- SendMouseEvent(mi);
- }
- if(mid->ButtonFlags & MOUSE_BUTTON_4_DOWN)
- {
- mi.mouseData |= XBUTTON1;
- mi.dwFlags |= MOUSEEVENTF_XDOWN;
- SendMouseEvent(mi);
- }
- if(mid->ButtonFlags & MOUSE_BUTTON_4_UP)
- {
- mi.mouseData |= XBUTTON1;
- mi.dwFlags |= MOUSEEVENTF_XUP;
- SendMouseEvent(mi);
- }
- if(mid->ButtonFlags & MOUSE_BUTTON_5_DOWN)
- {
- mi.mouseData |= XBUTTON2;
- mi.dwFlags |= MOUSEEVENTF_XDOWN;
- SendMouseEvent(mi);
- }
- if(mid->ButtonFlags & MOUSE_BUTTON_5_UP)
- {
- mi.mouseData |= XBUTTON2;
- mi.dwFlags |= MOUSEEVENTF_XUP;
- SendMouseEvent(mi);
- }
- if(mid->ButtonFlags & MOUSE_WHEEL)
- {
- mi.mouseData = mid->ButtonData;
- mi.dwFlags |= MOUSEEVENTF_WHEEL;
- SendMouseEvent(mi);
- }
- }
- }
-
- SendMouseEvent(mi);
-}
-
-BOOL FASTCALL
-IntMouseInput(MOUSEINPUT *mi, BOOL Injected)
-{
- 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;
- BOOL SwapButtons;
+ mi.dwExtraInfo = mid->ExtraInformation;
+
+ /* Mouse position */
+ if (mi.dx != 0 || mi.dy != 0)
+ mi.dwFlags |= MOUSEEVENTF_MOVE;
+
+ /* Flags for absolute move */
+ if (mid->Flags & MOUSE_MOVE_ABSOLUTE)
+ mi.dwFlags |= MOUSEEVENTF_ABSOLUTE;
+ if (mid->Flags & MOUSE_VIRTUAL_DESKTOP)
+ mi.dwFlags |= MOUSEEVENTF_VIRTUALDESK;
+
+ /* Left button */
+ if (mid->ButtonFlags & MOUSE_LEFT_BUTTON_DOWN)
+ mi.dwFlags |= MOUSEEVENTF_LEFTDOWN;
+ if (mid->ButtonFlags & MOUSE_LEFT_BUTTON_UP)
+ mi.dwFlags |= MOUSEEVENTF_LEFTUP;
+
+ /* Middle button */
+ if (mid->ButtonFlags & MOUSE_MIDDLE_BUTTON_DOWN)
+ mi.dwFlags |= MOUSEEVENTF_MIDDLEDOWN;
+ if (mid->ButtonFlags & MOUSE_MIDDLE_BUTTON_UP)
+ mi.dwFlags |= MOUSEEVENTF_MIDDLEUP;
+
+ /* Right button */
+ if (mid->ButtonFlags & MOUSE_RIGHT_BUTTON_DOWN)
+ mi.dwFlags |= MOUSEEVENTF_RIGHTDOWN;
+ if (mid->ButtonFlags & MOUSE_RIGHT_BUTTON_UP)
+ mi.dwFlags |= MOUSEEVENTF_RIGHTUP;
+
+ /* Note: next buttons use mouseData field so they cannot be sent in one call */
+
+ /* Button 4 */
+ if (mid->ButtonFlags & MOUSE_BUTTON_4_DOWN)
+ {
+ mi.dwFlags |= MOUSEEVENTF_XDOWN;
+ mi.mouseData |= XBUTTON1;
+ }
+ if (mid->ButtonFlags & MOUSE_BUTTON_4_UP)
+ {
+ mi.dwFlags |= MOUSEEVENTF_XUP;
+ mi.mouseData |= XBUTTON1;
+ }
+
+ /* If mouseData is used by button 4, send input and clear mi */
+ if (mi.dwFlags & (MOUSE_BUTTON_4_DOWN | MOUSE_BUTTON_4_UP))
+ {
+ UserSendMouseInput(&mi, FALSE);
+ RtlZeroMemory(&mi, sizeof(mi));
+ }
+
+ /* Button 5 */
+ if (mid->ButtonFlags & MOUSE_BUTTON_5_DOWN)
+ {
+ mi.mouseData |= XBUTTON2;
+ mi.dwFlags |= MOUSEEVENTF_XDOWN;
+ }
+ if (mid->ButtonFlags & MOUSE_BUTTON_5_UP)
+ {
+ mi.mouseData |= XBUTTON2;
+ mi.dwFlags |= MOUSEEVENTF_XUP;
+ }
+
+ /* If mouseData is used by button 5, send input and clear mi */
+ if (mi.dwFlags & (MOUSE_BUTTON_5_DOWN | MOUSE_BUTTON_5_UP))
+ {
+ UserSendMouseInput(&mi, FALSE);
+ RtlZeroMemory(&mi, sizeof(mi));
+ }
+
+ /* Mouse wheel */
+ if (mid->ButtonFlags & MOUSE_WHEEL)
+ {
+ mi.mouseData = mid->ButtonData;
+ mi.dwFlags |= MOUSEEVENTF_WHEEL;
+ }
+
+ /* If something has changed, send input to user */
+ if (mi.dwFlags)
+ UserSendMouseInput(&mi, FALSE);
+}
+
+/*
+ * IntFixMouseInputButtons
+ *
+ * Helper function for supporting mouse button swap function
+ */
+DWORD
+IntFixMouseInputButtons(DWORD dwFlags)
+{
+ DWORD dwNewFlags;
+
+ if (!gspv.bMouseBtnSwap)
+ return dwFlags;
+
+ /* Buttons other than left and right are not affected */
+ dwNewFlags = dwFlags & ~(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP |
+ MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP);
+
+ /* Swap buttons */
+ if (dwFlags & MOUSEEVENTF_LEFTDOWN)
+ dwNewFlags |= MOUSEEVENTF_RIGHTDOWN;
+ if (dwFlags & MOUSEEVENTF_LEFTUP)
+ dwNewFlags |= MOUSEEVENTF_RIGHTUP;
+ if (dwFlags & MOUSEEVENTF_RIGHTDOWN)
+ dwNewFlags |= MOUSEEVENTF_LEFTDOWN;
+ if (dwFlags & MOUSEEVENTF_RIGHTUP)
+ dwNewFlags |= MOUSEEVENTF_LEFTUP;
+
+ return dwNewFlags;
+}
+
+/*
+ * UserSendMouseInput
+ *
+ * Process mouse input from input devices and SendInput API
+ */
+BOOL NTAPI
+UserSendMouseInput(MOUSEINPUT *pmi, BOOL bInjected)
+{
+ POINT ptCursor;
+ PSYSTEM_CURSORINFO pCurInfo;
MSG Msg;
-
- ASSERT(mi);
-
- CurInfo = IntGetSysCursorInfo();
-
- if(!mi->time)
+ DWORD dwFlags;
+
+ ASSERT(pmi);
+
+ pCurInfo = IntGetSysCursorInfo();
+ ptCursor = gpsi->ptCursor;
+ dwFlags = IntFixMouseInputButtons(pmi->dwFlags);
+
+ if (pmi->dwFlags & MOUSEEVENTF_MOVE)
+ {
+ /* Mouse has changes position */
+ if (!(pmi->dwFlags & MOUSEEVENTF_ABSOLUTE))
+ {
+ /* Relative move */
+ ptCursor.x += pmi->dx;
+ ptCursor.y += pmi->dy;
+ }
+ else if (pmi->dwFlags & MOUSEEVENTF_VIRTUALDESK)
+ {
+ /* Absolute move in virtual screen units */
+ ptCursor.x = pmi->dx * UserGetSystemMetrics(SM_CXVIRTUALSCREEN) >>
16;
+ ptCursor.y = pmi->dy * UserGetSystemMetrics(SM_CYVIRTUALSCREEN) >>
16;
+ }
+ else
+ {
+ /* Absolute move in primary monitor units */
+ ptCursor.x = pmi->dx * UserGetSystemMetrics(SM_CXSCREEN) >> 16;
+ ptCursor.y = pmi->dy * UserGetSystemMetrics(SM_CYSCREEN) >> 16;
+ }
+ }
+
+ /* Init message fields */
+ Msg.wParam = UserGetMouseButtonsState();
+ Msg.lParam = MAKELPARAM(ptCursor.x, ptCursor.y);
+ Msg.pt = ptCursor;
+ Msg.time = pmi->time;
+ if (!Msg.time)
{
LARGE_INTEGER LargeTickCount;
KeQueryTickCount(&LargeTickCount);
- mi->time = MsqCalculateMessageTime(&LargeTickCount);
- }
-
- SwapButtons = gspv.bMouseBtnSwap;
-
- MousePos = gpsi->ptCursor;
-
- if(mi->dwFlags & MOUSEEVENTF_MOVE)
- {
- if(mi->dwFlags & MOUSEEVENTF_ABSOLUTE)
- {
- MousePos.x = mi->dx * UserGetSystemMetrics(SM_CXVIRTUALSCREEN) >>
16;
- MousePos.y = mi->dy * UserGetSystemMetrics(SM_CYVIRTUALSCREEN) >>
16;
- }
- else
- {
- MousePos.x += mi->dx;
- MousePos.y += mi->dy;
- }
+ Msg.time = MsqCalculateMessageTime(&LargeTickCount);
}
/* Do GetMouseMovePointsEx FIFO. */
- MouseHistoryOfMoves[gcur_count].x = MousePos.x;
- MouseHistoryOfMoves[gcur_count].y = MousePos.y;
- MouseHistoryOfMoves[gcur_count].time = mi->time;
- MouseHistoryOfMoves[gcur_count].dwExtraInfo = mi->dwExtraInfo;
- if (++gcur_count == ARRAYSIZE(MouseHistoryOfMoves))
- gcur_count = 0; // 0 - 63 is 64, FIFO forwards.
-
- /*
- * Insert the messages into the system queue
- */
- Msg.wParam = 0;
- Msg.lParam = MAKELPARAM(MousePos.x, MousePos.y);
- Msg.pt = MousePos;
-
- if (IS_KEY_DOWN(gafAsyncKeyState, VK_SHIFT))
- {
- Msg.wParam |= MK_SHIFT;
- }
-
- if (IS_KEY_DOWN(gafAsyncKeyState, VK_CONTROL))
- {
- Msg.wParam |= MK_CONTROL;
- }
-
- if(mi->dwFlags & MOUSEEVENTF_MOVE)
- {
- UserSetCursorPos(MousePos.x, MousePos.y, Injected, mi->dwExtraInfo, TRUE);
- }
- if(mi->dwFlags & MOUSEEVENTF_LEFTDOWN)
+ gMouseHistoryOfMoves[gcMouseHistoryOfMoves].x = ptCursor.x;
+ gMouseHistoryOfMoves[gcMouseHistoryOfMoves].y = ptCursor.y;
+ gMouseHistoryOfMoves[gcMouseHistoryOfMoves].time = Msg.time;
+ gMouseHistoryOfMoves[gcMouseHistoryOfMoves].dwExtraInfo = pmi->dwExtraInfo;
+ if (++gcMouseHistoryOfMoves == ARRAYSIZE(gMouseHistoryOfMoves))
+ gcMouseHistoryOfMoves = 0; // 0 - 63 is 64, FIFO forwards.
+
+ /* Update cursor position */
+ if (dwFlags & MOUSEEVENTF_MOVE)
+ {
+ UserSetCursorPos(ptCursor.x, ptCursor.y, bInjected, pmi->dwExtraInfo, TRUE);
+ }
+
+ /* Left button */
+ if (dwFlags & MOUSEEVENTF_LEFTDOWN)
{
SET_KEY_DOWN(gafAsyncKeyState, VK_LBUTTON, TRUE);
- Msg.message = SwapBtnMsg[0][SwapButtons];
- CurInfo->ButtonsDown |= SwapBtn[SwapButtons];
- Msg.wParam |= CurInfo->ButtonsDown;
- co_MsqInsertMouseMessage(&Msg, Injected, mi->dwExtraInfo, TRUE);
- }
- else if(mi->dwFlags & MOUSEEVENTF_LEFTUP)
+ Msg.message = WM_LBUTTONDOWN;
+ pCurInfo->ButtonsDown |= MK_LBUTTON;
+ Msg.wParam |= MK_LBUTTON;
+ co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
+ }
+ else if (dwFlags & MOUSEEVENTF_LEFTUP)
{
SET_KEY_DOWN(gafAsyncKeyState, VK_LBUTTON, FALSE);
- Msg.message = SwapBtnMsg[1][SwapButtons];
- CurInfo->ButtonsDown &= ~SwapBtn[SwapButtons];
- Msg.wParam |= CurInfo->ButtonsDown;
- co_MsqInsertMouseMessage(&Msg, Injected, mi->dwExtraInfo, TRUE);
- }
- if(mi->dwFlags & MOUSEEVENTF_MIDDLEDOWN)
+ Msg.message = WM_LBUTTONUP;
+ pCurInfo->ButtonsDown &= ~MK_LBUTTON;
+ Msg.wParam &= ~MK_LBUTTON;
+ co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
+ }
+
+ /* Middle button */
+ if (dwFlags & MOUSEEVENTF_MIDDLEDOWN)
{
SET_KEY_DOWN(gafAsyncKeyState, VK_MBUTTON, TRUE);
Msg.message = WM_MBUTTONDOWN;
- CurInfo->ButtonsDown |= MK_MBUTTON;
- Msg.wParam |= CurInfo->ButtonsDown;
- co_MsqInsertMouseMessage(&Msg, Injected, mi->dwExtraInfo, TRUE);
- }
- else if(mi->dwFlags & MOUSEEVENTF_MIDDLEUP)
+ pCurInfo->ButtonsDown |= MK_MBUTTON;
+ Msg.wParam |= MK_MBUTTON;
+ co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
+ }
+ else if (dwFlags & MOUSEEVENTF_MIDDLEUP)
{
SET_KEY_DOWN(gafAsyncKeyState, VK_MBUTTON, FALSE);
Msg.message = WM_MBUTTONUP;
- CurInfo->ButtonsDown &= ~MK_MBUTTON;
- Msg.wParam |= CurInfo->ButtonsDown;
- co_MsqInsertMouseMessage(&Msg, Injected, mi->dwExtraInfo, TRUE);
- }
- if(mi->dwFlags & MOUSEEVENTF_RIGHTDOWN)
+ pCurInfo->ButtonsDown &= ~MK_MBUTTON;
+ Msg.wParam &= ~MK_MBUTTON;
+ co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
+ }
+
+ /* Right button */
+ if (dwFlags & MOUSEEVENTF_RIGHTDOWN)
{
SET_KEY_DOWN(gafAsyncKeyState, VK_RBUTTON, TRUE);
- Msg.message = SwapBtnMsg[0][!SwapButtons];
- CurInfo->ButtonsDown |= SwapBtn[!SwapButtons];
- Msg.wParam |= CurInfo->ButtonsDown;
- co_MsqInsertMouseMessage(&Msg, Injected, mi->dwExtraInfo, TRUE);
- }
- else if(mi->dwFlags & MOUSEEVENTF_RIGHTUP)
+ Msg.message = WM_RBUTTONDOWN;
+ pCurInfo->ButtonsDown |= MK_RBUTTON;
+ Msg.wParam |= MK_RBUTTON;
+ co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
+ }
+ else if (dwFlags & MOUSEEVENTF_RIGHTUP)
{
SET_KEY_DOWN(gafAsyncKeyState, VK_RBUTTON, FALSE);
- Msg.message = SwapBtnMsg[1][!SwapButtons];
- CurInfo->ButtonsDown &= ~SwapBtn[!SwapButtons];
- Msg.wParam |= CurInfo->ButtonsDown;
- co_MsqInsertMouseMessage(&Msg, Injected, mi->dwExtraInfo, TRUE);
- }
-
- if((mi->dwFlags & (MOUSEEVENTF_XDOWN | MOUSEEVENTF_XUP)) &&
- (mi->dwFlags & MOUSEEVENTF_WHEEL))
- {
- /* fail because both types of events use the mouseData field */
+ Msg.message = WM_RBUTTONUP;
+ pCurInfo->ButtonsDown &= ~MK_RBUTTON;
+ Msg.wParam &= ~MK_RBUTTON;
+ co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
+ }
+
+ if((dwFlags & (MOUSEEVENTF_XDOWN | MOUSEEVENTF_XUP)) &&
+ (dwFlags & MOUSEEVENTF_WHEEL))
+ {
+ /* Fail because both types of events use the mouseData field */
+ WARN("Invalid flags!\n");
return FALSE;
}
- if(mi->dwFlags & MOUSEEVENTF_XDOWN)
+ /* X-Button (4 or 5) */
+ if (dwFlags & MOUSEEVENTF_XDOWN)
{
Msg.message = WM_XBUTTONDOWN;
- if(mi->mouseData & XBUTTON1)
+ if (pmi->mouseData & XBUTTON1)
{
SET_KEY_DOWN(gafAsyncKeyState, VK_XBUTTON1, TRUE);
- CurInfo->ButtonsDown |= MK_XBUTTON1;
- Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, XBUTTON1);
- co_MsqInsertMouseMessage(&Msg, Injected, mi->dwExtraInfo, TRUE);
- }
- if(mi->mouseData & XBUTTON2)
+ pCurInfo->ButtonsDown |= MK_XBUTTON1;
+ Msg.wParam |= MAKEWPARAM(MK_XBUTTON1, XBUTTON1);
+ co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
+ }
+ if (pmi->mouseData & XBUTTON2)
{
SET_KEY_DOWN(gafAsyncKeyState, VK_XBUTTON2, TRUE);
- CurInfo->ButtonsDown |= MK_XBUTTON2;
- Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, XBUTTON2);
- co_MsqInsertMouseMessage(&Msg, Injected, mi->dwExtraInfo, TRUE);
- }
- }
- else if(mi->dwFlags & MOUSEEVENTF_XUP)
+ pCurInfo->ButtonsDown |= MK_XBUTTON2;
+ Msg.wParam |= MAKEWPARAM(MK_XBUTTON2, XBUTTON2);
+ co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
+ }
+ }
+ else if (dwFlags & MOUSEEVENTF_XUP)
{
Msg.message = WM_XBUTTONUP;
- if(mi->mouseData & XBUTTON1)
+ if(pmi->mouseData & XBUTTON1)
{
SET_KEY_DOWN(gafAsyncKeyState, VK_XBUTTON1, FALSE);
- CurInfo->ButtonsDown &= ~MK_XBUTTON1;
- Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, XBUTTON1);
- co_MsqInsertMouseMessage(&Msg, Injected, mi->dwExtraInfo, TRUE);
- }
- if(mi->mouseData & XBUTTON2)
+ pCurInfo->ButtonsDown &= ~MK_XBUTTON1;
+ Msg.wParam &= ~MK_XBUTTON1;
+ Msg.wParam |= MAKEWPARAM(0, XBUTTON2);
+ co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
+ }
+ if (pmi->mouseData & XBUTTON2)
{
SET_KEY_DOWN(gafAsyncKeyState, VK_XBUTTON2, FALSE);
- CurInfo->ButtonsDown &= ~MK_XBUTTON2;
- Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, XBUTTON2);
- co_MsqInsertMouseMessage(&Msg, Injected, mi->dwExtraInfo, TRUE);
- }
- }
- if(mi->dwFlags & MOUSEEVENTF_WHEEL)
+ pCurInfo->ButtonsDown &= ~MK_XBUTTON2;
+ Msg.wParam &= ~MK_XBUTTON2;
+ Msg.wParam |= MAKEWPARAM(0, XBUTTON2);
+ co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
+ }
+ }
+
+ /* Mouse wheel */
+ if (dwFlags & MOUSEEVENTF_WHEEL)
{
Msg.message = WM_MOUSEWHEEL;
- Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, mi->mouseData);
- co_MsqInsertMouseMessage(&Msg, Injected, mi->dwExtraInfo, TRUE);
+ Msg.wParam = MAKEWPARAM(pCurInfo->ButtonsDown, pmi->mouseData);
+ co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
}
return TRUE;
@@ -462,9 +508,6 @@
return bRet;
}
-extern MOUSEMOVEPOINT MouseHistoryOfMoves[];
-extern INT gcur_count;
-
DWORD
APIENTRY
NtUserGetMouseMovePointsEx(
@@ -508,18 +551,18 @@
//
http://msdn.microsoft.com/en-us/library/ms646259(v=vs.85).aspx
// This explains the math issues in transforming points.
- iRet = gcur_count; // FIFO is forward so retrieve backward.
+ iRet = gcMouseHistoryOfMoves; // FIFO is forward so retrieve backward.
//Hit = FALSE;
do
{
if (Safeppt.x == 0 && Safeppt.y == 0)
break; // No test.
// Finds the point, it returns the last nBufPoints prior to and including the
supplied point.
- if (MouseHistoryOfMoves[iRet].x == Safeppt.x &&
MouseHistoryOfMoves[iRet].y == Safeppt.y)
+ if (gMouseHistoryOfMoves[iRet].x == Safeppt.x &&
gMouseHistoryOfMoves[iRet].y == Safeppt.y)
{
if (Safeppt.time) // Now test time and it seems to be absolute.
{
- if (Safeppt.time == MouseHistoryOfMoves[iRet].time)
+ if (Safeppt.time == gMouseHistoryOfMoves[iRet].time)
{
//Hit = TRUE;
break;
@@ -535,7 +578,7 @@
}
if (--iRet < 0) iRet = 63;
}
- while (iRet != gcur_count);
+ while (iRet != gcMouseHistoryOfMoves);
switch(resolution)
{
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/timer.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/timer.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/timer.c [iso-8859-1] Fri Oct 21 21:23:51
2011
@@ -10,8 +10,6 @@
#include <win32k.h>
DBG_DEFAULT_CHANNEL(UserTimer);
-
-WORD FASTCALL UserGetMouseButtonsState(VOID);
/* GLOBALS *******************************************************************/
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/window.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/window.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/window.c [iso-8859-1] Fri Oct 21 21:23:51
2011
@@ -2506,7 +2506,7 @@
/* Generate mouse move message for the next window */
msg.message = WM_MOUSEMOVE;
- msg.wParam = IntGetSysCursorInfo()->ButtonsDown;
+ msg.wParam = UserGetMouseButtonsState();
msg.lParam = MAKELPARAM(gpsi->ptCursor.x, gpsi->ptCursor.y);
msg.pt = gpsi->ptCursor;
co_MsqInsertMouseMessage(&msg, 0, 0, TRUE);
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/winpos.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/winpos.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/winpos.c [iso-8859-1] Fri Oct 21 21:23:51
2011
@@ -1317,7 +1317,7 @@
/* Generate mouse move message */
MSG msg;
msg.message = WM_MOUSEMOVE;
- msg.wParam = IntGetSysCursorInfo()->ButtonsDown;
+ msg.wParam = UserGetMouseButtonsState();
msg.lParam = MAKELPARAM(gpsi->ptCursor.x, gpsi->ptCursor.y);
msg.pt = gpsi->ptCursor;
co_MsqInsertMouseMessage(&msg, 0, 0, TRUE);