Browse Source

Merge pull request #221 from Hoikas/window-fixes

Window fixes
Adam Johnson 12 years ago
parent
commit
8aa9e25ec0
  1. 96
      Sources/Plasma/Apps/plClient/winmain.cpp
  2. 24
      Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.cpp
  3. 1
      Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.h
  4. 4
      Sources/Plasma/PubUtilLib/plInputCore/plInputManager.cpp
  5. 3
      Sources/Plasma/PubUtilLib/plPipeline/plDXPipeline.cpp

96
Sources/Plasma/Apps/plClient/winmain.cpp

@ -59,6 +59,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pfCrashHandler/plCrashCli.h" #include "pfCrashHandler/plCrashCli.h"
#include "plNetClient/plNetClientMgr.h" #include "plNetClient/plNetClientMgr.h"
#include "plNetClient/plNetLinkingMgr.h" #include "plNetClient/plNetLinkingMgr.h"
#include "plInputCore/plInputDevice.h"
#include "plInputCore/plInputManager.h" #include "plInputCore/plInputManager.h"
#include "plUnifiedTime/plUnifiedTime.h" #include "plUnifiedTime/plUnifiedTime.h"
#include "plPipeline.h" #include "plPipeline.h"
@ -370,7 +371,7 @@ void DebugMsgF(const char* format, ...);
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{ {
static bool gDragging = false; static bool gDragging = false;
static uint32_t keyState=0; static uint8_t mouse_down = 0;
// Messages we registered for manually (no const value) // Messages we registered for manually (no const value)
if (message == s_WmTaskbarList) if (message == s_WmTaskbarList)
@ -394,31 +395,45 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
nc->ResetServerTimeOffset(true); nc->ResetServerTimeOffset(true);
break; break;
case WM_KEYDOWN : case WM_LBUTTONDOWN:
case WM_LBUTTONDOWN : case WM_RBUTTONDOWN:
case WM_RBUTTONDOWN : case WM_LBUTTONDBLCLK:
case WM_LBUTTONDBLCLK : // The left mouse button was double-clicked. case WM_MBUTTONDBLCLK:
case WM_MBUTTONDBLCLK : // The middle mouse button was double-clicked. case WM_MBUTTONDOWN:
case WM_MBUTTONDOWN : // The middle mouse button was pressed. case WM_RBUTTONDBLCLK:
case WM_RBUTTONDBLCLK : // The right mouse button was double-clicked. // Ensure we don't leave the client area during clicks
if (!(mouse_down++))
SetCapture(hWnd);
// fall through to old case
case WM_KEYDOWN:
case WM_CHAR:
// If they did anything but move the mouse, quit any intro movie playing. // If they did anything but move the mouse, quit any intro movie playing.
if (gClient)
{ {
if( gClient ) gClient->SetQuitIntro(true);
gClient->SetQuitIntro(true);
// normal input processing
if (gClient->WindowActive() && gClient->GetInputManager())
gClient->GetInputManager()->HandleWin32ControlEvent(message, wParam, lParam, hWnd);
} }
// Fall through to other events break;
case WM_CHAR: case WM_LBUTTONUP:
case WM_KEYUP : case WM_RBUTTONUP:
case WM_LBUTTONUP : case WM_MBUTTONUP:
case WM_RBUTTONUP : // Stop hogging the cursor
case WM_MBUTTONUP : // The middle mouse button was released. if (!(--mouse_down))
case WM_MOUSEMOVE : ReleaseCapture();
case 0x020A: // fuc&ing windows b.s... // 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:
{ {
if (gClient && gClient->WindowActive() && gClient->GetInputManager()) if (gClient && gClient->GetInputManager())
{
gClient->GetInputManager()->HandleWin32ControlEvent(message, wParam, lParam, hWnd); gClient->GetInputManager()->HandleWin32ControlEvent(message, wParam, lParam, hWnd);
}
} }
break; break;
@ -457,6 +472,26 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
} }
break; break;
case WM_SETCURSOR:
{
static bool winCursor = true;
bool enterWnd = LOWORD(lParam) == HTCLIENT;
if (enterWnd && winCursor)
{
winCursor = !winCursor;
ShowCursor(winCursor != 0);
plMouseDevice::ShowCursor();
}
else if (!enterWnd && !winCursor)
{
winCursor = !winCursor;
ShowCursor(winCursor != 0);
plMouseDevice::HideCursor();
}
return TRUE;
}
break;
case WM_ACTIVATE: case WM_ACTIVATE:
{ {
bool active = (LOWORD(wParam) == WA_ACTIVE || LOWORD(wParam) == WA_CLICKACTIVE); bool active = (LOWORD(wParam) == WA_ACTIVE || LOWORD(wParam) == WA_CLICKACTIVE);
@ -469,25 +504,6 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
if (gClient && !minimized && !gClient->GetDone()) 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); gClient->WindowActivate(active);
} }
else else

24
Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.cpp

@ -750,27 +750,3 @@ bool plMouseDevice::MsgReceive(plMessage* msg)
} }
return false; 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 );
}
}

1
Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.h

@ -160,7 +160,6 @@ public:
~plMouseDevice(); ~plMouseDevice();
const char* GetInputName() { return "mouse"; } const char* GetInputName() { return "mouse"; }
void HandleWindowActivate(bool bActive, hsWindowHndl hWnd);
bool HasControlFlag(int f) const { return fControlFlags.IsBitSet(f); } bool HasControlFlag(int f) const { return fControlFlags.IsBitSet(f); }
void SetControlFlag(int f) void SetControlFlag(int f)

4
Sources/Plasma/PubUtilLib/plInputCore/plInputManager.cpp

@ -584,8 +584,6 @@ void plDInputMgr::AddDevice(IDirectInputDevice8* device)
void plDInputMgr::ConfigureDevice() void plDInputMgr::ConfigureDevice()
{ {
::ShowCursor( TRUE ); ::ShowCursor( TRUE );
ReleaseCapture();
DICOLORSET dics; DICOLORSET dics;
ZeroMemory(&dics, sizeof(DICOLORSET)); ZeroMemory(&dics, sizeof(DICOLORSET));
@ -607,8 +605,6 @@ void plDInputMgr::ConfigureDevice()
fDI->fSticks[i]->fDevice->SetActionMap( fDI->fActionFormat, NULL, DIDSAM_FORCESAVE ); fDI->fSticks[i]->fDevice->SetActionMap( fDI->fActionFormat, NULL, DIDSAM_FORCESAVE );
::ShowCursor( FALSE ); ::ShowCursor( FALSE );
SetCapture(fhWnd);
} }
bool plDInputMgr::MsgReceive(plMessage* msg) bool plDInputMgr::MsgReceive(plMessage* msg)

3
Sources/Plasma/PubUtilLib/plPipeline/plDXPipeline.cpp

@ -2247,7 +2247,6 @@ bool plDXPipeline::IResetDevice()
{ {
IClearShadowSlaves(); IClearShadowSlaves();
ReleaseCapture();
Sleep(100); Sleep(100);
HRESULT coopLev = fD3DDevice->TestCooperativeLevel(); HRESULT coopLev = fD3DDevice->TestCooperativeLevel();
if( coopLev == D3DERR_DEVICELOST ) if( coopLev == D3DERR_DEVICELOST )
@ -2295,8 +2294,6 @@ bool plDXPipeline::IResetDevice()
/// all device-specific stuff needs to be recreated /// all device-specific stuff needs to be recreated
plDeviceRecreateMsg* clean = new plDeviceRecreateMsg(); plDeviceRecreateMsg* clean = new plDeviceRecreateMsg();
plgDispatch::MsgSend(clean); plgDispatch::MsgSend(clean);
SetCapture(fSettings.fHWnd);
} }
fDevWasLost = true; fDevWasLost = true;
fDeviceLost = false; fDeviceLost = false;

Loading…
Cancel
Save