@@ -694,6 +694,12 @@ void CHW::Reset(HWND hwnd)
694694 cd.Windowed = bWindowed;
695695#endif
696696
697+ if (!bWindowed)
698+ {
699+ ShowWindow (hwnd, SW_SHOWNORMAL);
700+ SetForegroundWindow (hwnd);
701+ }
702+
697703 m_pSwapChain->SetFullscreenState (!bWindowed, NULL );
698704
699705#if defined(USE_DX11)
@@ -841,6 +847,7 @@ D3DFORMAT CHW::selectDepthStencil(D3DFORMAT fTarget)
841847}
842848
843849extern void GetMonitorResolution (u32 & horizontal, u32 & vertical);
850+ extern void GetMonitorPosition (int & x, int & y);
844851
845852void CHW::selectResolution (u32 & dwWidth, u32 & dwHeight, BOOL bWindowed)
846853{
@@ -849,12 +856,19 @@ void CHW::selectResolution(u32& dwWidth, u32& dwHeight, BOOL bWindowed)
849856 if (psCurrentVidMode[0 ] == 0 || psCurrentVidMode[1 ] == 0 )
850857 GetMonitorResolution (psCurrentVidMode[0 ], psCurrentVidMode[1 ]);
851858
852- if (bWindowed)
859+ if (g_screenmode == 0 )
860+ {
861+ RECT clientRect;
862+ GetClientRect (Device.m_hWnd , &clientRect);
863+ dwWidth = clientRect.right ;
864+ dwHeight = clientRect.bottom ;
865+ }
866+ else if (g_screenmode == 1 )
853867 {
854868 dwWidth = psCurrentVidMode[0 ];
855- dwHeight = psCurrentVidMode[1 ];
869+ dwHeight = psCurrentVidMode[1 ];
856870 }
857- else // check
871+ else
858872 {
859873 string64 buff;
860874 xr_sprintf (buff, sizeof (buff), " %dx%d" , psCurrentVidMode[0 ], psCurrentVidMode[1 ]);
@@ -1082,15 +1096,23 @@ void CHW::updateWindowProps(HWND m_hWnd)
10821096 // BOOL bWindowed = strstr(Core.Params,"-dedicated") ? TRUE : !psDeviceFlags.is (rsFullscreen);
10831097 BOOL bWindowed = (g_screenmode != 2 );
10841098
1085- u32 dwWindowStyle = 0 ;
10861099 // Set window properties depending on what mode were in.
10871100 if (bWindowed)
10881101 {
10891102 if (m_move_window)
10901103 {
1091- dwWindowStyle = WS_BORDER | WS_VISIBLE;
1092- if (!strstr (Core.Params , " -no_dialog_header" ))
1093- dwWindowStyle |= WS_DLGFRAME | WS_SYSMENU | WS_MINIMIZEBOX;
1104+ u32 dwWindowStyle = 0 ;
1105+ if (g_screenmode == 1 )
1106+ {
1107+ dwWindowStyle |= WS_POPUP;
1108+ }
1109+ else
1110+ {
1111+ dwWindowStyle |= WS_BORDER | WS_OVERLAPPEDWINDOW;
1112+ if (!strstr (Core.Params , " -no_dialog_header" ))
1113+ dwWindowStyle |= WS_DLGFRAME | WS_SYSMENU | WS_MINIMIZEBOX;
1114+ }
1115+
10941116 SetWindowLong (m_hWnd, GWL_STYLE, dwWindowStyle);
10951117 // When moving from fullscreen to windowed mode, it is important to
10961118 // adjust the window size after recreating the device rather than
@@ -1101,39 +1123,39 @@ void CHW::updateWindowProps(HWND m_hWnd)
11011123 // changed to 1024x768, because windows cannot be larger than the
11021124 // desktop.
11031125
1104- RECT m_rcWindowBounds;
1105- RECT DesktopRect;
1126+ u32 monW, monH;
1127+ GetMonitorResolution (monW, monH);
1128+ int monX, monY;
1129+ GetMonitorPosition (monX, monY);
11061130
1107- GetClientRect (GetDesktopWindow (), &DesktopRect);
1131+ if (psCurrentVidMode[0 ] == 0 || psCurrentVidMode[1 ] == 0 )
1132+ GetMonitorResolution (psCurrentVidMode[0 ], psCurrentVidMode[1 ]);
1133+ LONG res_width = g_screenmode == 0 ? psCurrentVidMode[0 ] : monW;
1134+ LONG res_height = g_screenmode == 0 ? psCurrentVidMode[1 ] : monH;
11081135
1109- #if defined(USE_DX11)
1110- UINT res_width = m_ChainDesc.Width ;
1111- UINT res_height = m_ChainDesc.Height ;
1112- #elif defined(USE_DX10)
1113- UINT res_width = m_ChainDesc.BufferDesc .Width ;
1114- UINT res_height = m_ChainDesc.BufferDesc .Height ;
1115- #endif
1136+ RECT m_rcWindowBounds;
1137+ RECT DesktopRect;
11161138
1117- SetRect (&m_rcWindowBounds,
1118- (DesktopRect.right - res_width) / 2 ,
1119- (DesktopRect.bottom - res_height) / 2 ,
1120- (DesktopRect.right + res_width) / 2 ,
1121- (DesktopRect.bottom + res_height) / 2 );
1139+ GetClientRect (GetDesktopWindow (), &DesktopRect);
11221140
1123- AdjustWindowRect (&m_rcWindowBounds, dwWindowStyle, FALSE );
1141+ SetRect (&m_rcWindowBounds,
1142+ (LONG (monW) - res_width) / 2 ,
1143+ (LONG (monH) - res_height) / 2 ,
1144+ (monW + res_width) / 2 ,
1145+ (monH + res_height) / 2 );
11241146
11251147 SetWindowPos (m_hWnd,
11261148 HWND_NOTOPMOST,
1127- m_rcWindowBounds.left ,
1128- m_rcWindowBounds.top ,
1149+ monX + m_rcWindowBounds.left ,
1150+ monY + m_rcWindowBounds.top ,
11291151 (m_rcWindowBounds.right - m_rcWindowBounds.left ),
11301152 (m_rcWindowBounds.bottom - m_rcWindowBounds.top ),
11311153 SWP_SHOWWINDOW | SWP_NOCOPYBITS | SWP_DRAWFRAME);
11321154 }
11331155 }
11341156 else
11351157 {
1136- SetWindowLong (m_hWnd, GWL_STYLE, dwWindowStyle = ( WS_POPUP | WS_VISIBLE) );
1158+ SetWindowLong (m_hWnd, GWL_STYLE, WS_POPUP | WS_VISIBLE);
11371159 }
11381160
11391161 ShowCursor (FALSE );
0 commit comments