From 6f4da45eebced76dbd3af78eb5654f24ecd3149a Mon Sep 17 00:00:00 2001 From: Ricky Zhang Date: Thu, 2 Jul 2020 18:24:32 -0400 Subject: [PATCH] Enhanced scale up and scale down in SDL2. - Enable window mode to be resizable. - When restore the window, restore the scale ratio to 1. Signed-off-by: Ricky Zhang --- BasiliskII/src/SDL/video_sdl2.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/BasiliskII/src/SDL/video_sdl2.cpp b/BasiliskII/src/SDL/video_sdl2.cpp index 10bd96db..0a11443f 100644 --- a/BasiliskII/src/SDL/video_sdl2.cpp +++ b/BasiliskII/src/SDL/video_sdl2.cpp @@ -690,7 +690,7 @@ static SDL_Surface * init_sdl_video(int width, int height, int bpp, Uint32 flags int window_width = width; int window_height = height; - Uint32 window_flags = SDL_WINDOW_ALLOW_HIGHDPI; + Uint32 window_flags = SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_RESIZABLE; const int window_flags_to_monitor = SDL_WINDOW_FULLSCREEN; if (flags & SDL_WINDOW_FULLSCREEN) { @@ -2124,9 +2124,17 @@ static int SDLCALL on_sdl_event_generated(void *userdata, SDL_Event * event) } #endif } - } break; + } break; // end of SDL_WINDOWEVENT_RESIZED + case SDL_WINDOWEVENT_RESTORED: { + // When the user minimizes the window and then restore it, + // we restore the scale factor to 1. + if (sdl_window) { + const VIDEO_MODE &mode = drv->mode; + SDL_SetWindowSize(sdl_window, VIDEO_MODE_X, VIDEO_MODE_Y); + } + } break; // end of SDL_WINDOWEVENT_RESTORED } - } break; + } break; // end of SDL_WINDOWEVENT } return EVENT_ADD_TO_QUEUE;