summaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
Diffstat (limited to 'sway')
-rw-r--r--sway/ipc-json.c25
-rw-r--r--sway/ipc-server.c13
-rw-r--r--sway/sway-security.7.txt3
3 files changed, 41 insertions, 0 deletions
diff --git a/sway/ipc-json.c b/sway/ipc-json.c
index ea7fd9ad..ad37216f 100644
--- a/sway/ipc-json.c
+++ b/sway/ipc-json.c
@@ -267,6 +267,31 @@ json_object *ipc_json_describe_input(struct sway_input_device *device) {
267 return object; 267 return object;
268} 268}
269 269
270json_object *ipc_json_describe_seat(struct sway_seat *seat) {
271 if (!(sway_assert(seat, "Seat must not be null"))) {
272 return NULL;
273 }
274
275 json_object *object = json_object_new_object();
276 struct sway_container *focus = seat_get_focus(seat);
277
278 json_object_object_add(object, "name",
279 json_object_new_string(seat->wlr_seat->name));
280 json_object_object_add(object, "capabilities",
281 json_object_new_int(seat->wlr_seat->capabilities));
282 json_object_object_add(object, "focus",
283 json_object_new_int(focus ? focus->id : 0));
284
285 json_object *devices = json_object_new_array();
286 struct sway_seat_device *device = NULL;
287 wl_list_for_each(device, &seat->devices, link) {
288 json_object_array_add(devices, ipc_json_describe_input(device->input_device));
289 }
290 json_object_object_add(object, "devices", devices);
291
292 return object;
293}
294
270json_object *ipc_json_describe_bar_config(struct bar_config *bar) { 295json_object *ipc_json_describe_bar_config(struct bar_config *bar) {
271 if (!sway_assert(bar, "Bar must not be NULL")) { 296 if (!sway_assert(bar, "Bar must not be NULL")) {
272 return NULL; 297 return NULL;
diff --git a/sway/ipc-server.c b/sway/ipc-server.c
index 39d1d0a7..8734e8f8 100644
--- a/sway/ipc-server.c
+++ b/sway/ipc-server.c
@@ -546,6 +546,19 @@ void ipc_client_handle_command(struct ipc_client *client) {
546 goto exit_cleanup; 546 goto exit_cleanup;
547 } 547 }
548 548
549 case IPC_GET_SEATS:
550 {
551 json_object *seats = json_object_new_array();
552 struct sway_seat *seat = NULL;
553 wl_list_for_each(seat, &input_manager->seats, link) {
554 json_object_array_add(seats, ipc_json_describe_seat(seat));
555 }
556 const char *json_string = json_object_to_json_string(seats);
557 ipc_send_reply(client, json_string, (uint32_t)strlen(json_string));
558 json_object_put(seats); // free
559 goto exit_cleanup;
560 }
561
549 case IPC_GET_TREE: 562 case IPC_GET_TREE:
550 { 563 {
551 json_object *tree = 564 json_object *tree =
diff --git a/sway/sway-security.7.txt b/sway/sway-security.7.txt
index c8d6758c..2cb4e76d 100644
--- a/sway/sway-security.7.txt
+++ b/sway/sway-security.7.txt
@@ -195,6 +195,9 @@ The following commands are available within this block:
195**outputs** <enabled|disabled>:: 195**outputs** <enabled|disabled>::
196 Controls GET_OUTPUTS. 196 Controls GET_OUTPUTS.
197 197
198**seats** <enabled|disabled>::
199 Controls GET_SEATS.
200
198**tree** <enabled|disabled>:: 201**tree** <enabled|disabled>::
199 Controls GET_TREE. 202 Controls GET_TREE.
200 203