summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Luminarys <kizunanohikari@gmail.com>2015-08-30 21:34:10 -0500
committerLibravatar Luminarys <kizunanohikari@gmail.com>2015-08-30 21:34:24 -0500
commit12e96f0f9e77658e4f490a1ae94c66a4df40b66f (patch)
tree60c4c9e7e61126f695c6fb049e2fde7337fc731c
parentMerge pull request #155 from Luminarys/master (diff)
downloadsway-12e96f0f9e77658e4f490a1ae94c66a4df40b66f.tar.gz
sway-12e96f0f9e77658e4f490a1ae94c66a4df40b66f.tar.zst
sway-12e96f0f9e77658e4f490a1ae94c66a4df40b66f.zip
Added in workspace_auto_back_and_forth
-rw-r--r--include/config.h1
-rw-r--r--sway/commands.c13
-rw-r--r--sway/config.c1
-rw-r--r--sway/workspace.c8
4 files changed, 20 insertions, 3 deletions
diff --git a/include/config.h b/include/config.h
index d1a6d0ac..653e790f 100644
--- a/include/config.h
+++ b/include/config.h
@@ -52,6 +52,7 @@ struct sway_config {
52 bool active; 52 bool active;
53 bool failed; 53 bool failed;
54 bool reloading; 54 bool reloading;
55 bool auto_back_and_forth;
55 56
56 int gaps_inner; 57 int gaps_inner;
57 int gaps_outer; 58 int gaps_outer;
diff --git a/sway/commands.c b/sway/commands.c
index 1825be4f..177c54ab 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -852,6 +852,16 @@ static bool cmd_workspace(struct sway_config *config, int argc, char **argv) {
852 return true; 852 return true;
853} 853}
854 854
855static bool cmd_ws_auto_back_and_forth(struct sway_config *config, int argc, char **argv) {
856 if (!checkarg(argc, "workspace_auto_back_and_forth", EXPECTED_EQUAL_TO, 1)) {
857 return false;
858 }
859 if (strcasecmp(argv[0], "yes") == 0) {
860 config->auto_back_and_forth = true;
861 }
862 return true;
863}
864
855/* Keep alphabetized */ 865/* Keep alphabetized */
856static struct cmd_handler handlers[] = { 866static struct cmd_handler handlers[] = {
857 { "bindsym", cmd_bindsym }, 867 { "bindsym", cmd_bindsym },
@@ -877,7 +887,8 @@ static struct cmd_handler handlers[] = {
877 { "split", cmd_split }, 887 { "split", cmd_split },
878 { "splith", cmd_splith }, 888 { "splith", cmd_splith },
879 { "splitv", cmd_splitv }, 889 { "splitv", cmd_splitv },
880 { "workspace", cmd_workspace } 890 { "workspace", cmd_workspace },
891 { "workspace_auto_back_and_forth", cmd_ws_auto_back_and_forth }
881}; 892};
882 893
883static char **split_directive(char *line, int *argc) { 894static char **split_directive(char *line, int *argc) {
diff --git a/sway/config.c b/sway/config.c
index f10c73b2..2d7e241d 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -36,6 +36,7 @@ void config_defaults(struct sway_config *config) {
36 config->reloading = false; 36 config->reloading = false;
37 config->active = false; 37 config->active = false;
38 config->failed = false; 38 config->failed = false;
39 config->auto_back_and_forth = false;
39 40
40 config->gaps_inner = 0; 41 config->gaps_inner = 0;
41 config->gaps_outer = 0; 42 config->gaps_outer = 0;
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 @@
13#include "focus.h" 13#include "focus.h"
14#include "util.h" 14#include "util.h"
15 15
16char *prev_workspace_name; 16char *prev_workspace_name = "";
17 17
18char *workspace_next_name(void) { 18char *workspace_next_name(void) {
19 sway_log(L_DEBUG, "Workspace: Generating new name"); 19 sway_log(L_DEBUG, "Workspace: Generating new name");
@@ -182,7 +182,11 @@ void workspace_switch(swayc_t *workspace) {
182 if (!workspace) { 182 if (!workspace) {
183 return; 183 return;
184 } 184 }
185 if (!prev_workspace_name || strcmp(prev_workspace_name, swayc_active_workspace()->name) != 0) { 185 if (strcmp(prev_workspace_name, swayc_active_workspace()->name) != 0 && swayc_active_workspace() != workspace) {
186 prev_workspace_name = malloc(strlen(swayc_active_workspace()->name) + 1);
187 strcpy(prev_workspace_name, swayc_active_workspace()->name);
188 } else if (config->auto_back_and_forth && swayc_active_workspace() == workspace && strlen(prev_workspace_name) != 0) {
189 workspace = workspace_by_name(prev_workspace_name) ? workspace_by_name(prev_workspace_name) : workspace_create(prev_workspace_name);
186 prev_workspace_name = malloc(strlen(swayc_active_workspace()->name) + 1); 190 prev_workspace_name = malloc(strlen(swayc_active_workspace()->name) + 1);
187 strcpy(prev_workspace_name, swayc_active_workspace()->name); 191 strcpy(prev_workspace_name, swayc_active_workspace()->name);
188 } 192 }