]> git.sur5r.net Git - i3/i3/blobdiff - src/load_layout.c
Allow multiple marks on windows.
[i3/i3] / src / load_layout.c
index 4a67e6b1fe1828883329004597186c3ca921ae9f..68c4f4a2bb244048a08c185b2d6f73a814bd86d9 100644 (file)
@@ -28,6 +28,7 @@ static bool parsing_deco_rect;
 static bool parsing_window_rect;
 static bool parsing_geometry;
 static bool parsing_focus;
+static bool parsing_marks;
 struct Match *current_swallow;
 
 /* This list is used for reordering the focus stack after parsing the 'focus'
@@ -159,12 +160,16 @@ static int json_end_map(void *ctx) {
 
 static int json_end_array(void *ctx) {
     LOG("end of array\n");
-    if (!parsing_swallows && !parsing_focus) {
+    if (!parsing_swallows && !parsing_focus && !parsing_marks) {
         con_fix_percent(json_node);
     }
     if (parsing_swallows) {
         parsing_swallows = false;
     }
+    if (parsing_marks) {
+        parsing_marks = false;
+    }
+
     if (parsing_focus) {
         /* Clear the list of focus mappings */
         struct focus_mapping *mapping;
@@ -214,6 +219,9 @@ static int json_key(void *ctx, const unsigned char *val, size_t len) {
     if (strcasecmp(last_key, "focus") == 0)
         parsing_focus = true;
 
+    if (strcasecmp(last_key, "marks") == 0)
+        parsing_marks = true;
+
     return 1;
 }
 
@@ -234,6 +242,11 @@ static int json_string(void *ctx, const unsigned char *val, size_t len) {
             ELOG("swallow key %s unknown\n", last_key);
         }
         free(sval);
+    } else if (parsing_marks) {
+        char *mark;
+        sasprintf(&mark, "%.*s", (int)len, val);
+
+        con_mark(json_node, mark);
     } else {
         if (strcasecmp(last_key, "name") == 0) {
             json_node->name = scalloc(len + 1, 1);
@@ -336,13 +349,12 @@ static int json_string(void *ctx, const unsigned char *val, size_t len) {
                 LOG("Unhandled \"last_splitlayout\": %s\n", buf);
             free(buf);
         } else if (strcasecmp(last_key, "mark") == 0) {
+            DLOG("Found deprecated key \"mark\".\n");
+
             char *buf = NULL;
             sasprintf(&buf, "%.*s", (int)len, val);
 
-            /* We unmark any containers using this mark to avoid duplicates. */
-            con_unmark(buf);
-
-            json_node->mark = buf;
+            con_mark(json_node, buf);
         } else if (strcasecmp(last_key, "floating") == 0) {
             char *buf = NULL;
             sasprintf(&buf, "%.*s", (int)len, val);
@@ -589,6 +601,7 @@ void tree_append_json(Con *con, const char *filename, char **errormsg) {
     parsing_window_rect = false;
     parsing_geometry = false;
     parsing_focus = false;
+    parsing_marks = false;
     setlocale(LC_NUMERIC, "C");
     stat = yajl_parse(hand, (const unsigned char *)buf, n);
     if (stat != yajl_status_ok) {