From 467cfa1889564a86b1406cd7a34023fb64a7d9d7 Mon Sep 17 00:00:00 2001 From: Jim Ramsay Date: Thu, 24 Nov 2022 20:57:26 -0500 Subject: [PATCH] Add wayvncctl capture-changed event Signed-off-by: Jim Ramsay --- include/ctl-server.h | 3 +++ src/ctl-server.c | 16 ++++++++++++++++ src/main.c | 2 ++ wayvnc.scd | 10 ++++++++++ 4 files changed, 31 insertions(+) diff --git a/include/ctl-server.h b/include/ctl-server.h index 9dfbb8e..8c99f3c 100644 --- a/include/ctl-server.h +++ b/include/ctl-server.h @@ -76,3 +76,6 @@ void ctl_server_event_disconnected(struct ctl*, const char* client_hostname, const char* client_username, int new_connection_count); + +void ctl_server_event_capture_changed(struct ctl*, + const char* captured_output); diff --git a/src/ctl-server.c b/src/ctl-server.c index e7c237a..2f7e695 100644 --- a/src/ctl-server.c +++ b/src/ctl-server.c @@ -56,6 +56,7 @@ enum cmd_type { enum event_type { EVT_CLIENT_CONNECTED, EVT_CLIENT_DISCONNECTED, + EVT_CAPTURE_CHANGED, EVT_UNKNOWN, }; #define EVT_LIST_LEN EVT_UNKNOWN @@ -130,6 +131,14 @@ static struct cmd_info evt_list[] = { "Sent when a vnc client disconnects from wayvnc", { CLIENT_EVENT_PARAMS("not including") } }, + [EVT_CAPTURE_CHANGED] = {"capture-changed", + "Sent when wayvnc changes which output is captured", + { + {"output", "The name of the output now being captured"}, + {NULL, NULL}, + }, + }, + }; struct cmd { @@ -1038,3 +1047,10 @@ void ctl_server_event_disconnected(struct ctl* self, ctl_server_event_connect(self, EVT_CLIENT_DISCONNECTED, client_id, client_hostname, client_username, new_connection_count); } + +void ctl_server_event_capture_changed(struct ctl* self, + const char* captured_output) +{ + ctl_server_enqueue_event(self, EVT_CAPTURE_CHANGED, + json_pack("{s:s}", "output", captured_output)); +} diff --git a/src/main.c b/src/main.c index ae86b59..bc0264e 100644 --- a/src/main.c +++ b/src/main.c @@ -1087,6 +1087,8 @@ void set_selected_output(struct wayvnc* self, struct output* output) { self->screencopy.wl_output = output->wl_output; output->on_dimension_change = on_output_dimension_change; output->userdata = self; + if (self->ctl) + ctl_server_event_capture_changed(self->ctl, output->name); log_selected_output(self); } diff --git a/wayvnc.scd b/wayvnc.scd index 9202aba..e8178a4 100644 --- a/wayvnc.scd +++ b/wayvnc.scd @@ -262,6 +262,16 @@ Parameters: *username=...* The username used to authenticate this client. May be null. +_CAPTURE_CHANGED_ + +The *capture-changed* event is sent when the currently captured output +changes. + +Parameters: + +*output=...* + The name of the output now being captured. + ## IPC MESSAGE FORMAT The *wayvncctl(1)* command line utility will construct properly-formatted json