Skip to content

Commit 16c5093

Browse files
committed
Avoid unnecessary SDL window-size set calls
This avoids making SDL set the window size when in fullscreen mode (and adds an assert to make sure of that). Previously on macOS, up to three extra set-window-size callbacks could happen when switching from fullscreen.
1 parent b91f861 commit 16c5093

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/gui/sdlmain.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,8 @@ static SDL_Point get_initial_window_position_or_default(int default_val)
806806
// firing before the window is resized in which case an endless loop can occur
807807
static void safe_set_window_size(const int w, const int h)
808808
{
809+
assert(sdl.desktop.fullscreen == false);
810+
809811
decltype(sdl.draw.callback) saved_callback = nullptr;
810812
// Swap and save the callback with a a no-op
811813
std::swap(sdl.draw.callback, saved_callback);
@@ -1884,6 +1886,7 @@ Bitu GFX_SetSize(int width,
18841886
// Adjust the window size if needed and permitted
18851887
if (sdl.scaling_mode != SCALING_MODE::PERFECT &&
18861888
window_doesnt_match_desired && desired_size_is_valid &&
1889+
!sdl.desktop.fullscreen &&
18871890
!sdl.desktop.window.adjusted_initial_size) {
18881891
sdl.desktop.window.adjusted_initial_size = true;
18891892
safe_set_window_size(desired_w, desired_h);
@@ -2073,6 +2076,7 @@ Bitu GFX_SetSize(int width,
20732076
// Adjust the window size if needed and permitted
20742077
if (sdl.scaling_mode != SCALING_MODE::PERFECT &&
20752078
window_doesnt_match_desired && desired_size_is_valid &&
2079+
!sdl.desktop.fullscreen &&
20762080
!sdl.desktop.window.adjusted_initial_size) {
20772081
sdl.desktop.window.adjusted_initial_size = true;
20782082
safe_set_window_size(desired_w, desired_h);

0 commit comments

Comments
 (0)