]> git.sur5r.net Git - i3/i3/commitdiff
Preserve back_and_forth during restart 3551/head
authorAlbert Safin <xzfcpw@gmail.com>
Mon, 10 Dec 2018 14:51:30 +0000 (21:51 +0700)
committerAlbert Safin <xzfcpw@gmail.com>
Tue, 11 Dec 2018 13:46:06 +0000 (20:46 +0700)
Add new key "previous_workspace_name" to the json dump of the root container.

include/workspace.h
src/ipc.c
src/load_layout.c
src/workspace.c
testcases/t/176-workspace-baf.t

index 28d9eb66cd18f8179bd373e5b8362d6ce0a7bd2f..db544ce8eea6d154120b5a13118dc033a0c533b4 100644 (file)
 #define NET_WM_DESKTOP_NONE 0xFFFFFFF0
 #define NET_WM_DESKTOP_ALL 0xFFFFFFFF
 
+/**
+ * Stores a copy of the name of the last used workspace for the workspace
+ * back-and-forth switching.
+ *
+ */
+extern char *previous_workspace_name;
+
 /**
  * Returns the workspace with the given name or NULL if such a workspace does
  * not exist.
index d0fb965c3d8e55dafbd5fdbd8c97f63e1794d913..2ad5ae0f4e3bef4e41325b165fa82e87098e3fb1 100644 (file)
--- a/src/ipc.c
+++ b/src/ipc.c
@@ -651,6 +651,11 @@ void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) {
         y(integer, con->depth);
     }
 
+    if (inplace_restart && con->type == CT_ROOT && previous_workspace_name) {
+        ystr("previous_workspace_name");
+        ystr(previous_workspace_name);
+    }
+
     y(map_close);
 }
 
index 003affeee35385ec1dac77a24bf213e0ac8b9f3d..47daada1c20048809439fb16d1f7d741c4d54e63 100644 (file)
@@ -420,6 +420,9 @@ static int json_string(void *ctx, const unsigned char *val, size_t len) {
             else if (strcasecmp(buf, "changed") == 0)
                 json_node->scratchpad_state = SCRATCHPAD_CHANGED;
             free(buf);
+        } else if (strcasecmp(last_key, "previous_workspace_name") == 0) {
+            FREE(previous_workspace_name);
+            previous_workspace_name = sstrndup((const char *)val, len);
         }
     }
     return 1;
index f95073c9f911b7bcfef17375071cb9d3726f4dc8..2af88d73de1f915d67717c530a9331393c1e3274 100644 (file)
 #include "all.h"
 #include "yajl_utils.h"
 
-/* Stores a copy of the name of the last used workspace for the workspace
- * back-and-forth switching. */
-static char *previous_workspace_name = NULL;
+/*
+ * Stores a copy of the name of the last used workspace for the workspace
+ * back-and-forth switching.
+ *
+ */
+char *previous_workspace_name = NULL;
 
 /* NULL-terminated list of workspace names (in order) extracted from
  * keybindings. */
index 01906e4620094c8029860aa3ac43877c0a28462d..133e00fc0eeb59accf232ad28b882e2a97ed1b88 100644 (file)
@@ -163,6 +163,14 @@ cmd 'scratchpad show';
 cmd 'workspace back_and_forth';
 is(focused_ws, '6: baz', 'workspace 6 now focused');
 
+################################################################################
+# See if BAF is preserved after restart
+################################################################################
+
+cmd 'restart';
+cmd 'workspace back_and_forth';
+is(focused_ws, '5: foo', 'workspace 5 focused after restart');
+
 exit_gracefully($pid);
 
 done_testing;