diff options
| author | Drew DeVault <sir@cmpwn.com> | 2015-08-30 21:03:35 -0400 | 
|---|---|---|
| committer | Drew DeVault <sir@cmpwn.com> | 2015-08-30 21:03:35 -0400 | 
| commit | 0ab71f5f0a47fd87bb71d7361ea90a8fa88c8361 (patch) | |
| tree | abbc99ff9749bd8d051572c2c1b3fbd1ee17ea30 /sway | |
| parent | 7fbb8b785e229341171470228fea22caac3ee896 (diff) | |
| parent | 23f040133d93ae6d1bf1dc328e3f67f43fa3aeef (diff) | |
| download | sway-0ab71f5f0a47fd87bb71d7361ea90a8fa88c8361.tar.xz | |
Merge pull request #155 from Luminarys/master
Added in workspace back_and_forth
Diffstat (limited to 'sway')
| -rw-r--r-- | sway/commands.c | 18 | ||||
| -rw-r--r-- | sway/workspace.c | 7 | 
2 files changed, 21 insertions, 4 deletions
diff --git a/sway/commands.c b/sway/commands.c index 9a90fe5f..1825be4f 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -800,26 +800,36 @@ static bool cmd_workspace(struct sway_config *config, int argc, char **argv) {  	if (argc == 1) {  		// Handle workspace next/prev -		if (strcmp(argv[0], "next") == 0) { +		if (strcasecmp(argv[0], "next") == 0) {  			workspace_switch(workspace_next());  			return true;  		} -		if (strcmp(argv[0], "prev") == 0) { +		if (strcasecmp(argv[0], "prev") == 0) {  			workspace_switch(workspace_prev());  			return true;  		}  		// Handle workspace output_next/prev -		if (strcmp(argv[0], "next_on_output") == 0) { +		if (strcasecmp(argv[0], "next_on_output") == 0) {  			workspace_switch(workspace_output_next());  			return true;  		} -		if (strcmp(argv[0], "prev_on_output") == 0) { +		if (strcasecmp(argv[0], "prev_on_output") == 0) {  			workspace_switch(workspace_output_prev());  			return true;  		} +		if (strcasecmp(argv[0], "back_and_forth") == 0) { +			if (prev_workspace_name) { +				if (workspace_by_name(prev_workspace_name)) { +					workspace_switch(workspace_by_name(prev_workspace_name)); +				} else { +					workspace_switch(workspace_create(prev_workspace_name)); +				} +			} +			return true; +		}  		swayc_t *workspace = workspace_by_name(argv[0]);  		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 @@  #include "focus.h"  #include "util.h" +char *prev_workspace_name; +  char *workspace_next_name(void) {  	sway_log(L_DEBUG, "Workspace: Generating new name");  	int i; @@ -180,6 +182,11 @@ void workspace_switch(swayc_t *workspace) {  	if (!workspace) {  		return;  	} +	if (!prev_workspace_name || strcmp(prev_workspace_name, swayc_active_workspace()->name) != 0) { +		prev_workspace_name = malloc(strlen(swayc_active_workspace()->name) + 1); +		strcpy(prev_workspace_name, swayc_active_workspace()->name); +	} +  	sway_log(L_DEBUG, "Switching to workspace %p:%s", workspace, workspace->name);  	set_focused_container(get_focused_view(workspace));  	arrange_windows(workspace, -1, -1);  | 
