Remove minimise from staging branch for the moment.

This commit is contained in:
Nicholas Marriott
2026-05-19 11:34:20 +01:00
parent 57b17bbb70
commit 93e63cef18
13 changed files with 23 additions and 897 deletions

View File

@@ -117,7 +117,6 @@ dist_tmux_SOURCES = \
cmd-list-windows.c \
cmd-load-buffer.c \
cmd-lock-server.c \
cmd-minimise-pane.c \
cmd-move-window.c \
cmd-new-session.c \
cmd-new-window.c \
@@ -150,7 +149,6 @@ dist_tmux_SOURCES = \
cmd-source-file.c \
cmd-split-window.c \
cmd-swap-pane.c \
cmd-tile-float-pane.c \
cmd-swap-window.c \
cmd-switch-client.c \
cmd-unbind-key.c \

View File

@@ -1,222 +0,0 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/types.h>
#include <stdlib.h>
#include <string.h>
#include "tmux.h"
/*
* Increase or decrease pane size.
*/
static enum cmd_retval cmd_minimise_pane_minimise_exec(struct cmd *, struct cmdq_item *);
static enum cmd_retval cmd_minimise_pane_unminimise_exec(struct cmd *, struct cmdq_item *);
static enum cmd_retval cmd_minimise_pane_minimise(struct window *, struct window_pane *,
struct cmdq_item *);
static enum cmd_retval cmd_minimise_pane_unminimise(struct window *, struct window_pane *);
const struct cmd_entry cmd_minimise_pane_entry = {
.name = "minimise-pane",
.alias = "minimize-pane",
.args = { "at:", 0, 1, NULL },
.usage = "[-a] " CMD_TARGET_PANE_USAGE,
.target = { 't', CMD_FIND_PANE, 0 },
.flags = CMD_AFTERHOOK,
.exec = cmd_minimise_pane_minimise_exec
};
const struct cmd_entry cmd_unminimise_pane_entry = {
.name = "unminimise-pane",
.alias = "unminimize-pane",
.args = { "at:", 0, 1, NULL },
.usage = "[-a] " CMD_TARGET_PANE_USAGE,
.target = { 't', CMD_FIND_PANE, 0 },
.flags = CMD_AFTERHOOK,
.exec = cmd_minimise_pane_unminimise_exec
};
static enum cmd_retval
cmd_minimise_pane_minimise_exec(struct cmd *self, struct cmdq_item *item)
{
__attribute((unused)) struct args *args = cmd_get_args(self);
struct cmd_find_state *target = cmdq_get_target(item);
struct winlink *wl = target->wl;
struct window *w = wl->window;
struct window_pane *wp;
u_int id;
char *cause = NULL;
enum cmd_retval rv;
if (args_has(args, 'a')) {
struct window_pane *active_pane = w->active;
TAILQ_FOREACH(wp, &w->z_index, zentry) {
if (!window_pane_visible(wp) || wp == active_pane)
continue;
rv = cmd_minimise_pane_minimise(w, wp, item);
if (rv != CMD_RETURN_NORMAL)
return (rv);
}
return (CMD_RETURN_NORMAL);
} else {
wp = target->wp;
if (wp == NULL) {
id = args_strtonum_and_expand(args, 't', 0, INT_MAX, item, &cause);
if (cause != NULL) {
cmdq_error(item, "%s target pane", cause);
return (CMD_RETURN_ERROR);
}
wp = window_pane_find_by_id(id);
}
if (wp == NULL) {
cmdq_error(item, "No target pane to miminise.");
return (CMD_RETURN_ERROR);
}
return (cmd_minimise_pane_minimise(w, wp, item));
}
}
static enum cmd_retval
cmd_minimise_pane_unminimise_exec(struct cmd *self, struct cmdq_item *item)
{
__attribute((unused)) struct args *args = cmd_get_args(self);
struct cmd_find_state *target = cmdq_get_target(item);
struct winlink *wl = target->wl;
struct window *w = wl->window;
struct window_pane *wp;
u_int id;
char *cause = NULL;
enum cmd_retval rv;
if (args_has(args, 'a')) {
TAILQ_FOREACH(wp, &w->z_index, zentry) {
if (!window_pane_visible(wp))
continue;
rv = cmd_minimise_pane_unminimise(w, wp);
if (rv != CMD_RETURN_NORMAL)
return (rv);
}
return (CMD_RETURN_NORMAL);
} else {
wp = target->wp;
if (wp == NULL) {
id = args_strtonum_and_expand(args, 't', 0, INT_MAX, item, &cause);
if (cause != NULL) {
cmdq_error(item, "%s target pane", cause);
return (CMD_RETURN_ERROR);
}
wp = window_pane_find_by_id(id);
}
if (wp == NULL) {
cmdq_error(item, "No target pane to unmiminise.");
return (CMD_RETURN_ERROR);
}
return (cmd_minimise_pane_unminimise(w, wp));
}
}
static enum cmd_retval
cmd_minimise_pane_minimise(struct window *w, struct window_pane *wp,
__attribute__((unused)) struct cmdq_item *item)
{
struct window_pane *pwp = NULL;
if (wp->flags & PANE_MINIMISED)
return (CMD_RETURN_NORMAL);
if (wp == w->active) {
/*
* Unzoom before searching: under zoom, window_pane_visible
* returns false for every non-active pane.
*/
if (w->flags & WINDOW_ZOOMED)
window_unzoom(w, 1);
/* Find previous active pane. */
TAILQ_FOREACH(pwp, &w->last_panes, sentry) {
if (pwp != wp && window_pane_visible(pwp))
break;
}
if (pwp == NULL) {
TAILQ_FOREACH(pwp, &w->z_index, zentry) {
if (pwp != wp &&
window_pane_visible(pwp))
break;
}
}
}
wp->flags |= PANE_MINIMISED;
if (w->layout_root != NULL) {
wp->saved_layout_cell = wp->layout_cell;
layout_minimise_cell(w, wp->layout_cell);
layout_fix_offsets(w);
layout_fix_panes(w, NULL);
}
window_pane_stack_remove(&w->last_panes, wp);
if (pwp != NULL) {
window_set_active_pane(w, pwp, 1);
} else if (wp == w->active) {
/* No visible previous active pane; null active pane
* to show dots background. */
w->active = NULL;
if (options_get_number(global_options, "focus-events"))
window_pane_update_focus(wp);
notify_window("window-pane-changed", w);
notify_window("window-layout-changed", w);
server_redraw_window(w);
} else {
notify_window("window-layout-changed", w);
server_redraw_window(w);
}
return (CMD_RETURN_NORMAL);
}
static enum cmd_retval
cmd_minimise_pane_unminimise(struct window *w, struct window_pane *wp)
{
wp->flags &= ~PANE_MINIMISED;
/* Fix pane offsets and sizes. */
if (w->layout_root != NULL && wp->saved_layout_cell != NULL) {
wp->layout_cell = wp->saved_layout_cell;
wp->saved_layout_cell = NULL;
layout_unminimise_cell(w, wp->layout_cell);
layout_fix_offsets(w);
layout_fix_panes(w, NULL);
}
window_set_active_pane(w, wp, 1);
notify_window("window-layout-changed", w);
server_redraw_window(w);
return (CMD_RETURN_NORMAL);
}

View File

@@ -108,11 +108,6 @@ cmd_split_window_get_tiled_layout_cell(struct cmdq_item *item,
return (NULL);
}
if (wp->flags & PANE_MINIMISED) {
cmdq_error(item, "can't split a minimised pane");
return (NULL);
}
if (window_pane_tile_geometry(w, wp, &size, &flags, &type, item, args,
&cause) != 0) {
cmdq_error(item, "invalid tiled geometry %s", cause);

View File

@@ -1,361 +0,0 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2026 Michael Grant <mgrant@grant.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/types.h>
#include <stdlib.h>
#include <string.h>
#include "tmux.h"
/*
* float-pane: lift a tiled pane out of the layout tree into a floating pane.
* tile-pane: insert a floating pane back into the tiled layout.
*
* saved_layout_cell is reused to remember the pane's tiled slot while it is
* floating, using the same mechanism as minimise-pane. The cell's wp pointer
* is cleared while the pane is floating so that layout helpers treat the slot
* as empty.
*/
static enum cmd_retval cmd_float_pane_exec(struct cmd *, struct cmdq_item *);
static enum cmd_retval cmd_tile_pane_exec(struct cmd *, struct cmdq_item *);
const struct cmd_entry cmd_float_pane_entry = {
.name = "float-pane",
.alias = NULL,
.args = { "t:x:y:w:h:", 0, 0, NULL },
.usage = "[-h height] [-w width] [-x x] [-y y] "
CMD_TARGET_PANE_USAGE,
.target = { 't', CMD_FIND_PANE, 0 },
.flags = CMD_AFTERHOOK,
.exec = cmd_float_pane_exec
};
const struct cmd_entry cmd_tile_pane_entry = {
.name = "tile-pane",
.alias = NULL,
.args = { "t:", 0, 0, NULL },
.usage = CMD_TARGET_PANE_USAGE,
.target = { 't', CMD_FIND_PANE, 0 },
.flags = CMD_AFTERHOOK,
.exec = cmd_tile_pane_exec
};
/*
* Parse geometry arguments for float-pane.
* Returns 0 on success, -1 on error (error message already set on item).
* x/y/sx/sy are set to parsed values or cascade defaults.
* last_x/last_y are the static cascade counters; pass the address of the
* caller's statics.
*/
static int
cmd_float_pane_parse_geometry(struct args *args, struct cmdq_item *item,
struct window *w, int *out_x, int *out_y, u_int *out_sx, u_int *out_sy,
int *last_x, int *last_y)
{
char *cause = NULL;
int x, y;
u_int sx, sy;
/* Default size: half the window. */
sx = w->sx / 2;
sy = w->sy / 2;
if (args_has(args, 'w')) {
sx = args_strtonum_and_expand(args, 'w', 1, USHRT_MAX, item,
&cause);
if (cause != NULL) {
cmdq_error(item, "width %s", cause);
free(cause);
return (-1);
}
}
if (args_has(args, 'h')) {
sy = args_strtonum_and_expand(args, 'h', 1, USHRT_MAX, item,
&cause);
if (cause != NULL) {
cmdq_error(item, "height %s", cause);
free(cause);
return (-1);
}
}
/* Default position: cascade from (5,5), step +5, wrap at window edge. */
if (args_has(args, 'x')) {
x = args_strtonum_and_expand(args, 'x', SHRT_MIN, SHRT_MAX,
item, &cause);
if (cause != NULL) {
cmdq_error(item, "x %s", cause);
free(cause);
return (-1);
}
} else {
if (*last_x == 0) {
x = 5;
} else {
x = (*last_x += 5);
if (*last_x > (int)w->sx)
x = *last_x = 5;
}
}
if (args_has(args, 'y')) {
y = args_strtonum_and_expand(args, 'y', SHRT_MIN, SHRT_MAX,
item, &cause);
if (cause != NULL) {
cmdq_error(item, "y %s", cause);
free(cause);
return (-1);
}
} else {
if (*last_y == 0) {
y = 5;
} else {
y = (*last_y += 5);
if (*last_y > (int)w->sy)
y = *last_y = 5;
}
}
*last_x = x;
*last_y = y;
*out_x = x;
*out_y = y;
*out_sx = sx;
*out_sy = sy;
return (0);
}
static enum cmd_retval
cmd_float_pane_exec(struct cmd *self, struct cmdq_item *item)
{
struct args *args = cmd_get_args(self);
struct cmd_find_state *target = cmdq_get_target(item);
struct window *w = target->wl->window;
struct window_pane *wp = target->wp;
static int last_x = 0, last_y = 0;
int x, y;
u_int sx, sy;
struct layout_cell *lc;
if (wp->flags & PANE_FLOATING) {
cmdq_error(item, "pane is already floating");
return (CMD_RETURN_ERROR);
}
if (wp->flags & PANE_MINIMISED) {
cmdq_error(item, "can't float a minimised pane");
return (CMD_RETURN_ERROR);
}
if (w->flags & WINDOW_ZOOMED) {
cmdq_error(item, "can't float a pane while window is zoomed");
return (CMD_RETURN_ERROR);
}
/*
* If no geometry was given explicitly and we have a saved floating
* position from a previous tile-pane, restore it.
*/
if ((wp->flags & PANE_SAVED_FLOAT) &&
!args_has(args, 'x') && !args_has(args, 'y') &&
!args_has(args, 'w') && !args_has(args, 'h')) {
x = wp->saved_float_xoff;
y = wp->saved_float_yoff;
sx = wp->saved_float_sx;
sy = wp->saved_float_sy;
} else {
if (cmd_float_pane_parse_geometry(args, item, w, &x, &y, &sx,
&sy, &last_x, &last_y) != 0)
return (CMD_RETURN_ERROR);
}
/*
* Remove the pane from the tiled layout tree so neighbours reclaim
* the space. layout_close_pane calls layout_destroy_cell which frees
* the tiled layout_cell and sets wp->layout_cell = NULL via
* layout_free_cell. It also calls layout_fix_offsets/fix_panes and
* notify_window, which is fine to do here before we set up the
* floating cell.
*/
layout_close_pane(wp); /* wp->layout_cell is NULL afterwards */
/* Create a detached floating cell with the requested geometry. */
lc = layout_create_cell(NULL);
lc->xoff = x;
lc->yoff = y;
lc->sx = sx;
lc->sy = sy;
layout_make_leaf(lc, wp); /* sets wp->layout_cell = lc, lc->wp = wp */
wp->flags |= PANE_FLOATING;
TAILQ_REMOVE(&w->z_index, wp, zentry);
TAILQ_INSERT_HEAD(&w->z_index, wp, zentry);
if (w->layout_root != NULL)
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_tile_pane_exec(struct cmd *self, struct cmdq_item *item)
{
__attribute((unused)) struct args *args = cmd_get_args(self);
struct cmd_find_state *target = cmdq_get_target(item);
struct window *w = target->wl->window;
struct window_pane *wp = target->wp;
struct window_pane *target_wp, *wpiter;
struct layout_cell *float_lc, *lc;
int was_minimised;
if (!(wp->flags & PANE_FLOATING)) {
cmdq_error(item, "pane is not floating");
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);
}
was_minimised = (wp->flags & PANE_MINIMISED) != 0;
/*
* Save the floating geometry so we can restore it next time this pane
* is floated without an explicit position/size.
*/
float_lc = wp->layout_cell;
wp->saved_float_xoff = float_lc->xoff;
wp->saved_float_yoff = float_lc->yoff;
wp->saved_float_sx = float_lc->sx;
wp->saved_float_sy = float_lc->sy;
wp->flags |= PANE_SAVED_FLOAT;
/*
* If the pane is also minimised, clear saved_layout_cell before
* freeing the floating cell — otherwise the pointer would dangle.
*/
if (was_minimised)
wp->saved_layout_cell = NULL;
/*
* Free the detached floating cell. Clear its wp pointer first so
* layout_free_cell's WINDOWPANE case does not corrupt wp->layout_cell.
*/
float_lc->wp = NULL;
layout_free_cell(float_lc);
wp->layout_cell = NULL;
/*
* Find the best tiled pane to split after, prefer a visible (non-
* minimised) tiled pane. If all tiled panes are minimised, fall back
* to any tiled pane so the new pane enters the existing tree rather
* than becoming a disconnected root.
*/
target_wp = NULL;
if (w->active != NULL && !(w->active->flags & PANE_FLOATING) &&
!(w->active->flags & PANE_MINIMISED))
target_wp = w->active;
if (target_wp == NULL) {
TAILQ_FOREACH(wpiter, &w->last_panes, sentry) {
if (!(wpiter->flags & (PANE_FLOATING|PANE_MINIMISED)) &&
window_pane_visible(wpiter)) {
target_wp = wpiter;
break;
}
}
}
if (target_wp == NULL) {
TAILQ_FOREACH(wpiter, &w->panes, entry) {
if (!(wpiter->flags & (PANE_FLOATING|PANE_MINIMISED)) &&
window_pane_visible(wpiter)) {
target_wp = wpiter;
break;
}
}
}
/* Fall back to any tiled pane (even minimised) to stay in the tree. */
if (target_wp == NULL) {
TAILQ_FOREACH(wpiter, &w->panes, entry) {
if (!(wpiter->flags & PANE_FLOATING)) {
target_wp = wpiter;
break;
}
}
}
if (target_wp != NULL) {
lc = layout_split_pane(target_wp, LAYOUT_TOPBOTTOM, -1, 0);
if (lc == NULL)
lc = layout_split_pane(target_wp, LAYOUT_LEFTRIGHT,
-1, 0);
if (lc == NULL) {
cmdq_error(item, "not enough space to tile pane");
return (CMD_RETURN_ERROR);
}
layout_assign_pane(lc, wp, 0);
/*
* Redistribute space equally among all visible panes at this
* level, so the new pane gets an equal share rather than just
* half of the split target.
*/
if (wp->layout_cell != NULL && wp->layout_cell->parent != NULL)
layout_redistribute_cells(w, wp->layout_cell->parent,
wp->layout_cell->parent->type);
} else {
/*
* No tiled panes at all: make this pane the sole tiled pane
* (new layout root).
*/
lc = layout_create_cell(NULL);
lc->sx = w->sx;
lc->sy = w->sy;
lc->xoff = 0;
lc->yoff = 0;
w->layout_root = lc;
layout_make_leaf(lc, wp);
}
/*
* If the pane was minimised while floating, record its new tiled cell
* as the saved cell so unminimise can restore it correctly.
*/
if (was_minimised)
wp->saved_layout_cell = wp->layout_cell;
wp->flags &= ~PANE_FLOATING;
TAILQ_REMOVE(&w->z_index, wp, zentry);
TAILQ_INSERT_TAIL(&w->z_index, wp, zentry);
if (!(wp->flags & PANE_MINIMISED))
window_set_active_pane(w, wp, 1);
if (w->layout_root != NULL)
layout_fix_offsets(w);
layout_fix_panes(w, NULL);
notify_window("window-layout-changed", w);
server_redraw_window(w);
return (CMD_RETURN_NORMAL);
}

7
cmd.c
View File

@@ -70,7 +70,6 @@ extern const struct cmd_entry cmd_lock_client_entry;
extern const struct cmd_entry cmd_lock_server_entry;
extern const struct cmd_entry cmd_lock_session_entry;
extern const struct cmd_entry cmd_float_pane_entry;
extern const struct cmd_entry cmd_minimise_pane_entry;
extern const struct cmd_entry cmd_move_pane_entry;
extern const struct cmd_entry cmd_move_window_entry;
extern const struct cmd_entry cmd_new_pane_entry;
@@ -119,8 +118,6 @@ extern const struct cmd_entry cmd_swap_window_entry;
extern const struct cmd_entry cmd_switch_client_entry;
extern const struct cmd_entry cmd_unbind_key_entry;
extern const struct cmd_entry cmd_unlink_window_entry;
extern const struct cmd_entry cmd_tile_pane_entry;
extern const struct cmd_entry cmd_unminimise_pane_entry;
extern const struct cmd_entry cmd_wait_for_entry;
const struct cmd_entry *cmd_table[] = {
@@ -166,8 +163,6 @@ const struct cmd_entry *cmd_table[] = {
&cmd_lock_client_entry,
&cmd_lock_server_entry,
&cmd_lock_session_entry,
&cmd_float_pane_entry,
&cmd_minimise_pane_entry,
&cmd_move_pane_entry,
&cmd_move_window_entry,
&cmd_new_pane_entry,
@@ -216,8 +211,6 @@ const struct cmd_entry *cmd_table[] = {
&cmd_switch_client_entry,
&cmd_unbind_key_entry,
&cmd_unlink_window_entry,
&cmd_tile_pane_entry,
&cmd_unminimise_pane_entry,
&cmd_wait_for_entry,
NULL
};

View File

@@ -2249,20 +2249,6 @@ format_cb_pane_marked_set(struct format_tree *ft)
return (NULL);
}
/* Callback for pane_minimised_flag. */
static void *
format_cb_pane_minimised_flag(struct format_tree *ft)
{
struct window_pane *wp = ft->wp;
if (wp != NULL) {
if (wp->flags & PANE_MINIMISED)
return (xstrdup("1"));
return (xstrdup("0"));
}
return (NULL);
}
/* Callback for pane_mode. */
static void *
format_cb_pane_mode(struct format_tree *ft)
@@ -3460,9 +3446,6 @@ static const struct format_table_entry format_table[] = {
{ "pane_marked_set", FORMAT_TABLE_STRING,
format_cb_pane_marked_set
},
{ "pane_minimised_flag", FORMAT_TABLE_STRING,
format_cb_pane_minimised_flag
},
{ "pane_mode", FORMAT_TABLE_STRING,
format_cb_pane_mode
},

View File

@@ -351,8 +351,6 @@ key_bindings_init(void)
{
static const char *const defaults[] = {
/* Prefix keys. */
"bind -N 'Minimise pane' _ { minimise-pane }",
"bind -N 'Send the prefix key' C-b { send-prefix }",
"bind -N 'Rotate through the panes' C-o { rotate-window }",
"bind -N 'Suspend the current client' C-z { suspend-client }",
@@ -365,7 +363,6 @@ key_bindings_init(void)
"bind -N 'Kill current window' & { confirm-before -p\"kill-window #W? (y/n)\" kill-window }",
"bind -N 'Prompt for window index to select' \"'\" { command-prompt -T window-target -pindex { select-window -t ':%%' } }",
"bind -N 'New floating pane' * { new-pane }",
"bind -N 'Toggle pane between floating and tiled' @ { if -F '#{pane_floating_flag}' { tile-pane } { float-pane } }",
"bind -N 'Switch to previous client' ( { switch-client -p }",
"bind -N 'Switch to next client' ) { switch-client -n }",
"bind -N 'Rename current window' , { command-prompt -I'#W' { rename-window -- '%%' } }",
@@ -471,7 +468,7 @@ key_bindings_init(void)
"bind -n MouseDrag1Border { resize-pane -M }",
/* Mouse button 1 down on status line. */
"bind -n MouseDown1Status { if -F '#{&&:#{pane_active},#{!#{pane_minimised_flag}}}' { minimise-pane -t= } { switch-client -t= } }",
"bind -n MouseDown1Status { switch-client -t= }",
"bind -n C-MouseDown1Status { swap-window -t@ }",
/* Mouse button 1 down on default pane-border-format */

211
layout.c
View File

@@ -46,7 +46,6 @@ static int layout_set_size_check(struct window *, struct layout_cell *,
enum layout_type, int);
static void layout_resize_child_cells(struct window *,
struct layout_cell *);
static struct layout_cell *layout_active_neighbour(struct layout_cell *, int);
void layout_redistribute_cells(struct window *, struct layout_cell *,
enum layout_type);
@@ -147,7 +146,7 @@ layout_print_cell(struct layout_cell *lc, const char *hdr, u_int n)
case LAYOUT_TOPBOTTOM:
case LAYOUT_FLOATING:
TAILQ_FOREACH(lcchild, &lc->cells, entry)
layout_print_cell(lcchild, hdr, n + 1);
layout_print_cell(lcchild, hdr, n + 1);
break;
case LAYOUT_WINDOWPANE:
break;
@@ -234,6 +233,7 @@ layout_make_node(struct layout_cell *lc, enum layout_type type)
lc->wp = NULL;
}
/* Fix Z indexes. */
void
layout_fix_zindexes(struct window *w, struct layout_cell *lc)
{
@@ -267,10 +267,6 @@ layout_fix_offsets1(struct layout_cell *lc)
if (lc->type == LAYOUT_LEFTRIGHT) {
xoff = lc->xoff;
TAILQ_FOREACH(lcchild, &lc->cells, entry) {
if (lcchild->type == LAYOUT_WINDOWPANE &&
lcchild->wp != NULL &&
lcchild->wp->flags & PANE_MINIMISED)
continue;
lcchild->xoff = xoff;
lcchild->yoff = lc->yoff;
if (lcchild->type != LAYOUT_WINDOWPANE)
@@ -280,10 +276,6 @@ layout_fix_offsets1(struct layout_cell *lc)
} else {
yoff = lc->yoff;
TAILQ_FOREACH(lcchild, &lc->cells, entry) {
if (lcchild->type == LAYOUT_WINDOWPANE &&
lcchild->wp != NULL &&
lcchild->wp->flags & PANE_MINIMISED)
continue;
lcchild->xoff = lc->xoff;
lcchild->yoff = yoff;
if (lcchild->type != LAYOUT_WINDOWPANE)
@@ -297,7 +289,7 @@ layout_fix_offsets1(struct layout_cell *lc)
void
layout_fix_offsets(struct window *w)
{
struct layout_cell *lc = w->layout_root;
struct layout_cell *lc = w->layout_root;
lc->xoff = 0;
lc->yoff = 0;
@@ -534,100 +526,12 @@ layout_resize_adjust(struct window *w, struct layout_cell *lc,
}
}
/*
* Return the nearest sibling of lc that is not a minimised WINDOWPANE leaf,
* walking forward (direction=1) or backward (direction=0) in the parent's list.
* Container cells (TOPBOTTOM/LEFTRIGHT) are never skipped.
*/
static struct layout_cell *
layout_active_neighbour(struct layout_cell *lc, int direction)
{
struct layout_cell *lcother;
if (direction)
lcother = TAILQ_NEXT(lc, entry);
else
lcother = TAILQ_PREV(lc, layout_cells, entry);
while (lcother != NULL) {
if (lcother->type != LAYOUT_WINDOWPANE)
return (lcother); /* container — not skipped */
if (lcother->wp == NULL ||
(~lcother->wp->flags & PANE_MINIMISED))
return (lcother); /* visible leaf */
/* minimised leaf — keep walking */
if (direction)
lcother = TAILQ_NEXT(lcother, entry);
else
lcother = TAILQ_PREV(lcother, layout_cells, entry);
}
return (NULL);
}
/*
* Redistribute space equally among all visible (non-minimised WINDOWPANE)
* children of lcparent in the given direction. Minimised WINDOWPANE leaves
* are skipped; their stored sizes are left untouched. Container children
* have their own children resized proportionally via layout_resize_child_cells.
*
* If all children happen to be minimised (n==0), nothing is done.
*/
void
layout_redistribute_cells(struct window *w, struct layout_cell *lcparent,
enum layout_type type)
{
struct layout_cell *lc;
u_int n, total, each, rem, i, target;
/* Count visible cells at this level. */
n = 0;
TAILQ_FOREACH(lc, &lcparent->cells, entry) {
if (lc->type == LAYOUT_WINDOWPANE &&
lc->wp != NULL &&
(lc->wp->flags & PANE_MINIMISED))
continue;
n++;
}
if (n == 0)
return;
total = (type == LAYOUT_LEFTRIGHT) ? lcparent->sx : lcparent->sy;
if (total + 1 < n) /* can't fit even the minimum borders */
return;
/*
* each * n + (n-1) borders = total
* → each = (total - (n-1)) / n, rem = (total - (n-1)) % n
* The first `rem` visible cells get (each+1) to consume the remainder.
*/
each = (total - (n - 1)) / n;
rem = (total - (n - 1)) % n;
i = 0;
TAILQ_FOREACH(lc, &lcparent->cells, entry) {
if (lc->type == LAYOUT_WINDOWPANE &&
lc->wp != NULL &&
(lc->wp->flags & PANE_MINIMISED))
continue;
target = each + (i < rem ? 1 : 0);
if (type == LAYOUT_LEFTRIGHT)
lc->sx = target;
else
lc->sy = target;
if (lc->type != LAYOUT_WINDOWPANE)
layout_resize_child_cells(w, lc);
i++;
}
}
/* Destroy a cell and redistribute the space in tiled cells. */
/* Destroy a cell and redistribute the space. */
void
layout_destroy_cell(struct window *w, struct layout_cell *lc,
struct layout_cell **lcroot)
{
struct layout_cell *lcother, *lcparent;
int direction;
int is_minimised;
/*
* If no parent, this is either a floating pane or the last
@@ -649,30 +553,23 @@ layout_destroy_cell(struct window *w, struct layout_cell *lc,
return;
}
/* In tiled layouts, merge the space into the previous or next cell. */
if (lcparent->type != LAYOUT_FLOATING) {
is_minimised = (lc->wp != NULL && (lc->wp->flags & PANE_MINIMISED));
direction = (lc == TAILQ_FIRST(&lcparent->cells)) ? 1 : 0;
lcother = layout_active_neighbour(lc, direction);
if (lcother == NULL)
lcother = layout_active_neighbour(lc, !direction);
if (lcother != NULL && lcparent->type == LAYOUT_LEFTRIGHT &&
!is_minimised)
layout_resize_adjust(w, lcother, lcparent->type, lc->sx + 1);
else if (lcother != NULL && !is_minimised)
layout_resize_adjust(w, lcother, lcparent->type, lc->sy + 1);
}
/* Merge the space into the previous or next cell. */
if (lc == TAILQ_FIRST(&lcparent->cells))
lcother = TAILQ_NEXT(lc, entry);
else
lcother = TAILQ_PREV(lc, layout_cells, entry);
if (lcother != NULL && lcparent->type == LAYOUT_LEFTRIGHT)
layout_resize_adjust(w, lcother, lcparent->type, lc->sx + 1);
else if (lcother != NULL)
layout_resize_adjust(w, lcother, lcparent->type, lc->sy + 1);
/* Remove this from the parent's list. */
TAILQ_REMOVE(&lcparent->cells, lc, entry);
layout_free_cell(lc);
if (lcparent->type == LAYOUT_FLOATING)
return;
/*
* In tiled layouts, if the parent now has one cell, remove
* the parent from the tree and replace it by that cell.
* If the parent now has one cell, remove the parent from the tree and
* replace it by that cell.
*/
lc = TAILQ_FIRST(&lcparent->cells);
if (lc != NULL && TAILQ_NEXT(lc, entry) == NULL) {
@@ -682,20 +579,6 @@ layout_destroy_cell(struct window *w, struct layout_cell *lc,
if (lc->parent == NULL) {
lc->xoff = 0;
lc->yoff = 0;
/*
* If the sole remaining child is a minimised
* WINDOWPANE, its stored size may be stale (it never
* received the space that was given to the removed
* cell). Restore the full window size so that
* unminimise can reclaim the correct amount.
*/
if (lc->type == LAYOUT_WINDOWPANE &&
lc->wp != NULL &&
(lc->wp->flags & PANE_MINIMISED)) {
lc->sx = lcparent->sx;
lc->sy = lcparent->sy;
}
*lcroot = lc;
} else
TAILQ_REPLACE(&lc->parent->cells, lcparent, lc, entry);
@@ -704,70 +587,6 @@ layout_destroy_cell(struct window *w, struct layout_cell *lc,
}
}
/* Minimise a cell and redistribute the space in tiled cells. */
void
layout_minimise_cell(struct window *w, struct layout_cell *lc)
{
struct layout_cell *lcother, *lcparent, *lcchild;
u_int space = 0;
int direction;
lcparent = lc->parent;
if (lcparent == NULL ||
lcparent->type == LAYOUT_FLOATING) {
return;
}
/* Merge the space into the nearest non-minimised sibling. */
{
direction = (lc == TAILQ_FIRST(&lcparent->cells)) ? 1 : 0;
lcother = layout_active_neighbour(lc, direction);
if (lcother == NULL)
lcother = layout_active_neighbour(lc, !direction);
}
if (lcother != NULL && lcparent->type == LAYOUT_LEFTRIGHT)
layout_resize_adjust(w, lcother, lcparent->type, lc->sx + 1);
else if (lcother != NULL)
layout_resize_adjust(w, lcother, lcparent->type, lc->sy + 1);
/* If the parent cells are all minimised, minimise it too. */
if (lcparent != NULL) {
TAILQ_FOREACH(lcchild, &lcparent->cells, entry) {
if (lcchild->wp == NULL ||
lcchild->wp->flags & PANE_MINIMISED)
continue;
if (lcparent->type == LAYOUT_LEFTRIGHT) {
space += lcchild->sx;
} else if (lcparent->type == LAYOUT_TOPBOTTOM) {
space += lcchild->sy;
}
}
if (space == 0)
layout_minimise_cell(w, lcparent);
}
}
/* Unminimise a cell and redistribute the space in tiled cells. */
void
layout_unminimise_cell(struct window *w, struct layout_cell *lc)
{
struct layout_cell *lcparent;
if (lc == NULL)
return;
lcparent = lc->parent;
if (lcparent == NULL || lcparent->type == LAYOUT_FLOATING)
return;
/*
* Redistribute the parent's space equally among all visible (non-
* minimised) children, including lc which has just been unminimised.
* This ensures every pane at this level gets an equal share rather
* than one pane losing most of its space to the restored pane.
*/
layout_redistribute_cells(w, lcparent, lcparent->type);
}
/* Initialize layout for pane. */
void
layout_init(struct window *w, struct window_pane *wp)

View File

@@ -461,15 +461,13 @@ screen_redraw_check_cell(struct screen_redraw_ctx *ctx, u_int px, u_int py,
sb_w = wp->scrollbar_style.width +
wp->scrollbar_style.pad;
if (sb_pos == PANE_SCROLLBARS_LEFT) {
if (~wp->flags & PANE_MINIMISED &&
((int)px >= (int)wp->xoff - 1 - sb_w &&
if (((int)px >= (int)wp->xoff - 1 - sb_w &&
(int)px <= wp->xoff + (int)wp->sx) &&
((int)py >= (int)wp->yoff - 1 &&
(int)py <= wp->yoff + (int)wp->sy))
break;
} else { /* PANE_SCROLLBARS_RIGHT or none. */
if (~wp->flags & PANE_MINIMISED &&
((int)px >= (int)wp->xoff - 1 &&
if (((int)px >= (int)wp->xoff - 1 &&
(int)px <= wp->xoff + (int)wp->sx + sb_w) &&
((int)py >= (int)wp->yoff - 1 &&
(int)py <= wp->yoff + (int)wp->sy))
@@ -1165,7 +1163,7 @@ screen_redraw_get_visible_ranges(struct window_pane *base_wp, u_int px,
u_int lb, rb, tb, bb;
u_int i, s;
if (base_wp == NULL || base_wp->flags & PANE_MINIMISED) {
if (base_wp == NULL) {
if (r != NULL) {
return (r);
} else {
@@ -1196,8 +1194,6 @@ screen_redraw_get_visible_ranges(struct window_pane *base_wp, u_int px,
found_self = 0;
TAILQ_FOREACH_REVERSE(wp, &w->z_index, window_panes_zindex, zentry) {
if (wp->flags & PANE_MINIMISED)
continue;
if (wp == base_wp) {
found_self = 1;
continue;

View File

@@ -145,9 +145,6 @@ screen_write_set_client_cb(struct tty_ctx *ttyctx, struct client *c)
if (wp->layout_cell == NULL)
return (0);
if (wp->flags & PANE_MINIMISED)
return (0);
if (wp->flags & (PANE_REDRAW|PANE_DROP))
return (-1);
if (c->flags & CLIENT_REDRAWPANES) {
@@ -1999,7 +1996,6 @@ screen_write_pane_obscured(struct window_pane *base_wp)
continue;
}
if (found_self && wp->flags & PANE_FLOATING &&
! (wp->flags & PANE_MINIMISED) &&
((wp->yoff >= base_wp->yoff &&
wp->yoff <= base_wp->yoff + (int)base_wp->sy) ||
(wp->yoff + (int)wp->sy >= base_wp->yoff &&

8
tmux.h
View File

@@ -1279,14 +1279,6 @@ struct window_pane {
#define PANE_THEMECHANGED 0x2000
#define PANE_UNSEENCHANGES 0x4000
#define PANE_REDRAWSCROLLBAR 0x8000
#define PANE_MINIMISED 0x20000
#define PANE_SAVED_FLOAT 0x80000 /* saved_float_* fields are valid */
/* Last floating position/size, saved when the pane is tiled. */
int saved_float_xoff;
int saved_float_yoff;
u_int saved_float_sx;
u_int saved_float_sy;
u_int sb_slider_y;
u_int sb_slider_h;

View File

@@ -269,12 +269,6 @@ window_tree_build_window(struct session *s, struct winlink *wl,
if (data->type == WINDOW_TREE_SESSION ||
data->type == WINDOW_TREE_WINDOW) {
expanded = 0;
/* Without this, the only way to reach a minimised
* floating pane would be to first expand the window
* manually (with the right-arrow key) and then press
* its number — which is non-obvious and breaks the
* expected workflow.
*/
TAILQ_FOREACH(fwp, &wl->window->panes, entry) {
if (fwp->flags & PANE_FLOATING) {
expanded = 1;

View File

@@ -542,26 +542,13 @@ window_set_active_pane(struct window *w, struct window_pane *wp, int notify)
w->active->active_point = next_active_point++;
w->active->flags |= PANE_CHANGED;
if (wp->flags & PANE_MINIMISED) {
wp->flags &= ~PANE_MINIMISED;
if (w->layout_root != NULL && wp->saved_layout_cell != NULL) {
wp->layout_cell = wp->saved_layout_cell;
wp->saved_layout_cell = NULL;
layout_unminimise_cell(w, wp->layout_cell);
layout_fix_offsets(w);
layout_fix_panes(w, NULL);
}
}
notify_window("window-layout-changed", w);
server_redraw_window(w);
if (options_get_number(global_options, "focus-events")) {
window_pane_update_focus(lastwp);
window_pane_update_focus(w->active);
}
tty_update_window_offset(w);
server_redraw_window(w);
if (notify)
notify_window("window-pane-changed", w);
@@ -722,21 +709,6 @@ window_zoom(struct window_pane *wp)
window_set_active_pane(w, wp, 1);
wp->flags |= PANE_ZOOMED;
/* Bring pane above other tiled panes and minimise floating panes. */
TAILQ_FOREACH(wp1, &w->z_index, zentry) {
if (wp1 == wp) {
wp1->saved_flags |= (wp1->flags & PANE_MINIMISED);
wp1->flags &= ~PANE_MINIMISED;
continue;
}
if (wp1->flags & PANE_FLOATING) {
wp1->saved_flags |= (wp1->flags & PANE_MINIMISED);
wp1->flags |= PANE_MINIMISED;
continue;
}
break;
}
TAILQ_FOREACH(wp1, &w->panes, entry) {
wp1->saved_layout_cell = wp1->layout_cell;
wp1->layout_cell = NULL;
@@ -763,20 +735,9 @@ window_unzoom(struct window *w, int notify)
w->layout_root = w->saved_layout_root;
w->saved_layout_root = NULL;
TAILQ_FOREACH(wp, &w->z_index, zentry) {
if (wp->flags & PANE_FLOATING) {
wp->flags &= ~PANE_MINIMISED | (wp->saved_flags & PANE_MINIMISED);
continue;
}
break;
}
TAILQ_FOREACH(wp, &w->panes, entry) {
wp->layout_cell = wp->saved_layout_cell;
if (wp->flags & PANE_MINIMISED)
wp->saved_layout_cell = wp->layout_cell;
else
wp->saved_layout_cell = NULL;
wp->saved_layout_cell = NULL;
wp->flags &= ~PANE_ZOOMED;
}
layout_fix_panes(w, NULL);
@@ -996,8 +957,8 @@ window_printable_flags(struct winlink *wl, int escape)
const char *
window_pane_printable_flags(struct window_pane *wp)
{
static char flags[32];
struct window *w = wp->window;
static char flags[32];
int pos = 0;
if (wp == w->active)
@@ -1008,9 +969,6 @@ window_pane_printable_flags(struct window_pane *wp)
flags[pos++] = 'Z';
if (wp->flags & PANE_FLOATING)
flags[pos++] = 'F';
if (wp->flags & PANE_MINIMISED)
flags[pos++] = 'm';
flags[pos] = '\0';
return (flags);
}
@@ -1386,10 +1344,8 @@ window_pane_key(struct window_pane *wp, struct client *c, struct session *s,
int
window_pane_visible(struct window_pane *wp)
{
if (~wp->window->flags & WINDOW_ZOOMED &&
~wp->flags & PANE_MINIMISED)
if (~wp->window->flags & WINDOW_ZOOMED)
return (1);
return (wp == wp->window->active);
}
@@ -2179,16 +2135,6 @@ window_pane_float_geometry(struct window *w, struct window_pane *wp,
u_int x, y, sx, sy;
const u_int cx = 4, cy = 2;
if (wp != NULL && (wp->flags & PANE_SAVED_FLOAT) &&
!args_has(args, 'x') && !args_has(args, 'y') &&
!args_has(args, 'X') && !args_has(args, 'Y')) {
x = wp->saved_float_xoff;
y = wp->saved_float_yoff;
sx = wp->saved_float_sx;
sy = wp->saved_float_sy;
goto out;
}
/* Default size. */
sx = w->sx / 2;
sy = w->sy / 2;