Skip to content

Commit

Permalink
Disable "resize to fit" in maximized state
Browse files Browse the repository at this point in the history
In maximized state (but not fullscreen), it was possible to resize to
fit the device screen (with Ctrl+x or double-clicking on black borders).

This caused problems on macOS with the "expand to fullscreen" feature,
which behaves like a fullscreen mode but is seen as maximized by SDL.
In that state, resizing to fit causes unexpected results.

To keep the behavior consistent on all platforms, just disable "resize
to fit" when the window is maximized.
  • Loading branch information
rom1v committed May 15, 2020
1 parent b19d708 commit eb189ce
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions app/src/screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,15 +484,10 @@ screen_switch_fullscreen(struct screen *screen) {

void
screen_resize_to_fit(struct screen *screen) {
if (screen->fullscreen) {
if (screen->fullscreen || screen->maximized) {
return;
}

if (screen->maximized) {
SDL_RestoreWindow(screen->window);
screen->maximized = false;
}

struct size optimal_size =
get_optimal_window_size(screen, screen->content_size);
SDL_SetWindowSize(screen->window, optimal_size.width, optimal_size.height);
Expand Down

0 comments on commit eb189ce

Please sign in to comment.