Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/video/SDL_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,12 @@ SDL_SetWindowDisplayMode(SDL_Window * window, const SDL_DisplayMode * mode)
SDL_DisplayMode fullscreen_mode;
if (SDL_GetWindowDisplayMode(window, &fullscreen_mode) == 0) {
SDL_SetDisplayModeForDisplay(SDL_GetDisplayForWindow(window), &fullscreen_mode);
/* make sure the window size (and internals like window-surface size) are adjusted */
if (window->w != fullscreen_mode.w || window->h != fullscreen_mode.h) {
window->w = fullscreen_mode.w;
window->h = fullscreen_mode.h;
SDL_OnWindowResized(window);
}
}
}
return 0;
Expand Down Expand Up @@ -1589,6 +1595,22 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
displayIndex = SDL_GetIndexOfDisplay(display);
SDL_GetDisplayBounds(displayIndex, &bounds);

/* for real fullscreen we might switch the resolution, so get width and height
* from closest supported mode and use that instead of current resolution
*/
if ((flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP
&& (bounds.w != w || bounds.h != h)) {
SDL_DisplayMode fullscreen_mode, closest_mode;
SDL_zero(fullscreen_mode);
fullscreen_mode.w = w;
fullscreen_mode.h = h;
if(SDL_GetClosestDisplayModeForDisplay(display, &fullscreen_mode, &closest_mode) != NULL) {
bounds.w = closest_mode.w;
bounds.h = closest_mode.h;
}
}
window->fullscreen_mode.w = bounds.w;
window->fullscreen_mode.h = bounds.h;
window->x = bounds.x;
window->y = bounds.y;
window->w = bounds.w;
Expand Down