Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

sdl: improve window resizing on macOS

This enables smooth resizing of the window using a
fixed aspect ratio, instead of snapping into the
correct aspect ratio only when the resize operation
has finished, by using an SDL event filter that gets
events delivered during the resize operation
(whereas SDL_PollEvent blocks until done on macOS).

Change-Id: Ie6614e4b6f49a24469c5ee6a69721c9fbd440dae

+14 -8
+2 -2
firmware/drivers/button_queue.c
··· 23 23 #include "kernel.h" 24 24 #include "button.h" 25 25 #ifdef HAVE_SDL 26 - #include "button-sdl.h" 26 + #include "SDL.h" 27 27 #include "window-sdl.h" 28 28 #endif 29 29 ··· 101 101 unsigned long curr_tick, remaining; 102 102 while(true) 103 103 { 104 - handle_sdl_events(); /* Includes window updates after resize events */ 104 + SDL_PumpEvents(); 105 105 queue_wait_w_tmo(&button_queue, evp, TIMEOUT_NOBLOCK); 106 106 if (evp->id != SYS_TIMEOUT || timeout == TIMEOUT_NOBLOCK) 107 107 return;
+4 -4
firmware/target/hosted/sdl/button-sdl.c
··· 382 382 } 383 383 384 384 #ifdef __APPLE__ 385 - void handle_sdl_events(void) 385 + int sdl_event_filter(void *userdata, SDL_Event * event) 386 386 { 387 - SDL_Event event; 388 - while(SDL_PollEvent(&event)) 389 - event_handler(&event); 387 + (void) userdata; 388 + event_handler(event); 389 + return 0; 390 390 } 391 391 #endif 392 392
+2 -1
firmware/target/hosted/sdl/button-sdl.h
··· 25 25 26 26 #include <stdbool.h> 27 27 #include "config.h" 28 + #include "SDL.h" 28 29 29 30 extern int sdl_app_has_input_focus; 30 31 31 32 #ifdef __APPLE__ 32 - void handle_sdl_events(void); 33 + int sdl_event_filter(void *userdata, SDL_Event * event); 33 34 #endif 34 35 35 36 bool button_hold(void);
+3
firmware/target/hosted/sdl/system-sdl.c
··· 33 33 #include "system-sdl.h" 34 34 #include "sim-ui-defines.h" 35 35 #include "window-sdl.h" 36 + #include "button-sdl.h" 36 37 #include "lcd-bitmap.h" 37 38 #ifdef HAVE_REMOTE_LCD 38 39 #include "lcd-remote-bitmap.h" ··· 235 236 SDL_SemWait(s); 236 237 /* cleanup */ 237 238 SDL_DestroySemaphore(s); 239 + #else 240 + SDL_AddEventWatch(sdl_event_filter, NULL); 238 241 #endif 239 242 } 240 243
+3 -1
firmware/target/hosted/sdl/window-sdl.c
··· 81 81 SDL_GetWindowSize(sdlWindow, &w, &h); 82 82 if (w != original_width || h != original_height) 83 83 { 84 + SDL_DisplayMode sdl_dm; 84 85 h = w * aspect_ratio; 85 - SDL_SetWindowSize(sdlWindow, w, h); 86 + if (SDL_GetCurrentDisplayMode(0, &sdl_dm) || h <= sdl_dm.h) 87 + SDL_SetWindowSize(sdlWindow, w, h); 86 88 } 87 89 } 88 90 #endif