summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/workspace.h2
-rw-r--r--sway/commands.c19
-rw-r--r--sway/workspace.c7
3 files changed, 24 insertions, 4 deletions
diff --git a/include/workspace.h b/include/workspace.h
index a731068d..7343b055 100644
--- a/include/workspace.h
+++ b/include/workspace.h
@@ -5,6 +5,8 @@
5#include "list.h" 5#include "list.h"
6#include "layout.h" 6#include "layout.h"
7 7
8extern char *prev_workspace_name;
9
8char *workspace_next_name(void); 10char *workspace_next_name(void);
9swayc_t *workspace_create(const char*); 11swayc_t *workspace_create(const char*);
10swayc_t *workspace_by_name(const char*); 12swayc_t *workspace_by_name(const char*);
diff --git a/sway/commands.c b/sway/commands.c
index 9a90fe5f..caf8d928 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -800,26 +800,37 @@ static bool cmd_workspace(struct sway_config *config, int argc, char **argv) {
800 800
801 if (argc == 1) { 801 if (argc == 1) {
802 // Handle workspace next/prev 802 // Handle workspace next/prev
803 if (strcmp(argv[0], "next") == 0) { 803 if (strcasecmp(argv[0], "next") == 0) {
804 workspace_switch(workspace_next()); 804 workspace_switch(workspace_next());
805 return true; 805 return true;
806 } 806 }
807 807
808 if (strcmp(argv[0], "prev") == 0) { 808 if (strcasecmp(argv[0], "prev") == 0) {
809 workspace_switch(workspace_prev()); 809 workspace_switch(workspace_prev());
810 return true; 810 return true;
811 } 811 }
812 812
813 // Handle workspace output_next/prev 813 // Handle workspace output_next/prev
814 if (strcmp(argv[0], "next_on_output") == 0) { 814 if (strcasecmp(argv[0], "next_on_output") == 0) {
815 workspace_switch(workspace_output_next()); 815 workspace_switch(workspace_output_next());
816 return true; 816 return true;
817 } 817 }
818 818
819 if (strcmp(argv[0], "prev_on_output") == 0) { 819 if (strcasecmp(argv[0], "prev_on_output") == 0) {
820 workspace_switch(workspace_output_prev()); 820 workspace_switch(workspace_output_prev());
821 return true; 821 return true;
822 } 822 }
823 if (strcasecmp(argv[0], "back_and_forth") == 0) {
824 if (prev_workspace_name) {
825 sway_log(L_INFO, "Trying to switch to WS wtih name %s", prev_workspace_name);
826 if (workspace_by_name(prev_workspace_name)) {
827 workspace_switch(workspace_by_name(prev_workspace_name));
828 } else {
829 workspace_switch(workspace_create(prev_workspace_name));
830 }
831 }
832 return true;
833 }
823 834
824 swayc_t *workspace = workspace_by_name(argv[0]); 835 swayc_t *workspace = workspace_by_name(argv[0]);
825 if (!workspace) { 836 if (!workspace) {
diff --git a/sway/workspace.c b/sway/workspace.c
index 252526ce..0f36e35a 100644
--- a/sway/workspace.c
+++ b/sway/workspace.c
@@ -13,6 +13,8 @@
13#include "focus.h" 13#include "focus.h"
14#include "util.h" 14#include "util.h"
15 15
16char *prev_workspace_name;
17
16char *workspace_next_name(void) { 18char *workspace_next_name(void) {
17 sway_log(L_DEBUG, "Workspace: Generating new name"); 19 sway_log(L_DEBUG, "Workspace: Generating new name");
18 int i; 20 int i;
@@ -180,6 +182,11 @@ void workspace_switch(swayc_t *workspace) {
180 if (!workspace) { 182 if (!workspace) {
181 return; 183 return;
182 } 184 }
185 if (!prev_workspace_name || strcmp(prev_workspace_name, swayc_active_workspace()->name) != 0) {
186 prev_workspace_name = malloc(strlen(swayc_active_workspace()->name) + 1);
187 strcpy(prev_workspace_name, swayc_active_workspace()->name);
188 }
189
183 sway_log(L_DEBUG, "Switching to workspace %p:%s", workspace, workspace->name); 190 sway_log(L_DEBUG, "Switching to workspace %p:%s", workspace, workspace->name);
184 set_focused_container(get_focused_view(workspace)); 191 set_focused_container(get_focused_view(workspace));
185 arrange_windows(workspace, -1, -1); 192 arrange_windows(workspace, -1, -1);