Preserve back_and_forth during restart
Add new key "previous_workspace_name" to the json dump of the root container.
This commit is contained in:
parent
f08119298e
commit
64ab1f42b7
|
@ -24,6 +24,13 @@
|
||||||
#define NET_WM_DESKTOP_NONE 0xFFFFFFF0
|
#define NET_WM_DESKTOP_NONE 0xFFFFFFF0
|
||||||
#define NET_WM_DESKTOP_ALL 0xFFFFFFFF
|
#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
|
* Returns the workspace with the given name or NULL if such a workspace does
|
||||||
* not exist.
|
* not exist.
|
||||||
|
|
|
@ -651,6 +651,11 @@ void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) {
|
||||||
y(integer, con->depth);
|
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);
|
y(map_close);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -420,6 +420,9 @@ static int json_string(void *ctx, const unsigned char *val, size_t len) {
|
||||||
else if (strcasecmp(buf, "changed") == 0)
|
else if (strcasecmp(buf, "changed") == 0)
|
||||||
json_node->scratchpad_state = SCRATCHPAD_CHANGED;
|
json_node->scratchpad_state = SCRATCHPAD_CHANGED;
|
||||||
free(buf);
|
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;
|
return 1;
|
||||||
|
|
|
@ -11,9 +11,12 @@
|
||||||
#include "all.h"
|
#include "all.h"
|
||||||
#include "yajl_utils.h"
|
#include "yajl_utils.h"
|
||||||
|
|
||||||
/* Stores a copy of the name of the last used workspace for the workspace
|
/*
|
||||||
* back-and-forth switching. */
|
* Stores a copy of the name of the last used workspace for the workspace
|
||||||
static char *previous_workspace_name = NULL;
|
* back-and-forth switching.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
char *previous_workspace_name = NULL;
|
||||||
|
|
||||||
/* NULL-terminated list of workspace names (in order) extracted from
|
/* NULL-terminated list of workspace names (in order) extracted from
|
||||||
* keybindings. */
|
* keybindings. */
|
||||||
|
|
|
@ -163,6 +163,14 @@ cmd 'scratchpad show';
|
||||||
cmd 'workspace back_and_forth';
|
cmd 'workspace back_and_forth';
|
||||||
is(focused_ws, '6: baz', 'workspace 6 now focused');
|
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);
|
exit_gracefully($pid);
|
||||||
|
|
||||||
done_testing;
|
done_testing;
|
||||||
|
|
Loading…
Reference in New Issue