mirror of
https://github.com/tmux/tmux.git
synced 2025-09-05 08:07:03 +00:00
Sync OpenBSD patchset 905:
Add a new option, mouse-resize-pane. When on, panes may be resized by dragging their borders. From hsim at gmx.li.
This commit is contained in:
49
layout.c
49
layout.c
@ -1,4 +1,4 @@
|
||||
/* $Id: layout.c,v 1.19 2010-07-02 02:54:52 tcunha Exp $ */
|
||||
/* $Id: layout.c,v 1.20 2011-05-18 20:30:14 tcunha Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -485,6 +485,53 @@ layout_resize_pane(struct window_pane *wp, enum layout_type type, int change)
|
||||
layout_fix_panes(wp->window, wp->window->sx, wp->window->sy);
|
||||
}
|
||||
|
||||
void
|
||||
layout_resize_pane_mouse(struct client *c, struct mouse_event *mouse)
|
||||
{
|
||||
struct window *w;
|
||||
struct window_pane *wp;
|
||||
int pane_border;
|
||||
|
||||
w = c->session->curw->window;
|
||||
|
||||
pane_border = 0;
|
||||
if ((c->last_mouse.b & MOUSE_BUTTON) != MOUSE_UP &&
|
||||
(c->last_mouse.b & MOUSE_RESIZE_PANE)) {
|
||||
TAILQ_FOREACH(wp, &w->panes, entry) {
|
||||
if (wp->xoff + wp->sx == c->last_mouse.x &&
|
||||
wp->yoff <= 1 + c->last_mouse.y &&
|
||||
wp->yoff + wp->sy >= c->last_mouse.y) {
|
||||
layout_resize_pane(wp, LAYOUT_LEFTRIGHT,
|
||||
mouse->x - c->last_mouse.x);
|
||||
pane_border = 1;
|
||||
}
|
||||
if (wp->yoff + wp->sy == c->last_mouse.y &&
|
||||
wp->xoff <= 1 + c->last_mouse.x &&
|
||||
wp->xoff + wp->sx >= c->last_mouse.x) {
|
||||
layout_resize_pane(wp, LAYOUT_TOPBOTTOM,
|
||||
mouse->y - c->last_mouse.y);
|
||||
pane_border = 1;
|
||||
}
|
||||
}
|
||||
if (pane_border)
|
||||
server_redraw_window(w);
|
||||
} else if (mouse->b != MOUSE_UP &&
|
||||
mouse->b == (mouse->b & MOUSE_BUTTON)) {
|
||||
TAILQ_FOREACH(wp, &w->panes, entry) {
|
||||
if ((wp->xoff + wp->sx == mouse->x &&
|
||||
wp->yoff <= 1 + mouse->y &&
|
||||
wp->yoff + wp->sy >= mouse->y) ||
|
||||
(wp->yoff + wp->sy == mouse->y &&
|
||||
wp->xoff <= 1 + mouse->x &&
|
||||
wp->xoff + wp->sx >= mouse->x)) {
|
||||
pane_border = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pane_border)
|
||||
mouse->b |= MOUSE_RESIZE_PANE;
|
||||
}
|
||||
|
||||
int
|
||||
layout_resize_pane_grow(
|
||||
struct layout_cell *lc, enum layout_type type, int needed)
|
||||
|
Reference in New Issue
Block a user