]> git.sur5r.net Git - i3/i3/commitdiff
properly serialize floating/scratchpad state when restarting
authorMichael Stapelberg <michael@stapelberg.de>
Thu, 5 Jan 2012 21:39:18 +0000 (21:39 +0000)
committerMichael Stapelberg <michael@stapelberg.de>
Thu, 5 Jan 2012 21:41:20 +0000 (21:41 +0000)
src/ipc.c
src/load_layout.c
testcases/t/116-nestedcons.t

index 5143695bc29bfeb7da4a58da5e7f39aecdf4e734..8a50761d1a01362572af12a9562c94c10e828f69 100644 (file)
--- a/src/ipc.c
+++ b/src/ipc.c
@@ -274,6 +274,22 @@ void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) {
     ystr("fullscreen_mode");
     y(integer, con->fullscreen_mode);
 
+    ystr("floating");
+    switch (con->floating) {
+        case FLOATING_AUTO_OFF:
+            ystr("auto_off");
+            break;
+        case FLOATING_AUTO_ON:
+            ystr("auto_on");
+            break;
+        case FLOATING_USER_OFF:
+            ystr("user_off");
+            break;
+        case FLOATING_USER_ON:
+            ystr("user_on");
+            break;
+    }
+
     ystr("swallows");
     y(array_open);
     Match *match;
index ef787fd1a8356df2812c25665b2b270bb7eafb75..08d03bd13e50cadbb4c834f1e979bfeb1524ef6f 100644 (file)
@@ -156,6 +156,28 @@ static int json_string(void *ctx, const unsigned char *val, unsigned int len) {
             char *buf = NULL;
             sasprintf(&buf, "%.*s", (int)len, val);
             json_node->mark = buf;
+        } else if (strcasecmp(last_key, "floating") == 0) {
+            char *buf = NULL;
+            sasprintf(&buf, "%.*s", (int)len, val);
+            if (strcasecmp(buf, "auto_off") == 0)
+                json_node->floating = FLOATING_AUTO_OFF;
+            else if (strcasecmp(buf, "auto_on") == 0)
+                json_node->floating = FLOATING_AUTO_ON;
+            else if (strcasecmp(buf, "user_off") == 0)
+                json_node->floating = FLOATING_USER_OFF;
+            else if (strcasecmp(buf, "user_on") == 0)
+                json_node->floating = FLOATING_USER_ON;
+            free(buf);
+        } else if (strcasecmp(last_key, "scratchpad_state") == 0) {
+            char *buf = NULL;
+            sasprintf(&buf, "%.*s", (int)len, val);
+            if (strcasecmp(buf, "none") == 0)
+                json_node->scratchpad_state = SCRATCHPAD_NONE;
+            else if (strcasecmp(buf, "fresh") == 0)
+                json_node->scratchpad_state = SCRATCHPAD_FRESH;
+            else if (strcasecmp(buf, "changed") == 0)
+                json_node->scratchpad_state = SCRATCHPAD_CHANGED;
+            free(buf);
         }
     }
     return 1;
index d3ed9969b46c6e1cc9765e464716d98787b6e5bf..3a495e2788d5ee6842c745197fc96977511cb27e 100644 (file)
@@ -46,6 +46,7 @@ my $expected = {
     swallows => $ignore,
     percent => undef,
     layout => 'default',
+    floating => 'auto_off',
     scratchpad_state => 'none',
     focus => $ignore,
     focused => JSON::XS::false,