2009-06-01 22:58:49 +00:00
|
|
|
/* $OpenBSD$ */
|
|
|
|
|
|
|
|
/*
|
2016-01-19 15:59:12 +00:00
|
|
|
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
2009-06-01 22:58:49 +00:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
|
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
2015-10-27 13:23:24 +00:00
|
|
|
#include <sys/queue.h>
|
2017-10-12 11:32:27 +00:00
|
|
|
#include <sys/wait.h>
|
2015-10-27 13:23:24 +00:00
|
|
|
#include <sys/uio.h>
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2015-10-27 13:23:24 +00:00
|
|
|
#include <imsg.h>
|
2012-07-10 11:53:01 +00:00
|
|
|
#include <stdlib.h>
|
2009-06-01 22:58:49 +00:00
|
|
|
#include <string.h>
|
2009-07-14 06:59:06 +00:00
|
|
|
#include <time.h>
|
2009-06-01 22:58:49 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include "tmux.h"
|
|
|
|
|
2016-10-10 21:29:23 +00:00
|
|
|
static struct session *server_next_session(struct session *);
|
2016-10-11 13:21:59 +00:00
|
|
|
static void server_destroy_session_group(struct session *);
|
2009-11-04 23:29:42 +00:00
|
|
|
|
2009-06-01 22:58:49 +00:00
|
|
|
void
|
|
|
|
server_redraw_client(struct client *c)
|
|
|
|
{
|
2018-08-19 16:45:03 +00:00
|
|
|
c->flags |= CLIENT_ALLREDRAWFLAGS;
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
server_status_client(struct client *c)
|
|
|
|
{
|
2018-08-19 16:45:03 +00:00
|
|
|
c->flags |= CLIENT_REDRAWSTATUS;
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
server_redraw_session(struct session *s)
|
|
|
|
{
|
|
|
|
struct client *c;
|
|
|
|
|
2015-04-24 23:17:11 +00:00
|
|
|
TAILQ_FOREACH(c, &clients, entry) {
|
2009-06-01 22:58:49 +00:00
|
|
|
if (c->session == s)
|
|
|
|
server_redraw_client(c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-10 10:02:48 +00:00
|
|
|
void
|
|
|
|
server_redraw_session_group(struct session *s)
|
|
|
|
{
|
|
|
|
struct session_group *sg;
|
|
|
|
|
2017-02-09 15:04:53 +00:00
|
|
|
if ((sg = session_group_contains(s)) == NULL)
|
2009-10-10 10:02:48 +00:00
|
|
|
server_redraw_session(s);
|
|
|
|
else {
|
|
|
|
TAILQ_FOREACH(s, &sg->sessions, gentry)
|
|
|
|
server_redraw_session(s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-01 22:58:49 +00:00
|
|
|
void
|
|
|
|
server_status_session(struct session *s)
|
|
|
|
{
|
|
|
|
struct client *c;
|
|
|
|
|
2015-04-24 23:17:11 +00:00
|
|
|
TAILQ_FOREACH(c, &clients, entry) {
|
2009-06-01 22:58:49 +00:00
|
|
|
if (c->session == s)
|
|
|
|
server_status_client(c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-10 10:02:48 +00:00
|
|
|
void
|
|
|
|
server_status_session_group(struct session *s)
|
|
|
|
{
|
|
|
|
struct session_group *sg;
|
|
|
|
|
2017-02-09 15:04:53 +00:00
|
|
|
if ((sg = session_group_contains(s)) == NULL)
|
2009-10-10 10:02:48 +00:00
|
|
|
server_status_session(s);
|
|
|
|
else {
|
|
|
|
TAILQ_FOREACH(s, &sg->sessions, gentry)
|
|
|
|
server_status_session(s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-01 22:58:49 +00:00
|
|
|
void
|
|
|
|
server_redraw_window(struct window *w)
|
|
|
|
{
|
|
|
|
struct client *c;
|
|
|
|
|
2015-04-24 23:17:11 +00:00
|
|
|
TAILQ_FOREACH(c, &clients, entry) {
|
|
|
|
if (c->session != NULL && c->session->curw->window == w)
|
2009-06-01 22:58:49 +00:00
|
|
|
server_redraw_client(c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-03 12:51:05 +00:00
|
|
|
void
|
|
|
|
server_redraw_window_borders(struct window *w)
|
|
|
|
{
|
|
|
|
struct client *c;
|
|
|
|
|
2015-04-24 23:17:11 +00:00
|
|
|
TAILQ_FOREACH(c, &clients, entry) {
|
|
|
|
if (c->session != NULL && c->session->curw->window == w)
|
2018-08-19 16:45:03 +00:00
|
|
|
c->flags |= CLIENT_REDRAWBORDERS;
|
2010-01-03 12:51:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-01 22:58:49 +00:00
|
|
|
void
|
|
|
|
server_status_window(struct window *w)
|
|
|
|
{
|
|
|
|
struct session *s;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is slightly different. We want to redraw the status line of any
|
2013-03-24 09:54:10 +00:00
|
|
|
* clients containing this window rather than anywhere it is the
|
2009-06-01 22:58:49 +00:00
|
|
|
* current window.
|
|
|
|
*/
|
|
|
|
|
2010-12-21 22:37:59 +00:00
|
|
|
RB_FOREACH(s, sessions, &sessions) {
|
2015-04-22 15:32:33 +00:00
|
|
|
if (session_has(s, w))
|
2009-06-01 22:58:49 +00:00
|
|
|
server_status_session(s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
server_lock(void)
|
|
|
|
{
|
2009-09-24 14:17:09 +00:00
|
|
|
struct client *c;
|
2009-09-02 16:38:35 +00:00
|
|
|
|
2015-04-24 23:17:11 +00:00
|
|
|
TAILQ_FOREACH(c, &clients, entry) {
|
|
|
|
if (c->session != NULL)
|
|
|
|
server_lock_client(c);
|
2009-09-24 14:17:09 +00:00
|
|
|
}
|
|
|
|
}
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2009-09-24 14:17:09 +00:00
|
|
|
void
|
|
|
|
server_lock_session(struct session *s)
|
|
|
|
{
|
|
|
|
struct client *c;
|
|
|
|
|
2015-04-24 23:17:11 +00:00
|
|
|
TAILQ_FOREACH(c, &clients, entry) {
|
|
|
|
if (c->session == s)
|
|
|
|
server_lock_client(c);
|
2009-12-03 22:50:09 +00:00
|
|
|
}
|
2009-09-24 14:17:09 +00:00
|
|
|
}
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2009-09-24 14:17:09 +00:00
|
|
|
void
|
|
|
|
server_lock_client(struct client *c)
|
|
|
|
{
|
2013-10-10 12:13:56 +00:00
|
|
|
const char *cmd;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2013-03-22 10:42:55 +00:00
|
|
|
if (c->flags & CLIENT_CONTROL)
|
2013-03-21 18:47:01 +00:00
|
|
|
return;
|
|
|
|
|
2009-10-04 10:55:30 +00:00
|
|
|
if (c->flags & CLIENT_SUSPENDED)
|
|
|
|
return;
|
|
|
|
|
2015-10-27 15:58:42 +00:00
|
|
|
cmd = options_get_string(c->session->options, "lock-command");
|
2017-08-29 09:18:48 +00:00
|
|
|
if (*cmd == '\0' || strlen(cmd) + 1 > MAX_IMSGSIZE - IMSG_HEADER_SIZE)
|
2009-09-24 14:17:09 +00:00
|
|
|
return;
|
2009-12-03 22:50:09 +00:00
|
|
|
|
2009-09-24 14:17:09 +00:00
|
|
|
tty_stop_tty(&c->tty);
|
|
|
|
tty_raw(&c->tty, tty_term_string(c->tty.term, TTYC_SMCUP));
|
|
|
|
tty_raw(&c->tty, tty_term_string(c->tty.term, TTYC_CLEAR));
|
2011-10-23 10:16:14 +00:00
|
|
|
tty_raw(&c->tty, tty_term_string(c->tty.term, TTYC_E3));
|
2009-09-24 14:17:09 +00:00
|
|
|
|
|
|
|
c->flags |= CLIENT_SUSPENDED;
|
2017-07-12 09:07:52 +00:00
|
|
|
proc_send(c->peer, MSG_LOCK, -1, cmd, strlen(cmd) + 1);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
2009-07-17 20:37:03 +00:00
|
|
|
|
2018-04-10 10:48:44 +00:00
|
|
|
void
|
|
|
|
server_kill_pane(struct window_pane *wp)
|
|
|
|
{
|
|
|
|
struct window *w = wp->window;
|
|
|
|
|
|
|
|
if (window_count_panes(w) == 1) {
|
|
|
|
server_kill_window(w);
|
|
|
|
recalculate_sizes();
|
|
|
|
} else {
|
|
|
|
server_unzoom_window(w);
|
|
|
|
layout_close_pane(wp);
|
|
|
|
window_remove_pane(w, wp);
|
|
|
|
server_redraw_window(w);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-17 20:37:03 +00:00
|
|
|
void
|
|
|
|
server_kill_window(struct window *w)
|
|
|
|
{
|
2013-07-05 14:52:33 +00:00
|
|
|
struct session *s, *next_s, *target_s;
|
|
|
|
struct session_group *sg;
|
|
|
|
struct winlink *wl;
|
2009-12-03 22:50:09 +00:00
|
|
|
|
2010-12-23 21:56:38 +00:00
|
|
|
next_s = RB_MIN(sessions, &sessions);
|
|
|
|
while (next_s != NULL) {
|
|
|
|
s = next_s;
|
|
|
|
next_s = RB_NEXT(sessions, &sessions, s);
|
|
|
|
|
2015-04-22 15:32:33 +00:00
|
|
|
if (!session_has(s, w))
|
2009-07-17 20:37:03 +00:00
|
|
|
continue;
|
2015-01-06 09:12:53 +00:00
|
|
|
server_unzoom_window(w);
|
2010-01-23 21:07:31 +00:00
|
|
|
while ((wl = winlink_find_by_window(&s->windows, w)) != NULL) {
|
|
|
|
if (session_detach(s, wl)) {
|
|
|
|
server_destroy_session_group(s);
|
|
|
|
break;
|
|
|
|
} else
|
|
|
|
server_redraw_session_group(s);
|
|
|
|
}
|
2012-04-29 17:20:01 +00:00
|
|
|
|
2015-10-27 15:58:42 +00:00
|
|
|
if (options_get_number(s->options, "renumber-windows")) {
|
2017-02-09 15:04:53 +00:00
|
|
|
if ((sg = session_group_contains(s)) != NULL) {
|
2013-07-05 14:52:33 +00:00
|
|
|
TAILQ_FOREACH(target_s, &sg->sessions, gentry)
|
|
|
|
session_renumber_windows(target_s);
|
|
|
|
} else
|
|
|
|
session_renumber_windows(s);
|
|
|
|
}
|
2009-07-17 20:37:03 +00:00
|
|
|
}
|
2013-04-22 13:35:18 +00:00
|
|
|
recalculate_sizes();
|
2009-09-20 17:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2009-10-10 10:02:48 +00:00
|
|
|
server_link_window(struct session *src, struct winlink *srcwl,
|
2014-04-17 14:45:49 +00:00
|
|
|
struct session *dst, int dstidx, int killflag, int selectflag,
|
|
|
|
char **cause)
|
2009-09-20 17:27:18 +00:00
|
|
|
{
|
2009-10-10 10:02:48 +00:00
|
|
|
struct winlink *dstwl;
|
|
|
|
struct session_group *srcsg, *dstsg;
|
|
|
|
|
2017-02-09 15:04:53 +00:00
|
|
|
srcsg = session_group_contains(src);
|
|
|
|
dstsg = session_group_contains(dst);
|
2009-10-10 10:02:48 +00:00
|
|
|
if (src != dst && srcsg != NULL && dstsg != NULL && srcsg == dstsg) {
|
|
|
|
xasprintf(cause, "sessions are grouped");
|
|
|
|
return (-1);
|
|
|
|
}
|
2009-09-20 17:27:18 +00:00
|
|
|
|
|
|
|
dstwl = NULL;
|
|
|
|
if (dstidx != -1)
|
|
|
|
dstwl = winlink_find_by_index(&dst->windows, dstidx);
|
|
|
|
if (dstwl != NULL) {
|
2010-10-09 12:58:00 +00:00
|
|
|
if (dstwl->window == srcwl->window) {
|
|
|
|
xasprintf(cause, "same index: %d", dstidx);
|
2010-08-11 07:36:23 +00:00
|
|
|
return (-1);
|
2010-10-09 12:58:00 +00:00
|
|
|
}
|
2009-09-20 17:27:18 +00:00
|
|
|
if (killflag) {
|
|
|
|
/*
|
|
|
|
* Can't use session_detach as it will destroy session
|
|
|
|
* if this makes it empty.
|
|
|
|
*/
|
2016-10-16 22:06:40 +00:00
|
|
|
notify_session_window("window-unlinked", dst,
|
|
|
|
dstwl->window);
|
2010-06-21 01:27:46 +00:00
|
|
|
dstwl->flags &= ~WINLINK_ALERTFLAGS;
|
2009-09-20 17:27:18 +00:00
|
|
|
winlink_stack_remove(&dst->lastw, dstwl);
|
|
|
|
winlink_remove(&dst->windows, dstwl);
|
|
|
|
|
|
|
|
/* Force select/redraw if current. */
|
2009-10-11 10:39:27 +00:00
|
|
|
if (dstwl == dst->curw) {
|
2009-09-20 17:27:18 +00:00
|
|
|
selectflag = 1;
|
2009-10-11 10:39:27 +00:00
|
|
|
dst->curw = NULL;
|
|
|
|
}
|
2009-09-20 17:27:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dstidx == -1)
|
2015-10-27 15:58:42 +00:00
|
|
|
dstidx = -1 - options_get_number(dst->options, "base-index");
|
2009-09-20 17:27:18 +00:00
|
|
|
dstwl = session_attach(dst, srcwl->window, dstidx, cause);
|
|
|
|
if (dstwl == NULL)
|
|
|
|
return (-1);
|
|
|
|
|
2009-10-10 10:02:48 +00:00
|
|
|
if (selectflag)
|
2009-09-20 17:27:18 +00:00
|
|
|
session_select(dst, dstwl->idx);
|
2009-10-10 10:02:48 +00:00
|
|
|
server_redraw_session_group(dst);
|
2009-09-20 17:27:18 +00:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
server_unlink_window(struct session *s, struct winlink *wl)
|
|
|
|
{
|
|
|
|
if (session_detach(s, wl))
|
2009-10-10 10:02:48 +00:00
|
|
|
server_destroy_session_group(s);
|
2009-09-20 17:27:18 +00:00
|
|
|
else
|
2009-10-10 10:02:48 +00:00
|
|
|
server_redraw_session_group(s);
|
|
|
|
}
|
|
|
|
|
2009-11-13 17:33:07 +00:00
|
|
|
void
|
2016-10-16 22:06:40 +00:00
|
|
|
server_destroy_pane(struct window_pane *wp, int notify)
|
2009-11-13 17:33:07 +00:00
|
|
|
{
|
2011-09-05 23:40:51 +00:00
|
|
|
struct window *w = wp->window;
|
|
|
|
struct screen_write_ctx ctx;
|
|
|
|
struct grid_cell gc;
|
2017-10-12 11:32:27 +00:00
|
|
|
time_t t;
|
|
|
|
char tim[26];
|
2009-11-13 17:33:07 +00:00
|
|
|
|
2010-04-17 23:25:16 +00:00
|
|
|
if (wp->fd != -1) {
|
|
|
|
bufferevent_free(wp->event);
|
2018-11-30 08:44:40 +00:00
|
|
|
wp->event = NULL;
|
2012-01-29 02:22:11 +00:00
|
|
|
close(wp->fd);
|
2010-04-17 23:25:16 +00:00
|
|
|
wp->fd = -1;
|
|
|
|
}
|
2009-11-13 17:33:07 +00:00
|
|
|
|
2019-06-20 11:59:59 +00:00
|
|
|
if (options_get_number(wp->options, "remain-on-exit")) {
|
2017-10-12 11:32:27 +00:00
|
|
|
if (~wp->flags & PANE_STATUSREADY)
|
2011-09-05 23:40:51 +00:00
|
|
|
return;
|
2016-10-16 22:06:40 +00:00
|
|
|
|
2017-10-12 11:32:27 +00:00
|
|
|
if (wp->flags & PANE_STATUSDRAWN)
|
|
|
|
return;
|
|
|
|
wp->flags |= PANE_STATUSDRAWN;
|
|
|
|
|
2016-10-16 22:06:40 +00:00
|
|
|
if (notify)
|
|
|
|
notify_pane("pane-died", wp);
|
|
|
|
|
2011-09-05 23:40:51 +00:00
|
|
|
screen_write_start(&ctx, wp, &wp->base);
|
|
|
|
screen_write_scrollregion(&ctx, 0, screen_size_y(ctx.s) - 1);
|
2019-03-12 20:02:47 +00:00
|
|
|
screen_write_cursormove(&ctx, 0, screen_size_y(ctx.s) - 1, 0);
|
2017-05-12 13:00:56 +00:00
|
|
|
screen_write_linefeed(&ctx, 1, 8);
|
2011-09-05 23:40:51 +00:00
|
|
|
memcpy(&gc, &grid_default_cell, sizeof gc);
|
2017-10-12 11:32:27 +00:00
|
|
|
|
|
|
|
time(&t);
|
|
|
|
ctime_r(&t, tim);
|
|
|
|
|
|
|
|
if (WIFEXITED(wp->status)) {
|
|
|
|
screen_write_nputs(&ctx, -1, &gc,
|
|
|
|
"Pane is dead (status %d, %s)",
|
|
|
|
WEXITSTATUS(wp->status),
|
|
|
|
tim);
|
|
|
|
} else if (WIFSIGNALED(wp->status)) {
|
|
|
|
screen_write_nputs(&ctx, -1, &gc,
|
|
|
|
"Pane is dead (signal %d, %s)",
|
|
|
|
WTERMSIG(wp->status),
|
|
|
|
tim);
|
|
|
|
}
|
|
|
|
|
2011-09-05 23:40:51 +00:00
|
|
|
screen_write_stop(&ctx);
|
|
|
|
wp->flags |= PANE_REDRAW;
|
2009-11-13 17:33:07 +00:00
|
|
|
return;
|
2011-09-05 23:40:51 +00:00
|
|
|
}
|
2009-11-13 17:33:07 +00:00
|
|
|
|
2016-10-16 22:06:40 +00:00
|
|
|
if (notify)
|
|
|
|
notify_pane("pane-exited", wp);
|
|
|
|
|
2013-03-24 09:57:59 +00:00
|
|
|
server_unzoom_window(w);
|
2009-11-13 17:33:07 +00:00
|
|
|
layout_close_pane(wp);
|
|
|
|
window_remove_pane(w, wp);
|
|
|
|
|
|
|
|
if (TAILQ_EMPTY(&w->panes))
|
|
|
|
server_kill_window(w);
|
|
|
|
else
|
|
|
|
server_redraw_window(w);
|
|
|
|
}
|
|
|
|
|
2016-10-11 13:21:59 +00:00
|
|
|
static void
|
2009-10-10 10:02:48 +00:00
|
|
|
server_destroy_session_group(struct session *s)
|
|
|
|
{
|
|
|
|
struct session_group *sg;
|
2013-10-10 11:46:28 +00:00
|
|
|
struct session *s1;
|
2009-10-10 10:02:48 +00:00
|
|
|
|
2017-02-09 15:04:53 +00:00
|
|
|
if ((sg = session_group_contains(s)) == NULL)
|
2009-10-10 10:02:48 +00:00
|
|
|
server_destroy_session(s);
|
|
|
|
else {
|
2013-10-10 11:46:28 +00:00
|
|
|
TAILQ_FOREACH_SAFE(s, &sg->sessions, gentry, s1) {
|
2009-10-10 10:02:48 +00:00
|
|
|
server_destroy_session(s);
|
2019-04-17 14:37:48 +00:00
|
|
|
session_destroy(s, 1, __func__);
|
2013-10-10 11:46:28 +00:00
|
|
|
}
|
2009-10-10 10:02:48 +00:00
|
|
|
}
|
2009-07-17 20:37:03 +00:00
|
|
|
}
|
2009-08-31 20:46:19 +00:00
|
|
|
|
2016-10-10 21:29:23 +00:00
|
|
|
static struct session *
|
2010-06-27 00:22:22 +00:00
|
|
|
server_next_session(struct session *s)
|
|
|
|
{
|
|
|
|
struct session *s_loop, *s_out;
|
|
|
|
|
|
|
|
s_out = NULL;
|
2010-12-21 22:37:59 +00:00
|
|
|
RB_FOREACH(s_loop, sessions, &sessions) {
|
|
|
|
if (s_loop == s)
|
2010-06-27 00:22:22 +00:00
|
|
|
continue;
|
|
|
|
if (s_out == NULL ||
|
|
|
|
timercmp(&s_loop->activity_time, &s_out->activity_time, <))
|
|
|
|
s_out = s_loop;
|
|
|
|
}
|
|
|
|
return (s_out);
|
|
|
|
}
|
|
|
|
|
2009-09-12 13:01:19 +00:00
|
|
|
void
|
|
|
|
server_destroy_session(struct session *s)
|
|
|
|
{
|
|
|
|
struct client *c;
|
2010-06-27 00:22:22 +00:00
|
|
|
struct session *s_new;
|
2009-12-03 22:50:09 +00:00
|
|
|
|
2015-10-27 15:58:42 +00:00
|
|
|
if (!options_get_number(s->options, "detach-on-destroy"))
|
2010-06-27 00:22:22 +00:00
|
|
|
s_new = server_next_session(s);
|
|
|
|
else
|
|
|
|
s_new = NULL;
|
|
|
|
|
2015-04-24 23:17:11 +00:00
|
|
|
TAILQ_FOREACH(c, &clients, entry) {
|
|
|
|
if (c->session != s)
|
2009-09-12 13:01:19 +00:00
|
|
|
continue;
|
2010-06-27 00:22:22 +00:00
|
|
|
if (s_new == NULL) {
|
|
|
|
c->session = NULL;
|
2010-07-24 20:11:59 +00:00
|
|
|
c->flags |= CLIENT_EXIT;
|
2010-06-27 00:22:22 +00:00
|
|
|
} else {
|
2010-12-20 00:17:22 +00:00
|
|
|
c->last_session = NULL;
|
2010-06-27 00:22:22 +00:00
|
|
|
c->session = s_new;
|
2015-12-12 18:32:24 +00:00
|
|
|
server_client_set_key_table(c, NULL);
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are 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. The default is
currently largest but this may change. 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). The
offset of the visible portion of the window is shown in status-right.
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-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
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 much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
tty_update_client_offset(c);
|
2015-08-28 12:16:28 +00:00
|
|
|
status_timer_start(c);
|
2016-10-16 22:06:40 +00:00
|
|
|
notify_client("client-session-changed", c);
|
2015-08-28 13:01:03 +00:00
|
|
|
session_update_activity(s_new, NULL);
|
2015-09-10 08:58:14 +00:00
|
|
|
gettimeofday(&s_new->last_attached_time, NULL);
|
2010-06-27 00:22:22 +00:00
|
|
|
server_redraw_client(c);
|
2015-12-11 12:39:47 +00:00
|
|
|
alerts_check_session(s_new);
|
2010-06-27 00:22:22 +00:00
|
|
|
}
|
2009-09-12 13:01:19 +00:00
|
|
|
}
|
2010-06-26 23:55:50 +00:00
|
|
|
recalculate_sizes();
|
2009-09-12 13:01:19 +00:00
|
|
|
}
|
|
|
|
|
2010-09-26 20:43:30 +00:00
|
|
|
void
|
2014-02-14 13:59:01 +00:00
|
|
|
server_check_unattached(void)
|
2010-09-26 20:43:30 +00:00
|
|
|
{
|
|
|
|
struct session *s;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If any sessions are no longer attached and have destroy-unattached
|
|
|
|
* set, collect them.
|
|
|
|
*/
|
2010-12-21 22:37:59 +00:00
|
|
|
RB_FOREACH(s, sessions, &sessions) {
|
2018-08-18 20:08:52 +00:00
|
|
|
if (s->attached != 0)
|
2010-09-26 20:43:30 +00:00
|
|
|
continue;
|
2015-10-27 15:58:42 +00:00
|
|
|
if (options_get_number (s->options, "destroy-unattached"))
|
2019-04-17 14:37:48 +00:00
|
|
|
session_destroy(s, 1, __func__);
|
2010-09-26 20:43:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-24 09:57:59 +00:00
|
|
|
void
|
|
|
|
server_unzoom_window(struct window *w)
|
|
|
|
{
|
2018-02-28 08:55:44 +00:00
|
|
|
if (window_unzoom(w) == 0)
|
2015-04-19 21:34:21 +00:00
|
|
|
server_redraw_window(w);
|
2013-03-24 09:57:59 +00:00
|
|
|
}
|