Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

main: Added quit on last client disconnect #309

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ enum socket_type {

struct wayvnc {
bool do_exit;
bool exit_on_disconnect;

struct wl_display* display;
struct wl_registry* registry;
Expand Down Expand Up @@ -1296,6 +1297,10 @@ static void client_destroy(void* obj)
nvnc_log(NVNC_LOG_DEBUG, "Client disconnected, new client count: %d",
wayvnc->nr_clients);

if (self->server->exit_on_disconnect && self->server->nr_clients == 0) {
wayvnc_exit(wayvnc);
}

if (wayvnc->ctl) {
struct ctl_server_client_info info = {};
compose_client_info(self, &info);
Expand Down Expand Up @@ -1720,6 +1725,8 @@ int main(int argc, char* argv[])
bool disable_input = false;
bool use_transient_seat = false;

bool exit_on_disconnect = false;

int drm_fd MAYBE_UNUSED = -1;

int log_level = NVNC_LOG_WARNING;
Expand Down Expand Up @@ -1752,6 +1759,8 @@ int main(int argc, char* argv[])
.default_ = "30" },
{ 'p', "performance", NULL,
"Show performance counters." },
{ 'e', "exit-on-disconnect", NULL,
"Exit on last client disconnect." },
{ 'u', "unix-socket", NULL,
"Create unix domain socket." },
{ 'd', "disable-input", NULL,
Expand Down Expand Up @@ -1794,6 +1803,7 @@ int main(int argc, char* argv[])
socket_path = option_parser_get_value(&option_parser, "socket");
overlay_cursor = !!option_parser_get_value(&option_parser, "render-cursor");
show_performance = !!option_parser_get_value(&option_parser, "performance");
exit_on_disconnect = !!option_parser_get_value(&option_parser, "exit-on-disconnect");
use_unix_socket = !!option_parser_get_value(&option_parser, "unix-socket");
use_websocket = !!option_parser_get_value(&option_parser, "websocket");
disable_input = !!option_parser_get_value(&option_parser, "disable-input");
Expand All @@ -1807,6 +1817,7 @@ int main(int argc, char* argv[])
start_detached = !!option_parser_get_value(&option_parser, "detached");

self.start_detached = start_detached;
self.exit_on_disconnect = exit_on_disconnect;

keyboard_options = option_parser_get_value(&option_parser, "keyboard");
if (keyboard_options)
Expand Down
Loading