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 <https://github.com/Genymobile/scrcpy/pull/2947>
pull/2947/head
Romain Vimont 2 years ago
parent 4fb61ac83d
commit fa30f9806a

@ -693,6 +693,12 @@ sc_screen_update_frame(struct sc_screen *screen) {
} }
update_texture(screen, frame); 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); sc_screen_render(screen, false);
return true; return true;
} }
@ -763,17 +769,13 @@ sc_screen_is_mouse_capture_key(SDL_Keycode key) {
bool bool
sc_screen_handle_event(struct sc_screen *screen, SDL_Event *event) { sc_screen_handle_event(struct sc_screen *screen, SDL_Event *event) {
switch (event->type) { switch (event->type) {
case EVENT_NEW_FRAME: 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);
}
bool ok = sc_screen_update_frame(screen); bool ok = sc_screen_update_frame(screen);
if (!ok) { if (!ok) {
LOGW("Frame update failed\n"); LOGW("Frame update failed\n");
} }
return true; return true;
}
case SDL_WINDOWEVENT: case SDL_WINDOWEVENT:
if (!screen->has_frame) { if (!screen->has_frame) {
// Do nothing // Do nothing

Loading…
Cancel
Save