@@ -91,7 +91,7 @@ void VideoSDL2::UpdateCurrentSizes()
9191 SetNewSize (VideoMode (w, h), Extent (w2, h2));
9292}
9393
94- bool VideoSDL2::CreateScreen (const std::string& title, const VideoMode& size, bool fullscreen )
94+ bool VideoSDL2::CreateScreen (const std::string& title, const VideoMode& size, DisplayMode displayMode )
9595{
9696 if (!initialized)
9797 return false ;
@@ -113,30 +113,33 @@ bool VideoSDL2::CreateScreen(const std::string& title, const VideoMode& size, bo
113113 CHECK_SDL (SDL_GL_SetAttribute (SDL_GL_BLUE_SIZE, 8 ));
114114 CHECK_SDL (SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1 ));
115115
116- int wndPos = SDL_WINDOWPOS_CENTERED;
117-
116+ const int wndPos = SDL_WINDOWPOS_CENTERED;
117+ const auto fullscreen = (displayMode & DisplayMode::Fullscreen) != DisplayMode::None;
118+ const auto resizable = (displayMode & DisplayMode::Resizable) != DisplayMode::None;
118119 const auto requestedSize = fullscreen ? FindClosestVideoMode (size) : size;
120+ const unsigned commonFlags = SDL_WINDOW_OPENGL | (resizable ? SDL_WINDOW_RESIZABLE : 0 );
121+ const unsigned fullscreenFlag = (fullscreen ? SDL_WINDOW_FULLSCREEN : 0 );
119122
120123 window = SDL_CreateWindow (title.c_str (), wndPos, wndPos, requestedSize.width , requestedSize.height ,
121- SDL_WINDOW_OPENGL | (fullscreen ? SDL_WINDOW_FULLSCREEN : SDL_WINDOW_RESIZABLE) );
124+ commonFlags | fullscreenFlag );
122125
123126 // Fallback to non-fullscreen
124127 if (!window && fullscreen)
125- {
126- window = SDL_CreateWindow (title.c_str (), wndPos, wndPos, requestedSize.width , requestedSize.height ,
127- SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE);
128- }
128+ window =
129+ SDL_CreateWindow (title.c_str (), wndPos, wndPos, requestedSize.width , requestedSize.height , commonFlags);
129130
130131 if (!window)
131132 {
132133 PrintError (SDL_GetError ());
133134 return false ;
134135 }
135136
136- isFullscreen_ = (SDL_GetWindowFlags (window) & SDL_WINDOW_FULLSCREEN) != 0 ;
137+ const auto flags = SDL_GetWindowFlags (window);
138+ SetFullscreenFlag ((flags & SDL_WINDOW_FULLSCREEN) != 0 );
139+ SetResizableFlag ((flags & SDL_WINDOW_RESIZABLE) != 0 );
137140 UpdateCurrentSizes ();
138141
139- if (!isFullscreen_ )
142+ if (!IsFullscreen () )
140143 MoveWindowToCenter ();
141144
142145 SDL_Surface* iconSurf =
@@ -161,27 +164,34 @@ bool VideoSDL2::CreateScreen(const std::string& title, const VideoMode& size, bo
161164 return true ;
162165}
163166
164- bool VideoSDL2::ResizeScreen (const VideoMode& newSize, bool fullscreen )
167+ bool VideoSDL2::ResizeScreen (const VideoMode& newSize, DisplayMode displayMode )
165168{
166169 if (!initialized)
167170 return false ;
168171
169- if (isFullscreen_ != fullscreen)
172+ const auto fullscreen = (displayMode & DisplayMode::Fullscreen) != DisplayMode::None;
173+ const auto resizable = (displayMode & DisplayMode::Resizable) != DisplayMode::None;
174+
175+ if (IsFullscreen () != fullscreen)
170176 {
171177 SDL_SetWindowFullscreen (window, fullscreen ? SDL_WINDOW_FULLSCREEN : 0 );
172- isFullscreen_ = (SDL_GetWindowFlags (window) & SDL_WINDOW_FULLSCREEN) != 0 ;
173- if (!isFullscreen_)
174- {
178+ SetFullscreenFlag ((SDL_GetWindowFlags (window) & SDL_WINDOW_FULLSCREEN) != 0 );
179+ if (!IsFullscreen ())
180+ MoveWindowToCenter ();
181+ }
182+
183+ if (displayMode_ != displayMode)
184+ {
185+ if (!IsFullscreen ())
175186#if SDL_VERSION_ATLEAST(2, 0, 5)
176- SDL_SetWindowResizable (window, SDL_TRUE );
187+ SDL_SetWindowResizable (window, static_cast <SDL_bool>(resizable) );
177188#endif
178- MoveWindowToCenter ();
179- }
189+ SetResizableFlag ((SDL_GetWindowFlags (window) & SDL_WINDOW_RESIZABLE) != 0 );
180190 }
181191
182192 if (newSize != GetWindowSize ())
183193 {
184- if (isFullscreen_ )
194+ if (IsFullscreen () )
185195 {
186196 auto const targetMode = FindClosestVideoMode (newSize);
187197 SDL_DisplayMode target;
@@ -203,6 +213,7 @@ bool VideoSDL2::ResizeScreen(const VideoMode& newSize, bool fullscreen)
203213 }
204214 UpdateCurrentSizes ();
205215 }
216+
206217 return true ;
207218}
208219
@@ -265,7 +276,7 @@ bool VideoSDL2::MessageLoop()
265276 {
266277 case SDL_WINDOWEVENT_RESIZED:
267278 {
268- isFullscreen_ = ( SDL_GetWindowFlags (window) & SDL_WINDOW_FULLSCREEN) != 0 ;
279+ SetFullscreenFlag (( SDL_GetWindowFlags (window) & SDL_WINDOW_FULLSCREEN) != 0 ) ;
269280 VideoMode newSize (ev.window .data1 , ev.window .data2 );
270281 if (newSize != GetWindowSize ())
271282 {
0 commit comments