aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/mark.c
diff options
context:
space:
mode:
authorLibravatar Calvin Lee <cyrus296@gmail.com>2017-04-07 11:37:51 -0600
committerLibravatar Calvin Lee <cyrus296@gmail.com>2017-04-07 11:37:51 -0600
commit154c6718c1f0e34e0f217150ba2770ee100e5b38 (patch)
treeb929def6e7bcdbff10a7f1cc815f9a278821c666 /sway/commands/mark.c
parentMerge pull request #1153 from SirCmpwn/fix-1152 (diff)
downloadsway-154c6718c1f0e34e0f217150ba2770ee100e5b38.tar.gz
sway-154c6718c1f0e34e0f217150ba2770ee100e5b38.tar.zst
sway-154c6718c1f0e34e0f217150ba2770ee100e5b38.zip
Add `-t get_marks` and use more i3-like marks
In i3 every mark is unique and one mark cannot be used in more than one window, sway behavior has been amended to match this. `swaymsg -t get_marks` will now return an array of all marks used in sway. See #98
Diffstat (limited to 'sway/commands/mark.c')
-rw-r--r--sway/commands/mark.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/sway/commands/mark.c b/sway/commands/mark.c
index 919883b0..c1d959df 100644
--- a/sway/commands/mark.c
+++ b/sway/commands/mark.c
@@ -5,6 +5,15 @@
5#include "list.h" 5#include "list.h"
6#include "stringop.h" 6#include "stringop.h"
7 7
8static void find_marks_callback(swayc_t *container, void *_mark) {
9 char *mark = (char *)_mark;
10
11 int index;
12 if (container->marks && ((index = list_seq_find(container->marks, (int (*)(const void *, const void *))strcmp, mark)) != -1)) {
13 list_del(container->marks, index);
14 }
15}
16
8struct cmd_results *cmd_mark(int argc, char **argv) { 17struct cmd_results *cmd_mark(int argc, char **argv) {
9 struct cmd_results *error = NULL; 18 struct cmd_results *error = NULL;
10 if (config->reading) return cmd_results_new(CMD_FAILURE, "mark", "Can't be used in config file."); 19 if (config->reading) return cmd_results_new(CMD_FAILURE, "mark", "Can't be used in config file.");
@@ -30,6 +39,10 @@ struct cmd_results *cmd_mark(int argc, char **argv) {
30 39
31 if (argc) { 40 if (argc) {
32 char *mark = join_args(argv, argc); 41 char *mark = join_args(argv, argc);
42
43 // Remove all existing marks of this type
44 container_map(&root_container, find_marks_callback, mark);
45
33 if (view->marks) { 46 if (view->marks) {
34 if (add) { 47 if (add) {
35 int index; 48 int index;