Prohibit swapping 2 floating panes, that doesn't make sense.

This commit is contained in:
Michael Grant
2026-03-20 07:59:25 +00:00
parent 943490cfa1
commit 10a9ce1ed2
2 changed files with 16 additions and 0 deletions

View File

@@ -79,6 +79,11 @@ cmd_swap_pane_exec(struct cmd *self, struct cmdq_item *item)
if (src_wp == dst_wp)
goto out;
if ((src_wp->flags & PANE_FLOATING) && (dst_wp->flags & PANE_FLOATING)) {
cmdq_error(item, "cannot swap two floating panes");
return (CMD_RETURN_ERROR);
}
server_client_remove_pane(src_wp);
server_client_remove_pane(dst_wp);
@@ -99,6 +104,13 @@ cmd_swap_pane_exec(struct cmd *self, struct cmdq_item *item)
dst_lc->wp = src_wp;
src_wp->layout_cell = dst_lc;
/* Swap PANE_FLOATING flag to keep each pane consistent with its new
* layout cell (floating cells have parent == NULL). */
if ((src_wp->flags ^ dst_wp->flags) & PANE_FLOATING) {
src_wp->flags ^= PANE_FLOATING;
dst_wp->flags ^= PANE_FLOATING;
}
src_wp->window = dst_w;
options_set_parent(src_wp->options, dst_w->options);
src_wp->flags |= (PANE_STYLECHANGED|PANE_THEMECHANGED);