diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-05-12 09:01:16 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2018-05-12 09:01:16 -0400 |
commit | 2da685e913432716f55cd537fd3d64f3fb3cc09a (patch) | |
tree | c986cca12ecdb3e3ac4d94d38205028788315889 /sway | |
parent | Merge branch 'master' into scdoc (diff) | |
parent | Merge pull request #1959 from RyanDwyer/ipc-get-seats (diff) | |
download | sway-2da685e913432716f55cd537fd3d64f3fb3cc09a.tar.gz sway-2da685e913432716f55cd537fd3d64f3fb3cc09a.tar.zst sway-2da685e913432716f55cd537fd3d64f3fb3cc09a.zip |
Merge remote-tracking branch 'origin/master' into scdoc
Diffstat (limited to 'sway')
-rw-r--r-- | sway/ipc-json.c | 25 | ||||
-rw-r--r-- | sway/ipc-server.c | 13 |
2 files changed, 38 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 | ||
270 | json_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 | |||
270 | json_object *ipc_json_describe_bar_config(struct bar_config *bar) { | 295 | json_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 = |