@@ -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, WindowMode windowMode, bool fullscreen)
9595{
9696 if (!initialized)
9797 return false ;
@@ -116,15 +116,18 @@ bool VideoSDL2::CreateScreen(const std::string& title, const VideoMode& size, bo
116116 int wndPos = SDL_WINDOWPOS_CENTERED;
117117
118118 const auto requestedSize = fullscreen ? FindClosestVideoMode (size) : size;
119+ unsigned commonFlags = SDL_WINDOW_OPENGL;
120+ unsigned fullscreenFlags = (fullscreen ? SDL_WINDOW_FULLSCREEN : 0 );
121+ unsigned windowFlags = (windowMode == WindowMode::Resizable ? SDL_WINDOW_RESIZABLE : 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 | fullscreenFlags | windowFlags );
122125
123126 // Fallback to non-fullscreen
124127 if (!window && fullscreen)
125128 {
126129 window = SDL_CreateWindow (title.c_str (), wndPos, wndPos, requestedSize.width , requestedSize.height ,
127- SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE );
130+ commonFlags | windowFlags );
128131 }
129132
130133 if (!window)
@@ -133,7 +136,9 @@ bool VideoSDL2::CreateScreen(const std::string& title, const VideoMode& size, bo
133136 return false ;
134137 }
135138
136- isFullscreen_ = (SDL_GetWindowFlags (window) & SDL_WINDOW_FULLSCREEN) != 0 ;
139+ const auto flags = SDL_GetWindowFlags (window);
140+ isFullscreen_ = (flags & SDL_WINDOW_FULLSCREEN) != 0 ;
141+ windowMode_ = ((flags & SDL_WINDOW_RESIZABLE) != 0 ? WindowMode::Resizable : WindowMode::NonResizable);
137142 UpdateCurrentSizes ();
138143
139144 if (!isFullscreen_)
@@ -161,7 +166,7 @@ bool VideoSDL2::CreateScreen(const std::string& title, const VideoMode& size, bo
161166 return true ;
162167}
163168
164- bool VideoSDL2::ResizeScreen (const VideoMode& newSize, bool fullscreen)
169+ bool VideoSDL2::ResizeScreen (const VideoMode& newSize, WindowMode windowMode, bool fullscreen)
165170{
166171 if (!initialized)
167172 return false ;
@@ -171,12 +176,17 @@ bool VideoSDL2::ResizeScreen(const VideoMode& newSize, bool fullscreen)
171176 SDL_SetWindowFullscreen (window, fullscreen ? SDL_WINDOW_FULLSCREEN : 0 );
172177 isFullscreen_ = (SDL_GetWindowFlags (window) & SDL_WINDOW_FULLSCREEN) != 0 ;
173178 if (!isFullscreen_)
174- {
179+ MoveWindowToCenter ();
180+ }
181+
182+ if (!isFullscreen_ || windowMode != windowMode_)
183+ {
184+ if (!isFullscreen_)
175185#if SDL_VERSION_ATLEAST(2, 0, 5)
176- SDL_SetWindowResizable (window, SDL_TRUE );
186+ SDL_SetWindowResizable (window, static_cast <SDL_bool>(windowMode == WindowMode::Resizable) );
177187#endif
178- MoveWindowToCenter ();
179- }
188+ windowMode_ =
189+ (( SDL_GetWindowFlags (window) & SDL_WINDOW_RESIZABLE) != 0 ? WindowMode::Resizable : WindowMode::NonResizable);
180190 }
181191
182192 if (newSize != GetWindowSize ())
@@ -203,6 +213,17 @@ bool VideoSDL2::ResizeScreen(const VideoMode& newSize, bool fullscreen)
203213 }
204214 UpdateCurrentSizes ();
205215 }
216+
217+ if (isFullscreen_ != fullscreen || windowMode != windowMode_)
218+ {
219+ if (!isFullscreen_)
220+ #if SDL_VERSION_ATLEAST(2, 0, 5)
221+ SDL_SetWindowResizable (window, static_cast <SDL_bool>(windowMode == WindowMode::Resizable));
222+ #endif
223+ windowMode_ =
224+ ((SDL_GetWindowFlags (window) & SDL_WINDOW_RESIZABLE) != 0 ? WindowMode::Resizable : WindowMode::NonResizable);
225+ }
226+
206227 return true ;
207228}
208229
0 commit comments