From 6c6cd533e105e64ca48fb63c2565decc2d452308 Mon Sep 17 00:00:00 2001 From: Thomas Bluemel Date: Sat, 20 Dec 2003 21:45:14 +0000 Subject: [PATCH] partially implemented WM_SETCURSOR messages svn path=/trunk/; revision=7149 --- reactos/subsys/win32k/eng/mouse.c | 85 ++++++------------------- reactos/subsys/win32k/include/window.h | 1 - reactos/subsys/win32k/ntuser/message.c | 62 +++++++++++++++++- reactos/subsys/win32k/ntuser/msgqueue.c | 7 +- 4 files changed, 86 insertions(+), 69 deletions(-) diff --git a/reactos/subsys/win32k/eng/mouse.c b/reactos/subsys/win32k/eng/mouse.c index 77f7982d03e..6e0544b7d70 100644 --- a/reactos/subsys/win32k/eng/mouse.c +++ b/reactos/subsys/win32k/eng/mouse.c @@ -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.48 2003/12/13 22:38:29 weiden Exp $ +/* $Id: mouse.c,v 1.49 2003/12/20 21:45:14 weiden Exp $ * * PROJECT: ReactOS kernel * PURPOSE: Mouse @@ -295,6 +295,15 @@ MouseMoveCursor(LONG X, LONG Y) IntCheckClipCursor(&X, &Y, CurInfo); if((X != CurInfo->x) || (Y != CurInfo->y)) { + /* move cursor */ + CurInfo->x = X; + CurInfo->y = Y; + if(CurInfo->Enabled) + { + ExAcquireFastMutexUnsafe(&CurInfo->CursorMutex); + SurfGDI->MovePointer(SurfObj, CurInfo->x, CurInfo->y, &MouseRect); + ExReleaseFastMutexUnsafe(&CurInfo->CursorMutex); + } /* send MOUSEMOVE message */ KeQueryTickCount(&LargeTickCount); TickCount = LargeTickCount.u.LowPart; @@ -305,15 +314,6 @@ MouseMoveCursor(LONG X, LONG Y) Msg.pt.x = X; Msg.pt.y = Y; MsqInsertSystemMessage(&Msg, TRUE); - /* move cursor */ - CurInfo->x = X; - CurInfo->y = Y; - if(CurInfo->Enabled) - { - ExAcquireFastMutexUnsafe(&CurInfo->CursorMutex); - SurfGDI->MovePointer(SurfObj, CurInfo->x, CurInfo->y, &MouseRect); - ExReleaseFastMutexUnsafe(&CurInfo->CursorMutex); - } res = TRUE; } @@ -333,7 +333,6 @@ MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount) ULONG i; PSYSTEM_CURSORINFO CurInfo; BOOL MouseEnabled = FALSE; - BOOL MouseMoveAdded = FALSE; BOOL Moved = FALSE; LONG mouse_ox, mouse_oy; LONG mouse_cx = 0, mouse_cy = 0; @@ -399,21 +398,11 @@ MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount) Msg.pt.x = CurInfo->x; Msg.pt.y = CurInfo->y; - MouseMoveAdded = FALSE; - - //PrintInputData(i, Data[i]); - if (Data[i].ButtonFlags != 0) { wp = 0; if ((Data[i].ButtonFlags & MOUSE_LEFT_BUTTON_DOWN) > 0) { - /* insert WM_MOUSEMOVE messages before Button down messages */ - if ((0 != Data[i].LastX) || (0 != Data[i].LastY)) - { - MsqInsertSystemMessage(&Msg, FALSE); - MouseMoveAdded = TRUE; - } CurInfo->ButtonsDown |= CurInfo->SwapButtons ? MK_RBUTTON : MK_LBUTTON; if(IntDetectDblClick(CurInfo, TickCount)) Msg.message = CurInfo->SwapButtons ? WM_RBUTTONDBLCLK : WM_LBUTTONDBLCLK; @@ -422,12 +411,6 @@ MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount) } if ((Data[i].ButtonFlags & MOUSE_MIDDLE_BUTTON_DOWN) > 0) { - /* insert WM_MOUSEMOVE messages before Button down messages */ - if ((0 != Data[i].LastX) || (0 != Data[i].LastY)) - { - MsqInsertSystemMessage(&Msg, FALSE); - MouseMoveAdded = TRUE; - } CurInfo->ButtonsDown |= MK_MBUTTON; if(IntDetectDblClick(CurInfo, TickCount)) Msg.message = WM_MBUTTONDBLCLK; @@ -436,12 +419,6 @@ MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount) } if ((Data[i].ButtonFlags & MOUSE_RIGHT_BUTTON_DOWN) > 0) { - /* insert WM_MOUSEMOVE messages before Button down messages */ - if ((0 != Data[i].LastX) || (0 != Data[i].LastY)) - { - MsqInsertSystemMessage(&Msg, FALSE); - MouseMoveAdded = TRUE; - } CurInfo->ButtonsDown |= CurInfo->SwapButtons ? MK_LBUTTON : MK_RBUTTON; if(IntDetectDblClick(CurInfo, TickCount)) Msg.message = CurInfo->SwapButtons ? WM_LBUTTONDBLCLK : WM_RBUTTONDBLCLK; @@ -451,35 +428,23 @@ MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount) if ((Data[i].ButtonFlags & MOUSE_BUTTON_4_DOWN) > 0) { - /* insert WM_MOUSEMOVE messages before Button down messages */ - if ((0 != Data[i].LastX) || (0 != Data[i].LastY)) - { - MsqInsertSystemMessage(&Msg, FALSE); - MouseMoveAdded = TRUE; - } CurInfo->ButtonsDown |= MK_XBUTTON1; if(IntDetectDblClick(CurInfo, TickCount)) { Msg.message = WM_XBUTTONDBLCLK; wp = XBUTTON1; - } + } else Msg.message = WM_XBUTTONDOWN; } if ((Data[i].ButtonFlags & MOUSE_BUTTON_5_DOWN) > 0) { - /* insert WM_MOUSEMOVE messages before Button down messages */ - if ((0 != Data[i].LastX) || (0 != Data[i].LastY)) - { - MsqInsertSystemMessage(&Msg, FALSE); - MouseMoveAdded = TRUE; - } CurInfo->ButtonsDown |= MK_XBUTTON2; if(IntDetectDblClick(CurInfo, TickCount)) { Msg.message = WM_XBUTTONDBLCLK; wp = XBUTTON2; - } + } else Msg.message = WM_XBUTTONDOWN; } @@ -532,14 +497,6 @@ MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount) Msg.wParam = CurInfo->ButtonsDown; MsqInsertSystemMessage(&Msg, FALSE); - - /* insert WM_MOUSEMOVE messages after Button up messages */ - if(!MouseMoveAdded && Moved) - { - Msg.message = WM_MOUSEMOVE; - MsqInsertSystemMessage(&Msg, FALSE); - MouseMoveAdded = TRUE; - } } } } @@ -550,17 +507,13 @@ MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount) /* If the mouse moved then move the pointer. */ if ((mouse_cx != 0 || mouse_cy != 0) && MouseEnabled) { - - if(!MouseMoveAdded) - { - Msg.wParam = CurInfo->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, TRUE); - } + Msg.wParam = CurInfo->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, TRUE); if (!CurInfo->SafetySwitch && !CurInfo->SafetySwitch2 && ((mouse_ox != CurInfo->x) || (mouse_oy != CurInfo->y))) diff --git a/reactos/subsys/win32k/include/window.h b/reactos/subsys/win32k/include/window.h index ec016a8b9bc..17b32fbe3c8 100644 --- a/reactos/subsys/win32k/include/window.h +++ b/reactos/subsys/win32k/include/window.h @@ -81,7 +81,6 @@ typedef struct _WINDOW_OBJECT WNDPROC WndProcW; PETHREAD OwnerThread; HWND hWndLastPopup; /* handle to last active popup window (wine doesn't use pointer, for unk. reason)*/ - RECT NormalRect; } WINDOW_OBJECT; /* PWINDOW_OBJECT already declared at top of file */ /* Window flags. */ diff --git a/reactos/subsys/win32k/ntuser/message.c b/reactos/subsys/win32k/ntuser/message.c index e886da79809..620eb800e01 100644 --- a/reactos/subsys/win32k/ntuser/message.c +++ b/reactos/subsys/win32k/ntuser/message.c @@ -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: message.c,v 1.38 2003/12/14 23:52:54 weiden Exp $ +/* $Id: message.c,v 1.39 2003/12/20 21:45:14 weiden Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -121,6 +121,64 @@ NtUserDispatchMessage(CONST MSG* UnsafeMsg) return Result; } +VOID FASTCALL +IntSendSpecialMessages(PUSER_MESSAGE_QUEUE ThreadQueue, LPMSG Msg) +{ + if(!Msg->hwnd || ThreadQueue->CaptureWindow) + { + return; + } + + switch(Msg->message) + { + case WM_MOUSEMOVE: + { + IntSendMessage(Msg->hwnd, WM_SETCURSOR, (WPARAM)Msg->hwnd, MAKELPARAM(HTCLIENT, Msg->message), TRUE); + break; + } + case WM_NCMOUSEMOVE: + { + IntSendMessage(Msg->hwnd, WM_SETCURSOR, (WPARAM)Msg->hwnd, MAKELPARAM(Msg->wParam, Msg->message), TRUE); + break; + } + case WM_LBUTTONDOWN: + case WM_MBUTTONDOWN: + case WM_RBUTTONDOWN: + case WM_XBUTTONDOWN: + case WM_LBUTTONDBLCLK: + case WM_MBUTTONDBLCLK: + case WM_RBUTTONDBLCLK: + case WM_XBUTTONDBLCLK: + { + WPARAM wParam; + + if(!IntGetWindowStationObject(InputWindowStation)) + { + break; + } + wParam = (WPARAM)InputWindowStation->SystemCursor.ButtonsDown; + ObDereferenceObject(InputWindowStation); + + IntSendMessage(Msg->hwnd, WM_MOUSEMOVE, wParam, Msg->lParam, TRUE); + IntSendMessage(Msg->hwnd, WM_SETCURSOR, (WPARAM)Msg->hwnd, MAKELPARAM(HTCLIENT, Msg->message), TRUE); + break; + } + case WM_NCLBUTTONDOWN: + case WM_NCMBUTTONDOWN: + case WM_NCRBUTTONDOWN: + case WM_NCXBUTTONDOWN: + case WM_NCLBUTTONDBLCLK: + case WM_NCMBUTTONDBLCLK: + case WM_NCRBUTTONDBLCLK: + case WM_NCXBUTTONDBLCLK: + { + IntSendMessage(Msg->hwnd, WM_NCMOUSEMOVE, (WPARAM)Msg->wParam, Msg->lParam, TRUE); + IntSendMessage(Msg->hwnd, WM_SETCURSOR, (WPARAM)Msg->hwnd, MAKELPARAM(Msg->wParam, Msg->message), TRUE); + break; + } + } +} + /* * Internal version of PeekMessage() doing all the work */ @@ -178,6 +236,7 @@ IntPeekMessage(LPMSG Msg, if (RemoveMessages) { MsqDestroyMessage(Message); + IntSendSpecialMessages(ThreadQueue, Msg); } return TRUE; } @@ -196,6 +255,7 @@ IntPeekMessage(LPMSG Msg, if (RemoveMessages) { MsqDestroyMessage(Message); + IntSendSpecialMessages(ThreadQueue, Msg); } return TRUE; } diff --git a/reactos/subsys/win32k/ntuser/msgqueue.c b/reactos/subsys/win32k/ntuser/msgqueue.c index e5d7fac783e..626e05e952c 100644 --- a/reactos/subsys/win32k/ntuser/msgqueue.c +++ b/reactos/subsys/win32k/ntuser/msgqueue.c @@ -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.52 2003/12/20 15:42:47 weiden Exp $ +/* $Id: msgqueue.c,v 1.53 2003/12/20 21:45:14 weiden Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -252,6 +252,11 @@ MsqTranslateMouseMessage(HWND hWnd, UINT FilterLow, UINT FilterHigh, else { *HitTest = WinPosWindowFromPoint(ScopeWin, Message->Msg.pt, &Window); + if(!Window) + { + /* change the cursor on desktop background */ + IntLoadDefaultCursors(TRUE); + } } } else