Skip to content

Commit

Permalink
Windowed mode now act like borderless by default. (fullscreen in wind…
Browse files Browse the repository at this point in the history
…owed mode is now possible)

Removed startup key from engine: -no_dialog_header
Added new startup key for engine: -draw_borders >>> draw window name\borders and system buttons
  • Loading branch information
ShokerStlk authored and Xottab-DUTY committed Jan 15, 2018
1 parent 7b10da4 commit a9420a8
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 21 deletions.
39 changes: 30 additions & 9 deletions src/Layers/xrRender/HW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ BOOL CHW::support(D3DFORMAT fmt, DWORD type, DWORD usage)
void CHW::updateWindowProps(HWND m_hWnd)
{
bool bWindowed = true;

#ifndef _EDITOR
if (!GEnv.isDedicatedServer)
bWindowed = !psDeviceFlags.is(rsFullscreen);
Expand All @@ -510,9 +511,10 @@ void CHW::updateWindowProps(HWND m_hWnd)
{
if (m_move_window)
{
dwWindowStyle = WS_BORDER | WS_VISIBLE;
if (!strstr(Core.Params, "-no_dialog_header"))
dwWindowStyle |= WS_DLGFRAME | WS_SYSMENU | WS_MINIMIZEBOX;
bool bBordersMode = strstr(Core.Params, "-draw_borders");
dwWindowStyle = WS_VISIBLE;
if (bBordersMode)
dwWindowStyle |= WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_MINIMIZEBOX;
SetWindowLong(m_hWnd, GWL_STYLE, dwWindowStyle);
// When moving from fullscreen to windowed mode, it is important to
// adjust the window size after recreating the device rather than
Expand All @@ -524,17 +526,36 @@ void CHW::updateWindowProps(HWND m_hWnd)
// desktop.

RECT m_rcWindowBounds;
RECT DesktopRect;
float fYOffset = 0.f;
bool bCenter = false;
if (strstr(Core.Params, "-center_screen"))
bCenter = true;

GetClientRect(GetDesktopWindow(), &DesktopRect);
#ifndef _EDITOR
if (GEnv.isDedicatedServer)
bCenter = true;
#endif

if (bCenter)
{
RECT DesktopRect;

SetRect(&m_rcWindowBounds, (DesktopRect.right - DevPP.BackBufferWidth) / 2,
(DesktopRect.bottom - DevPP.BackBufferHeight) / 2, (DesktopRect.right + DevPP.BackBufferWidth) / 2,
(DesktopRect.bottom + DevPP.BackBufferHeight) / 2);
GetClientRect(GetDesktopWindow(), &DesktopRect);

SetRect(&m_rcWindowBounds, (DesktopRect.right - DevPP.BackBufferWidth) / 2,
(DesktopRect.bottom - DevPP.BackBufferHeight) / 2, (DesktopRect.right + DevPP.BackBufferWidth) / 2,
(DesktopRect.bottom + DevPP.BackBufferHeight) / 2);
}
else
{
if (bBordersMode)
fYOffset = GetSystemMetrics(SM_CYCAPTION); // size of the window title bar
SetRect(&m_rcWindowBounds, 0, 0, DevPP.BackBufferWidth, DevPP.BackBufferHeight);
};

AdjustWindowRect(&m_rcWindowBounds, dwWindowStyle, FALSE);

SetWindowPos(m_hWnd, HWND_NOTOPMOST, m_rcWindowBounds.left, m_rcWindowBounds.top,
SetWindowPos(m_hWnd, HWND_NOTOPMOST, m_rcWindowBounds.left, m_rcWindowBounds.top + fYOffset,
(m_rcWindowBounds.right - m_rcWindowBounds.left), (m_rcWindowBounds.bottom - m_rcWindowBounds.top),
SWP_SHOWWINDOW | SWP_NOCOPYBITS | SWP_DRAWFRAME);
}
Expand Down
39 changes: 27 additions & 12 deletions src/Layers/xrRenderDX10/dx10HW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,8 @@ void CHW::CreateDevice(HWND m_hWnd, bool move_window)
#ifdef USE_DX11
D3D_FEATURE_LEVEL pFeatureLevels[] = {
D3D_FEATURE_LEVEL_11_0,
//D3D_FEATURE_LEVEL_10_1,
//D3D_FEATURE_LEVEL_10_0,
// D3D_FEATURE_LEVEL_10_1,
// D3D_FEATURE_LEVEL_10_0,
};

R = D3D11CreateDeviceAndSwapChain(
Expand Down Expand Up @@ -713,9 +713,10 @@ void CHW::updateWindowProps(HWND m_hWnd)
{
if (m_move_window)
{
dwWindowStyle = WS_BORDER | WS_VISIBLE;
if (!strstr(Core.Params, "-no_dialog_header"))
dwWindowStyle |= WS_DLGFRAME | WS_SYSMENU | WS_MINIMIZEBOX;
bool bBordersMode = strstr(Core.Params, "-draw_borders");
dwWindowStyle = WS_VISIBLE;
if (bBordersMode)
dwWindowStyle |= WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_MINIMIZEBOX;
SetWindowLong(m_hWnd, GWL_STYLE, dwWindowStyle);
// When moving from fullscreen to windowed mode, it is important to
// adjust the window size after recreating the device rather than
Expand All @@ -727,18 +728,32 @@ void CHW::updateWindowProps(HWND m_hWnd)
// desktop.

RECT m_rcWindowBounds;
RECT DesktopRect;
float fYOffset = 0.f;
bool bCenter = false;
if (strstr(Core.Params, "-center_screen"))
bCenter = true;

GetClientRect(GetDesktopWindow(), &DesktopRect);
if (bCenter)
{
RECT DesktopRect;

GetClientRect(GetDesktopWindow(), &DesktopRect);

SetRect(&m_rcWindowBounds, (DesktopRect.right - m_ChainDesc.BufferDesc.Width) / 2,
(DesktopRect.bottom - m_ChainDesc.BufferDesc.Height) / 2,
(DesktopRect.right + m_ChainDesc.BufferDesc.Width) / 2,
(DesktopRect.bottom + m_ChainDesc.BufferDesc.Height) / 2);
SetRect(&m_rcWindowBounds, (DesktopRect.right - m_ChainDesc.BufferDesc.Width) / 2,
(DesktopRect.bottom - m_ChainDesc.BufferDesc.Height) / 2,
(DesktopRect.right + m_ChainDesc.BufferDesc.Width) / 2,
(DesktopRect.bottom + m_ChainDesc.BufferDesc.Height) / 2);
}
else
{
if (bBordersMode)
fYOffset = GetSystemMetrics(SM_CYCAPTION); // size of the window title bar
SetRect(&m_rcWindowBounds, 0, 0, m_ChainDesc.BufferDesc.Width, m_ChainDesc.BufferDesc.Height);
};

AdjustWindowRect(&m_rcWindowBounds, dwWindowStyle, FALSE);

SetWindowPos(m_hWnd, HWND_NOTOPMOST, m_rcWindowBounds.left, m_rcWindowBounds.top,
SetWindowPos(m_hWnd, HWND_NOTOPMOST, m_rcWindowBounds.left, m_rcWindowBounds.top + fYOffset,
(m_rcWindowBounds.right - m_rcWindowBounds.left), (m_rcWindowBounds.bottom - m_rcWindowBounds.top),
SWP_SHOWWINDOW | SWP_NOCOPYBITS | SWP_DRAWFRAME);
}
Expand Down

0 comments on commit a9420a8

Please sign in to comment.