diff options
Diffstat (limited to 'sway/commands')
-rw-r--r-- | sway/commands/client.c | 4 | ||||
-rw-r--r-- | sway/commands/mark.c | 19 | ||||
-rw-r--r-- | sway/commands/move.c | 6 | ||||
-rw-r--r-- | sway/commands/reload.c | 4 | ||||
-rw-r--r-- | sway/commands/show_marks.c | 4 | ||||
-rw-r--r-- | sway/commands/swap.c | 4 | ||||
-rw-r--r-- | sway/commands/unmark.c | 41 |
7 files changed, 35 insertions, 47 deletions
diff --git a/sway/commands/client.c b/sway/commands/client.c index 9f54fa94..746e8713 100644 --- a/sway/commands/client.c +++ b/sway/commands/client.c @@ -5,9 +5,7 @@ #include "sway/tree/container.h" static void rebuild_textures_iterator(struct sway_container *con, void *data) { - if (con->view) { - view_update_marks_textures(con->view); - } + container_update_marks_textures(con); container_update_title_textures(con); } diff --git a/sway/commands/mark.c b/sway/commands/mark.c index b1f47be1..c76e1d63 100644 --- a/sway/commands/mark.c +++ b/sway/commands/mark.c @@ -19,11 +19,10 @@ struct cmd_results *cmd_mark(int argc, char **argv) { return error; } struct sway_container *container = config->handler_context.container; - if (!container || !container->view) { + if (!container) { return cmd_results_new(CMD_INVALID, "mark", - "Only views can have marks"); + "Only containers can have marks"); } - struct sway_view *view = container->view; bool add = false, toggle = false; while (argc > 0 && strncmp(*argv, "--", 2) == 0) { @@ -47,22 +46,24 @@ struct cmd_results *cmd_mark(int argc, char **argv) { } char *mark = join_args(argv, argc); - bool had_mark = view_has_mark(view, mark); + bool had_mark = container_has_mark(container, mark); if (!add) { // Replacing - view_clear_marks(view); + container_clear_marks(container); } - view_find_and_unmark(mark); + container_find_and_unmark(mark); if (!toggle || !had_mark) { - view_add_mark(view, mark); + container_add_mark(container, mark); } free(mark); - view_update_marks_textures(view); - view_execute_criteria(view); + container_update_marks_textures(container); + if (container->view) { + view_execute_criteria(container->view); + } return cmd_results_new(CMD_SUCCESS, NULL, NULL); } diff --git a/sway/commands/move.c b/sway/commands/move.c index 9035e3e2..7d8c1f1a 100644 --- a/sway/commands/move.c +++ b/sway/commands/move.c @@ -488,12 +488,12 @@ static struct cmd_results *cmd_move_container(int argc, char **argv) { } destination = seat_get_focus_inactive(seat, &new_output->node); } else if (strcasecmp(argv[1], "mark") == 0) { - struct sway_view *dest_view = view_find_mark(argv[2]); - if (dest_view == NULL) { + struct sway_container *dest_con = container_find_mark(argv[2]); + if (dest_con == NULL) { return cmd_results_new(CMD_FAILURE, "move", "Mark '%s' not found", argv[2]); } - destination = &dest_view->container->node; + destination = &dest_con->node; } else { return cmd_results_new(CMD_INVALID, "move", expected_syntax); } diff --git a/sway/commands/reload.c b/sway/commands/reload.c index 791081a8..62105cdc 100644 --- a/sway/commands/reload.c +++ b/sway/commands/reload.c @@ -10,9 +10,7 @@ #include "log.h" static void rebuild_textures_iterator(struct sway_container *con, void *data) { - if (con->view) { - view_update_marks_textures(con->view); - } + container_update_marks_textures(con); container_update_title_textures(con); } diff --git a/sway/commands/show_marks.c b/sway/commands/show_marks.c index d501584a..0baf6852 100644 --- a/sway/commands/show_marks.c +++ b/sway/commands/show_marks.c @@ -11,9 +11,7 @@ #include "util.h" static void rebuild_marks_iterator(struct sway_container *con, void *data) { - if (con->view) { - view_update_marks_textures(con->view); - } + container_update_marks_textures(con); } struct cmd_results *cmd_show_marks(int argc, char **argv) { diff --git a/sway/commands/swap.c b/sway/commands/swap.c index a70a6cdd..23e8d583 100644 --- a/sway/commands/swap.c +++ b/sway/commands/swap.c @@ -159,8 +159,8 @@ static bool test_id(struct sway_container *container, void *id) { } static bool test_mark(struct sway_container *container, void *mark) { - if (container->view && container->view->marks->length) { - return !list_seq_find(container->view->marks, + if (container->marks->length) { + return !list_seq_find(container->marks, (int (*)(const void *, const void *))strcmp, mark); } return false; diff --git a/sway/commands/unmark.c b/sway/commands/unmark.c index c671ed4e..98ac6ff2 100644 --- a/sway/commands/unmark.c +++ b/sway/commands/unmark.c @@ -9,10 +9,8 @@ #include "stringop.h" static void remove_all_marks_iterator(struct sway_container *con, void *data) { - if (con->view) { - view_clear_marks(con->view); - view_update_marks_textures(con->view); - } + container_clear_marks(con); + container_update_marks_textures(con); } // unmark Remove all marks from all views @@ -21,15 +19,10 @@ static void remove_all_marks_iterator(struct sway_container *con, void *data) { // [criteria] unmark foo Remove single mark from matched view struct cmd_results *cmd_unmark(int argc, char **argv) { - // Determine the view - struct sway_view *view = NULL; + // Determine the container + struct sway_container *con = NULL; if (config->handler_context.using_criteria) { - struct sway_container *container = config->handler_context.container; - if (!container || !container->view) { - return cmd_results_new(CMD_INVALID, "unmark", - "Only views can have marks"); - } - view = container->view; + con = config->handler_context.container; } // Determine the mark @@ -38,20 +31,20 @@ struct cmd_results *cmd_unmark(int argc, char **argv) { mark = join_args(argv, argc); } - if (view && mark) { - // Remove the mark from the given view - if (view_has_mark(view, mark)) { - view_find_and_unmark(mark); + if (con && mark) { + // Remove the mark from the given container + if (container_has_mark(con, mark)) { + container_find_and_unmark(mark); } - } else if (view && !mark) { - // Clear all marks from the given view - view_clear_marks(view); - view_update_marks_textures(view); - } else if (!view && mark) { - // Remove mark from whichever view has it - view_find_and_unmark(mark); + } else if (con && !mark) { + // Clear all marks from the given container + container_clear_marks(con); + container_update_marks_textures(con); + } else if (!con && mark) { + // Remove mark from whichever container has it + container_find_and_unmark(mark); } else { - // Remove all marks from all views + // Remove all marks from all containers root_for_each_container(remove_all_marks_iterator, NULL); } free(mark); |