diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-05-12 09:00:32 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-12 09:00:32 -0400 |
commit | 51b0b25587d69593eb77e3337e3fa459c1024f5c (patch) | |
tree | 77c93c14fbbe1e4df15c957c63baefcfe6473669 /sway | |
parent | 32a572cecfd0f6072a78ce0a381a2f8365f9010a (diff) | |
parent | 28eb97299e564daee96d3af1f9130d6439f170f6 (diff) | |
download | sway-51b0b25587d69593eb77e3337e3fa459c1024f5c.tar.xz |
Merge pull request #1959 from RyanDwyer/ipc-get-seats
Implement IPC get_seats command
Diffstat (limited to 'sway')
-rw-r--r-- | sway/ipc-json.c | 25 | ||||
-rw-r--r-- | sway/ipc-server.c | 13 | ||||
-rw-r--r-- | sway/sway-security.7.txt | 3 |
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) { return object; } +json_object *ipc_json_describe_seat(struct sway_seat *seat) { + if (!(sway_assert(seat, "Seat must not be null"))) { + return NULL; + } + + json_object *object = json_object_new_object(); + struct sway_container *focus = seat_get_focus(seat); + + json_object_object_add(object, "name", + json_object_new_string(seat->wlr_seat->name)); + json_object_object_add(object, "capabilities", + json_object_new_int(seat->wlr_seat->capabilities)); + json_object_object_add(object, "focus", + json_object_new_int(focus ? focus->id : 0)); + + json_object *devices = json_object_new_array(); + struct sway_seat_device *device = NULL; + wl_list_for_each(device, &seat->devices, link) { + json_object_array_add(devices, ipc_json_describe_input(device->input_device)); + } + json_object_object_add(object, "devices", devices); + + return object; +} + json_object *ipc_json_describe_bar_config(struct bar_config *bar) { if (!sway_assert(bar, "Bar must not be NULL")) { 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) { goto exit_cleanup; } + case IPC_GET_SEATS: + { + json_object *seats = json_object_new_array(); + struct sway_seat *seat = NULL; + wl_list_for_each(seat, &input_manager->seats, link) { + json_object_array_add(seats, ipc_json_describe_seat(seat)); + } + const char *json_string = json_object_to_json_string(seats); + ipc_send_reply(client, json_string, (uint32_t)strlen(json_string)); + json_object_put(seats); // free + goto exit_cleanup; + } + case IPC_GET_TREE: { 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: **outputs** <enabled|disabled>:: Controls GET_OUTPUTS. +**seats** <enabled|disabled>:: + Controls GET_SEATS. + **tree** <enabled|disabled>:: Controls GET_TREE. |