mirror of https://github.com/encounter/SDL.git
Only update the window size if setting the display mode succeeded
This commit is contained in:
parent
0eb6f79190
commit
3cad447ee7
|
@ -1162,12 +1162,15 @@ SDL_SetWindowDisplayMode(SDL_Window * window, const SDL_DisplayMode * mode)
|
||||||
if (FULLSCREEN_VISIBLE(window) && (window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP) {
|
if (FULLSCREEN_VISIBLE(window) && (window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP) {
|
||||||
SDL_DisplayMode fullscreen_mode;
|
SDL_DisplayMode fullscreen_mode;
|
||||||
if (SDL_GetWindowDisplayMode(window, &fullscreen_mode) == 0) {
|
if (SDL_GetWindowDisplayMode(window, &fullscreen_mode) == 0) {
|
||||||
SDL_SetDisplayModeForDisplay(SDL_GetDisplayForWindow(window), &fullscreen_mode);
|
if (SDL_SetDisplayModeForDisplay(SDL_GetDisplayForWindow(window), &fullscreen_mode) == 0) {
|
||||||
/* make sure the window size (and internals like window-surface size) are adjusted */
|
#ifndef ANDROID
|
||||||
if (window->w != fullscreen_mode.w || window->h != fullscreen_mode.h) {
|
/* Android may not resize the window to exactly what our fullscreen mode is, especially on
|
||||||
window->w = fullscreen_mode.w;
|
* windowed Android environments like the Chromebook or Samsung DeX. Given this, we shouldn't
|
||||||
window->h = fullscreen_mode.h;
|
* use fullscreen_mode.w and fullscreen_mode.h, but rather get our current native size. As such,
|
||||||
SDL_OnWindowResized(window);
|
* Android's SetWindowFullscreen will generate the window event for us with the proper final size.
|
||||||
|
*/
|
||||||
|
SDL_SendWindowEvent(other, SDL_WINDOWEVENT_RESIZED, fullscreen_mode.w, fullscreen_mode.h);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1364,11 +1367,11 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)
|
||||||
/* Generate a mode change event here */
|
/* Generate a mode change event here */
|
||||||
if (resized) {
|
if (resized) {
|
||||||
#ifndef ANDROID
|
#ifndef ANDROID
|
||||||
// Android may not resize the window to exactly what our fullscreen mode is, especially on
|
/* Android may not resize the window to exactly what our fullscreen mode is, especially on
|
||||||
// windowed Android environments like the Chromebook or Samsung DeX. Given this, we shouldn't
|
* windowed Android environments like the Chromebook or Samsung DeX. Given this, we shouldn't
|
||||||
// use fullscreen_mode.w and fullscreen_mode.h, but rather get our current native size. As such,
|
* use fullscreen_mode.w and fullscreen_mode.h, but rather get our current native size. As such,
|
||||||
// Android's SetWindowFullscreen will generate the window event for us with the proper final size.
|
* Android's SetWindowFullscreen will generate the window event for us with the proper final size.
|
||||||
|
*/
|
||||||
SDL_SendWindowEvent(other, SDL_WINDOWEVENT_RESIZED,
|
SDL_SendWindowEvent(other, SDL_WINDOWEVENT_RESIZED,
|
||||||
fullscreen_mode.w, fullscreen_mode.h);
|
fullscreen_mode.w, fullscreen_mode.h);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue