aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/move.c
diff options
context:
space:
mode:
authorLibravatar db <github@benedik.si>2018-04-08 22:49:06 +0200
committerLibravatar db <github@benedik.si>2018-04-09 21:34:56 +0200
commit63b2543749e57e4340f539a2742fd13e89d96d94 (patch)
treef024ad39b9ef79045bbcf0a49087f12270126a03 /sway/commands/move.c
parentMerge pull request #1783 from RyanDwyer/swaybar-buffer-fixes (diff)
downloadsway-63b2543749e57e4340f539a2742fd13e89d96d94.tar.gz
sway-63b2543749e57e4340f539a2742fd13e89d96d94.tar.zst
sway-63b2543749e57e4340f539a2742fd13e89d96d94.zip
Add workspace_auto_back_and_forth for move cmd
Diffstat (limited to 'sway/commands/move.c')
-rw-r--r--sway/commands/move.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/sway/commands/move.c b/sway/commands/move.c
index 15a5ebc4..a5273ba4 100644
--- a/sway/commands/move.c
+++ b/sway/commands/move.c
@@ -1,3 +1,4 @@
1#define _XOPEN_SOURCE 500
1#include <string.h> 2#include <string.h>
2#include <strings.h> 3#include <strings.h>
3#include <wlr/types/wlr_output.h> 4#include <wlr/types/wlr_output.h>
@@ -63,18 +64,29 @@ static struct cmd_results *cmd_move_container(struct sway_container *current,
63 "Can only move containers and views."); 64 "Can only move containers and views.");
64 } 65 }
65 struct sway_container *ws; 66 struct sway_container *ws;
66 const char *num_name = NULL;
67 char *ws_name = NULL; 67 char *ws_name = NULL;
68 if (argc == 5 && strcasecmp(argv[3], "number") == 0) { 68 if (argc == 5 && strcasecmp(argv[3], "number") == 0) {
69 // move "container to workspace number x" 69 // move "container to workspace number x"
70 num_name = argv[4]; 70 ws_name = strdup(argv[4]);
71 ws = workspace_by_number(num_name); 71 ws = workspace_by_number(ws_name);
72 } else { 72 } else {
73 ws_name = join_args(argv + 3, argc - 3); 73 ws_name = join_args(argv + 3, argc - 3);
74 ws = workspace_by_name(ws_name); 74 ws = workspace_by_name(ws_name);
75 } 75 }
76
77 if (config->auto_back_and_forth && prev_workspace_name) {
78 // auto back and forth move
79 struct sway_container *curr_ws = container_parent(current, C_WORKSPACE);
80 if (curr_ws->name && strcmp(curr_ws->name, ws_name) == 0) {
81 // if target workspace is the current one
82 free(ws_name);
83 ws_name = strdup(prev_workspace_name);
84 ws = workspace_by_name(ws_name);
85 }
86 }
87
76 if (!ws) { 88 if (!ws) {
77 ws = workspace_create(NULL, ws_name ? ws_name : num_name); 89 ws = workspace_create(NULL, ws_name);
78 } 90 }
79 free(ws_name); 91 free(ws_name);
80 struct sway_container *old_parent = current->parent; 92 struct sway_container *old_parent = current->parent;