2
3
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-15 10:54:18 +00:00

Compare commits

..

3 Commits

Author SHA1 Message Date
76ee9975b7 Window shouldn't have a resizing border.
This removes the WS_THICKFRAME & WS_MAXIMIZEBOX window styles in windowed mode.
2012-10-02 12:11:30 +10:00
eba0968808 Avoid truncated window size after going from fullscreen to a window of the same size.
Must set the window size after the display resolution, otherwise Windows may clamp it to a smaller size than specified.
2012-06-17 00:38:07 +02:00
f4b3a43026 Fix improperly calculated window size in initial Windowed mode. 2011-07-20 23:07:46 -07:00
8 changed files with 130 additions and 137 deletions

View File

@ -767,7 +767,7 @@ hsBool plClient::MsgReceive(plMessage* msg)
{
ISetGraphicsDefaults();
ResetDisplayDevice(plPipeline::fDefaultPipeParams.Width, plPipeline::fDefaultPipeParams.Height, plPipeline::fDefaultPipeParams.ColorDepth, plPipeline::fDefaultPipeParams.Windowed,
plPipeline::fDefaultPipeParams.AntiAliasingAmount, plPipeline::fDefaultPipeParams.AnisotropicLevel, plPipeline::fDefaultPipeParams.VSync, true);
plPipeline::fDefaultPipeParams.AntiAliasingAmount, plPipeline::fDefaultPipeParams.AnisotropicLevel, plPipeline::fDefaultPipeParams.VSync);
}
break;
@ -1546,7 +1546,6 @@ 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;
@ -2165,54 +2164,61 @@ hsG3DDeviceModeRecord plClient::ILoadDevMode(const char* devModeFile)
return dmr;
}
void plClient::ResetDisplayDevice(int Width, int Height, int ColorDepth, hsBool Windowed, int NumAASamples, int MaxAnisotropicSamples, hsBool VSync, hsBool windowOnly)
void plClient::ResetDisplayDevice(int Width, int Height, int ColorDepth, hsBool Windowed, int NumAASamples, int MaxAnisotropicSamples, hsBool VSync)
{
if(!fPipeline) return;
int BorderWidth = 0, BorderHeight = 0, CaptionHeight = 0;
WindowActivate(false);
int ActualWidth;
int ActualHeight;
if( Windowed )
{
BorderWidth = GetSystemMetrics( SM_CXSIZEFRAME );
BorderHeight = GetSystemMetrics( SM_CYSIZEFRAME );
CaptionHeight = GetSystemMetrics( SM_CYCAPTION );
ActualWidth = Width + BorderWidth * 2;
ActualHeight = Height + BorderHeight * 2 + CaptionHeight;
SetWindowLong( fWindowHndl, GWL_STYLE,
WS_POPUP | WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE);
SetWindowLong(fWindowHndl, GWL_EXSTYLE, 0);
}
else
{
SetWindowLong(fWindowHndl, GWL_STYLE,
WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_MAXIMIZE | WS_VISIBLE);
SetWindowLong(fWindowHndl, GWL_EXSTYLE, WS_EX_APPWINDOW);
}
if(!windowOnly)
fPipeline->ResetDisplayDevice(Width, Height, ColorDepth, Windowed, NumAASamples, MaxAnisotropicSamples, VSync);
float aspectratio = (float)Width / (float)Height;
plMouseDevice::Instance()->SetDisplayResolution((float)Width, (float)Height);
pfGameGUIMgr::GetInstance()->SetAspectRatio( aspectratio );
UINT flags = SWP_NOCOPYBITS | SWP_NOMOVE | SWP_SHOWWINDOW;
if(Windowed)
{
SetWindowPos( fWindowHndl, HWND_NOTOPMOST, 0, 0, ActualWidth, ActualHeight, flags );
}
else
{
SetWindowPos( fWindowHndl, HWND_TOP, 0, 0, Width, Height, flags );
}
fPipeline->ResetDisplayDevice(Width, Height, ColorDepth, Windowed, NumAASamples, MaxAnisotropicSamples, VSync);
ResizeDisplayDevice(Width, Height, Windowed);
WindowActivate(true);
}
void plClient::ResizeDisplayDevice(int Width, int Height, hsBool Windowed)
{
if (plMouseDevice::Instance())
plMouseDevice::Instance()->SetDisplayResolution((float)Width, (float)Height);
float aspectratio = (float)Width / (float)Height;
if (pfGameGUIMgr::GetInstance())
pfGameGUIMgr::GetInstance()->SetAspectRatio( aspectratio );
UInt32 winStyle, winExStyle;
if( Windowed )
{
// WS_VISIBLE appears necessary to avoid leaving behind framebuffer junk when going from windowed to a smaller window
winStyle = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_VISIBLE;
winExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
} else {
winStyle = WS_POPUP;
winExStyle = WS_EX_APPWINDOW;
}
SetWindowLong(fWindowHndl, GWL_STYLE, winStyle);
SetWindowLong(fWindowHndl, GWL_EXSTYLE, winExStyle);
UInt32 flags = SWP_NOCOPYBITS | SWP_SHOWWINDOW | SWP_FRAMECHANGED;
UInt32 OutsideWidth, OutsideHeight;
HWND insertAfter;
if( Windowed )
{
RECT winRect = { 0, 0, Width, Height };
AdjustWindowRectEx(&winRect, winStyle, false, winExStyle);
OutsideWidth = winRect.right - winRect.left;
OutsideHeight = winRect.bottom - winRect.top;
insertAfter = HWND_NOTOPMOST;
} else {
OutsideWidth = Width;
OutsideHeight = Height;
insertAfter = HWND_TOP;
}
SetWindowPos( fWindowHndl, insertAfter, 0, 0, OutsideWidth, OutsideHeight, flags );
}
void WriteBool(hsStream *stream, char *name, hsBool on )
{

View File

@ -292,7 +292,8 @@ public:
virtual hsBool WindowActive() const { return fWindowActive; }
void SetMessagePumpProc( plMessagePumpProc proc ) { fMessagePumpProc = proc; }
void ResetDisplayDevice(int Width, int Height, int ColorDepth, hsBool Windowed, int NumAASamples, int MaxAnisotropicSamples, hsBool VSync = false, hsBool windowOnly = false);
void ResetDisplayDevice(int Width, int Height, int ColorDepth, hsBool Windowed, int NumAASamples, int MaxAnisotropicSamples, hsBool VSync = false);
void ResizeDisplayDevice(int Width, int Height, hsBool Windowed);
void IDetectAudioVideoSettings();
void IWriteDefaultGraphicsSettings(const wchar* destFile);

View File

@ -57,7 +57,6 @@ 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"
@ -432,48 +431,34 @@ void DebugMsgF(const char* format, ...);
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static bool gDragging = false;
static UInt8 mouse_down = 0;
static UInt32 keyState=0;
// Handle messages
switch (message) {
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_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.
// If they did anything but move the mouse, quit any intro movie playing.
if (gClient)
{
gClient->SetQuitIntro(true);
// normal input processing
if (gClient->WindowActive() && gClient->GetInputManager())
gClient->GetInputManager()->HandleWin32ControlEvent(message, wParam, lParam, hWnd);
if( gClient )
gClient->SetQuitIntro(true);
}
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:
// Fall through to other events
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...
{
if (gClient && gClient->GetInputManager())
if (gClient && gClient->WindowActive() && gClient->GetInputManager())
{
gClient->GetInputManager()->HandleWin32ControlEvent(message, wParam, lParam, hWnd);
}
}
break;
@ -512,31 +497,6 @@ 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);
@ -548,7 +508,28 @@ 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;
@ -804,11 +785,6 @@ bool InitClient( HWND hWnd )
#ifdef DETACH_EXE
hInstance = ((LPCREATESTRUCT) lParam)->hInstance;
#endif
// If in fullscreen mode, get rid of the window borders. Note: this won't take
// effect until the next SetWindowPos call
#ifdef DETACH_EXE
// This Function loads the EXE into Virtual memory...supposedly
HRESULT hr = DetachFromMedium(hInstance, DMDFM_ALWAYS | DMDFM_ALLPAGES);
@ -818,34 +794,7 @@ bool InitClient( HWND hWnd )
gClient->SetDone(true);
else
{
if( gClient->GetPipeline()->IsFullScreen() )
{
SetWindowLong(hWnd, GWL_STYLE, WS_POPUP);
SetWindowLong(hWnd, GWL_EXSTYLE, WS_EX_TOPMOST);
SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
gWinBorderDX = gWinBorderDY = gWinMenuDY = 0;
}
else {
SetWindowLong(hWnd, GWL_STYLE, WS_OVERLAPPED | WS_CAPTION);
SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}
int goodWidth = gClient->GetPipeline()->Width() + gWinBorderDX * 2;
int goodHeight = gClient->GetPipeline()->Height() + gWinBorderDY * 2 + gWinMenuDY;
SetWindowPos(
hWnd,
nil,
0,
0,
goodWidth,
goodHeight,
SWP_NOCOPYBITS
| SWP_NOMOVE
| SWP_NOOWNERZORDER
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
gClient->ResizeDisplayDevice(gClient->GetPipeline()->Width(), gClient->GetPipeline()->Height(), !gClient->GetPipeline()->IsFullScreen());
}
if( gPendingActivate )

View File

@ -155,8 +155,7 @@ void ErrorMinimizeAppWindow () {
// If the application's topmost window is a fullscreen
// popup window, minimize it before displaying an error
HWND appWindow = GetActiveWindow();
if ( ((GetWindowLong(appWindow, GWL_STYLE) & WS_POPUP) != 0) &&
((GetWindowLong(appWindow, GWL_EXSTYLE) & WS_EX_TOPMOST) != 0) )
if ( ((GetWindowLong(appWindow, GWL_STYLE) & WS_POPUP) != 0) )
SetWindowPos(
appWindow,
HWND_NOTOPMOST,

View File

@ -933,3 +933,28 @@ 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 );
::ClipCursor(&rect);
::ShowCursor( FALSE );
SetCapture(hWnd);
}
else
{
ReleaseCapture();
::ClipCursor(nil);
::ShowCursor( TRUE );
}
}

View File

@ -173,6 +173,7 @@ 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)

View File

@ -563,7 +563,10 @@ void plDInputMgr::AddDevice(IDirectInputDevice8* device)
void plDInputMgr::ConfigureDevice()
{
::ClipCursor(nil);
::ShowCursor( TRUE );
ReleaseCapture();
DICOLORSET dics;
ZeroMemory(&dics, sizeof(DICOLORSET));
@ -584,7 +587,13 @@ 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);
}
hsBool plDInputMgr::MsgReceive(plMessage* msg)

View File

@ -2233,6 +2233,7 @@ hsBool plDXPipeline::IResetDevice()
{
IClearShadowSlaves();
ReleaseCapture();
Sleep(100);
HRESULT coopLev = fD3DDevice->TestCooperativeLevel();
if( coopLev == D3DERR_DEVICELOST )
@ -2280,6 +2281,8 @@ 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;