sdl: make window resizable, enable high DPI

Tested on Linux, MacOS, and Windows.

On MacOS and Windows, we constrain the window's aspect
ratio by adjusting the size when responding to resize
events.

On Linux, I've not found a way to do so, that doesn't
result in fairly stuttery behavior and weird jumpy
behavior of the resize handle, possibly depending
on your window manager. So, black bars are displayed
around the content.
Maybe someone, at some point, finds a way.
(SDL3 seems to have SDL_SetWindowAspectRatio)

When the window is in fullscreen, black bars are
display necessarily, of course, on all systems,
unless the player GUI has exactly the same aspect
ratio as the screen...

Change-Id: I535e6617497611ea57a4c19e08e552f990859cfe
This commit is contained in:
Christian Soffke 2023-08-27 01:17:34 +02:00
parent 79191bf9bb
commit 60f3283f48
5 changed files with 127 additions and 30 deletions

View file

@ -24,6 +24,7 @@
#include "button.h"
#ifdef HAVE_SDL
#include "button-sdl.h"
#include "lcd-sdl.h"
#endif
static struct event_queue button_queue SHAREDBSS_ATTR;
@ -100,7 +101,7 @@ static inline void button_queue_wait(struct queue_event *evp, int timeout)
unsigned long curr_tick, remaining;
while(true)
{
handle_sdl_events();
handle_sdl_events(); /* Includes window updates after resize events */
queue_wait_w_tmo(&button_queue, evp, TIMEOUT_NOBLOCK);
if (evp->id != SYS_TIMEOUT || timeout == TIMEOUT_NOBLOCK)
return;
@ -117,6 +118,9 @@ static inline void button_queue_wait(struct queue_event *evp, int timeout)
}
#else
queue_wait_w_tmo(&button_queue, evp, timeout);
#ifdef HAVE_SDL
sdl_update_window(); /* Window may have been resized */
#endif
#endif
}
#endif /* HAVE_ADJUSTABLE_CPU_FREQ */