@@ -64,7 +64,7 @@ void CHW::DestroyD3D()
6464 _RELEASE (m_pFactory);
6565}
6666
67- void CHW::CreateDevice (SDL_Window* hWnd , bool move_window)
67+ void CHW::CreateDevice (SDL_Window* m_sdlWnd , bool move_window)
6868{
6969 m_move_window = move_window;
7070 CreateD3D ();
@@ -196,7 +196,7 @@ void CHW::CreateDevice(SDL_Window* hWnd, bool move_window)
196196 Msg (" * Texture memory: %d M" , memory / (1024 * 1024 ));
197197 // Msg("* DDI-level: %2.1f", float(D3DXGetDriverLevel(pDevice)) / 100.f);
198198#ifndef _EDITOR
199- updateWindowProps (m_hWnd );
199+ updateWindowProps (m_sdlWnd );
200200 fill_vid_mode_list (this );
201201#endif
202202}
@@ -240,7 +240,7 @@ void CHW::DestroyDevice()
240240// ////////////////////////////////////////////////////////////////////
241241// Resetting device
242242// ////////////////////////////////////////////////////////////////////
243- void CHW::Reset (HWND hwnd )
243+ void CHW::Reset (SDL_Window* m_sdlWnd )
244244{
245245 DXGI_SWAP_CHAIN_DESC& cd = m_ChainDesc;
246246 BOOL bWindowed = !psDeviceFlags.is (rsFullscreen);
@@ -265,8 +265,8 @@ void CHW::Reset(HWND hwnd)
265265 cd.BufferCount , desc.Width , desc.Height , desc.Format , DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH));
266266 UpdateViews ();
267267
268- updateWindowProps (hwnd );
269- ShowWindow (hwnd, SW_SHOWNORMAL );
268+ updateWindowProps (m_sdlWnd );
269+ SDL_ShowWindow (m_sdlWnd );
270270}
271271
272272D3DFORMAT CHW::selectDepthStencil (D3DFORMAT /* fTarget*/ )
@@ -352,7 +352,7 @@ BOOL CHW::support(D3DFORMAT fmt, DWORD type, DWORD usage)
352352 return TRUE ;
353353}
354354
355- void CHW::updateWindowProps (HWND m_hWnd )
355+ void CHW::updateWindowProps (SDL_Window* m_sdlWnd )
356356{
357357 bool bWindowed = !psDeviceFlags.is (rsFullscreen);
358358
@@ -362,11 +362,8 @@ void CHW::updateWindowProps(HWND m_hWnd)
362362 {
363363 if (m_move_window)
364364 {
365- const bool drawBorders = strstr (Core.Params , " -draw_borders" );
366- dwWindowStyle = WS_VISIBLE;
367- if (drawBorders)
368- dwWindowStyle |= WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_MINIMIZEBOX;
369- SetWindowLong (m_hWnd, GWL_STYLE, dwWindowStyle);
365+ if (NULL != strstr (Core.Params , " -draw_borders" ))
366+ SDL_SetWindowBordered (m_sdlWnd, SDL_TRUE);
370367 // When moving from fullscreen to windowed mode, it is important to
371368 // adjust the window size after recreating the device rather than
372369 // beforehand to ensure that you get the window size you want. For
@@ -376,45 +373,29 @@ void CHW::updateWindowProps(HWND m_hWnd)
376373 // changed to 1024x768, because windows cannot be larger than the
377374 // desktop.
378375
379- RECT m_rcWindowBounds;
380- float fYOffset = 0 .f ;
381376 bool centerScreen = false ;
382- if (strstr (Core.Params , " -center_screen" ))
377+ if (GEnv. isDedicatedServer || strstr (Core.Params , " -center_screen" ))
383378 centerScreen = true ;
384379
380+ SDL_SetWindowSize (m_sdlWnd, m_ChainDesc.BufferDesc .Width , m_ChainDesc.BufferDesc .Height );
381+
385382 if (centerScreen)
386383 {
387- RECT DesktopRect;
388- GetClientRect (GetDesktopWindow (), &DesktopRect);
389-
390- SetRect (&m_rcWindowBounds,
391- (DesktopRect.right - m_ChainDesc.BufferDesc .Width ) / 2 ,
392- (DesktopRect.bottom - m_ChainDesc.BufferDesc .Height ) / 2 ,
393- (DesktopRect.right + m_ChainDesc.BufferDesc .Width ) / 2 ,
394- (DesktopRect.bottom + m_ChainDesc.BufferDesc .Height ) / 2 );
384+ SDL_SetWindowPosition (m_sdlWnd, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
395385 }
396386 else
397387 {
398- if (drawBorders)
399- fYOffset = GetSystemMetrics (SM_CYCAPTION); // size of the window title bar
400- SetRect (&m_rcWindowBounds, 0 , 0 , m_ChainDesc.BufferDesc .Width , m_ChainDesc.BufferDesc .Height );
401- };
402-
403- AdjustWindowRect (&m_rcWindowBounds, dwWindowStyle, FALSE );
404-
405- SetWindowPos (m_hWnd, HWND_NOTOPMOST,
406- m_rcWindowBounds.left , m_rcWindowBounds.top + fYOffset ,
407- m_rcWindowBounds.right - m_rcWindowBounds.left ,
408- m_rcWindowBounds.bottom - m_rcWindowBounds.top ,
409- SWP_HIDEWINDOW | SWP_NOCOPYBITS | SWP_DRAWFRAME);
388+ SDL_SetWindowPosition (m_sdlWnd, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED);
389+ }
410390 }
411391 }
412392 else
413393 {
414- SetWindowLong (m_hWnd, GWL_STYLE, dwWindowStyle = WS_POPUP | WS_VISIBLE );
394+ SDL_ShowWindow (m_sdlWnd );
415395 }
416396
417- SetForegroundWindow (m_hWnd);
397+ if (!GEnv.isDedicatedServer )
398+ SDL_SetWindowGrab (m_sdlWnd, SDL_TRUE);
418399}
419400
420401struct uniqueRenderingMode
0 commit comments