mirror of
https://github.com/tmux/tmux.git
synced 2026-05-30 22:26:18 +00:00
More (currently disabled) bits for creating floating panes, from Michael
Grant and Dane Jensen.
This commit is contained in:
80
window.c
80
window.c
@@ -541,6 +541,7 @@ window_set_active_pane(struct window *w, struct window_pane *wp, int notify)
|
||||
}
|
||||
|
||||
tty_update_window_offset(w);
|
||||
server_redraw_window(w);
|
||||
|
||||
if (notify)
|
||||
notify_window("window-pane-changed", w);
|
||||
@@ -585,6 +586,8 @@ window_redraw_active_switch(struct window *w, struct window_pane *wp)
|
||||
wp->flags |= PANE_REDRAW;
|
||||
}
|
||||
}
|
||||
if (wp == w->active)
|
||||
break;
|
||||
|
||||
/* If the pane is floating, move to the front. */
|
||||
if (wp->flags & PANE_FLOATING) {
|
||||
@@ -593,9 +596,9 @@ window_redraw_active_switch(struct window *w, struct window_pane *wp)
|
||||
wp->flags |= PANE_REDRAW;
|
||||
}
|
||||
|
||||
if (wp == w->active)
|
||||
break;
|
||||
wp = w->active;
|
||||
if (wp == NULL)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -613,7 +616,7 @@ window_get_active_at(struct window *w, u_int x, u_int y)
|
||||
continue;
|
||||
window_pane_full_size_offset(wp, &xoff, &yoff, &sx, &sy);
|
||||
if (~wp->flags & PANE_FLOATING) {
|
||||
/* Tiled - to and including bottom or right border. */
|
||||
/* Tiled - to and including bottom or right border. */
|
||||
if ((int)x < xoff || x > xoff + sx)
|
||||
continue;
|
||||
if (pane_status == PANE_STATUS_TOP) {
|
||||
@@ -689,7 +692,6 @@ window_zoom(struct window_pane *wp)
|
||||
|
||||
if (w->flags & WINDOW_ZOOMED)
|
||||
return (-1);
|
||||
|
||||
if (window_count_panes(w, 1) == 1)
|
||||
return (-1);
|
||||
|
||||
@@ -726,7 +728,7 @@ window_unzoom(struct window *w, int notify)
|
||||
TAILQ_FOREACH(wp, &w->panes, entry) {
|
||||
wp->layout_cell = wp->saved_layout_cell;
|
||||
wp->saved_layout_cell = NULL;
|
||||
wp->flags ^= PANE_ZOOMED;
|
||||
wp->flags &= ~PANE_ZOOMED;
|
||||
}
|
||||
layout_fix_panes(w, NULL);
|
||||
|
||||
@@ -779,7 +781,7 @@ window_add_pane(struct window *w, struct window_pane *other, u_int hlimit,
|
||||
TAILQ_INSERT_BEFORE(other, wp, entry);
|
||||
} else {
|
||||
log_debug("%s: @%u after %%%u", __func__, w->id, wp->id);
|
||||
if (flags & SPAWN_FULLSIZE)
|
||||
if (flags & (SPAWN_FULLSIZE|SPAWN_FLOATING))
|
||||
TAILQ_INSERT_TAIL(&w->panes, wp, entry);
|
||||
else
|
||||
TAILQ_INSERT_AFTER(&w->panes, other, wp, entry);
|
||||
@@ -787,8 +789,8 @@ window_add_pane(struct window *w, struct window_pane *other, u_int hlimit,
|
||||
if (~flags & SPAWN_FLOATING)
|
||||
TAILQ_INSERT_TAIL(&w->z_index, wp, zentry);
|
||||
else {
|
||||
TAILQ_INSERT_HEAD(&w->z_index, wp, zentry);
|
||||
wp->flags |= PANE_FLOATING;
|
||||
TAILQ_INSERT_HEAD(&w->z_index, wp, zentry);
|
||||
}
|
||||
return (wp);
|
||||
}
|
||||
@@ -946,7 +948,7 @@ window_pane_printable_flags(struct window_pane *wp)
|
||||
{
|
||||
struct window *w = wp->window;
|
||||
static char flags[32];
|
||||
u_int pos = 0;
|
||||
int pos = 0;
|
||||
|
||||
if (wp == w->active)
|
||||
flags[pos++] = '*';
|
||||
@@ -2057,8 +2059,9 @@ window_pane_border_status_get_range(struct window_pane *wp, u_int x, u_int y)
|
||||
return (style_ranges_get_range(srs, x - wp->xoff - 2));
|
||||
}
|
||||
|
||||
/* Work out geometry for tiled panes. */
|
||||
int
|
||||
window_pane_tile_geometry(struct window *w, struct window_pane *wp,
|
||||
window_pane_tiled_geometry(struct window *w, struct window_pane *wp,
|
||||
int *out_size, int *out_flags, enum layout_type *out_type,
|
||||
struct cmdq_item *item, struct args *args, char **cause)
|
||||
{
|
||||
@@ -2106,3 +2109,62 @@ window_pane_tile_geometry(struct window *w, struct window_pane *wp,
|
||||
*out_type = type;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Work out geometry for floating panes. */
|
||||
int
|
||||
window_pane_floating_geometry(struct window *w, __unused struct window_pane *wp,
|
||||
u_int *out_x, u_int *out_y, u_int *out_sx, u_int *out_sy,
|
||||
struct cmdq_item *item, struct args *args, char **cause)
|
||||
{
|
||||
u_int x, y, sx = w->sx / 2, sy = w->sy / 2;
|
||||
|
||||
if (args_has(args, 'x')) {
|
||||
sx = args_percentage_and_expand(args, 'x', 0, USHRT_MAX, w->sx,
|
||||
item, cause);
|
||||
if (*cause != NULL)
|
||||
return (-1);
|
||||
}
|
||||
if (args_has(args, 'y')) {
|
||||
sy = args_percentage_and_expand(args, 'y', 0, USHRT_MAX, w->sy,
|
||||
item, cause);
|
||||
if (*cause != NULL)
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (args_has(args, 'X')) {
|
||||
x = args_percentage_and_expand(args, 'X', 0, USHRT_MAX, w->sx,
|
||||
item, cause);
|
||||
if (*cause != NULL)
|
||||
return (-1);
|
||||
} else {
|
||||
if (w->last_new_pane_x == 0)
|
||||
x = 4;
|
||||
else {
|
||||
x = w->last_new_pane_x + 4;
|
||||
if (w->last_new_pane_x > w->sx)
|
||||
x = 4;
|
||||
}
|
||||
w->last_new_pane_x = x;
|
||||
}
|
||||
if (args_has(args, 'Y')) {
|
||||
y = args_percentage_and_expand(args, 'Y', 0, USHRT_MAX, w->sy,
|
||||
item, cause);
|
||||
if (*cause != NULL)
|
||||
return (-1);
|
||||
} else {
|
||||
if (w->last_new_pane_y == 0)
|
||||
y = 2;
|
||||
else {
|
||||
y = w->last_new_pane_y + 2;
|
||||
if (w->last_new_pane_y > w->sy)
|
||||
y = 2;
|
||||
}
|
||||
w->last_new_pane_y = y;
|
||||
}
|
||||
|
||||
*out_x = x;
|
||||
*out_y = y;
|
||||
*out_sx = sx;
|
||||
*out_sy = sy;
|
||||
return (0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user