diff options
author | Drew DeVault <sir@cmpwn.com> | 2015-08-31 07:11:02 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2015-08-31 07:11:02 -0400 |
commit | 4d9b05e649ff902c3b53b7e56c0feaa6087f13dc (patch) | |
tree | 60c4c9e7e61126f695c6fb049e2fde7337fc731c /sway/workspace.c | |
parent | 0ab71f5f0a47fd87bb71d7361ea90a8fa88c8361 (diff) | |
parent | 12e96f0f9e77658e4f490a1ae94c66a4df40b66f (diff) |
Merge pull request #156 from Luminarys/master
Added in workspace_auto_back_and_forth
Diffstat (limited to 'sway/workspace.c')
-rw-r--r-- | sway/workspace.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/sway/workspace.c b/sway/workspace.c index 0f36e35a..866276d8 100644 --- a/sway/workspace.c +++ b/sway/workspace.c @@ -13,7 +13,7 @@ #include "focus.h" #include "util.h" -char *prev_workspace_name; +char *prev_workspace_name = ""; char *workspace_next_name(void) { sway_log(L_DEBUG, "Workspace: Generating new name"); @@ -182,7 +182,11 @@ void workspace_switch(swayc_t *workspace) { if (!workspace) { return; } - if (!prev_workspace_name || strcmp(prev_workspace_name, swayc_active_workspace()->name) != 0) { + if (strcmp(prev_workspace_name, swayc_active_workspace()->name) != 0 && swayc_active_workspace() != workspace) { + prev_workspace_name = malloc(strlen(swayc_active_workspace()->name) + 1); + strcpy(prev_workspace_name, swayc_active_workspace()->name); + } else if (config->auto_back_and_forth && swayc_active_workspace() == workspace && strlen(prev_workspace_name) != 0) { + workspace = workspace_by_name(prev_workspace_name) ? workspace_by_name(prev_workspace_name) : workspace_create(prev_workspace_name); prev_workspace_name = malloc(strlen(swayc_active_workspace()->name) + 1); strcpy(prev_workspace_name, swayc_active_workspace()->name); } |