Some more easy floating panes bits.

This commit is contained in:
nicm
2026-05-19 12:16:25 +00:00
parent a46cdb8bbc
commit f5a086ac98
9 changed files with 75 additions and 26 deletions

View File

@@ -96,7 +96,7 @@ cmd_break_pane_exec(struct cmd *self, struct cmdq_item *item)
} }
TAILQ_REMOVE(&w->panes, wp, entry); TAILQ_REMOVE(&w->panes, wp, entry);
TAILQ_REMOVE(&w->z_index, wp, zentry); TAILQ_REMOVE(&w->z_index, wp, zentry);
server_client_remove_pane(wp); server_client_remove_pane(wp);
window_lost_pane(w, wp); window_lost_pane(w, wp);
layout_close_pane(wp); layout_close_pane(wp);
@@ -105,7 +105,7 @@ cmd_break_pane_exec(struct cmd *self, struct cmdq_item *item)
options_set_parent(wp->options, w->options); options_set_parent(wp->options, w->options);
wp->flags |= (PANE_STYLECHANGED|PANE_THEMECHANGED); wp->flags |= (PANE_STYLECHANGED|PANE_THEMECHANGED);
TAILQ_INSERT_HEAD(&w->panes, wp, entry); TAILQ_INSERT_HEAD(&w->panes, wp, entry);
TAILQ_INSERT_HEAD(&w->z_index, wp, zentry); TAILQ_INSERT_HEAD(&w->z_index, wp, zentry);
w->active = wp; w->active = wp;
w->latest = tc; w->latest = tc;

View File

@@ -147,14 +147,14 @@ cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item)
server_client_remove_pane(src_wp); server_client_remove_pane(src_wp);
window_lost_pane(src_w, src_wp); window_lost_pane(src_w, src_wp);
TAILQ_REMOVE(&src_w->panes, src_wp, entry); TAILQ_REMOVE(&src_w->panes, src_wp, entry);
TAILQ_REMOVE(&src_w->z_index, src_wp, zentry); TAILQ_REMOVE(&src_w->z_index, src_wp, zentry);
src_wp->window = dst_w; src_wp->window = dst_w;
options_set_parent(src_wp->options, dst_w->options); options_set_parent(src_wp->options, dst_w->options);
src_wp->flags |= (PANE_STYLECHANGED|PANE_THEMECHANGED); src_wp->flags |= (PANE_STYLECHANGED|PANE_THEMECHANGED);
if (flags & SPAWN_BEFORE) { if (flags & SPAWN_BEFORE) {
TAILQ_INSERT_BEFORE(dst_wp, src_wp, entry); TAILQ_INSERT_BEFORE(dst_wp, src_wp, entry);
TAILQ_INSERT_BEFORE(dst_wp, src_wp, zentry); TAILQ_INSERT_BEFORE(dst_wp, src_wp, zentry);
} else { } else {
TAILQ_INSERT_AFTER(&dst_w->panes, dst_wp, src_wp, entry); TAILQ_INSERT_AFTER(&dst_w->panes, dst_wp, src_wp, entry);
TAILQ_INSERT_AFTER(&dst_w->z_index, dst_wp, src_wp, zentry); TAILQ_INSERT_AFTER(&dst_w->z_index, dst_wp, src_wp, zentry);

View File

@@ -62,6 +62,10 @@ cmd_kill_pane_exec(struct cmd *self, struct cmdq_item *item)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
if (wp == NULL) {
cmdq_error(item, "no active pane to kill");
return (CMD_RETURN_ERROR);
}
server_kill_pane(wp); server_kill_pane(wp);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }

View File

@@ -160,6 +160,10 @@ cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item)
server_redraw_window_borders(markedwp->window); server_redraw_window_borders(markedwp->window);
server_status_window(markedwp->window); server_status_window(markedwp->window);
} }
if (wp->flags & PANE_FLOATING) {
window_redraw_active_switch(w, wp);
window_set_active_pane(w, wp, 1);
}
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }

View File

@@ -77,6 +77,8 @@ control_notify_window_pane_changed(struct window *w)
{ {
struct client *c; struct client *c;
if (w->active == NULL)
return;
TAILQ_FOREACH(c, &clients, entry) { TAILQ_FOREACH(c, &clients, entry) {
if (!CONTROL_SHOULD_NOTIFY_CLIENT(c)) if (!CONTROL_SHOULD_NOTIFY_CLIENT(c))
continue; continue;

View File

@@ -4200,7 +4200,6 @@ format_strip(struct format_expand_state *es, const char *s)
return (out); return (out);
} }
/* Skip until end. */ /* Skip until end. */
static const char * static const char *
format_skip1(struct format_expand_state *es, const char *s, const char *end) format_skip1(struct format_expand_state *es, const char *s, const char *end)

View File

@@ -460,6 +460,9 @@ key_bindings_init(void)
/* Mouse button 1 triple click on pane. */ /* Mouse button 1 triple click on pane. */
"bind -n TripleClick1Pane { select-pane -t=; if -F '#{||:#{pane_in_mode},#{mouse_any_flag}}' { send -M } { copy-mode -H; send -X select-line; run -d0.3; send -X copy-pipe-and-cancel } }", "bind -n TripleClick1Pane { select-pane -t=; if -F '#{||:#{pane_in_mode},#{mouse_any_flag}}' { send -M } { copy-mode -H; send -X select-line; run -d0.3; send -X copy-pipe-and-cancel } }",
/* Mouse button 1 on border. */
"bind -n MouseDown1Border { select-pane -M }",
/* Mouse button 1 drag on border. */ /* Mouse button 1 drag on border. */
"bind -n MouseDrag1Border { resize-pane -M }", "bind -n MouseDrag1Border { resize-pane -M }",

View File

@@ -123,6 +123,18 @@ layout_set_previous(struct window *w)
return (layout); return (layout);
} }
static struct window_pane *
layout_first_tiled(struct window *w)
{
struct window_pane *wp;
TAILQ_FOREACH(wp, &w->panes, entry) {
if (~wp->flags & PANE_FLOATING)
return (wp);
}
return (NULL);
}
static void static void
layout_set_even(struct window *w, enum layout_type type) layout_set_even(struct window *w, enum layout_type type)
{ {
@@ -156,6 +168,8 @@ layout_set_even(struct window *w, enum layout_type type)
/* Build new leaf cells. */ /* Build new leaf cells. */
TAILQ_FOREACH(wp, &w->panes, entry) { TAILQ_FOREACH(wp, &w->panes, entry) {
if (wp->flags & PANE_FLOATING)
continue;
lcnew = layout_create_cell(lc); lcnew = layout_create_cell(lc);
layout_make_leaf(lcnew, wp); layout_make_leaf(lcnew, wp);
lcnew->sx = w->sx; lcnew->sx = w->sx;
@@ -250,14 +264,16 @@ layout_set_main_h(struct window *w)
/* Create the main pane. */ /* Create the main pane. */
lcmain = layout_create_cell(lc); lcmain = layout_create_cell(lc);
layout_set_size(lcmain, sx, mainh, 0, 0); layout_set_size(lcmain, sx, mainh, 0, 0);
layout_make_leaf(lcmain, TAILQ_FIRST(&w->panes)); layout_make_leaf(lcmain, layout_first_tiled(w));
TAILQ_INSERT_TAIL(&lc->cells, lcmain, entry); TAILQ_INSERT_TAIL(&lc->cells, lcmain, entry);
/* Create the other pane. */ /* Create the other pane. */
lcother = layout_create_cell(lc); lcother = layout_create_cell(lc);
layout_set_size(lcother, sx, otherh, 0, 0); layout_set_size(lcother, sx, otherh, 0, 0);
if (n == 1) { if (n == 1) {
wp = TAILQ_NEXT(TAILQ_FIRST(&w->panes), entry); wp = TAILQ_NEXT(layout_first_tiled(w), entry);
while (wp != NULL && (wp->flags & PANE_FLOATING))
wp = TAILQ_NEXT(wp, entry);
layout_make_leaf(lcother, wp); layout_make_leaf(lcother, wp);
TAILQ_INSERT_TAIL(&lc->cells, lcother, entry); TAILQ_INSERT_TAIL(&lc->cells, lcother, entry);
} else { } else {
@@ -266,7 +282,9 @@ layout_set_main_h(struct window *w)
/* Add the remaining panes as children. */ /* Add the remaining panes as children. */
TAILQ_FOREACH(wp, &w->panes, entry) { TAILQ_FOREACH(wp, &w->panes, entry) {
if (wp == TAILQ_FIRST(&w->panes)) if (wp->flags & PANE_FLOATING)
continue;
if (wp == layout_first_tiled(w))
continue; continue;
lcchild = layout_create_cell(lcother); lcchild = layout_create_cell(lcother);
layout_set_size(lcchild, PANE_MINIMUM, otherh, 0, 0); layout_set_size(lcchild, PANE_MINIMUM, otherh, 0, 0);
@@ -349,7 +367,9 @@ layout_set_main_h_mirrored(struct window *w)
lcother = layout_create_cell(lc); lcother = layout_create_cell(lc);
layout_set_size(lcother, sx, otherh, 0, 0); layout_set_size(lcother, sx, otherh, 0, 0);
if (n == 1) { if (n == 1) {
wp = TAILQ_NEXT(TAILQ_FIRST(&w->panes), entry); wp = TAILQ_NEXT(layout_first_tiled(w), entry);
while (wp != NULL && (wp->flags & PANE_FLOATING))
wp = TAILQ_NEXT(wp, entry);
layout_make_leaf(lcother, wp); layout_make_leaf(lcother, wp);
TAILQ_INSERT_TAIL(&lc->cells, lcother, entry); TAILQ_INSERT_TAIL(&lc->cells, lcother, entry);
} else { } else {
@@ -358,7 +378,9 @@ layout_set_main_h_mirrored(struct window *w)
/* Add the remaining panes as children. */ /* Add the remaining panes as children. */
TAILQ_FOREACH(wp, &w->panes, entry) { TAILQ_FOREACH(wp, &w->panes, entry) {
if (wp == TAILQ_FIRST(&w->panes)) if (wp->flags & PANE_FLOATING)
continue;
if (wp == layout_first_tiled(w))
continue; continue;
lcchild = layout_create_cell(lcother); lcchild = layout_create_cell(lcother);
layout_set_size(lcchild, PANE_MINIMUM, otherh, 0, 0); layout_set_size(lcchild, PANE_MINIMUM, otherh, 0, 0);
@@ -371,7 +393,7 @@ layout_set_main_h_mirrored(struct window *w)
/* Create the main pane. */ /* Create the main pane. */
lcmain = layout_create_cell(lc); lcmain = layout_create_cell(lc);
layout_set_size(lcmain, sx, mainh, 0, 0); layout_set_size(lcmain, sx, mainh, 0, 0);
layout_make_leaf(lcmain, TAILQ_FIRST(&w->panes)); layout_make_leaf(lcmain, layout_first_tiled(w));
TAILQ_INSERT_TAIL(&lc->cells, lcmain, entry); TAILQ_INSERT_TAIL(&lc->cells, lcmain, entry);
/* Fix cell offsets. */ /* Fix cell offsets. */
@@ -446,14 +468,16 @@ layout_set_main_v(struct window *w)
/* Create the main pane. */ /* Create the main pane. */
lcmain = layout_create_cell(lc); lcmain = layout_create_cell(lc);
layout_set_size(lcmain, mainw, sy, 0, 0); layout_set_size(lcmain, mainw, sy, 0, 0);
layout_make_leaf(lcmain, TAILQ_FIRST(&w->panes)); layout_make_leaf(lcmain, layout_first_tiled(w));
TAILQ_INSERT_TAIL(&lc->cells, lcmain, entry); TAILQ_INSERT_TAIL(&lc->cells, lcmain, entry);
/* Create the other pane. */ /* Create the other pane. */
lcother = layout_create_cell(lc); lcother = layout_create_cell(lc);
layout_set_size(lcother, otherw, sy, 0, 0); layout_set_size(lcother, otherw, sy, 0, 0);
if (n == 1) { if (n == 1) {
wp = TAILQ_NEXT(TAILQ_FIRST(&w->panes), entry); wp = TAILQ_NEXT(layout_first_tiled(w), entry);
while (wp != NULL && (wp->flags & PANE_FLOATING))
wp = TAILQ_NEXT(wp, entry);
layout_make_leaf(lcother, wp); layout_make_leaf(lcother, wp);
TAILQ_INSERT_TAIL(&lc->cells, lcother, entry); TAILQ_INSERT_TAIL(&lc->cells, lcother, entry);
} else { } else {
@@ -462,7 +486,9 @@ layout_set_main_v(struct window *w)
/* Add the remaining panes as children. */ /* Add the remaining panes as children. */
TAILQ_FOREACH(wp, &w->panes, entry) { TAILQ_FOREACH(wp, &w->panes, entry) {
if (wp == TAILQ_FIRST(&w->panes)) if (wp->flags & PANE_FLOATING)
continue;
if (wp == layout_first_tiled(w))
continue; continue;
lcchild = layout_create_cell(lcother); lcchild = layout_create_cell(lcother);
layout_set_size(lcchild, otherw, PANE_MINIMUM, 0, 0); layout_set_size(lcchild, otherw, PANE_MINIMUM, 0, 0);
@@ -545,7 +571,9 @@ layout_set_main_v_mirrored(struct window *w)
lcother = layout_create_cell(lc); lcother = layout_create_cell(lc);
layout_set_size(lcother, otherw, sy, 0, 0); layout_set_size(lcother, otherw, sy, 0, 0);
if (n == 1) { if (n == 1) {
wp = TAILQ_NEXT(TAILQ_FIRST(&w->panes), entry); wp = TAILQ_NEXT(layout_first_tiled(w), entry);
while (wp != NULL && (wp->flags & PANE_FLOATING))
wp = TAILQ_NEXT(wp, entry);
layout_make_leaf(lcother, wp); layout_make_leaf(lcother, wp);
TAILQ_INSERT_TAIL(&lc->cells, lcother, entry); TAILQ_INSERT_TAIL(&lc->cells, lcother, entry);
} else { } else {
@@ -554,7 +582,9 @@ layout_set_main_v_mirrored(struct window *w)
/* Add the remaining panes as children. */ /* Add the remaining panes as children. */
TAILQ_FOREACH(wp, &w->panes, entry) { TAILQ_FOREACH(wp, &w->panes, entry) {
if (wp == TAILQ_FIRST(&w->panes)) if (wp->flags & PANE_FLOATING)
continue;
if (wp == layout_first_tiled(w))
continue; continue;
lcchild = layout_create_cell(lcother); lcchild = layout_create_cell(lcother);
layout_set_size(lcchild, otherw, PANE_MINIMUM, 0, 0); layout_set_size(lcchild, otherw, PANE_MINIMUM, 0, 0);
@@ -567,7 +597,7 @@ layout_set_main_v_mirrored(struct window *w)
/* Create the main pane. */ /* Create the main pane. */
lcmain = layout_create_cell(lc); lcmain = layout_create_cell(lc);
layout_set_size(lcmain, mainw, sy, 0, 0); layout_set_size(lcmain, mainw, sy, 0, 0);
layout_make_leaf(lcmain, TAILQ_FIRST(&w->panes)); layout_make_leaf(lcmain, layout_first_tiled(w));
TAILQ_INSERT_TAIL(&lc->cells, lcmain, entry); TAILQ_INSERT_TAIL(&lc->cells, lcmain, entry);
/* Fix cell offsets. */ /* Fix cell offsets. */
@@ -629,8 +659,10 @@ layout_set_tiled(struct window *w)
layout_set_size(lc, sx, sy, 0, 0); layout_set_size(lc, sx, sy, 0, 0);
layout_make_node(lc, LAYOUT_TOPBOTTOM); layout_make_node(lc, LAYOUT_TOPBOTTOM);
/* Create a grid of the cells. */ /* Create a grid of the cells, skipping any floating panes. */
wp = TAILQ_FIRST(&w->panes); wp = TAILQ_FIRST(&w->panes);
while (wp != NULL && (wp->flags & PANE_FLOATING))
wp = TAILQ_NEXT(wp, entry);
for (j = 0; j < rows; j++) { for (j = 0; j < rows; j++) {
/* If this is the last cell, all done. */ /* If this is the last cell, all done. */
if (wp == NULL) if (wp == NULL)
@@ -645,6 +677,8 @@ layout_set_tiled(struct window *w)
if (n - (j * columns) == 1 || columns == 1) { if (n - (j * columns) == 1 || columns == 1) {
layout_make_leaf(lcrow, wp); layout_make_leaf(lcrow, wp);
wp = TAILQ_NEXT(wp, entry); wp = TAILQ_NEXT(wp, entry);
while (wp != NULL && (wp->flags & PANE_FLOATING))
wp = TAILQ_NEXT(wp, entry);
continue; continue;
} }
@@ -657,8 +691,11 @@ layout_set_tiled(struct window *w)
layout_make_leaf(lcchild, wp); layout_make_leaf(lcchild, wp);
TAILQ_INSERT_TAIL(&lcrow->cells, lcchild, entry); TAILQ_INSERT_TAIL(&lcrow->cells, lcchild, entry);
/* Move to the next cell. */ /* Move to the next non-floating cell. */
if ((wp = TAILQ_NEXT(wp, entry)) == NULL) wp = TAILQ_NEXT(wp, entry);
while (wp != NULL && (wp->flags & PANE_FLOATING))
wp = TAILQ_NEXT(wp, entry);
if (wp == NULL)
break; break;
} }

View File

@@ -146,7 +146,7 @@ layout_print_cell(struct layout_cell *lc, const char *hdr, u_int n)
case LAYOUT_TOPBOTTOM: case LAYOUT_TOPBOTTOM:
case LAYOUT_FLOATING: case LAYOUT_FLOATING:
TAILQ_FOREACH(lcchild, &lc->cells, entry) TAILQ_FOREACH(lcchild, &lc->cells, entry)
layout_print_cell(lcchild, hdr, n + 1); layout_print_cell(lcchild, hdr, n + 1);
break; break;
case LAYOUT_WINDOWPANE: case LAYOUT_WINDOWPANE:
break; break;
@@ -245,15 +245,15 @@ layout_fix_zindexes(struct window *w, struct layout_cell *lc)
switch (lc->type) { switch (lc->type) {
case LAYOUT_WINDOWPANE: case LAYOUT_WINDOWPANE:
TAILQ_INSERT_TAIL(&w->z_index, lc->wp, zentry); TAILQ_INSERT_TAIL(&w->z_index, lc->wp, zentry);
break; break;
case LAYOUT_LEFTRIGHT: case LAYOUT_LEFTRIGHT:
case LAYOUT_TOPBOTTOM: case LAYOUT_TOPBOTTOM:
case LAYOUT_FLOATING: case LAYOUT_FLOATING:
TAILQ_FOREACH(lcchild, &lc->cells, entry) TAILQ_FOREACH(lcchild, &lc->cells, entry)
layout_fix_zindexes(w, lcchild); layout_fix_zindexes(w, lcchild);
return; return;
default: default:
fatalx("bad layout type"); fatalx("bad layout type");
} }
} }
@@ -289,7 +289,7 @@ layout_fix_offsets1(struct layout_cell *lc)
void void
layout_fix_offsets(struct window *w) layout_fix_offsets(struct window *w)
{ {
struct layout_cell *lc = w->layout_root; struct layout_cell *lc = w->layout_root;
lc->xoff = 0; lc->xoff = 0;
lc->yoff = 0; lc->yoff = 0;