aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Ronan Pigott <rpigott@berkeley.edu>2022-01-22 10:52:03 -0700
committerLibravatar Simon Ser <contact@emersion.fr>2022-01-22 23:37:16 +0100
commit3a65ad427a2922ef747521ac173caab9eb6cdab1 (patch)
treea66eb235439b36e9c13480209c2bf53db6b6e117
parenttransaction: destroying nodes aren't hidden (diff)
downloadsway-3a65ad427a2922ef747521ac173caab9eb6cdab1.tar.gz
sway-3a65ad427a2922ef747521ac173caab9eb6cdab1.tar.zst
sway-3a65ad427a2922ef747521ac173caab9eb6cdab1.zip
cmd/swap: error on swapping a container with itself
(cherry picked from commit feea4b44108cf971ff8d1d474a75128dd737c1db)
-rw-r--r--sway/commands/swap.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/sway/commands/swap.c b/sway/commands/swap.c
index ce5e5128..9355944d 100644
--- a/sway/commands/swap.c
+++ b/sway/commands/swap.c
@@ -126,10 +126,10 @@ void container_swap(struct sway_container *con1, struct sway_container *con2) {
126 } 126 }
127 127
128 enum sway_fullscreen_mode fs1 = con1->pending.fullscreen_mode; 128 enum sway_fullscreen_mode fs1 = con1->pending.fullscreen_mode;
129 enum sway_fullscreen_mode fs2 = con2->pending.fullscreen_mode;
130 if (fs1) { 129 if (fs1) {
131 container_fullscreen_disable(con1); 130 container_fullscreen_disable(con1);
132 } 131 }
132 enum sway_fullscreen_mode fs2 = con2->pending.fullscreen_mode;
133 if (fs2) { 133 if (fs2) {
134 container_fullscreen_disable(con2); 134 container_fullscreen_disable(con2);
135 } 135 }
@@ -247,6 +247,9 @@ struct cmd_results *cmd_swap(int argc, char **argv) {
247 } else if (!current) { 247 } else if (!current) {
248 error = cmd_results_new(CMD_FAILURE, 248 error = cmd_results_new(CMD_FAILURE,
249 "Can only swap with containers and views"); 249 "Can only swap with containers and views");
250 } else if (current == other) {
251 error = cmd_results_new(CMD_FAILURE,
252 "Cannot swap a container with itself");
250 } else if (container_has_ancestor(current, other) 253 } else if (container_has_ancestor(current, other)
251 || container_has_ancestor(other, current)) { 254 || container_has_ancestor(other, current)) {
252 error = cmd_results_new(CMD_FAILURE, 255 error = cmd_results_new(CMD_FAILURE,