@@ -58,7 +58,6 @@ void CRenderDevice::Create()
5858 psDeviceFlags.set (rsFullscreen, false );
5959
6060 FillVidModesToken (Vid_SelectedMonitor);
61- SelectResolution (!psDeviceFlags.is (rsFullscreen));
6261 UpdateWindowProps (!psDeviceFlags.is (rsFullscreen));
6362 GEnv.Render ->Create (m_sdlWnd, dwWidth, dwHeight, fWidth_2 , fHeight_2 );
6463
@@ -73,49 +72,20 @@ void CRenderDevice::Create()
7372 PreCache (0 , false , false );
7473}
7574
76- void CRenderDevice::UpdateWindowProps (bool windowed)
75+ void CRenderDevice::UpdateWindowProps (const bool windowed)
7776{
7877 SelectResolution (windowed);
7978
8079 SDL_SetWindowFullscreen (m_sdlWnd, windowed ? 0 : SDL_WINDOW_FULLSCREEN);
81- SDL_Rect rect;
8280
8381 // Set window properties depending on what mode were in.
8482 if (windowed)
85- {
86- const bool drawBorders = strstr (Core.Params , " -draw_borders" );
87- if (drawBorders)
88- SDL_SetWindowBordered (m_sdlWnd, SDL_TRUE);
89-
9083 SDL_SetWindowSize (m_sdlWnd, psCurrentVidMode[0 ], psCurrentVidMode[1 ]);
91-
92- if (GEnv.isDedicatedServer || strstr (Core.Params , " -center_screen" ))
93- SDL_SetWindowPosition (m_sdlWnd, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
94- else
95- {
96- SDL_GetDisplayUsableBounds (Vid_SelectedMonitor, &rect);
97-
98- int top = 0 , left = 0 , right = 0 , bottom = 0 ;
99- // SDL_GetWindowBordersSize(m_sdlWnd, &top, &left, &bottom, &right);
100- #ifdef WINDOWS
101- // XXX: Currently SDL_GetWindowBordersSize is supported only on X11
102- // For now we must use method below.
103- if (drawBorders)
104- top = GetSystemMetrics (SM_CYCAPTION); // size of the window title bar
105- #else
106- #pragma TODO("Implement for other platforms")
107- #endif
108- SDL_SetWindowPosition (m_sdlWnd, rect.x + left, rect.y + top);
109- }
110-
111- SDL_GetWindowPosition (m_sdlWnd, &m_rcWindowClient.x , &m_rcWindowClient.y );
112- int w = 0 , h = 0 ;
113- SDL_GetWindowSize (m_sdlWnd, &w, &h);
114- m_rcWindowClient.w = m_rcWindowClient.x + w;
115- m_rcWindowClient.h = m_rcWindowClient.y + h;
116- }
11784 else
11885 {
86+ // XXX: fix monitor selection
87+ // it appears to be buggy
88+ SDL_Rect rect;
11989 SDL_GetDisplayBounds (Vid_SelectedMonitor, &rect);
12090 SDL_SetWindowPosition (m_sdlWnd, rect.x , rect.y );
12191 SDL_DisplayMode mode;
@@ -126,31 +96,35 @@ void CRenderDevice::UpdateWindowProps(bool windowed)
12696 SDL_SetWindowDisplayMode (m_sdlWnd, &mode);
12797 }
12898
129- if (!GEnv.isDedicatedServer )
130- SDL_SetWindowGrab (m_sdlWnd, SDL_TRUE);
131-
132- UpdateWindowRect ();
99+ UpdateWindowRects ();
133100 SDL_FlushEvents (SDL_WINDOWEVENT, SDL_SYSWMEVENT);
134101}
135102
136103
137- void CRenderDevice::UpdateWindowRect ()
104+ void CRenderDevice::UpdateWindowRects ()
138105{
139- SDL_GetWindowPosition (m_sdlWnd, &m_rcWindowClient.x , &m_rcWindowClient.y );
106+ m_rcWindowClient.x = 0 ;
107+ m_rcWindowClient.y = 0 ;
140108 SDL_GetWindowSize (m_sdlWnd, &m_rcWindowClient.w , &m_rcWindowClient.h );
141- m_rcWindowClient.w += m_rcWindowClient.x ;
142- m_rcWindowClient.h += m_rcWindowClient.y ;
109+
110+ SDL_GetWindowPosition (m_sdlWnd, &m_rcWindowBounds.x , &m_rcWindowBounds.y );
111+ SDL_GetWindowSize (m_sdlWnd, &m_rcWindowBounds.w , &m_rcWindowBounds.h );
112+ m_rcWindowBounds.w += m_rcWindowBounds.x ;
113+ m_rcWindowBounds.h += m_rcWindowBounds.y ;
114+
115+ // Do we need code below?
116+ int top, left, bottom, right;
117+ SDL_GetWindowBordersSize (m_sdlWnd, &top, &left, &bottom, &right);
118+ m_rcWindowBounds.x -= left;
119+ m_rcWindowBounds.y -= top;
120+ m_rcWindowBounds.w += right;
121+ m_rcWindowBounds.h += bottom;
122+ // XXX: check if we need this code when SDL_GetWindowBordersSize
123+ // will be available for Windows
143124}
144125
145- void CRenderDevice::SelectResolution (bool windowed)
126+ void CRenderDevice::SelectResolution (const bool windowed)
146127{
147- if (GEnv.isDedicatedServer )
148- {
149- dwWidth = 640 ;
150- dwHeight = 480 ;
151- return ;
152- }
153-
154128 if (windowed)
155129 {
156130 dwWidth = psCurrentVidMode[0 ];
@@ -172,7 +146,7 @@ void CRenderDevice::SelectResolution(bool windowed)
172146 if (SDL_GetClosestDisplayMode (Vid_SelectedMonitor, ¤t, &closest))
173147 xr_sprintf (buff, sizeof (buff), " vid_mode %dx%d" , closest.w , closest.h );
174148 else
175- xr_sprintf (buff, sizeof (buff), " vid_mode %s" , VidModesToken[ 0 ]. name );
149+ xr_sprintf (buff, sizeof (buff), " vid_mode %s" , VidModesToken. back () );
176150
177151 Console->Execute (buff);
178152 }
0 commit comments