When the window fullscreen mode changes, update the display resolution
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index f8556a6..7599e58 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -122,7 +122,7 @@ static SDL_VideoDevice *_this = NULL;
return retval; \
}
-#define FULLSCREEN_MASK ( SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_FULLSCREEN )
+#define FULLSCREEN_MASK (SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_FULLSCREEN)
#ifdef __MACOSX__
/* Support for Mac OS X fullscreen spaces */
@@ -626,9 +626,9 @@ SDL_GetIndexOfDisplay(SDL_VideoDisplay *display)
}
void *
-SDL_GetDisplayDriverData( int displayIndex )
+SDL_GetDisplayDriverData(int displayIndex)
{
- CHECK_DISPLAY_INDEX( displayIndex, NULL );
+ CHECK_DISPLAY_INDEX(displayIndex, NULL);
return _this->displays[displayIndex].driverdata;
}
@@ -1020,6 +1020,13 @@ SDL_SetWindowDisplayMode(SDL_Window * window, const SDL_DisplayMode * mode)
} else {
SDL_zero(window->fullscreen_mode);
}
+
+ if (FULLSCREEN_VISIBLE(window) && (window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP) {
+ SDL_DisplayMode fullscreen_mode;
+ if (SDL_GetWindowDisplayMode(window, &fullscreen_mode) == 0) {
+ SDL_SetDisplayModeForDisplay(SDL_GetDisplayForWindow(window), &fullscreen_mode);
+ }
+ }
return 0;
}
@@ -1029,12 +1036,12 @@ SDL_GetWindowDisplayMode(SDL_Window * window, SDL_DisplayMode * mode)
SDL_DisplayMode fullscreen_mode;
SDL_VideoDisplay *display;
+ CHECK_WINDOW_MAGIC(window, -1);
+
if (!mode) {
- return SDL_InvalidParamError("mode");
+ return SDL_InvalidParamError("mode");
}
- CHECK_WINDOW_MAGIC(window, -1);
-
fullscreen_mode = window->fullscreen_mode;
if (!fullscreen_mode.w) {
fullscreen_mode.w = window->w;
@@ -1046,11 +1053,9 @@ SDL_GetWindowDisplayMode(SDL_Window * window, SDL_DisplayMode * mode)
display = SDL_GetDisplayForWindow(window);
/* if in desktop size mode, just return the size of the desktop */
- if ( ( window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP ) == SDL_WINDOW_FULLSCREEN_DESKTOP )
- {
+ if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) {
fullscreen_mode = display->desktop_mode;
- }
- else if (!SDL_GetClosestDisplayModeForDisplay(SDL_GetDisplayForWindow(window),
+ } else if (!SDL_GetClosestDisplayModeForDisplay(SDL_GetDisplayForWindow(window),
&fullscreen_mode,
&fullscreen_mode)) {
return SDL_SetError("Couldn't find display mode match");
@@ -1450,7 +1455,7 @@ SDL_GetWindowFlags(SDL_Window * window)
void
SDL_SetWindowTitle(SDL_Window * window, const char *title)
{
- CHECK_WINDOW_MAGIC(window, );
+ CHECK_WINDOW_MAGIC(window,);
if (title == window->title) {
return;
@@ -1478,7 +1483,7 @@ SDL_GetWindowTitle(SDL_Window * window)
void
SDL_SetWindowIcon(SDL_Window * window, SDL_Surface * icon)
{
- CHECK_WINDOW_MAGIC(window, );
+ CHECK_WINDOW_MAGIC(window,);
if (!icon) {
return;
@@ -1568,7 +1573,7 @@ SDL_GetWindowData(SDL_Window * window, const char *name)
void
SDL_SetWindowPosition(SDL_Window * window, int x, int y)
{
- CHECK_WINDOW_MAGIC(window, );
+ CHECK_WINDOW_MAGIC(window,);
if (SDL_WINDOWPOS_ISCENTERED(x) || SDL_WINDOWPOS_ISCENTERED(y)) {
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
@@ -1612,7 +1617,7 @@ SDL_SetWindowPosition(SDL_Window * window, int x, int y)
void
SDL_GetWindowPosition(SDL_Window * window, int *x, int *y)
{
- CHECK_WINDOW_MAGIC(window, );
+ CHECK_WINDOW_MAGIC(window,);
/* Fullscreen windows are always at their display's origin */
if (window->flags & SDL_WINDOW_FULLSCREEN) {
@@ -1635,7 +1640,7 @@ SDL_GetWindowPosition(SDL_Window * window, int *x, int *y)
void
SDL_SetWindowBordered(SDL_Window * window, SDL_bool bordered)
{
- CHECK_WINDOW_MAGIC(window, );
+ CHECK_WINDOW_MAGIC(window,);
if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
const int want = (bordered != SDL_FALSE); /* normalize the flag. */
const int have = ((window->flags & SDL_WINDOW_BORDERLESS) == 0);
@@ -1653,7 +1658,7 @@ SDL_SetWindowBordered(SDL_Window * window, SDL_bool bordered)
void
SDL_SetWindowSize(SDL_Window * window, int w, int h)
{
- CHECK_WINDOW_MAGIC(window, );
+ CHECK_WINDOW_MAGIC(window,);
if (w <= 0) {
SDL_InvalidParamError("w");
return;
@@ -1681,10 +1686,16 @@ SDL_SetWindowSize(SDL_Window * window, int w, int h)
h = window->max_h;
}
- /* FIXME: Should this change fullscreen modes? */
if (window->flags & SDL_WINDOW_FULLSCREEN) {
window->windowed.w = w;
window->windowed.h = h;
+
+ if (FULLSCREEN_VISIBLE(window) && (window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP) {
+ SDL_DisplayMode fullscreen_mode;
+ if (SDL_GetWindowDisplayMode(window, &fullscreen_mode) == 0) {
+ SDL_SetDisplayModeForDisplay(SDL_GetDisplayForWindow(window), &fullscreen_mode);
+ }
+ }
} else {
window->w = w;
window->h = h;
@@ -1701,7 +1712,7 @@ SDL_SetWindowSize(SDL_Window * window, int w, int h)
void
SDL_GetWindowSize(SDL_Window * window, int *w, int *h)
{
- CHECK_WINDOW_MAGIC(window, );
+ CHECK_WINDOW_MAGIC(window,);
if (w) {
*w = window->w;
}
@@ -1713,7 +1724,7 @@ SDL_GetWindowSize(SDL_Window * window, int *w, int *h)
void
SDL_SetWindowMinimumSize(SDL_Window * window, int min_w, int min_h)
{
- CHECK_WINDOW_MAGIC(window, );
+ CHECK_WINDOW_MAGIC(window,);
if (min_w <= 0) {
SDL_InvalidParamError("min_w");
return;
@@ -1737,7 +1748,7 @@ SDL_SetWindowMinimumSize(SDL_Window * window, int min_w, int min_h)
void
SDL_GetWindowMinimumSize(SDL_Window * window, int *min_w, int *min_h)
{
- CHECK_WINDOW_MAGIC(window, );
+ CHECK_WINDOW_MAGIC(window,);
if (min_w) {
*min_w = window->min_w;
}
@@ -1749,7 +1760,7 @@ SDL_GetWindowMinimumSize(SDL_Window * window, int *min_w, int *min_h)
void
SDL_SetWindowMaximumSize(SDL_Window * window, int max_w, int max_h)
{
- CHECK_WINDOW_MAGIC(window, );
+ CHECK_WINDOW_MAGIC(window,);
if (max_w <= 0) {
SDL_InvalidParamError("max_w");
return;
@@ -1773,7 +1784,7 @@ SDL_SetWindowMaximumSize(SDL_Window * window, int max_w, int max_h)
void
SDL_GetWindowMaximumSize(SDL_Window * window, int *max_w, int *max_h)
{
- CHECK_WINDOW_MAGIC(window, );
+ CHECK_WINDOW_MAGIC(window,);
if (max_w) {
*max_w = window->max_w;
}
@@ -1785,7 +1796,7 @@ SDL_GetWindowMaximumSize(SDL_Window * window, int *max_w, int *max_h)
void
SDL_ShowWindow(SDL_Window * window)
{
- CHECK_WINDOW_MAGIC(window, );
+ CHECK_WINDOW_MAGIC(window,);
if (window->flags & SDL_WINDOW_SHOWN) {
return;
@@ -1800,7 +1811,7 @@ SDL_ShowWindow(SDL_Window * window)
void
SDL_HideWindow(SDL_Window * window)
{
- CHECK_WINDOW_MAGIC(window, );
+ CHECK_WINDOW_MAGIC(window,);
if (!(window->flags & SDL_WINDOW_SHOWN)) {
return;
@@ -1817,7 +1828,7 @@ SDL_HideWindow(SDL_Window * window)
void
SDL_RaiseWindow(SDL_Window * window)
{
- CHECK_WINDOW_MAGIC(window, );
+ CHECK_WINDOW_MAGIC(window,);
if (!(window->flags & SDL_WINDOW_SHOWN)) {
return;
@@ -1830,7 +1841,7 @@ SDL_RaiseWindow(SDL_Window * window)
void
SDL_MaximizeWindow(SDL_Window * window)
{
- CHECK_WINDOW_MAGIC(window, );
+ CHECK_WINDOW_MAGIC(window,);
if (window->flags & SDL_WINDOW_MAXIMIZED) {
return;
@@ -1846,7 +1857,7 @@ SDL_MaximizeWindow(SDL_Window * window)
void
SDL_MinimizeWindow(SDL_Window * window)
{
- CHECK_WINDOW_MAGIC(window, );
+ CHECK_WINDOW_MAGIC(window,);
if (window->flags & SDL_WINDOW_MINIMIZED) {
return;
@@ -1862,7 +1873,7 @@ SDL_MinimizeWindow(SDL_Window * window)
void
SDL_RestoreWindow(SDL_Window * window)
{
- CHECK_WINDOW_MAGIC(window, );
+ CHECK_WINDOW_MAGIC(window,);
if (!(window->flags & (SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED))) {
return;
@@ -1880,7 +1891,7 @@ SDL_SetWindowFullscreen(SDL_Window * window, Uint32 flags)
flags &= FULLSCREEN_MASK;
- if ( flags == (window->flags & FULLSCREEN_MASK) ) {
+ if (flags == (window->flags & FULLSCREEN_MASK)) {
return 0;
}
@@ -2083,7 +2094,7 @@ SDL_UpdateWindowGrab(SDL_Window * window)
void
SDL_SetWindowGrab(SDL_Window * window, SDL_bool grabbed)
{
- CHECK_WINDOW_MAGIC(window, );
+ CHECK_WINDOW_MAGIC(window,);
if (!!grabbed == !!(window->flags & SDL_WINDOW_INPUT_GRABBED)) {
return;
@@ -2239,7 +2250,7 @@ SDL_DestroyWindow(SDL_Window * window)
{
SDL_VideoDisplay *display;
- CHECK_WINDOW_MAGIC(window, );
+ CHECK_WINDOW_MAGIC(window,);
window->is_destroying = SDL_TRUE;
@@ -2468,7 +2479,7 @@ SDL_GL_UnloadLibrary(void)
static SDL_INLINE SDL_bool
isAtLeastGL3(const char *verstr)
{
- return ( verstr && (SDL_atoi(verstr) >= 3) );
+ return (verstr && (SDL_atoi(verstr) >= 3));
}
SDL_bool
@@ -2675,23 +2686,23 @@ SDL_GL_SetAttribute(SDL_GLattr attr, int value)
};
break;
case SDL_GL_CONTEXT_FLAGS:
- if( value & ~(SDL_GL_CONTEXT_DEBUG_FLAG |
- SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG |
- SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG |
- SDL_GL_CONTEXT_RESET_ISOLATION_FLAG) ) {
- retval = SDL_SetError("Unknown OpenGL context flag %d", value);
- break;
- }
+ if (value & ~(SDL_GL_CONTEXT_DEBUG_FLAG |
+ SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG |
+ SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG |
+ SDL_GL_CONTEXT_RESET_ISOLATION_FLAG)) {
+ retval = SDL_SetError("Unknown OpenGL context flag %d", value);
+ break;
+ }
_this->gl_config.flags = value;
break;
case SDL_GL_CONTEXT_PROFILE_MASK:
- if( value != 0 &&
- value != SDL_GL_CONTEXT_PROFILE_CORE &&
- value != SDL_GL_CONTEXT_PROFILE_COMPATIBILITY &&
- value != SDL_GL_CONTEXT_PROFILE_ES ) {
- retval = SDL_SetError("Unknown OpenGL context profile %d", value);
- break;
- }
+ if (value != 0 &&
+ value != SDL_GL_CONTEXT_PROFILE_CORE &&
+ value != SDL_GL_CONTEXT_PROFILE_COMPATIBILITY &&
+ value != SDL_GL_CONTEXT_PROFILE_ES) {
+ retval = SDL_SetError("Unknown OpenGL context profile %d", value);
+ break;
+ }
_this->gl_config.profile_mask = value;
break;
case SDL_GL_SHARE_WITH_CURRENT_CONTEXT:
@@ -2971,7 +2982,7 @@ SDL_GL_GetCurrentContext(void)
void SDL_GL_GetDrawableSize(SDL_Window * window, int *w, int *h)
{
- CHECK_WINDOW_MAGIC(window, );
+ CHECK_WINDOW_MAGIC(window,);
if (_this->GL_GetDrawableSize) {
_this->GL_GetDrawableSize(_this, window, w, h);
@@ -3011,7 +3022,7 @@ SDL_GL_GetSwapInterval(void)
void
SDL_GL_SwapWindow(SDL_Window * window)
{
- CHECK_WINDOW_MAGIC(window, );
+ CHECK_WINDOW_MAGIC(window,);
if (!(window->flags & SDL_WINDOW_OPENGL)) {
SDL_SetError("The specified window isn't an OpenGL window");