1
0
mirror of https://github.com/tmux/tmux.git synced 2025-03-29 10:18:49 +00:00

Merge branch 'obsd-master'

This commit is contained in:
Thomas Adam 2016-10-10 20:01:11 +01:00
commit 27126f8797
3 changed files with 18 additions and 16 deletions

View File

@ -111,13 +111,13 @@ cmd_resize_pane_exec(struct cmd *self, struct cmd_q *cmdq)
} }
if (args_has(self->args, 'L')) if (args_has(self->args, 'L'))
layout_resize_pane(wp, LAYOUT_LEFTRIGHT, -adjust); layout_resize_pane(wp, LAYOUT_LEFTRIGHT, -adjust, 1);
else if (args_has(self->args, 'R')) else if (args_has(self->args, 'R'))
layout_resize_pane(wp, LAYOUT_LEFTRIGHT, adjust); layout_resize_pane(wp, LAYOUT_LEFTRIGHT, adjust, 1);
else if (args_has(self->args, 'U')) else if (args_has(self->args, 'U'))
layout_resize_pane(wp, LAYOUT_TOPBOTTOM, -adjust); layout_resize_pane(wp, LAYOUT_TOPBOTTOM, -adjust, 1);
else if (args_has(self->args, 'D')) else if (args_has(self->args, 'D'))
layout_resize_pane(wp, LAYOUT_TOPBOTTOM, adjust); layout_resize_pane(wp, LAYOUT_TOPBOTTOM, adjust, 1);
server_redraw_window(wl->window); server_redraw_window(wl->window);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
@ -155,12 +155,12 @@ cmd_resize_pane_mouse_update(struct client *c, struct mouse_event *m)
if (wp->xoff + wp->sx == m->lx && if (wp->xoff + wp->sx == m->lx &&
wp->yoff <= 1 + ly && wp->yoff + wp->sy >= ly) { wp->yoff <= 1 + ly && wp->yoff + wp->sy >= ly) {
layout_resize_pane(wp, LAYOUT_LEFTRIGHT, m->x - m->lx); layout_resize_pane(wp, LAYOUT_LEFTRIGHT, m->x - m->lx, 0);
found = 1; found = 1;
} }
if (wp->yoff + wp->sy == ly && if (wp->yoff + wp->sy == ly &&
wp->xoff <= 1 + m->lx && wp->xoff + wp->sx >= m->lx) { wp->xoff <= 1 + m->lx && wp->xoff + wp->sx >= m->lx) {
layout_resize_pane(wp, LAYOUT_TOPBOTTOM, y - ly); layout_resize_pane(wp, LAYOUT_TOPBOTTOM, y - ly, 0);
found = 1; found = 1;
} }
} }

View File

@ -36,7 +36,7 @@
static u_int layout_resize_check(struct window *, struct layout_cell *, static u_int layout_resize_check(struct window *, struct layout_cell *,
enum layout_type); enum layout_type);
static int layout_resize_pane_grow(struct window *, struct layout_cell *, static int layout_resize_pane_grow(struct window *, struct layout_cell *,
enum layout_type, int); enum layout_type, int, int);
static int layout_resize_pane_shrink(struct window *, struct layout_cell *, static int layout_resize_pane_shrink(struct window *, struct layout_cell *,
enum layout_type, int); enum layout_type, int);
static int layout_need_status(struct layout_cell *, int); static int layout_need_status(struct layout_cell *, int);
@ -532,12 +532,13 @@ layout_resize_pane_to(struct window_pane *wp, enum layout_type type,
change = new_size - size; change = new_size - size;
/* Resize the pane. */ /* Resize the pane. */
layout_resize_pane(wp, type, change); layout_resize_pane(wp, type, change, 1);
} }
/* Resize a single pane within the layout. */ /* Resize a single pane within the layout. */
void void
layout_resize_pane(struct window_pane *wp, enum layout_type type, int change) layout_resize_pane(struct window_pane *wp, enum layout_type type, int change,
int opposite)
{ {
struct window *w = wp->window; struct window *w = wp->window;
struct layout_cell *lc, *lcparent; struct layout_cell *lc, *lcparent;
@ -562,7 +563,8 @@ layout_resize_pane(struct window_pane *wp, enum layout_type type, int change)
needed = change; needed = change;
while (needed != 0) { while (needed != 0) {
if (change > 0) { if (change > 0) {
size = layout_resize_pane_grow(w, lc, type, needed); size = layout_resize_pane_grow(w, lc, type, needed,
opposite);
needed -= size; needed -= size;
} else { } else {
size = layout_resize_pane_shrink(w, lc, type, needed); size = layout_resize_pane_shrink(w, lc, type, needed);
@ -582,10 +584,10 @@ layout_resize_pane(struct window_pane *wp, enum layout_type type, int change)
/* Helper function to grow pane. */ /* Helper function to grow pane. */
static int static int
layout_resize_pane_grow(struct window *w, struct layout_cell *lc, layout_resize_pane_grow(struct window *w, struct layout_cell *lc,
enum layout_type type, int needed) enum layout_type type, int needed, int opposite)
{ {
struct layout_cell *lcadd, *lcremove; struct layout_cell *lcadd, *lcremove;
u_int size; u_int size = 0;
/* Growing. Always add to the current cell. */ /* Growing. Always add to the current cell. */
lcadd = lc; lcadd = lc;
@ -600,7 +602,7 @@ layout_resize_pane_grow(struct window *w, struct layout_cell *lc,
} }
/* If none found, look towards the head. */ /* If none found, look towards the head. */
if (lcremove == NULL) { if (opposite && lcremove == NULL) {
lcremove = TAILQ_PREV(lc, layout_cells, entry); lcremove = TAILQ_PREV(lc, layout_cells, entry);
while (lcremove != NULL) { while (lcremove != NULL) {
size = layout_resize_check(w, lcremove, type); size = layout_resize_check(w, lcremove, type);
@ -608,9 +610,9 @@ layout_resize_pane_grow(struct window *w, struct layout_cell *lc,
break; break;
lcremove = TAILQ_PREV(lcremove, layout_cells, entry); lcremove = TAILQ_PREV(lcremove, layout_cells, entry);
} }
if (lcremove == NULL)
return (0);
} }
if (lcremove == NULL)
return (0);
/* Change the cells. */ /* Change the cells. */
if (size > (u_int) needed) if (size > (u_int) needed)

2
tmux.h
View File

@ -2219,7 +2219,7 @@ void layout_init(struct window *, struct window_pane *);
void layout_free(struct window *); void layout_free(struct window *);
void layout_resize(struct window *, u_int, u_int); void layout_resize(struct window *, u_int, u_int);
void layout_resize_pane(struct window_pane *, enum layout_type, void layout_resize_pane(struct window_pane *, enum layout_type,
int); int, int);
void layout_resize_pane_to(struct window_pane *, enum layout_type, void layout_resize_pane_to(struct window_pane *, enum layout_type,
u_int); u_int);
void layout_assign_pane(struct layout_cell *, struct window_pane *); void layout_assign_pane(struct layout_cell *, struct window_pane *);