diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-05-15 13:14:18 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-05-17 08:29:14 +1000 |
commit | 0e2cc0af3049c6d1b91bda3081238e2e723e81b7 (patch) | |
tree | 34a18b12524c8de5bf68712162071abe3e574d71 /sway/commands | |
parent | fe24f58297b4fb7bad94a5bad1593f12a764356c (diff) |
Implement show_marks
Diffstat (limited to 'sway/commands')
-rw-r--r-- | sway/commands/mark.c | 1 | ||||
-rw-r--r-- | sway/commands/show_marks.c | 43 | ||||
-rw-r--r-- | sway/commands/unmark.c | 2 |
3 files changed, 46 insertions, 0 deletions
diff --git a/sway/commands/mark.c b/sway/commands/mark.c index b131f2f3..5a897e69 100644 --- a/sway/commands/mark.c +++ b/sway/commands/mark.c @@ -62,6 +62,7 @@ struct cmd_results *cmd_mark(int argc, char **argv) { } free(mark); + view_update_marks_textures(view); view_execute_criteria(view); return cmd_results_new(CMD_SUCCESS, NULL, NULL); diff --git a/sway/commands/show_marks.c b/sway/commands/show_marks.c new file mode 100644 index 00000000..c7fdc538 --- /dev/null +++ b/sway/commands/show_marks.c @@ -0,0 +1,43 @@ +#define _POSIX_C_SOURCE 200809L +#include <string.h> +#include "sway/commands.h" +#include "sway/config.h" +#include "sway/tree/view.h" +#include "sway/output.h" +#include "list.h" +#include "log.h" +#include "stringop.h" + +static void rebuild_marks_iterator(struct sway_container *con, void *data) { + if (con->type == C_VIEW) { + view_update_marks_textures(con->sway_view); + } +} + +struct cmd_results *cmd_show_marks(int argc, char **argv) { + struct cmd_results *error = NULL; + if ((error = checkarg(argc, "show_marks", EXPECTED_AT_LEAST, 1))) { + return error; + } + + if (strcmp(*argv, "yes") == 0) { + config->show_marks = true; + } else if (strcmp(*argv, "no") == 0) { + config->show_marks = false; + } else { + return cmd_results_new(CMD_INVALID, "show_marks", + "Expected 'show_marks <yes|no>'"); + } + + if (config->show_marks) { + container_for_each_descendant_dfs(&root_container, + rebuild_marks_iterator, NULL); + } + + for (int i = 0; i < root_container.children->length; ++i) { + struct sway_container *con = root_container.children->items[i]; + output_damage_whole(con->sway_output); + } + + return cmd_results_new(CMD_SUCCESS, NULL, NULL); +} diff --git a/sway/commands/unmark.c b/sway/commands/unmark.c index ea2a5709..1ce2c56b 100644 --- a/sway/commands/unmark.c +++ b/sway/commands/unmark.c @@ -10,6 +10,7 @@ static void remove_all_marks_iterator(struct sway_container *con, void *data) { if (con->type == C_VIEW) { view_clear_marks(con->sway_view); + view_update_marks_textures(con->sway_view); } } @@ -45,6 +46,7 @@ struct cmd_results *cmd_unmark(int argc, char **argv) { } 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); |