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 | Merge pull request #1995 from RedSoxFan/fix-1985 (diff) | |
download | sway-0e2cc0af3049c6d1b91bda3081238e2e723e81b7.tar.gz sway-0e2cc0af3049c6d1b91bda3081238e2e723e81b7.tar.zst sway-0e2cc0af3049c6d1b91bda3081238e2e723e81b7.zip |
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) { | |||
62 | } | 62 | } |
63 | 63 | ||
64 | free(mark); | 64 | free(mark); |
65 | view_update_marks_textures(view); | ||
65 | view_execute_criteria(view); | 66 | view_execute_criteria(view); |
66 | 67 | ||
67 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 68 | 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 @@ | |||
1 | #define _POSIX_C_SOURCE 200809L | ||
2 | #include <string.h> | ||
3 | #include "sway/commands.h" | ||
4 | #include "sway/config.h" | ||
5 | #include "sway/tree/view.h" | ||
6 | #include "sway/output.h" | ||
7 | #include "list.h" | ||
8 | #include "log.h" | ||
9 | #include "stringop.h" | ||
10 | |||
11 | static void rebuild_marks_iterator(struct sway_container *con, void *data) { | ||
12 | if (con->type == C_VIEW) { | ||
13 | view_update_marks_textures(con->sway_view); | ||
14 | } | ||
15 | } | ||
16 | |||
17 | struct cmd_results *cmd_show_marks(int argc, char **argv) { | ||
18 | struct cmd_results *error = NULL; | ||
19 | if ((error = checkarg(argc, "show_marks", EXPECTED_AT_LEAST, 1))) { | ||
20 | return error; | ||
21 | } | ||
22 | |||
23 | if (strcmp(*argv, "yes") == 0) { | ||
24 | config->show_marks = true; | ||
25 | } else if (strcmp(*argv, "no") == 0) { | ||
26 | config->show_marks = false; | ||
27 | } else { | ||
28 | return cmd_results_new(CMD_INVALID, "show_marks", | ||
29 | "Expected 'show_marks <yes|no>'"); | ||
30 | } | ||
31 | |||
32 | if (config->show_marks) { | ||
33 | container_for_each_descendant_dfs(&root_container, | ||
34 | rebuild_marks_iterator, NULL); | ||
35 | } | ||
36 | |||
37 | for (int i = 0; i < root_container.children->length; ++i) { | ||
38 | struct sway_container *con = root_container.children->items[i]; | ||
39 | output_damage_whole(con->sway_output); | ||
40 | } | ||
41 | |||
42 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
43 | } | ||
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 @@ | |||
10 | static void remove_all_marks_iterator(struct sway_container *con, void *data) { | 10 | static void remove_all_marks_iterator(struct sway_container *con, void *data) { |
11 | if (con->type == C_VIEW) { | 11 | if (con->type == C_VIEW) { |
12 | view_clear_marks(con->sway_view); | 12 | view_clear_marks(con->sway_view); |
13 | view_update_marks_textures(con->sway_view); | ||
13 | } | 14 | } |
14 | } | 15 | } |
15 | 16 | ||
@@ -45,6 +46,7 @@ struct cmd_results *cmd_unmark(int argc, char **argv) { | |||
45 | } else if (view && !mark) { | 46 | } else if (view && !mark) { |
46 | // Clear all marks from the given view | 47 | // Clear all marks from the given view |
47 | view_clear_marks(view); | 48 | view_clear_marks(view); |
49 | view_update_marks_textures(view); | ||
48 | } else if (!view && mark) { | 50 | } else if (!view && mark) { |
49 | // Remove mark from whichever view has it | 51 | // Remove mark from whichever view has it |
50 | view_find_and_unmark(mark); | 52 | view_find_and_unmark(mark); |