Browse Source

Merge pull request #221 from Hoikas/window-fixes

Window fixes
Adam Johnson 12 years ago
parent
commit
8aa9e25ec0
  1. 92
      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

92
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 "plNetClient/plNetClientMgr.h"
#include "plNetClient/plNetLinkingMgr.h"
#include "plInputCore/plInputDevice.h"
#include "plInputCore/plInputManager.h"
#include "plUnifiedTime/plUnifiedTime.h"
#include "plPipeline.h"
@ -370,7 +371,7 @@ void DebugMsgF(const char* format, ...);
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static bool gDragging = false;
static uint32_t keyState=0;
static uint8_t mouse_down = 0;
// Messages we registered for manually (no const value)
if (message == s_WmTaskbarList)
@ -394,32 +395,46 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
nc->ResetServerTimeOffset(true);
break;
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 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 (gClient)
{
if( gClient )
gClient->SetQuitIntro(true);
// normal input processing
if (gClient->WindowActive() && gClient->GetInputManager())
gClient->GetInputManager()->HandleWin32ControlEvent(message, wParam, lParam, hWnd);
}
// Fall through to other events
case WM_CHAR:
case WM_KEYUP :
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...
{
break;
case WM_LBUTTONUP:
case WM_RBUTTONUP:
case WM_MBUTTONUP:
// Stop hogging the cursor
if (!(--mouse_down))
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:
{
if (gClient && gClient->GetInputManager())
gClient->GetInputManager()->HandleWin32ControlEvent(message, wParam, lParam, hWnd);
}
}
break;
#if 0
@ -457,6 +472,26 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
}
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:
{
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 (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

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

@ -750,27 +750,3 @@ bool 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 );
}
}

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

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

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

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

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

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

Loading…
Cancel
Save