diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-05-16 21:54:16 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-16 21:54:16 -0400 |
commit | c2c5a3f5f6bdc061acae4e0583c4fd85c7ed21ac (patch) | |
tree | 02f3205870487dbedb981a1770a6ec77c8894c15 /sway/commands/show_marks.c | |
parent | fe24f58297b4fb7bad94a5bad1593f12a764356c (diff) | |
parent | f0212d66eee61517ab1bb0f8bb68784d50e14c9a (diff) |
Merge pull request #1982 from RyanDwyer/show-marks
Implement show_marks
Diffstat (limited to 'sway/commands/show_marks.c')
-rw-r--r-- | sway/commands/show_marks.c | 43 |
1 files changed, 43 insertions, 0 deletions
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); +} |