From 9719db631e9e9e36a6b402e79d54d7f95712fd42 Mon Sep 17 00:00:00 2001 From: Thomas Bluemel Date: Thu, 28 Aug 2003 14:22:05 +0000 Subject: [PATCH] implemented SwapMouseButton() svn path=/trunk/; revision=5897 --- reactos/include/win32k/ntuser.h | 1 + reactos/lib/user32/misc/stubs.c | 15 +--------- reactos/lib/user32/windows/input.c | 15 +++++++++- reactos/ntoskrnl/include/internal/ex.h | 1 + reactos/subsys/win32k/eng/mouse.c | 38 ++++++++++++++++---------- reactos/subsys/win32k/include/mouse.h | 3 +- reactos/subsys/win32k/ntuser/misc.c | 17 +++++++++++- reactos/subsys/win32k/ntuser/winsta.c | 3 +- 8 files changed, 60 insertions(+), 33 deletions(-) diff --git a/reactos/include/win32k/ntuser.h b/reactos/include/win32k/ntuser.h index 4b301268164..34635974adb 100644 --- a/reactos/include/win32k/ntuser.h +++ b/reactos/include/win32k/ntuser.h @@ -165,6 +165,7 @@ NtUserCallNoParam( #define ONEPARAM_ROUTINE_ISWINDOWUNICODE 0x02 #define ONEPARAM_ROUTINE_WINDOWFROMDC 0x03 #define ONEPARAM_ROUTINE_GETWNDCONTEXTHLPID 0x04 +#define ONEPARAM_ROUTINE_SWAPMOUSEBUTTON 0x05 DWORD STDCALL NtUserCallOneParam( diff --git a/reactos/lib/user32/misc/stubs.c b/reactos/lib/user32/misc/stubs.c index a1ed6a6447e..028c8b41eb2 100644 --- a/reactos/lib/user32/misc/stubs.c +++ b/reactos/lib/user32/misc/stubs.c @@ -1,4 +1,4 @@ -/* $Id: stubs.c,v 1.37 2003/08/24 01:12:15 weiden Exp $ +/* $Id: stubs.c,v 1.38 2003/08/28 14:22:05 weiden Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS user32.dll @@ -400,19 +400,6 @@ SetSysColors( } -/* - * @unimplemented - */ -WINBOOL -STDCALL -SwapMouseButton( - WINBOOL fSwap) -{ - UNIMPLEMENTED; - return FALSE; -} - - /* * @unimplemented */ diff --git a/reactos/lib/user32/windows/input.c b/reactos/lib/user32/windows/input.c index e5092564a18..bfe60d39328 100644 --- a/reactos/lib/user32/windows/input.c +++ b/reactos/lib/user32/windows/input.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: input.c,v 1.14 2003/08/20 03:07:33 silverblade Exp $ +/* $Id: input.c,v 1.15 2003/08/28 14:22:05 weiden Exp $ * * PROJECT: ReactOS user32.dll * FILE: lib/user32/windows/input.c @@ -330,6 +330,19 @@ SetKeyboardState(LPBYTE lpKeyState) } +/* + * @implemented + */ +WINBOOL +STDCALL +SwapMouseButton( + WINBOOL fSwap) +{ + return (WINBOOL)NtUserCallOneParam((DWORD)fSwap, + ONEPARAM_ROUTINE_SWAPMOUSEBUTTON); +} + + /* * @unimplemented */ diff --git a/reactos/ntoskrnl/include/internal/ex.h b/reactos/ntoskrnl/include/internal/ex.h index f3973176c0c..2edb2bc8895 100644 --- a/reactos/ntoskrnl/include/internal/ex.h +++ b/reactos/ntoskrnl/include/internal/ex.h @@ -32,6 +32,7 @@ typedef struct _SYSCURSOR typedef struct _SYSTEM_CURSORINFO { BOOL Enabled; + BOOL SwapButtons; UINT CurrentCursor; LONG x, y; BOOL SafetySwitch, SafetySwitch2; diff --git a/reactos/subsys/win32k/eng/mouse.c b/reactos/subsys/win32k/eng/mouse.c index 1439f7d3077..558ad5ee1d2 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.36 2003/08/26 19:26:02 weiden Exp $ +/* $Id: mouse.c,v 1.37 2003/08/28 14:22:05 weiden Exp $ * * PROJECT: ReactOS kernel * PURPOSE: Mouse @@ -118,7 +118,7 @@ static UCHAR DefaultCursor[256] = { /* FUNCTIONS *****************************************************************/ BOOL FASTCALL -CheckClipCursor(LONG *x, LONG *y, PSYSTEM_CURSORINFO CurInfo) +IntCheckClipCursor(LONG *x, LONG *y, PSYSTEM_CURSORINFO CurInfo) { if(CurInfo->CursorClipInfo.IsClipped) { @@ -135,6 +135,14 @@ CheckClipCursor(LONG *x, LONG *y, PSYSTEM_CURSORINFO CurInfo) return TRUE; } +BOOL FASTCALL +IntSwapMouseButton(PWINSTATION_OBJECT WinStaObject, BOOL Swap) +{ + BOOL res = WinStaObject->SystemCursor.SwapButtons; + WinStaObject->SystemCursor.SwapButtons = Swap; + return res; +} + INT STDCALL MouseSafetyOnDrawStart(PSURFOBJ SurfObj, PSURFGDI SurfGDI, LONG HazardX1, LONG HazardY1, LONG HazardX2, LONG HazardY2) @@ -299,7 +307,7 @@ MouseMoveCursor(LONG X, LONG Y) SurfObj = (PSURFOBJ)AccessUserObject((ULONG) dc->Surface); SurfGDI = (PSURFGDI)AccessInternalObject((ULONG) dc->Surface); DC_UnlockDc( hDC ); - CheckClipCursor(&X, &Y, CurInfo); + IntCheckClipCursor(&X, &Y, CurInfo); if((X != CurInfo->x) || (Y != CurInfo->y)) { /* send MOUSEMOVE message */ @@ -394,7 +402,7 @@ MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount) CurInfo->x = min(CurInfo->x, SurfObj->sizlBitmap.cx - 20); CurInfo->y = min(CurInfo->y, SurfObj->sizlBitmap.cy - 20); - CheckClipCursor(&CurInfo->x, &CurInfo->y, CurInfo); + IntCheckClipCursor(&CurInfo->x, &CurInfo->y, CurInfo); KeQueryTickCount(&LargeTickCount); TickCount = LargeTickCount.u.LowPart; @@ -419,8 +427,8 @@ MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount) if ((Data[i].ButtonFlags & MOUSE_LEFT_BUTTON_DOWN) > 0) { - Msg.wParam = MK_LBUTTON; - Msg.message = WM_LBUTTONDOWN; + Msg.wParam = CurInfo->SwapButtons ? MK_RBUTTON : MK_LBUTTON; + Msg.message = CurInfo->SwapButtons ? WM_RBUTTONDOWN : WM_LBUTTONDOWN; } if ((Data[i].ButtonFlags & MOUSE_MIDDLE_BUTTON_DOWN) > 0) { @@ -429,14 +437,14 @@ MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount) } if ((Data[i].ButtonFlags & MOUSE_RIGHT_BUTTON_DOWN) > 0) { - Msg.wParam = MK_RBUTTON; - Msg.message = WM_RBUTTONDOWN; + Msg.wParam = CurInfo->SwapButtons ? MK_LBUTTON : MK_RBUTTON; + Msg.message = CurInfo->SwapButtons ? WM_LBUTTONDOWN : WM_RBUTTONDOWN; } if ((Data[i].ButtonFlags & MOUSE_LEFT_BUTTON_UP) > 0) { - Msg.wParam = MK_LBUTTON; - Msg.message = WM_LBUTTONUP; + Msg.wParam = CurInfo->SwapButtons ? MK_RBUTTON : MK_LBUTTON; + Msg.message = CurInfo->SwapButtons ? WM_RBUTTONUP : WM_LBUTTONUP; } if ((Data[i].ButtonFlags & MOUSE_MIDDLE_BUTTON_UP) > 0) { @@ -445,8 +453,8 @@ MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount) } if ((Data[i].ButtonFlags & MOUSE_RIGHT_BUTTON_UP) > 0) { - Msg.wParam = MK_RBUTTON; - Msg.message = WM_RBUTTONUP; + Msg.wParam = CurInfo->SwapButtons ? MK_LBUTTON : MK_RBUTTON; + Msg.message = CurInfo->SwapButtons ? WM_LBUTTONUP : WM_RBUTTONUP; } MsqInsertSystemMessage(&Msg, FALSE); @@ -527,9 +535,9 @@ EnableMouse(HDC hDisplayDC) MouseSurf = (PSURFOBJ)AccessUserObject((ULONG) hMouseSurf); DbgPrint("Setting Cursor up at 0x%x, 0x%x\n", CurInfo->x, CurInfo->y); - CheckClipCursor(&CurInfo->x, - &CurInfo->y, - CurInfo); + IntCheckClipCursor(&CurInfo->x, + &CurInfo->y, + CurInfo); PointerStatus = SurfGDI->SetPointerShape(SurfObj, MouseSurf, NULL, NULL, SysCursor->hx, diff --git a/reactos/subsys/win32k/include/mouse.h b/reactos/subsys/win32k/include/mouse.h index a50f00faa1d..ea4ca57982c 100644 --- a/reactos/subsys/win32k/include/mouse.h +++ b/reactos/subsys/win32k/include/mouse.h @@ -5,7 +5,8 @@ #include //#include -BOOL FASTCALL CheckClipCursor(LONG *x, LONG *y, PSYSTEM_CURSORINFO CurInfo); +BOOL FASTCALL IntCheckClipCursor(LONG *x, LONG *y, PSYSTEM_CURSORINFO CurInfo); +BOOL FASTCALL IntSwapMouseButton(PWINSTATION_OBJECT WinStaObject, BOOL Swap); INT STDCALL MouseSafetyOnDrawStart(PSURFOBJ SurfObj, PSURFGDI SurfGDI, LONG HazardX1, LONG HazardY1, LONG HazardX2, LONG HazardY2); INT FASTCALL MouseSafetyOnDrawEnd(PSURFOBJ SurfObj, PSURFGDI SurfGDI); BOOL FASTCALL MouseMoveCursor(LONG X, LONG Y); diff --git a/reactos/subsys/win32k/ntuser/misc.c b/reactos/subsys/win32k/ntuser/misc.c index 5bfb970115e..90225fd3ebf 100644 --- a/reactos/subsys/win32k/ntuser/misc.c +++ b/reactos/subsys/win32k/ntuser/misc.c @@ -1,4 +1,4 @@ -/* $Id: misc.c,v 1.12 2003/08/25 00:28:23 weiden Exp $ +/* $Id: misc.c,v 1.13 2003/08/28 14:22:05 weiden Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -48,8 +48,11 @@ NtUserCallOneParam( DWORD Param, DWORD Routine) { + NTSTATUS Status; DWORD Result = 0; + PWINSTATION_OBJECT WinStaObject; PWINDOW_OBJECT WindowObject; + switch(Routine) { case ONEPARAM_ROUTINE_GETMENU: @@ -91,6 +94,18 @@ NtUserCallOneParam( IntReleaseWindowObject(WindowObject); return Result; + case ONEPARAM_ROUTINE_SWAPMOUSEBUTTON: + Status = ValidateWindowStationHandle(PROCESS_WINDOW_STATION(), + KernelMode, + 0, + &WinStaObject); + if (!NT_SUCCESS(Status)) + return (DWORD)FALSE; + + Result = (DWORD)IntSwapMouseButton(WinStaObject, (BOOL)Param); + + ObDereferenceObject(WinStaObject); + return Result; } DPRINT1("Calling invalid routine number 0x%x in NtUserCallOneParam()\n Param=0x%x\n", diff --git a/reactos/subsys/win32k/ntuser/winsta.c b/reactos/subsys/win32k/ntuser/winsta.c index 1bd0258a495..573ce01401f 100644 --- a/reactos/subsys/win32k/ntuser/winsta.c +++ b/reactos/subsys/win32k/ntuser/winsta.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: winsta.c,v 1.30 2003/08/25 00:28:23 weiden Exp $ +/* $Id: winsta.c,v 1.31 2003/08/28 14:22:05 weiden Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -354,6 +354,7 @@ NtUserCreateWindowStation(PUNICODE_STRING lpszWindowStationName, ExInitializeFastMutex(&WinStaObject->SystemCursor.CursorMutex); WinStaObject->SystemCursor.Enabled = FALSE; + WinStaObject->SystemCursor.SwapButtons = FALSE; WinStaObject->SystemCursor.CurrentCursor = 0; WinStaObject->SystemCursor.x = (LONG)0; WinStaObject->SystemCursor.y = (LONG)0;