version 1.260, 2018/09/11 06:37:54 |
version 1.261, 2018/10/18 08:38:01 |
|
|
|
|
c->session = NULL; |
c->session = NULL; |
c->last_session = NULL; |
c->last_session = NULL; |
|
|
c->tty.sx = 80; |
c->tty.sx = 80; |
c->tty.sy = 24; |
c->tty.sy = 24; |
|
|
|
|
struct mouse_event *m = &c->tty.mouse; |
struct mouse_event *m = &c->tty.mouse; |
struct window *w; |
struct window *w; |
struct window_pane *wp; |
struct window_pane *wp; |
u_int x, y, b; |
u_int x, y, b, sx, sy, px, py; |
int flag; |
int flag; |
key_code key; |
key_code key; |
struct timeval tv; |
struct timeval tv; |
|
|
type = NOTYPE; |
type = NOTYPE; |
where = NOWHERE; |
where = NOWHERE; |
|
|
log_debug("mouse %02x at %u,%u (last %u,%u) (%d)", m->b, m->x, m->y, |
log_debug("%s mouse %02x at %u,%u (last %u,%u) (%d)", c->name, m->b, |
m->lx, m->ly, c->tty.mouse_drag_flag); |
m->x, m->y, m->lx, m->ly, c->tty.mouse_drag_flag); |
|
|
/* What type of event is this? */ |
/* What type of event is this? */ |
if ((m->sgr_type != ' ' && |
if ((m->sgr_type != ' ' && |
|
|
x = m->x, y = m->y, b = m->b; |
x = m->x, y = m->y, b = m->b; |
log_debug("drag update at %u,%u", x, y); |
log_debug("drag update at %u,%u", x, y); |
} else { |
} else { |
x = m->lx, y = m->ly, b = m->lb; |
x = m->lx - m->ox, y = m->ly - m->oy, b = m->lb; |
log_debug("drag start at %u,%u", x, y); |
log_debug("drag start at %u,%u", x, y); |
} |
} |
} else if (MOUSE_WHEEL(m->b)) { |
} else if (MOUSE_WHEEL(m->b)) { |
|
|
|
|
/* Not on status line. Adjust position and check for border or pane. */ |
/* Not on status line. Adjust position and check for border or pane. */ |
if (where == NOWHERE) { |
if (where == NOWHERE) { |
|
px = x; |
if (m->statusat == 0 && y > 0) |
if (m->statusat == 0 && y > 0) |
y--; |
py = y - 1; |
else if (m->statusat > 0 && y >= (u_int)m->statusat) |
else if (m->statusat > 0 && y >= (u_int)m->statusat) |
y = m->statusat - 1; |
py = m->statusat - 1; |
|
else |
|
py = y; |
|
|
|
tty_window_offset(&c->tty, &m->ox, &m->oy, &sx, &sy); |
|
log_debug("mouse window @%u at %u,%u (%ux%u)", |
|
s->curw->window->id, m->ox, m->oy, sx, sy); |
|
if (px > sx || py > sy) |
|
return (KEYC_UNKNOWN); |
|
px = px + m->ox; |
|
py = py + m->oy; |
|
m->x = x + m->ox; |
|
m->y = y + m->oy; |
|
|
/* Try the pane borders if not zoomed. */ |
/* Try the pane borders if not zoomed. */ |
if (~s->curw->window->flags & WINDOW_ZOOMED) { |
if (~s->curw->window->flags & WINDOW_ZOOMED) { |
TAILQ_FOREACH(wp, &s->curw->window->panes, entry) { |
TAILQ_FOREACH(wp, &s->curw->window->panes, entry) { |
if ((wp->xoff + wp->sx == x && |
if ((wp->xoff + wp->sx == px && |
wp->yoff <= 1 + y && |
wp->yoff <= 1 + py && |
wp->yoff + wp->sy >= y) || |
wp->yoff + wp->sy >= py) || |
(wp->yoff + wp->sy == y && |
(wp->yoff + wp->sy == py && |
wp->xoff <= 1 + x && |
wp->xoff <= 1 + px && |
wp->xoff + wp->sx >= x)) |
wp->xoff + wp->sx >= px)) |
break; |
break; |
} |
} |
if (wp != NULL) |
if (wp != NULL) |
|
|
|
|
/* Otherwise try inside the pane. */ |
/* Otherwise try inside the pane. */ |
if (where == NOWHERE) { |
if (where == NOWHERE) { |
wp = window_get_active_at(s->curw->window, x, y); |
wp = window_get_active_at(s->curw->window, px, py); |
if (wp != NULL) |
if (wp != NULL) |
where = PANE; |
where = PANE; |
} |
} |
|
|
return; |
return; |
window_unzoom(w); |
window_unzoom(w); |
wp = window_pane_at_index(w, key - '0'); |
wp = window_pane_at_index(w, key - '0'); |
if (wp != NULL && !window_pane_visible(wp)) |
|
wp = NULL; |
|
server_client_clear_identify(c, wp); |
server_client_clear_identify(c, wp); |
return; |
return; |
} |
} |
|
|
struct window_pane *wp = w->active, *loop; |
struct window_pane *wp = w->active, *loop; |
struct screen *s = wp->screen; |
struct screen *s = wp->screen; |
struct options *oo = c->session->options; |
struct options *oo = c->session->options; |
int lines, mode; |
int mode, cursor = 0; |
|
u_int cx = 0, cy = 0, ox, oy, sx, sy; |
|
|
if (c->flags & (CLIENT_CONTROL|CLIENT_SUSPENDED)) |
if (c->flags & (CLIENT_CONTROL|CLIENT_SUSPENDED)) |
return; |
return; |
|
mode = s->mode; |
|
|
tty_region_off(&c->tty); |
tty_region_off(&c->tty); |
tty_margin_off(&c->tty); |
tty_margin_off(&c->tty); |
|
|
if (status_at_line(c) != 0) |
/* Move cursor to pane cursor and offset. */ |
lines = 0; |
cursor = 0; |
else |
tty_window_offset(&c->tty, &ox, &oy, &sx, &sy); |
lines = status_line_size(c->session); |
if (wp->xoff + s->cx >= ox && wp->xoff + s->cx <= ox + sx && |
if (!window_pane_visible(wp) || wp->yoff + s->cy >= c->tty.sy - lines) |
wp->yoff + s->cy >= oy && wp->yoff + s->cy <= oy + sy) { |
tty_cursor(&c->tty, 0, 0); |
cursor = 1; |
else |
|
tty_cursor(&c->tty, wp->xoff + s->cx, lines + wp->yoff + s->cy); |
|
|
|
|
cx = wp->xoff + s->cx - ox; |
|
cy = wp->yoff + s->cy - oy; |
|
|
|
if (status_at_line(c) == 0) |
|
cy += status_line_size(c); |
|
} |
|
if (!cursor) |
|
mode &= ~MODE_CURSOR; |
|
tty_cursor(&c->tty, cx, cy); |
|
|
/* |
/* |
* Set mouse mode if requested. To support dragging, always use button |
* Set mouse mode if requested. To support dragging, always use button |
* mode. |
* mode. |
*/ |
*/ |
mode = s->mode; |
|
if (options_get_number(oo, "mouse")) { |
if (options_get_number(oo, "mouse")) { |
mode &= ~ALL_MOUSE_MODES; |
mode &= ~ALL_MOUSE_MODES; |
TAILQ_FOREACH(loop, &w->panes, entry) { |
TAILQ_FOREACH(loop, &w->panes, entry) { |