From fa30f9806aa928da5010c7110e6f0fafb5220eaf Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Sun, 16 Jan 2022 15:47:11 +0100 Subject: [PATCH] Move "show window" call on first frame Show the window only after the actual frame size is known (and if no error has occurred). This will allow to properly position and size the window when the size of the first frame is different from the size initially announced by the server. PR #2947 --- app/src/screen.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/src/screen.c b/app/src/screen.c index a2796278..78ab91d9 100644 --- a/app/src/screen.c +++ b/app/src/screen.c @@ -693,6 +693,12 @@ sc_screen_update_frame(struct sc_screen *screen) { } update_texture(screen, frame); + if (!screen->has_frame) { + screen->has_frame = true; + // this is the very first frame, show the window + sc_screen_show_window(screen); + } + sc_screen_render(screen, false); return true; } @@ -763,17 +769,13 @@ sc_screen_is_mouse_capture_key(SDL_Keycode key) { bool sc_screen_handle_event(struct sc_screen *screen, SDL_Event *event) { switch (event->type) { - case EVENT_NEW_FRAME: - if (!screen->has_frame) { - screen->has_frame = true; - // this is the very first frame, show the window - sc_screen_show_window(screen); - } + case EVENT_NEW_FRAME: { bool ok = sc_screen_update_frame(screen); if (!ok) { LOGW("Frame update failed\n"); } return true; + } case SDL_WINDOWEVENT: if (!screen->has_frame) { // Do nothing