From f06158497378e091d701bb1db7d5606e187c3ed8 Mon Sep 17 00:00:00 2001 From: kub Date: Sun, 9 Feb 2025 19:45:33 +0100 Subject: [PATCH] fix multiple redraw events (only handle last one) --- in_sdl.c | 9 +++++++-- plat_sdl.c | 8 ++++++++ plat_sdl.h | 1 + 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/in_sdl.c b/in_sdl.c index 9bde4fd..43d44c5 100644 --- a/in_sdl.c +++ b/in_sdl.c @@ -26,6 +26,7 @@ struct in_sdl_state { int axis_keydown[2]; #ifdef SDL_REDRAW_EVT int rdraw; + SDL_Event redraw; #endif keybits_t keystate[SDLK_LAST / KEYBITS_WORD_BITS + 1]; // emulator keys should always be processed immediately lest one is lost @@ -382,8 +383,10 @@ static int collect_events(struct in_sdl_state *state, int *one_kc, int *one_down break; default: #ifdef SDL_REDRAW_EVT - state->rdraw |= (one_kc != NULL && - event->type == SDL_VIDEORESIZE); + if (event->type == SDL_VIDEORESIZE) { + state->rdraw = 1; + state->redraw = *event; + } else #endif if (ext_event_handler != NULL) ext_event_handler(event); @@ -403,6 +406,8 @@ static int collect_events(struct in_sdl_state *state, int *one_kc, int *one_down #ifdef SDL_REDRAW_EVT // if the event queue has been emptied and resize events were in it if (state->rdraw && count == 0) { + if (ext_event_handler != NULL) + ext_event_handler(&state->redraw); state->rdraw = 0; // dummy key event to force returning from the key loop, // so the application has a chance to redraw the window diff --git a/plat_sdl.c b/plat_sdl.c index f90827a..2c983d7 100644 --- a/plat_sdl.c +++ b/plat_sdl.c @@ -154,6 +154,8 @@ int plat_sdl_change_video_mode(int w, int h, int force) plat_sdl_screen->w != win_w || plat_sdl_screen->h != win_h) plat_sdl_screen = SDL_SetVideoMode(win_w, win_h, 16, flags); screen_flags = flags; + window_w = win_w; + window_h = win_h; if (plat_sdl_screen == NULL) { fprintf(stderr, "SDL_SetVideoMode failed: %s\n", SDL_GetError()); return -1; @@ -383,4 +385,10 @@ int plat_sdl_is_windowed(void) { return window_b != 0; } + +int plat_sdl_is_fullscreen(void) +{ + // consider window title bar and screen menu here + return window_w >= fs_w && window_h >= fs_h - 2*window_b; +} // vim:shiftwidth=2:expandtab diff --git a/plat_sdl.h b/plat_sdl.h index 13e5197..5e6016d 100644 --- a/plat_sdl.h +++ b/plat_sdl.h @@ -8,6 +8,7 @@ extern void (*plat_sdl_quit_cb)(void); int plat_sdl_init(void); int plat_sdl_is_windowed(void); +int plat_sdl_is_fullscreen(void); int plat_sdl_change_video_mode(int w, int h, int force); void plat_sdl_overlay_clear(void); void plat_sdl_event_handler(void *event_); -- 2.39.5