Hide the window immediately on close
The screen may not be destroyed immediately on close to avoid undefined behavior, because it may still receive events from the decoder. But the visual window must still be closed immediately.
This commit is contained in:
parent
0272e6dc77
commit
0541f1bff2
3 changed files with 16 additions and 0 deletions
|
@ -398,6 +398,10 @@ scrcpy(const struct scrcpy_options *options) {
|
||||||
ret = event_loop(options);
|
ret = event_loop(options);
|
||||||
LOGD("quit...");
|
LOGD("quit...");
|
||||||
|
|
||||||
|
// Close the window immediately on closing, because screen_destroy() may
|
||||||
|
// only be called once the stream thread is joined (it may take time)
|
||||||
|
screen_hide_window(&screen);
|
||||||
|
|
||||||
end:
|
end:
|
||||||
// The stream is not stopped explicitly, because it will stop by itself on
|
// The stream is not stopped explicitly, because it will stop by itself on
|
||||||
// end-of-stream
|
// end-of-stream
|
||||||
|
|
|
@ -453,6 +453,11 @@ screen_show_window(struct screen *screen) {
|
||||||
SDL_ShowWindow(screen->window);
|
SDL_ShowWindow(screen->window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
screen_hide_window(struct screen *screen) {
|
||||||
|
SDL_HideWindow(screen->window);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
screen_destroy(struct screen *screen) {
|
screen_destroy(struct screen *screen) {
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
|
|
@ -73,6 +73,13 @@ screen_init(struct screen *screen, struct fps_counter *fps_counter,
|
||||||
void
|
void
|
||||||
screen_destroy(struct screen *screen);
|
screen_destroy(struct screen *screen);
|
||||||
|
|
||||||
|
// hide the window
|
||||||
|
//
|
||||||
|
// It is used to hide the window immediately on closing without waiting for
|
||||||
|
// screen_destroy()
|
||||||
|
void
|
||||||
|
screen_hide_window(struct screen *screen);
|
||||||
|
|
||||||
// render the texture to the renderer
|
// render the texture to the renderer
|
||||||
//
|
//
|
||||||
// Set the update_content_rect flag if the window or content size may have
|
// Set the update_content_rect flag if the window or content size may have
|
||||||
|
|
Loading…
Reference in a new issue