From 76a3d9805bf44f1d73fc47605b26f031c23773fa Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Mon, 15 Feb 2021 18:47:17 +0100 Subject: [PATCH] Inline window events handling Now that all screen-related events are handled from screen.c, there is no need for a separate method for window events. --- app/src/screen.c | 52 +++++++++++++++++++++--------------------------- 1 file changed, 23 insertions(+), 29 deletions(-) diff --git a/app/src/screen.c b/app/src/screen.c index 0cc90ad8..4b0321eb 100644 --- a/app/src/screen.c +++ b/app/src/screen.c @@ -541,34 +541,6 @@ screen_resize_to_pixel_perfect(struct screen *screen) { content_size.height); } -static void -screen_handle_window_event(struct screen *screen, - const SDL_WindowEvent *event) { - switch (event->event) { - case SDL_WINDOWEVENT_EXPOSED: - screen_render(screen, true); - break; - case SDL_WINDOWEVENT_SIZE_CHANGED: - screen_render(screen, true); - break; - case SDL_WINDOWEVENT_MAXIMIZED: - screen->maximized = true; - break; - case SDL_WINDOWEVENT_RESTORED: - if (screen->fullscreen) { - // On Windows, in maximized+fullscreen, disabling fullscreen - // mode unexpectedly triggers the "restored" then "maximized" - // events, leaving the window in a weird state (maximized - // according to the events, but not maximized visually). - break; - } - screen->maximized = false; - apply_pending_resize(screen); - break; - } -} - - bool screen_handle_event(struct screen *screen, SDL_Event *event) { switch (event->type) { @@ -588,7 +560,29 @@ screen_handle_event(struct screen *screen, SDL_Event *event) { // Do nothing return true; } - screen_handle_window_event(screen, &event->window); + switch (event->window.event) { + case SDL_WINDOWEVENT_EXPOSED: + screen_render(screen, true); + break; + case SDL_WINDOWEVENT_SIZE_CHANGED: + screen_render(screen, true); + break; + case SDL_WINDOWEVENT_MAXIMIZED: + screen->maximized = true; + break; + case SDL_WINDOWEVENT_RESTORED: + if (screen->fullscreen) { + // On Windows, in maximized+fullscreen, disabling + // fullscreen mode unexpectedly triggers the "restored" + // then "maximized" events, leaving the window in a + // weird state (maximized according to the events, but + // not maximized visually). + break; + } + screen->maximized = false; + apply_pending_resize(screen); + break; + } return true; }