Detach instead of exiting when compositor goes away

output-management
Andri Yngvason 2023-11-11 15:10:10 +00:00
parent 9647d1089a
commit 3af4851e4d
1 changed files with 13 additions and 2 deletions

View File

@ -119,6 +119,8 @@ struct wayvnc {
struct ctl* ctl;
bool is_initializing;
bool start_detached;
};
struct wayvnc_client {
@ -456,14 +458,21 @@ void on_wayland_event(void* obj)
if (wl_display_read_events(self->display) < 0) {
if (errno == EPIPE || errno == ECONNRESET) {
nvnc_log(NVNC_LOG_ERROR, "Compositor has gone away. Exiting...");
wayvnc_exit(self);
if (self->start_detached)
wayland_detach(self);
else
wayvnc_exit(self);
return;
} else {
nvnc_log(NVNC_LOG_ERROR, "Failed to read wayland events: %m");
}
}
if (wl_display_dispatch_pending(self->display) < 0)
if (wl_display_dispatch_pending(self->display) < 0) {
nvnc_log(NVNC_LOG_ERROR, "Failed to dispatch pending");
wayland_detach(self);
// TODO: Re-attach
}
}
static int init_wayland(struct wayvnc* self, const char* display)
@ -1693,6 +1702,8 @@ int main(int argc, char* argv[])
"transient-seat");
start_detached = !!option_parser_get_value(&option_parser, "detached");
self.start_detached = start_detached;
keyboard_options = option_parser_get_value(&option_parser, "keyboard");
if (keyboard_options)
parse_keyboard_option(&self, keyboard_options);