diff options
author | Ronan Pigott <rpigott@berkeley.edu> | 2022-01-22 10:52:03 -0700 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2022-01-22 19:08:15 +0100 |
commit | feea4b44108cf971ff8d1d474a75128dd737c1db (patch) | |
tree | 8384a8fc223742cfbda28d7963d4d416ee681601 | |
parent | tray: do not render passive items (diff) | |
download | sway-feea4b44108cf971ff8d1d474a75128dd737c1db.tar.gz sway-feea4b44108cf971ff8d1d474a75128dd737c1db.tar.zst sway-feea4b44108cf971ff8d1d474a75128dd737c1db.zip |
cmd/swap: error on swapping a container with itself
-rw-r--r-- | sway/commands/swap.c | 5 |
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, |