"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "server-client.c" between
tmux-3.2.tar.gz and tmux-3.2a.tar.gz

About: tmux is a terminal multiplexer that lets you switch easily between several programs in one terminal.

server-client.c  (tmux-3.2):server-client.c  (tmux-3.2a)
skipping to change at line 46 skipping to change at line 46
static void server_client_check_window_resize(struct window *); static void server_client_check_window_resize(struct window *);
static key_code server_client_check_mouse(struct client *, struct key_eve nt *); static key_code server_client_check_mouse(struct client *, struct key_eve nt *);
static void server_client_repeat_timer(int, short, void *); static void server_client_repeat_timer(int, short, void *);
static void server_client_click_timer(int, short, void *); static void server_client_click_timer(int, short, void *);
static void server_client_check_exit(struct client *); static void server_client_check_exit(struct client *);
static void server_client_check_redraw(struct client *); static void server_client_check_redraw(struct client *);
static void server_client_check_modes(struct client *); static void server_client_check_modes(struct client *);
static void server_client_set_title(struct client *); static void server_client_set_title(struct client *);
static void server_client_reset_state(struct client *); static void server_client_reset_state(struct client *);
static int server_client_assume_paste(struct session *); static int server_client_assume_paste(struct session *);
static void server_client_update_latest(struct client *);
static void server_client_dispatch(struct imsg *, void *); static void server_client_dispatch(struct imsg *, void *);
static void server_client_dispatch_command(struct client *, struct imsg *); static void server_client_dispatch_command(struct client *, struct imsg *);
static void server_client_dispatch_identify(struct client *, struct imsg *); static void server_client_dispatch_identify(struct client *, struct imsg *);
static void server_client_dispatch_shell(struct client *); static void server_client_dispatch_shell(struct client *);
/* Compare client windows. */ /* Compare client windows. */
static int static int
server_client_window_cmp(struct client_window *cw1, server_client_window_cmp(struct client_window *cw1,
struct client_window *cw2) struct client_window *cw2)
skipping to change at line 274 skipping to change at line 275
*cause = xstrdup("not a terminal"); *cause = xstrdup("not a terminal");
return (-1); return (-1);
} }
if (tty_open(&c->tty, cause) != 0) if (tty_open(&c->tty, cause) != 0)
return (-1); return (-1);
return (0); return (0);
} }
/* Lost an attached client. */
static void
server_client_attached_lost(struct client *c)
{
struct session *s = c->session;
struct window *w;
struct client *loop;
struct client *found;
log_debug("lost attached client %p", c);
/*
* By this point the session in the client has been cleared so walk all
* windows to find any with this client as the latest.
*/
RB_FOREACH(w, windows, &windows) {
if (w->latest != c)
continue;
found = NULL;
TAILQ_FOREACH(loop, &clients, entry) {
s = loop->session;
if (loop == c || s == NULL || s->curw->window != w)
continue;
if (found == NULL ||
timercmp(&loop->activity_time, &found->activity_time,
>))
found = loop;
}
if (found != NULL)
server_client_update_latest(found);
}
}
/* Lost a client. */ /* Lost a client. */
void void
server_client_lost(struct client *c) server_client_lost(struct client *c)
{ {
struct client_file *cf, *cf1; struct client_file *cf, *cf1;
struct client_window *cw, *cw1; struct client_window *cw, *cw1;
c->flags |= CLIENT_DEAD; c->flags |= CLIENT_DEAD;
server_client_clear_overlay(c); server_client_clear_overlay(c);
skipping to change at line 299 skipping to change at line 334
file_fire_done(cf); file_fire_done(cf);
} }
RB_FOREACH_SAFE(cw, client_windows, &c->windows, cw1) { RB_FOREACH_SAFE(cw, client_windows, &c->windows, cw1) {
RB_REMOVE(client_windows, &c->windows, cw); RB_REMOVE(client_windows, &c->windows, cw);
free(cw); free(cw);
} }
TAILQ_REMOVE(&clients, c, entry); TAILQ_REMOVE(&clients, c, entry);
log_debug("lost client %p", c); log_debug("lost client %p", c);
if (c->flags & CLIENT_ATTACHED) if (c->flags & CLIENT_ATTACHED) {
server_client_attached_lost(c);
notify_client("client-detached", c); notify_client("client-detached", c);
}
if (c->flags & CLIENT_CONTROL) if (c->flags & CLIENT_CONTROL)
control_stop(c); control_stop(c);
if (c->flags & CLIENT_TERMINAL) if (c->flags & CLIENT_TERMINAL)
tty_free(&c->tty); tty_free(&c->tty);
free(c->ttyname); free(c->ttyname);
free(c->term_name); free(c->term_name);
free(c->term_type); free(c->term_type);
tty_term_free_list(c->term_caps, c->term_ncaps); tty_term_free_list(c->term_caps, c->term_ncaps);
skipping to change at line 1413 skipping to change at line 1450
/* Resize timer event. */ /* Resize timer event. */
static void static void
server_client_resize_timer(__unused int fd, __unused short events, void *data) server_client_resize_timer(__unused int fd, __unused short events, void *data)
{ {
struct window_pane *wp = data; struct window_pane *wp = data;
log_debug("%s: %%%u resize timer expired", __func__, wp->id); log_debug("%s: %%%u resize timer expired", __func__, wp->id);
evtimer_del(&wp->resize_timer); evtimer_del(&wp->resize_timer);
} }
/* Start the resize timer. */
static void
server_client_start_resize_timer(struct window_pane *wp)
{
struct timeval tv = { .tv_usec = 250000 };
log_debug("%s: %%%u resize timer started", __func__, wp->id);
evtimer_add(&wp->resize_timer, &tv);
}
/* Force timer event. */
static void
server_client_force_timer(__unused int fd, __unused short events, void *data)
{
struct window_pane *wp = data;
log_debug("%s: %%%u force timer expired", __func__, wp->id);
evtimer_del(&wp->force_timer);
wp->flags |= PANE_RESIZENOW;
}
/* Start the force timer. */
static void
server_client_start_force_timer(struct window_pane *wp)
{
struct timeval tv = { .tv_usec = 10000 };
log_debug("%s: %%%u force timer started", __func__, wp->id);
evtimer_add(&wp->force_timer, &tv);
}
/* Check if pane should be resized. */ /* Check if pane should be resized. */
static void static void
server_client_check_pane_resize(struct window_pane *wp) server_client_check_pane_resize(struct window_pane *wp)
{ {
if (!event_initialized(&wp->resize_timer)) struct window_pane_resize *r;
evtimer_set(&wp->resize_timer, server_client_resize_timer, wp); struct window_pane_resize *r1;
if (!event_initialized(&wp->force_timer)) struct window_pane_resize *first;
evtimer_set(&wp->force_timer, server_client_force_timer, wp); struct window_pane_resize *last;
struct timeval tv = { .tv_usec = 250000 };
if (~wp->flags & PANE_RESIZE) if (TAILQ_EMPTY(&wp->resize_queue))
return; return;
log_debug("%s: %%%u needs to be resized", __func__, wp->id);
if (evtimer_pending(&wp->resize_timer, NULL)) { if (!event_initialized(&wp->resize_timer))
log_debug("%s: %%%u resize timer is running", __func__, wp->id); evtimer_set(&wp->resize_timer, server_client_resize_timer, wp);
if (evtimer_pending(&wp->resize_timer, NULL))
return; return;
log_debug("%s: %%%u needs to be resized", __func__, wp->id);
TAILQ_FOREACH(r, &wp->resize_queue, entry) {
log_debug("queued resize: %ux%u -> %ux%u", r->osx, r->osy,
r->sx, r->sy);
} }
server_client_start_resize_timer(wp);
if (~wp->flags & PANE_RESIZEFORCE) { /*
/* * There are three cases that matter:
* The timer is not running and we don't need to force a *
* resize, so just resize immediately. * - Only one resize. It can just be applied.
*/ *
log_debug("%s: resizing %%%u now", __func__, wp->id); * - Multiple resizes and the ending size is different from the
window_pane_send_resize(wp, 0); * starting size. We can discard all resizes except the most recent.
wp->flags &= ~PANE_RESIZE; *
* - Multiple resizes and the ending size is the same as the starting
* size. We must resize at least twice to force the application to
* redraw. So apply the first and leave the last on the queue for
* next time.
*/
first = TAILQ_FIRST(&wp->resize_queue);
last = TAILQ_LAST(&wp->resize_queue, window_pane_resizes);
if (first == last) {
/* Only one resize. */
window_pane_send_resize(wp, first->sx, first->sy);
TAILQ_REMOVE(&wp->resize_queue, first, entry);
free(first);
} else if (last->sx != first->osx || last->sy != first->osy) {
/* Multiple resizes ending up with a different size. */
window_pane_send_resize(wp, last->sx, last->sy);
TAILQ_FOREACH_SAFE(r, &wp->resize_queue, entry, r1) {
TAILQ_REMOVE(&wp->resize_queue, r, entry);
free(r);
}
} else { } else {
/* /*
* The timer is not running, but we need to force a resize. If * Multiple resizes ending up with the same size. There will
* the force timer has expired, resize to the real size now. * not be more than one to the same size in succession so we
* Otherwise resize to the force size and start the timer. * can just use the last-but-one on the list and leave the last
* for later. We reduce the time until the next check to avoid
* a long delay between the resizes.
*/ */
if (wp->flags & PANE_RESIZENOW) { r = TAILQ_PREV(last, window_pane_resizes, entry);
log_debug("%s: resizing %%%u after forced resize", window_pane_send_resize(wp, r->sx, r->sy);
__func__, wp->id); TAILQ_FOREACH_SAFE(r, &wp->resize_queue, entry, r1) {
window_pane_send_resize(wp, 0); if (r == last)
wp->flags &= ~(PANE_RESIZE|PANE_RESIZEFORCE|PANE_RESIZENO break;
W); TAILQ_REMOVE(&wp->resize_queue, r, entry);
} else if (!evtimer_pending(&wp->force_timer, NULL)) { free(r);
log_debug("%s: forcing resize of %%%u", __func__,
wp->id);
window_pane_send_resize(wp, 1);
server_client_start_force_timer(wp);
} }
tv.tv_usec = 10000;
} }
evtimer_add(&wp->resize_timer, &tv);
} }
/* Check pane buffer size. */ /* Check pane buffer size. */
static void static void
server_client_check_pane_buffer(struct window_pane *wp) server_client_check_pane_buffer(struct window_pane *wp)
{ {
struct evbuffer *evb = wp->event->input; struct evbuffer *evb = wp->event->input;
size_t minimum; size_t minimum;
struct client *c; struct client *c;
struct window_pane_offset *wpo; struct window_pane_offset *wpo;
 End of changes. 16 change blocks. 
63 lines changed or deleted 93 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)