Skip to content

Commit a9420a8

Browse files
ShokerStlkXottab-DUTY
authored andcommitted
Windowed mode now act like borderless by default. (fullscreen in windowed 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
1 parent 7b10da4 commit a9420a8

File tree

2 files changed

+57
-21
lines changed

2 files changed

+57
-21
lines changed

src/Layers/xrRender/HW.cpp

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ BOOL CHW::support(D3DFORMAT fmt, DWORD type, DWORD usage)
499499
void CHW::updateWindowProps(HWND m_hWnd)
500500
{
501501
bool bWindowed = true;
502+
502503
#ifndef _EDITOR
503504
if (!GEnv.isDedicatedServer)
504505
bWindowed = !psDeviceFlags.is(rsFullscreen);
@@ -510,9 +511,10 @@ void CHW::updateWindowProps(HWND m_hWnd)
510511
{
511512
if (m_move_window)
512513
{
513-
dwWindowStyle = WS_BORDER | WS_VISIBLE;
514-
if (!strstr(Core.Params, "-no_dialog_header"))
515-
dwWindowStyle |= WS_DLGFRAME | WS_SYSMENU | WS_MINIMIZEBOX;
514+
bool bBordersMode = strstr(Core.Params, "-draw_borders");
515+
dwWindowStyle = WS_VISIBLE;
516+
if (bBordersMode)
517+
dwWindowStyle |= WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_MINIMIZEBOX;
516518
SetWindowLong(m_hWnd, GWL_STYLE, dwWindowStyle);
517519
// When moving from fullscreen to windowed mode, it is important to
518520
// adjust the window size after recreating the device rather than
@@ -524,17 +526,36 @@ void CHW::updateWindowProps(HWND m_hWnd)
524526
// desktop.
525527

526528
RECT m_rcWindowBounds;
527-
RECT DesktopRect;
529+
float fYOffset = 0.f;
530+
bool bCenter = false;
531+
if (strstr(Core.Params, "-center_screen"))
532+
bCenter = true;
528533

529-
GetClientRect(GetDesktopWindow(), &DesktopRect);
534+
#ifndef _EDITOR
535+
if (GEnv.isDedicatedServer)
536+
bCenter = true;
537+
#endif
538+
539+
if (bCenter)
540+
{
541+
RECT DesktopRect;
530542

531-
SetRect(&m_rcWindowBounds, (DesktopRect.right - DevPP.BackBufferWidth) / 2,
532-
(DesktopRect.bottom - DevPP.BackBufferHeight) / 2, (DesktopRect.right + DevPP.BackBufferWidth) / 2,
533-
(DesktopRect.bottom + DevPP.BackBufferHeight) / 2);
543+
GetClientRect(GetDesktopWindow(), &DesktopRect);
544+
545+
SetRect(&m_rcWindowBounds, (DesktopRect.right - DevPP.BackBufferWidth) / 2,
546+
(DesktopRect.bottom - DevPP.BackBufferHeight) / 2, (DesktopRect.right + DevPP.BackBufferWidth) / 2,
547+
(DesktopRect.bottom + DevPP.BackBufferHeight) / 2);
548+
}
549+
else
550+
{
551+
if (bBordersMode)
552+
fYOffset = GetSystemMetrics(SM_CYCAPTION); // size of the window title bar
553+
SetRect(&m_rcWindowBounds, 0, 0, DevPP.BackBufferWidth, DevPP.BackBufferHeight);
554+
};
534555

535556
AdjustWindowRect(&m_rcWindowBounds, dwWindowStyle, FALSE);
536557

537-
SetWindowPos(m_hWnd, HWND_NOTOPMOST, m_rcWindowBounds.left, m_rcWindowBounds.top,
558+
SetWindowPos(m_hWnd, HWND_NOTOPMOST, m_rcWindowBounds.left, m_rcWindowBounds.top + fYOffset,
538559
(m_rcWindowBounds.right - m_rcWindowBounds.left), (m_rcWindowBounds.bottom - m_rcWindowBounds.top),
539560
SWP_SHOWWINDOW | SWP_NOCOPYBITS | SWP_DRAWFRAME);
540561
}

src/Layers/xrRenderDX10/dx10HW.cpp

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,8 @@ void CHW::CreateDevice(HWND m_hWnd, bool move_window)
332332
#ifdef USE_DX11
333333
D3D_FEATURE_LEVEL pFeatureLevels[] = {
334334
D3D_FEATURE_LEVEL_11_0,
335-
//D3D_FEATURE_LEVEL_10_1,
336-
//D3D_FEATURE_LEVEL_10_0,
335+
// D3D_FEATURE_LEVEL_10_1,
336+
// D3D_FEATURE_LEVEL_10_0,
337337
};
338338

339339
R = D3D11CreateDeviceAndSwapChain(
@@ -713,9 +713,10 @@ void CHW::updateWindowProps(HWND m_hWnd)
713713
{
714714
if (m_move_window)
715715
{
716-
dwWindowStyle = WS_BORDER | WS_VISIBLE;
717-
if (!strstr(Core.Params, "-no_dialog_header"))
718-
dwWindowStyle |= WS_DLGFRAME | WS_SYSMENU | WS_MINIMIZEBOX;
716+
bool bBordersMode = strstr(Core.Params, "-draw_borders");
717+
dwWindowStyle = WS_VISIBLE;
718+
if (bBordersMode)
719+
dwWindowStyle |= WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_MINIMIZEBOX;
719720
SetWindowLong(m_hWnd, GWL_STYLE, dwWindowStyle);
720721
// When moving from fullscreen to windowed mode, it is important to
721722
// adjust the window size after recreating the device rather than
@@ -727,18 +728,32 @@ void CHW::updateWindowProps(HWND m_hWnd)
727728
// desktop.
728729

729730
RECT m_rcWindowBounds;
730-
RECT DesktopRect;
731+
float fYOffset = 0.f;
732+
bool bCenter = false;
733+
if (strstr(Core.Params, "-center_screen"))
734+
bCenter = true;
731735

732-
GetClientRect(GetDesktopWindow(), &DesktopRect);
736+
if (bCenter)
737+
{
738+
RECT DesktopRect;
739+
740+
GetClientRect(GetDesktopWindow(), &DesktopRect);
733741

734-
SetRect(&m_rcWindowBounds, (DesktopRect.right - m_ChainDesc.BufferDesc.Width) / 2,
735-
(DesktopRect.bottom - m_ChainDesc.BufferDesc.Height) / 2,
736-
(DesktopRect.right + m_ChainDesc.BufferDesc.Width) / 2,
737-
(DesktopRect.bottom + m_ChainDesc.BufferDesc.Height) / 2);
742+
SetRect(&m_rcWindowBounds, (DesktopRect.right - m_ChainDesc.BufferDesc.Width) / 2,
743+
(DesktopRect.bottom - m_ChainDesc.BufferDesc.Height) / 2,
744+
(DesktopRect.right + m_ChainDesc.BufferDesc.Width) / 2,
745+
(DesktopRect.bottom + m_ChainDesc.BufferDesc.Height) / 2);
746+
}
747+
else
748+
{
749+
if (bBordersMode)
750+
fYOffset = GetSystemMetrics(SM_CYCAPTION); // size of the window title bar
751+
SetRect(&m_rcWindowBounds, 0, 0, m_ChainDesc.BufferDesc.Width, m_ChainDesc.BufferDesc.Height);
752+
};
738753

739754
AdjustWindowRect(&m_rcWindowBounds, dwWindowStyle, FALSE);
740755

741-
SetWindowPos(m_hWnd, HWND_NOTOPMOST, m_rcWindowBounds.left, m_rcWindowBounds.top,
756+
SetWindowPos(m_hWnd, HWND_NOTOPMOST, m_rcWindowBounds.left, m_rcWindowBounds.top + fYOffset,
742757
(m_rcWindowBounds.right - m_rcWindowBounds.left), (m_rcWindowBounds.bottom - m_rcWindowBounds.top),
743758
SWP_SHOWWINDOW | SWP_NOCOPYBITS | SWP_DRAWFRAME);
744759
}

0 commit comments

Comments
 (0)