summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRonan Pigott <rpigott@berkeley.edu>2022-01-22 10:52:03 -0700
committerSimon Ser <contact@emersion.fr>2022-01-22 23:37:16 +0100
commit3a65ad427a2922ef747521ac173caab9eb6cdab1 (patch)
treea66eb235439b36e9c13480209c2bf53db6b6e117
parent0adcf77f3f19dccd7cc50f303c7708a22c5f33b4 (diff)
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 ce5e5128b..9355944d9 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) {
}
enum sway_fullscreen_mode fs1 = con1->pending.fullscreen_mode;
- enum sway_fullscreen_mode fs2 = con2->pending.fullscreen_mode;
if (fs1) {
container_fullscreen_disable(con1);
}
+ enum sway_fullscreen_mode fs2 = con2->pending.fullscreen_mode;
if (fs2) {
container_fullscreen_disable(con2);
}
@@ -247,6 +247,9 @@ struct cmd_results *cmd_swap(int argc, char **argv) {
} else if (!current) {
error = cmd_results_new(CMD_FAILURE,
"Can only swap with containers and views");
+ } else if (current == other) {
+ error = cmd_results_new(CMD_FAILURE,
+ "Cannot swap a container with itself");
} else if (container_has_ancestor(current, other)
|| container_has_ancestor(other, current)) {
error = cmd_results_new(CMD_FAILURE,