From a617803fd027ba44fa541df21969c21987b230a5 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Tue, 23 Oct 2012 23:21:50 -0400 Subject: [PATCH] Capture the mouse on clicks This hack prevents the cursor from leaving the window when panning the camera or changing directions quickly. This is important for those with high mouse sensitivities. --- .../Sources/Plasma/Apps/plClient/winmain.cpp | 46 +++++++++++-------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/winmain.cpp b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/winmain.cpp index c990b244..088e8610 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/winmain.cpp +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/winmain.cpp @@ -436,31 +436,37 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) // Handle messages switch (message) { - case WM_KEYDOWN : - case WM_LBUTTONDOWN : - case WM_RBUTTONDOWN : - case WM_LBUTTONDBLCLK : // The left mouse button was double-clicked. - case WM_MBUTTONDBLCLK : // The middle mouse button was double-clicked. - case WM_MBUTTONDOWN : // The middle mouse button was pressed. - case WM_RBUTTONDBLCLK : // The right mouse button was double-clicked. + case WM_LBUTTONDOWN: + case WM_RBUTTONDOWN: + case WM_LBUTTONDBLCLK: + case WM_MBUTTONDBLCLK: + case WM_MBUTTONDOWN: + case WM_RBUTTONDBLCLK: + // Ensure we don't leave the client area during this action + SetCapture(hWnd); + // fall through to old case + case WM_KEYDOWN: // If they did anything but move the mouse, quit any intro movie playing. + if (gClient) { - if( gClient ) - gClient->SetQuitIntro(true); - } - // Fall through to other events - case WM_KEYUP : - case WM_LBUTTONUP : - case WM_RBUTTONUP : - case WM_MBUTTONUP : // The middle mouse button was released. - case 0x020A: // fuc&ing windows b.s... - { - if (gClient && gClient->WindowActive() && gClient->GetInputManager()) - { + gClient->SetQuitIntro(true); + + // normal input processing + if (gClient->WindowActive() && gClient->GetInputManager()) gClient->GetInputManager()->HandleWin32ControlEvent(message, wParam, lParam, hWnd); - } } break; + case WM_LBUTTONUP: + case WM_RBUTTONUP: + case WM_MBUTTONUP: + // Stop hogging the cursor + ReleaseCapture(); + // fall through to input processing + case WM_MOUSEWHEEL: + case WM_KEYUP: + if (gClient && gClient->WindowActive() && gClient->GetInputManager()) + gClient->GetInputManager()->HandleWin32ControlEvent(message, wParam, lParam, hWnd); + break; case WM_MOUSEMOVE: {