Merge pull request #3551 from xzfc/baf-restart

Preserve back_and_forth during restart
This commit is contained in:
Ingo Bürk 2018-12-11 20:53:08 +01:00 committed by GitHub
commit 32188d7b2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 3 deletions

View File

@ -24,6 +24,13 @@
#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.

View File

@ -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);
}

View 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;

View File

@ -11,9 +11,12 @@
#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. */

View 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;