mirror of
				https://github.com/swaywm/sway.git
				synced 2025-11-03 09:01:43 -05:00 
			
		
		
		
	Merge pull request #156 from Luminarys/master
Added in workspace_auto_back_and_forth
This commit is contained in:
		
						commit
						4d9b05e649
					
				
					 4 changed files with 20 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -52,6 +52,7 @@ struct sway_config {
 | 
			
		|||
	bool active;
 | 
			
		||||
	bool failed;
 | 
			
		||||
	bool reloading;
 | 
			
		||||
	bool auto_back_and_forth;
 | 
			
		||||
 | 
			
		||||
	int gaps_inner;
 | 
			
		||||
	int gaps_outer;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -852,6 +852,16 @@ static bool cmd_workspace(struct sway_config *config, int argc, char **argv) {
 | 
			
		|||
	return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static bool cmd_ws_auto_back_and_forth(struct sway_config *config, int argc, char **argv) {
 | 
			
		||||
	if (!checkarg(argc, "workspace_auto_back_and_forth", EXPECTED_EQUAL_TO, 1)) {
 | 
			
		||||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
	if (strcasecmp(argv[0], "yes") == 0) {
 | 
			
		||||
		config->auto_back_and_forth = true;
 | 
			
		||||
	}
 | 
			
		||||
	return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Keep alphabetized */
 | 
			
		||||
static struct cmd_handler handlers[] = {
 | 
			
		||||
	{ "bindsym", cmd_bindsym },
 | 
			
		||||
| 
						 | 
				
			
			@ -877,7 +887,8 @@ static struct cmd_handler handlers[] = {
 | 
			
		|||
	{ "split", cmd_split },
 | 
			
		||||
	{ "splith", cmd_splith },
 | 
			
		||||
	{ "splitv", cmd_splitv },
 | 
			
		||||
	{ "workspace", cmd_workspace }
 | 
			
		||||
	{ "workspace", cmd_workspace },
 | 
			
		||||
	{ "workspace_auto_back_and_forth", cmd_ws_auto_back_and_forth }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static char **split_directive(char *line, int *argc) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -36,6 +36,7 @@ void config_defaults(struct sway_config *config) {
 | 
			
		|||
	config->reloading = false;
 | 
			
		||||
	config->active = false;
 | 
			
		||||
	config->failed = false;
 | 
			
		||||
	config->auto_back_and_forth = false;
 | 
			
		||||
 | 
			
		||||
	config->gaps_inner = 0;
 | 
			
		||||
	config->gaps_outer = 0;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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);
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue