summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/layout.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2012-10-26 14:35:42 +0000
committernicm <nicm@openbsd.org>2012-10-26 14:35:42 +0000
commit6fb64d94ca693b518e097a5ab991262b9df2cf4f (patch)
tree5758b34ef8aaa619f8c354722013c090b6a53195 /usr.bin/tmux/layout.c
parentProperly clear trap frame in setregs() to avoid leaking registers across exec. (diff)
downloadwireguard-openbsd-6fb64d94ca693b518e097a5ab991262b9df2cf4f.tar.xz
wireguard-openbsd-6fb64d94ca693b518e097a5ab991262b9df2cf4f.zip
Make mouse event structure clearer by defining events (up, click, drag)
and simplifying how buttons and wheels are represented, from Ailin Nemui. Should be no functional changes.
Diffstat (limited to 'usr.bin/tmux/layout.c')
-rw-r--r--usr.bin/tmux/layout.c43
1 files changed, 22 insertions, 21 deletions
diff --git a/usr.bin/tmux/layout.c b/usr.bin/tmux/layout.c
index c7a519ff216..50354cbc71e 100644
--- a/usr.bin/tmux/layout.c
+++ b/usr.bin/tmux/layout.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: layout.c,v 1.14 2012/07/10 11:53:01 nicm Exp $ */
+/* $OpenBSD: layout.c,v 1.15 2012/10/26 14:35:42 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -488,50 +488,51 @@ layout_resize_pane(struct window_pane *wp, enum layout_type type, int change)
}
void
-layout_resize_pane_mouse(struct client *c, struct mouse_event *mouse)
+layout_resize_pane_mouse(struct client *c)
{
struct window *w;
struct window_pane *wp;
+ struct mouse_event *m = &c->tty.mouse;
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)) {
+ if (m->event & MOUSE_EVENT_DRAG && m->flags & 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) {
+ if (wp->xoff + wp->sx == m->lx &&
+ wp->yoff <= 1 + m->ly &&
+ wp->yoff + wp->sy >= m->ly) {
layout_resize_pane(wp, LAYOUT_LEFTRIGHT,
- mouse->x - c->last_mouse.x);
+ m->x - m->lx);
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) {
+ if (wp->yoff + wp->sy == m->ly &&
+ wp->xoff <= 1 + m->lx &&
+ wp->xoff + wp->sx >= m->lx) {
layout_resize_pane(wp, LAYOUT_TOPBOTTOM,
- mouse->y - c->last_mouse.y);
+ m->y - m->ly);
pane_border = 1;
}
}
if (pane_border)
server_redraw_window(w);
- } else if (mouse->b != MOUSE_UP &&
- mouse->b == (mouse->b & MOUSE_BUTTON)) {
+ } else if (~m->event & MOUSE_EVENT_UP) {
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)) {
+ if ((wp->xoff + wp->sx == m->x &&
+ wp->yoff <= 1 + m->y &&
+ wp->yoff + wp->sy >= m->y) ||
+ (wp->yoff + wp->sy == m->y &&
+ wp->xoff <= 1 + m->x &&
+ wp->xoff + wp->sx >= m->x)) {
pane_border = 1;
}
}
}
if (pane_border)
- mouse->b |= MOUSE_RESIZE_PANE;
+ m->flags |= MOUSE_RESIZE_PANE;
+ else
+ m->flags &= ~MOUSE_RESIZE_PANE;
}
int