diff options
Diffstat (limited to 'sway/ipc-server.c')
-rw-r--r-- | sway/ipc-server.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/sway/ipc-server.c b/sway/ipc-server.c index 8734e8f8..15ed6f80 100644 --- a/sway/ipc-server.c +++ b/sway/ipc-server.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include "sway/server.h" | 22 | #include "sway/server.h" |
23 | #include "sway/input/input-manager.h" | 23 | #include "sway/input/input-manager.h" |
24 | #include "sway/input/seat.h" | 24 | #include "sway/input/seat.h" |
25 | #include "sway/tree/view.h" | ||
25 | #include "list.h" | 26 | #include "list.h" |
26 | #include "log.h" | 27 | #include "log.h" |
27 | 28 | ||
@@ -429,6 +430,16 @@ static void ipc_get_workspaces_callback(struct sway_container *workspace, | |||
429 | json_object_new_boolean(visible)); | 430 | json_object_new_boolean(visible)); |
430 | } | 431 | } |
431 | 432 | ||
433 | static void ipc_get_marks_callback(struct sway_container *con, void *data) { | ||
434 | json_object *marks = (json_object *)data; | ||
435 | if (con->type == C_VIEW && con->sway_view->marks) { | ||
436 | for (int i = 0; i < con->sway_view->marks->length; ++i) { | ||
437 | char *mark = (char *)con->sway_view->marks->items[i]; | ||
438 | json_object_array_add(marks, json_object_new_string(mark)); | ||
439 | } | ||
440 | } | ||
441 | } | ||
442 | |||
432 | void ipc_client_handle_command(struct ipc_client *client) { | 443 | void ipc_client_handle_command(struct ipc_client *client) { |
433 | if (!sway_assert(client != NULL, "client != NULL")) { | 444 | if (!sway_assert(client != NULL, "client != NULL")) { |
434 | return; | 445 | return; |
@@ -569,6 +580,17 @@ void ipc_client_handle_command(struct ipc_client *client) { | |||
569 | goto exit_cleanup; | 580 | goto exit_cleanup; |
570 | } | 581 | } |
571 | 582 | ||
583 | case IPC_GET_MARKS: | ||
584 | { | ||
585 | json_object *marks = json_object_new_array(); | ||
586 | container_descendants(&root_container, C_VIEW, ipc_get_marks_callback, | ||
587 | marks); | ||
588 | const char *json_string = json_object_to_json_string(marks); | ||
589 | ipc_send_reply(client, json_string, (uint32_t)strlen(json_string)); | ||
590 | json_object_put(marks); | ||
591 | goto exit_cleanup; | ||
592 | } | ||
593 | |||
572 | case IPC_GET_VERSION: | 594 | case IPC_GET_VERSION: |
573 | { | 595 | { |
574 | json_object *version = ipc_json_get_version(); | 596 | json_object *version = ipc_json_get_version(); |