video: Return an error on failure to set the video mode

If SDL_UpdateFullscreenMode() fails to find a matching mode for the window, it will restore the window to its previous state, but still returns a success code of 0. Return an error code of -1 if no matching display mode can be found.
This commit is contained in:
Frank Praznik 2023-01-22 15:06:30 -05:00 committed by Sam Lantinga
parent b379c910d4
commit 8f8746cc1b

View file

@ -1324,6 +1324,7 @@ static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen)
{
SDL_VideoDisplay *display;
SDL_Window *other;
int retval = 0;
CHECK_WINDOW_MAGIC(window, -1);
@ -1468,6 +1469,9 @@ static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen)
window->last_fullscreen_flags = window->flags;
return 0;
} else {
/* Failed to find a matching mode, return an error after restoring windowed mode. */
retval = -1;
}
}
}
@ -1487,7 +1491,7 @@ static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen)
SDL_RestoreMousePosition(window);
window->last_fullscreen_flags = window->flags;
return 0;
return retval;
}
#define CREATE_FLAGS \