From 3c552912fa803a6397256b767df55e35d75bdeb9 Mon Sep 17 00:00:00 2001 From: Joseph Davies Date: Sun, 10 Jul 2011 19:10:51 -0700 Subject: [PATCH 1/5] Removed ClipCursor which prevented cursor from leaving client window. Disabled cursor being re-centered during progress screen. --- .../Plasma20/Sources/Plasma/Apps/plClient/plClient.cpp | 3 ++- .../Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.cpp | 2 -- .../Sources/Plasma/PubUtilLib/plInputCore/plInputManager.cpp | 5 ----- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/plClient.cpp b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/plClient.cpp index 7307e124..af2f8639 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/plClient.cpp +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/plClient.cpp @@ -1302,6 +1302,8 @@ void plClient::IIncProgress (hsScalar byHowMuch, const char * text) //============================================================================ void plClient::IStartProgress( const char *title, hsScalar len ) { + plInputManager::SetRecenterMouse(false); + if (fProgressBar) { fProgressBar->SetLength(fProgressBar->GetMax()+len); @@ -2207,7 +2209,6 @@ void plClient::ResetDisplayDevice(int Width, int Height, int ColorDepth, hsBool else { SetWindowPos( fWindowHndl, HWND_TOP, 0, 0, Width, Height, flags ); - ::ClipCursor(nil); } WindowActivate(true); diff --git a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.cpp b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.cpp index 389afd5d..0b6ab68c 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.cpp +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.cpp @@ -946,7 +946,6 @@ void plMouseDevice::HandleWindowActivate(bool bActive, HWND hWnd) // rect.bottom /= plInputManager::GetInstance()->GetMouseScale(); ::MapWindowPoints( hWnd, NULL, (POINT *)&rect, 2 ); - ::ClipCursor(&rect); ::ShowCursor( FALSE ); SetCapture(hWnd); @@ -954,7 +953,6 @@ void plMouseDevice::HandleWindowActivate(bool bActive, HWND hWnd) else { ReleaseCapture(); - ::ClipCursor(nil); ::ShowCursor( TRUE ); } } diff --git a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plInputCore/plInputManager.cpp b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plInputCore/plInputManager.cpp index a7c1bff5..69c37db4 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plInputCore/plInputManager.cpp +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plInputCore/plInputManager.cpp @@ -563,7 +563,6 @@ void plDInputMgr::AddDevice(IDirectInputDevice8* device) void plDInputMgr::ConfigureDevice() { - ::ClipCursor(nil); ::ShowCursor( TRUE ); ReleaseCapture(); @@ -587,10 +586,6 @@ void plDInputMgr::ConfigureDevice() for (int i = 0; i < fDI->fSticks.Count(); i++) fDI->fSticks[i]->fDevice->SetActionMap( fDI->fActionFormat, NULL, DIDSAM_FORCESAVE ); - RECT rect; - ::GetClientRect(fhWnd,&rect); - ::ClientToScreen(fhWnd,(LPPOINT)&rect); - ::ClipCursor(&rect); ::ShowCursor( FALSE ); SetCapture(fhWnd); From 487f63f60be25f69599060417b290804080cd5eb Mon Sep 17 00:00:00 2001 From: Joseph Davies Date: Fri, 20 Jan 2012 05:18:04 -0800 Subject: [PATCH 2/5] Fix mouse recentering. Existing fix didn't apply until after SecurePreloader completed. This disables the mouse recentering earlier. --- .../Plasma20/Sources/Plasma/Apps/plClient/plClient.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/plClient.cpp b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/plClient.cpp index af2f8639..626b1e0f 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/plClient.cpp +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/plClient.cpp @@ -1302,8 +1302,6 @@ void plClient::IIncProgress (hsScalar byHowMuch, const char * text) //============================================================================ void plClient::IStartProgress( const char *title, hsScalar len ) { - plInputManager::SetRecenterMouse(false); - if (fProgressBar) { fProgressBar->SetLength(fProgressBar->GetMax()+len); @@ -1548,6 +1546,7 @@ hsBool plClient::StartInit() pfGameGUIMgr::GetInstance()->SetAspectRatio( aspectratio ); plMouseDevice::Instance()->SetDisplayResolution((float)fPipeline->Width(), (float)fPipeline->Height()); + plInputManager::SetRecenterMouse(false); // create the listener for the audio system: plListener* pLMod = TRACKED_NEW plListener; From 357d4aa7d19e3737b6a585b3983824c35c7c4bd2 Mon Sep 17 00:00:00 2001 From: Skoader Date: Thu, 27 Sep 2012 22:25:38 +1000 Subject: [PATCH 3/5] Fix no cursor on window frame and title bar. Remove mouse capture and handle visibility via WM_SETCURSOR messages instead of window activation events. --- .../Sources/Plasma/Apps/plClient/winmain.cpp | 26 +++++++++++++++++++ .../PubUtilLib/plInputCore/plInputDevice.cpp | 23 ---------------- .../PubUtilLib/plInputCore/plInputDevice.h | 1 - .../PubUtilLib/plInputCore/plInputManager.cpp | 4 --- .../PubUtilLib/plPipeline/plDXPipeline.cpp | 3 --- 5 files changed, 26 insertions(+), 31 deletions(-) diff --git a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/winmain.cpp b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/winmain.cpp index a97c8f59..76b37153 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/winmain.cpp +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/winmain.cpp @@ -57,6 +57,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "../plNetClient/plNetClientMgr.h" #include "../plNetClient/plNetLinkingMgr.h" #include "../plInputCore/plInputManager.h" +#include "../plInputCore/plInputDevice.h" #include "../plUnifiedTime/plUnifiedTime.h" #include "plPipeline.h" #include "../plResMgr/plResManager.h" @@ -497,6 +498,31 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) } break; + case WM_SETCURSOR: + { + static bool winCursor = true; + if (LOWORD(lParam) == HTCLIENT) + { + if (winCursor) + { + winCursor = false; + ShowCursor(FALSE); + plMouseDevice::ShowCursor(); + } + } + else + { + if (!winCursor) + { + winCursor = true; + ShowCursor(TRUE); + plMouseDevice::HideCursor(); + } + } + return TRUE; + } + break; + case WM_ACTIVATE: { bool active = (LOWORD(wParam) == WA_ACTIVE || LOWORD(wParam) == WA_CLICKACTIVE); diff --git a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.cpp b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.cpp index 0b6ab68c..3e248862 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.cpp +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.cpp @@ -933,26 +933,3 @@ hsBool plMouseDevice::MsgReceive(plMessage* msg) return false; } - - -void plMouseDevice::HandleWindowActivate(bool bActive, HWND hWnd) -{ - if ( bActive ) - { - RECT rect; - ::GetClientRect(hWnd,&rect); - -// rect.right /= plInputManager::GetInstance()->GetMouseScale(); -// rect.bottom /= plInputManager::GetInstance()->GetMouseScale(); - - ::MapWindowPoints( hWnd, NULL, (POINT *)&rect, 2 ); - ::ShowCursor( FALSE ); - SetCapture(hWnd); - - } - else - { - ReleaseCapture(); - ::ShowCursor( TRUE ); - } -} diff --git a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.h b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.h index 4f8e8699..ad84837b 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.h +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.h @@ -173,7 +173,6 @@ public: ~plMouseDevice(); const char* GetInputName() { return "mouse"; } - void HandleWindowActivate(bool bActive, HWND hWnd); hsBool HasControlFlag(int f) const { return fControlFlags.IsBitSet(f); } void SetControlFlag(int f) diff --git a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plInputCore/plInputManager.cpp b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plInputCore/plInputManager.cpp index 69c37db4..a6ce26d2 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plInputCore/plInputManager.cpp +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plInputCore/plInputManager.cpp @@ -564,8 +564,6 @@ void plDInputMgr::AddDevice(IDirectInputDevice8* device) void plDInputMgr::ConfigureDevice() { ::ShowCursor( TRUE ); - ReleaseCapture(); - DICOLORSET dics; ZeroMemory(&dics, sizeof(DICOLORSET)); @@ -587,8 +585,6 @@ void plDInputMgr::ConfigureDevice() fDI->fSticks[i]->fDevice->SetActionMap( fDI->fActionFormat, NULL, DIDSAM_FORCESAVE ); ::ShowCursor( FALSE ); - SetCapture(fhWnd); - } hsBool plDInputMgr::MsgReceive(plMessage* msg) diff --git a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPipeline/plDXPipeline.cpp b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPipeline/plDXPipeline.cpp index 1e33ac05..49b5fffa 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPipeline/plDXPipeline.cpp +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPipeline/plDXPipeline.cpp @@ -2233,7 +2233,6 @@ hsBool plDXPipeline::IResetDevice() { IClearShadowSlaves(); - ReleaseCapture(); Sleep(100); HRESULT coopLev = fD3DDevice->TestCooperativeLevel(); if( coopLev == D3DERR_DEVICELOST ) @@ -2281,8 +2280,6 @@ hsBool plDXPipeline::IResetDevice() /// all device-specific stuff needs to be recreated plDeviceRecreateMsg* clean = TRACKED_NEW plDeviceRecreateMsg(); plgDispatch::MsgSend(clean); - - SetCapture(fSettings.fHWnd); } fDevWasLost = true; fDeviceLost = false; From ec29c270e4127e78bdc9713d63911b2bafa5b082 Mon Sep 17 00:00:00 2001 From: Skoader Date: Thu, 27 Sep 2012 22:32:41 +1000 Subject: [PATCH 4/5] Fix clicking on the title bar does not activate the window. --- .../Sources/Plasma/Apps/plClient/winmain.cpp | 21 ------------------- 1 file changed, 21 deletions(-) diff --git a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/winmain.cpp b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/winmain.cpp index 76b37153..a0c92a6f 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/winmain.cpp +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/winmain.cpp @@ -534,28 +534,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) (LOWORD(wParam) == WA_CLICKACTIVE) ? "true" : "false"); if (gClient && !minimized && !gClient->GetDone()) - { - if (LOWORD(wParam) == WA_CLICKACTIVE) - { - // See if they've clicked on the frame, in which case they just want to - // move, not activate, us. - POINT pt; - GetCursorPos(&pt); - ScreenToClient(hWnd, &pt); - - RECT rect; - GetClientRect(hWnd, &rect); - - if( (pt.x < rect.left) - ||(pt.x >= rect.right) - ||(pt.y < rect.top) - ||(pt.y >= rect.bottom) ) - { - active = false; - } - } gClient->WindowActivate(active); - } else { gPendingActivate = true; From 7f3d416290d7ec92e772f417d802813f5fb57387 Mon Sep 17 00:00:00 2001 From: Skoader Date: Thu, 27 Sep 2012 22:40:37 +1000 Subject: [PATCH 5/5] Fix no cursor when not the top level window. WM_MOUSEMOVE messages were only processed when the window was active. --- .../Plasma20/Sources/Plasma/Apps/plClient/winmain.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/winmain.cpp b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/winmain.cpp index a0c92a6f..c990b244 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/winmain.cpp +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/winmain.cpp @@ -453,7 +453,6 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) case WM_LBUTTONUP : case WM_RBUTTONUP : case WM_MBUTTONUP : // The middle mouse button was released. - case WM_MOUSEMOVE : case 0x020A: // fuc&ing windows b.s... { if (gClient && gClient->WindowActive() && gClient->GetInputManager()) @@ -463,6 +462,13 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) } break; + case WM_MOUSEMOVE: + { + if (gClient && gClient->GetInputManager()) + gClient->GetInputManager()->HandleWin32ControlEvent(message, wParam, lParam, hWnd); + } + break; + #if 0 case WM_KILLFOCUS: SetForegroundWindow(hWnd);