Moved functionality to float and tile panes into break-pane and

`join-pane`.
This commit is contained in:
Dane Jensen
2026-06-15 21:17:10 -07:00
parent c04236052c
commit 5602571c01
2 changed files with 103 additions and 5 deletions

View File

@@ -358,6 +358,45 @@ cmd_join_pane_zindex(struct cmdq_item *item, struct winlink *wl,
return (CMD_RETURN_NORMAL);
}
static enum cmd_retval
cmd_join_pane_tile(struct cmdq_item *item, struct args *args, struct window *w,
struct window_pane *wp)
{
struct layout_cell *lc = wp->layout_cell;
if (!window_pane_is_floating(wp)) {
cmdq_error(item, "pane is not floating");
return (CMD_RETURN_ERROR);
}
if (window_pane_is_hidden(wp)) {
cmdq_error(item, "can't tile a hidden pane");
return (CMD_RETURN_ERROR);
}
if (w->flags & WINDOW_ZOOMED) {
cmdq_error(item, "can't tile a pane while window is zoomed");
return (CMD_RETURN_ERROR);
}
layout_save_size(lc);
lc->flags &= ~LAYOUT_CELL_FLOATING;
if (layout_insert_tile(w, lc) == 0) {
cmdq_error(item, "can't tile a pane that is already tiled");
return (CMD_RETURN_ERROR);
}
TAILQ_REMOVE(&w->z_index, wp, zentry);
TAILQ_INSERT_TAIL(&w->z_index, wp, zentry);
if (!args_has(args, 'd'))
window_set_active_pane(w, wp, 1);
layout_fix_offsets(w);
layout_fix_panes(w, NULL);
notify_window("window-layout-changed", w);
server_redraw_window(w);
return (CMD_RETURN_NORMAL);
}
static enum cmd_retval
cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item)
{
@@ -372,7 +411,7 @@ cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item)
const char *s;
char *cause = NULL;
int flags = 0, dst_idx;
struct layout_cell *lc;
struct layout_cell *lc, *src_lc;
dst_s = target->s;
dst_wl = target->wl;
@@ -403,12 +442,16 @@ cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item)
src_wl = source->wl;
src_wp = source->wp;
src_lc = src_wp->layout_cell;
src_w = src_wl->window;
server_unzoom_window(src_w);
if (!args_has(args, 't') && window_pane_is_floating(src_wp))
return (cmd_join_pane_tile(item, args, src_w, src_wp));
if (src_wp == dst_wp) {
cmdq_error(item, "source and target panes must be different");
return (CMD_RETURN_ERROR);
return (CMD_RETURN_ERROR);
}
lc = layout_get_tiled_cell(item, args, dst_w, dst_wp, flags, &cause);
@@ -417,6 +460,12 @@ cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item)
free(cause);
return (CMD_RETURN_ERROR);
}
if (window_pane_is_floating(src_wp)) {
lc->saved_sx = src_lc->sx;
lc->saved_sy = src_lc->sy;
lc->saved_xoff = src_lc->xoff;
lc->saved_yoff = src_lc->yoff;
}
layout_close_pane(src_wp);