diff --git a/app/src/scrcpy.c b/app/src/scrcpy.c index 64165ac5..0e56696a 100644 --- a/app/src/scrcpy.c +++ b/app/src/scrcpy.c @@ -144,12 +144,7 @@ handle_event(SDL_Event *event, bool control) { } break; case SDL_WINDOWEVENT: - switch (event->window.event) { - case SDL_WINDOWEVENT_EXPOSED: - case SDL_WINDOWEVENT_SIZE_CHANGED: - screen_render(&screen); - break; - } + screen_handle_window_event(&screen, &event->window); break; case SDL_TEXTINPUT: if (!control) { diff --git a/app/src/screen.c b/app/src/screen.c index 4bc4c5c5..0ef803fe 100644 --- a/app/src/screen.c +++ b/app/src/screen.c @@ -327,3 +327,14 @@ screen_resize_to_pixel_perfect(struct screen *screen) { LOGD("Resized to pixel-perfect"); } } + +void +screen_handle_window_event(struct screen *screen, + const SDL_WindowEvent *event) { + switch (event->event) { + case SDL_WINDOWEVENT_EXPOSED: + case SDL_WINDOWEVENT_SIZE_CHANGED: + screen_render(screen); + break; + } +} diff --git a/app/src/screen.h b/app/src/screen.h index bc189189..1c5695bc 100644 --- a/app/src/screen.h +++ b/app/src/screen.h @@ -76,4 +76,8 @@ screen_resize_to_fit(struct screen *screen); void screen_resize_to_pixel_perfect(struct screen *screen); +// react to window events +void +screen_handle_window_event(struct screen *screen, const SDL_WindowEvent *event); + #endif