Exit when the compositor goes away

vencrypt
Andri Yngvason 2020-01-21 19:16:36 +00:00
parent 48907682c7
commit 0572693f21
1 changed files with 9 additions and 1 deletions

View File

@ -90,6 +90,7 @@ struct wayvnc {
const char* kb_layout; const char* kb_layout;
}; };
void wayvnc_exit(void);
void on_capture_done(struct frame_capture* capture); void on_capture_done(struct frame_capture* capture);
static enum frame_capture_backend_type static enum frame_capture_backend_type
@ -272,6 +273,12 @@ failure:
void on_wayland_event(uv_poll_t* handle, int status, int event) void on_wayland_event(uv_poll_t* handle, int status, int event)
{ {
if (event & UV_DISCONNECT) {
log_error("The compositor is gone. Exiting...\n");
wayvnc_exit();
return;
}
struct wayvnc* self = wl_container_of(handle, self, wayland_poller); struct wayvnc* self = wl_container_of(handle, self, wayland_poller);
wl_display_dispatch(self->display); wl_display_dispatch(self->display);
} }
@ -311,7 +318,8 @@ int init_main_loop(struct wayvnc* self)
uv_poll_init(loop, &self->wayland_poller, uv_poll_init(loop, &self->wayland_poller,
wl_display_get_fd(self->display)); wl_display_get_fd(self->display));
uv_poll_start(&self->wayland_poller, UV_READABLE, on_wayland_event); uv_poll_start(&self->wayland_poller, UV_READABLE | UV_DISCONNECT,
on_wayland_event);
uv_prepare_init(loop, &self->flusher); uv_prepare_init(loop, &self->flusher);
uv_prepare_start(&self->flusher, prepare_for_poll); uv_prepare_start(&self->flusher, prepare_for_poll);