diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2018-06-08 20:54:23 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2018-06-08 20:54:23 +0000 |
commit | 5e9d18249c1a87376617144177e1e3a14c70ff2d (patch) | |
tree | 9b3943b29044e3f7a4ccadc11c9b162c74ff985f /usr.bin/tmux/cmd-resize-pane.c | |
parent | d2c533db77b78e00ee105dd224f519d9fae3b069 (diff) |
Instead of working out which pane to resize with the mouse by walking
the panes list, look through the layout cells for the nearest border and
resize that cell. From Dan Aloni in GitHub issue 1374.
Diffstat (limited to 'usr.bin/tmux/cmd-resize-pane.c')
-rw-r--r-- | usr.bin/tmux/cmd-resize-pane.c | 51 |
1 files changed, 16 insertions, 35 deletions
diff --git a/usr.bin/tmux/cmd-resize-pane.c b/usr.bin/tmux/cmd-resize-pane.c index b235863edd0..c0508183953 100644 --- a/usr.bin/tmux/cmd-resize-pane.c +++ b/usr.bin/tmux/cmd-resize-pane.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-resize-pane.c,v 1.31 2017/05/11 07:24:42 nicm Exp $ */ +/* $OpenBSD: cmd-resize-pane.c,v 1.32 2018/06/08 20:54:22 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -129,14 +129,16 @@ static void cmd_resize_pane_mouse_update(struct client *c, struct mouse_event *m) { struct winlink *wl; - struct window_pane *loop, *wp_x, *wp_y; - u_int y, ly, x, lx, sx, sy, ex, ey; + struct window *w; + u_int y, ly, x, lx; + struct layout_cell *lc; wl = cmd_mouse_window(m, NULL); if (wl == NULL) { c->tty.mouse_drag_update = NULL; return; } + w = wl->window; y = m->y; x = m->x; if (m->statusat == 0 && y > 0) @@ -149,37 +151,16 @@ cmd_resize_pane_mouse_update(struct client *c, struct mouse_event *m) else if (m->statusat > 0 && ly >= (u_int)m->statusat) ly = m->statusat - 1; - wp_x = wp_y = NULL; - TAILQ_FOREACH(loop, &wl->window->panes, entry) { - if (!window_pane_visible(loop)) - continue; - - sx = loop->xoff; - if (sx != 0) - sx--; - ex = loop->xoff + loop->sx; - - sy = loop->yoff; - if (sy != 0) - sy--; - ey = loop->yoff + loop->sy; - - if ((lx == sx || lx == ex) && - (ly >= sy && ly <= ey) && - (wp_x == NULL || loop->sy > wp_x->sy)) - wp_x = loop; - if ((ly == sy || ly == ey) && - (lx >= sx && lx <= ex) && - (wp_y == NULL || loop->sx > wp_y->sx)) - wp_y = loop; - } - if (wp_x == NULL && wp_y == NULL) { - c->tty.mouse_drag_update = NULL; + lc = layout_search_by_border(w->layout_root, lx, ly); + if (lc == NULL) return; - } - if (wp_x != NULL) - layout_resize_pane(wp_x, LAYOUT_LEFTRIGHT, x - lx, 0); - if (wp_y != NULL) - layout_resize_pane(wp_y, LAYOUT_TOPBOTTOM, y - ly, 0); - server_redraw_window(wl->window); + + if (y != ly && lc->parent->type == LAYOUT_TOPBOTTOM) + layout_resize_layout(w, lc, LAYOUT_TOPBOTTOM, y - ly, 0); + else if (x != lx && lc->parent->type == LAYOUT_LEFTRIGHT) + layout_resize_layout(w, lc, LAYOUT_LEFTRIGHT, x - lx, 0); + else + return; + + server_redraw_window(w); } |