diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2018-08-20 15:22:14 +0100 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2018-08-20 15:22:14 +0100 |
commit | 641191ab2047d1437d46dc0ae787346b74fddca5 (patch) | |
tree | 21844a1ed3a4b3bc987f8d967457d74f10c888d5 /server-client.c | |
parent | bf03197e185b8f274fa6681fbaf6d4237c2bfe4f (diff) |
Support for windows larger than the client.
This adds two new options, window-size and default-size, and a new
command, resize-window.
The force-width and force-height options, and the session_width and
session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and
manual means that it does not automatically resize
windows. aggressive-resize modifies the choice of session for largest
and smallest as it did before.
If a window is in a session attached to a client that is too small,
only part of the window is shown. tmux attempts to keep the cursor
visible, so the part of the window displayed is changed as the cursor
moves (with a small delay, to try and avoid excess redrawing when
applications redraw status lines or similar that are not currently
visible).
Drawing windows which are larger than the client is not as efficient
as those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If
it is used, the window-size option is automatically set to manual for
the window (undo this with "setw -u window-size"). resize-window works
in a similar way to resize-pane (-U -D -L -R -x -y flags) but also has
-a and -A flags. -a sets the window to the size of the smallest client
(what it would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use
resize-width -x or -y.
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications
to complain and higher memory use if you make a window that big. The
minimum size is the size required for the current layout including
borders.
This change allows some code improvements, most notably that since
windows can now never be cropped, that code can be removed from the
layout code, and since panes can now never be outside the size of the
window, window_pane_visible can be removed.
Diffstat (limited to 'server-client.c')
-rw-r--r-- | server-client.c | 48 |
1 files changed, 32 insertions, 16 deletions
diff --git a/server-client.c b/server-client.c index 72efe736..49a4b37d 100644 --- a/server-client.c +++ b/server-client.c @@ -192,6 +192,7 @@ server_client_create(int fd) c->session = NULL; c->last_session = NULL; + c->tty.sx = 80; c->tty.sy = 24; @@ -409,7 +410,7 @@ server_client_check_mouse(struct client *c) struct mouse_event *m = &c->tty.mouse; struct window *w; struct window_pane *wp; - u_int x, y, b; + u_int x, y, b, sx, sy; int flag; key_code key; struct timeval tv; @@ -419,8 +420,8 @@ server_client_check_mouse(struct client *c) type = NOTYPE; where = NOWHERE; - log_debug("mouse %02x at %u,%u (last %u,%u) (%d)", m->b, m->x, m->y, - m->lx, m->ly, c->tty.mouse_drag_flag); + log_debug("%s mouse %02x at %u,%u (last %u,%u) (%d)", c->name, m->b, + m->x, m->y, m->lx, m->ly, c->tty.mouse_drag_flag); /* What type of event is this? */ if ((m->sgr_type != ' ' && @@ -439,7 +440,7 @@ server_client_check_mouse(struct client *c) x = m->x, y = m->y, b = m->b; log_debug("drag update at %u,%u", x, y); } 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); } } else if (MOUSE_WHEEL(m->b)) { @@ -514,6 +515,14 @@ have_event: else if (m->statusat > 0 && y >= (u_int)m->statusat) y = m->statusat - 1; + 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 (x > sx || y > sy) + return (KEYC_UNKNOWN); + x = m->x = x + m->ox; + y = m->y = y + m->oy; + TAILQ_FOREACH(wp, &s->curw->window->panes, entry) { if ((wp->xoff + wp->sx == x && wp->yoff <= 1 + y && @@ -836,8 +845,6 @@ server_client_handle_key(struct client *c, key_code key) return; window_unzoom(w); wp = window_pane_at_index(w, key - '0'); - if (wp != NULL && !window_pane_visible(wp)) - wp = NULL; server_client_clear_identify(c, wp); return; } @@ -1224,28 +1231,37 @@ server_client_reset_state(struct client *c) struct window_pane *wp = w->active, *loop; struct screen *s = wp->screen; 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)) return; + mode = s->mode; tty_region_off(&c->tty); tty_margin_off(&c->tty); - if (status_at_line(c) != 0) - lines = 0; - else - lines = status_line_size(c->session); - if (!window_pane_visible(wp) || wp->yoff + s->cy >= c->tty.sy - lines) - tty_cursor(&c->tty, 0, 0); - else - tty_cursor(&c->tty, wp->xoff + s->cx, lines + wp->yoff + s->cy); + /* Move cursor to pane cursor and offset. */ + cursor = 0; + tty_window_offset(&c->tty, &ox, &oy, &sx, &sy); + if (wp->xoff + s->cx >= ox && wp->xoff + s->cx <= ox + sx && + wp->yoff + s->cy >= oy && wp->yoff + s->cy <= oy + sy) { + cursor = 1; + + cx = wp->xoff + s->cx - ox; + cy = wp->yoff + s->cy - oy; + + if (status_at_line(c) == 0) + cy += status_line_size(c->session); + } + if (!cursor) + mode &= ~MODE_CURSOR; + tty_cursor(&c->tty, cx, cy); /* * Set mouse mode if requested. To support dragging, always use button * mode. */ - mode = s->mode; if (options_get_number(oo, "mouse")) { mode &= ~ALL_MOUSE_MODES; TAILQ_FOREACH(loop, &w->panes, entry) { |