Skip to content

Commit ac222fe

Browse files
author
Pavel Kovalenko
committed
Always center screen in windowed mode.
1 parent e762d26 commit ac222fe

File tree

2 files changed

+29
-56
lines changed

2 files changed

+29
-56
lines changed

src/Layers/xrRender/HW.cpp

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -539,10 +539,10 @@ void CHW::updateWindowProps (HWND m_hWnd)
539539
// Set window properties depending on what mode were in.
540540
if (bWindowed) {
541541
if (m_move_window) {
542-
if (strstr(Core.Params,"-no_dialog_header"))
543-
SetWindowLong ( m_hWnd, GWL_STYLE, dwWindowStyle=(WS_BORDER|WS_VISIBLE) );
544-
else
545-
SetWindowLong ( m_hWnd, GWL_STYLE, dwWindowStyle=(WS_BORDER|WS_DLGFRAME|WS_VISIBLE|WS_SYSMENU|WS_MINIMIZEBOX ) );
542+
dwWindowStyle = WS_BORDER | WS_VISIBLE;
543+
if (!strstr(Core.Params, "-no_dialog_header"))
544+
dwWindowStyle |= WS_DLGFRAME | WS_SYSMENU | WS_MINIMIZEBOX;
545+
SetWindowLong(m_hWnd, GWL_STYLE, dwWindowStyle);
546546
// When moving from fullscreen to windowed mode, it is important to
547547
// adjust the window size after recreating the device rather than
548548
// beforehand to ensure that you get the window size you want. For
@@ -553,38 +553,22 @@ void CHW::updateWindowProps (HWND m_hWnd)
553553
// desktop.
554554

555555
RECT m_rcWindowBounds;
556-
BOOL bCenter = FALSE;
557-
if (strstr(Core.Params, "-center_screen")) bCenter = TRUE;
558-
559-
#ifndef _EDITOR
560-
if (g_dedicated_server)
561-
bCenter = TRUE;
562-
#endif
563-
564-
if(bCenter){
565-
RECT DesktopRect;
556+
RECT DesktopRect;
566557

567-
GetClientRect (GetDesktopWindow(), &DesktopRect);
568-
569-
SetRect( &m_rcWindowBounds,
570-
(DesktopRect.right-DevPP.BackBufferWidth)/2,
571-
(DesktopRect.bottom-DevPP.BackBufferHeight)/2,
572-
(DesktopRect.right+DevPP.BackBufferWidth)/2,
573-
(DesktopRect.bottom+DevPP.BackBufferHeight)/2 );
574-
}else{
575-
SetRect( &m_rcWindowBounds,
576-
0,
577-
0,
578-
DevPP.BackBufferWidth,
579-
DevPP.BackBufferHeight );
580-
};
558+
GetClientRect (GetDesktopWindow(), &DesktopRect);
559+
560+
SetRect( &m_rcWindowBounds,
561+
(DesktopRect.right-DevPP.BackBufferWidth)/2,
562+
(DesktopRect.bottom-DevPP.BackBufferHeight)/2,
563+
(DesktopRect.right+DevPP.BackBufferWidth)/2,
564+
(DesktopRect.bottom+DevPP.BackBufferHeight)/2 );
581565

582566
AdjustWindowRect ( &m_rcWindowBounds, dwWindowStyle, FALSE );
583567

584568
SetWindowPos ( m_hWnd,
585569
HWND_NOTOPMOST,
586-
m_rcWindowBounds.left,
587-
m_rcWindowBounds.top,
570+
m_rcWindowBounds.left,
571+
m_rcWindowBounds.top,
588572
( m_rcWindowBounds.right - m_rcWindowBounds.left ),
589573
( m_rcWindowBounds.bottom - m_rcWindowBounds.top ),
590574
SWP_SHOWWINDOW|SWP_NOCOPYBITS|SWP_DRAWFRAME );

src/Layers/xrRenderDX10/dx10HW.cpp

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -744,10 +744,10 @@ void CHW::updateWindowProps(HWND m_hWnd)
744744
// Set window properties depending on what mode were in.
745745
if (bWindowed) {
746746
if (m_move_window) {
747-
if (strstr(Core.Params,"-no_dialog_header"))
748-
SetWindowLong ( m_hWnd, GWL_STYLE, dwWindowStyle=(WS_BORDER|WS_VISIBLE) );
749-
else
750-
SetWindowLong ( m_hWnd, GWL_STYLE, dwWindowStyle=(WS_BORDER|WS_DLGFRAME|WS_VISIBLE|WS_SYSMENU|WS_MINIMIZEBOX ) );
747+
dwWindowStyle = WS_BORDER | WS_VISIBLE;
748+
if (!strstr(Core.Params, "-no_dialog_header"))
749+
dwWindowStyle |= WS_DLGFRAME | WS_SYSMENU | WS_MINIMIZEBOX;
750+
SetWindowLong(m_hWnd, GWL_STYLE, dwWindowStyle);
751751
// When moving from fullscreen to windowed mode, it is important to
752752
// adjust the window size after recreating the device rather than
753753
// beforehand to ensure that you get the window size you want. For
@@ -758,33 +758,22 @@ void CHW::updateWindowProps(HWND m_hWnd)
758758
// desktop.
759759

760760
RECT m_rcWindowBounds;
761-
BOOL bCenter = FALSE;
762-
if (strstr(Core.Params, "-center_screen")) bCenter = TRUE;
763-
764-
if (bCenter) {
765-
RECT DesktopRect;
766-
767-
GetClientRect (GetDesktopWindow(), &DesktopRect);
768-
769-
SetRect( &m_rcWindowBounds,
770-
(DesktopRect.right-m_ChainDesc.BufferDesc.Width)/2,
771-
(DesktopRect.bottom-m_ChainDesc.BufferDesc.Height)/2,
772-
(DesktopRect.right+m_ChainDesc.BufferDesc.Width)/2,
773-
(DesktopRect.bottom+m_ChainDesc.BufferDesc.Height)/2);
774-
}else{
775-
SetRect( &m_rcWindowBounds,
776-
0,
777-
0,
778-
m_ChainDesc.BufferDesc.Width,
779-
m_ChainDesc.BufferDesc.Height);
780-
};
761+
RECT DesktopRect;
762+
763+
GetClientRect (GetDesktopWindow(), &DesktopRect);
764+
765+
SetRect( &m_rcWindowBounds,
766+
(DesktopRect.right-m_ChainDesc.BufferDesc.Width)/2,
767+
(DesktopRect.bottom-m_ChainDesc.BufferDesc.Height)/2,
768+
(DesktopRect.right+m_ChainDesc.BufferDesc.Width)/2,
769+
(DesktopRect.bottom+m_ChainDesc.BufferDesc.Height)/2);
781770

782771
AdjustWindowRect ( &m_rcWindowBounds, dwWindowStyle, FALSE );
783772

784773
SetWindowPos ( m_hWnd,
785774
HWND_NOTOPMOST,
786-
m_rcWindowBounds.left,
787-
m_rcWindowBounds.top,
775+
m_rcWindowBounds.left,
776+
m_rcWindowBounds.top,
788777
( m_rcWindowBounds.right - m_rcWindowBounds.left ),
789778
( m_rcWindowBounds.bottom - m_rcWindowBounds.top ),
790779
SWP_SHOWWINDOW|SWP_NOCOPYBITS|SWP_DRAWFRAME );

0 commit comments

Comments
 (0)