diff --git a/client.c b/client.c index 91f47650..691ace31 100644 --- a/client.c +++ b/client.c @@ -78,8 +78,8 @@ client_get_lock(char *lockfile) if ((lockfd = open(lockfile, O_WRONLY|O_CREAT, 0600)) == -1) fatal("open failed"); - if (flock(lockfd, LOCK_EX|LOCK_NB) == -1 && errno == EWOULDBLOCK) { - while (flock(lockfd, LOCK_EX) == -1 && errno == EINTR) + if (lockf(lockfd, F_TLOCK, 0) == -1 && errno == EAGAIN) { + while (lockf(lockfd, F_LOCK, 0) == -1 && errno == EINTR) /* nothing */; close(lockfd); return (-1); diff --git a/cmd-choose-tree.c b/cmd-choose-tree.c index e2d382b3..a9b6ffbc 100644 --- a/cmd-choose-tree.c +++ b/cmd-choose-tree.c @@ -89,10 +89,7 @@ cmd_choose_tree_exec(struct cmd *self, struct cmd_q *cmdq) return (CMD_RETURN_ERROR); } - if ((s = c->session) == NULL) - return (CMD_RETURN_ERROR); - - if ((wl = cmd_find_window(cmdq, args_get(args, 't'), NULL)) == NULL) + if ((wl = cmd_find_window(cmdq, args_get(args, 't'), &s)) == NULL) return (CMD_RETURN_ERROR); if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0) @@ -231,9 +228,12 @@ windows_only: free(final_win_template_last); window_choose_ready(wl->window->active, cur_win, NULL); + window_choose_collapse_all(wl->window->active); - if (args_has(args, 'u')) + if (args_has(args, 'u')) { window_choose_expand_all(wl->window->active); + window_choose_set_current(wl->window->active, cur_win); + } return (CMD_RETURN_NORMAL); } diff --git a/format.c b/format.c index fa2dd0b2..7de819a9 100644 --- a/format.c +++ b/format.c @@ -288,7 +288,7 @@ format_session(struct format_tree *ft, struct session *s) format_add(ft, "session_group", "%u", session_group_index(sg)); t = s->creation_time.tv_sec; - format_add(ft, "session_created", "%ld", (long) t); + format_add(ft, "session_created", "%lld", (long long) t); tim = ctime(&t); *strchr(tim, '\n') = '\0'; format_add(ft, "session_created_string", "%s", tim); @@ -314,13 +314,13 @@ format_client(struct format_tree *ft, struct client *c) format_add(ft, "client_termname", "%s", c->tty.termname); t = c->creation_time.tv_sec; - format_add(ft, "client_created", "%ld", (long) t); + format_add(ft, "client_created", "%lld", (long long) t); tim = ctime(&t); *strchr(tim, '\n') = '\0'; format_add(ft, "client_created_string", "%s", tim); t = c->activity_time.tv_sec; - format_add(ft, "client_activity", "%ld", (long) t); + format_add(ft, "client_activity", "%lld", (long long) t); tim = ctime(&t); *strchr(tim, '\n') = '\0'; format_add(ft, "client_activity_string", "%s", tim); diff --git a/job.c b/job.c index 33cdc76d..b2c2251c 100644 --- a/job.c +++ b/job.c @@ -143,8 +143,8 @@ job_write_callback(unused struct bufferevent *bufev, void *data) struct job *job = data; size_t len = EVBUFFER_LENGTH(EVBUFFER_OUTPUT(job->event)); - log_debug("job write %p: %s, pid %ld, output left %lu", job, job->cmd, - (long) job->pid, (unsigned long) len); + log_debug("job write %p: %s, pid %ld, output left %zu", job, job->cmd, + (long) job->pid, len); if (len == 0) { shutdown(job->fd, SHUT_WR); diff --git a/server-client.c b/server-client.c index 84633296..1c15a555 100644 --- a/server-client.c +++ b/server-client.c @@ -514,8 +514,10 @@ server_client_loop(void) w->flags &= ~WINDOW_REDRAW; TAILQ_FOREACH(wp, &w->panes, entry) { - server_client_check_focus(wp); - server_client_check_resize(wp); + if (wp->fd != -1) { + server_client_check_focus(wp); + server_client_check_resize(wp); + } wp->flags &= ~PANE_REDRAW; } } @@ -527,7 +529,7 @@ server_client_check_resize(struct window_pane *wp) { struct winsize ws; - if (wp->fd == -1 || !(wp->flags & PANE_RESIZE)) + if (!(wp->flags & PANE_RESIZE)) return; memset(&ws, 0, sizeof ws); diff --git a/server-fn.c b/server-fn.c index 566925f0..7ef64138 100644 --- a/server-fn.c +++ b/server-fn.c @@ -283,6 +283,7 @@ server_kill_window(struct window *w) if (options_get_number(&s->options, "renumber-windows")) session_renumber_windows(s); } + recalculate_sizes(); } int diff --git a/tmux.h b/tmux.h index f0b9edf0..d1033110 100644 --- a/tmux.h +++ b/tmux.h @@ -2253,6 +2253,8 @@ struct window_choose_data *window_choose_add_item(struct window_pane *, struct client *, struct winlink *, const char *, const char *, u_int); void window_choose_expand_all(struct window_pane *); +void window_choose_collapse_all(struct window_pane *); +void window_choose_set_current(struct window_pane *, u_int); /* names.c */ void queue_window_name(struct window *); diff --git a/window-choose.c b/window-choose.c index 3c68d101..5ed85f0e 100644 --- a/window-choose.c +++ b/window-choose.c @@ -44,7 +44,6 @@ void window_choose_scroll_down(struct window_pane *); void window_choose_collapse(struct window_pane *, struct session *); void window_choose_expand(struct window_pane *, struct session *, u_int); -void window_choose_collapse_all(struct window_pane *); enum window_choose_input_type { WINDOW_CHOOSE_NORMAL = -1, @@ -102,8 +101,7 @@ window_choose_add(struct window_pane *wp, struct window_choose_data *wcd) } void -window_choose_ready(struct window_pane *wp, u_int cur, - void (*callbackfn)(struct window_choose_data *)) +window_choose_set_current(struct window_pane *wp, u_int cur) { struct window_choose_mode_data *data = wp->modedata; struct screen *s = &data->screen; @@ -112,12 +110,22 @@ window_choose_ready(struct window_pane *wp, u_int cur, if (data->selected > screen_size_y(s) - 1) data->top = ARRAY_LENGTH(&data->list) - screen_size_y(s); + window_choose_redraw_screen(wp); +} + +void +window_choose_ready(struct window_pane *wp, u_int cur, + void (*callbackfn)(struct window_choose_data *)) +{ + struct window_choose_mode_data *data = wp->modedata; + data->callbackfn = callbackfn; if (data->callbackfn == NULL) data->callbackfn = window_choose_default_callback; ARRAY_CONCAT(&data->old_list, &data->list); + window_choose_set_current(wp, cur); window_choose_collapse_all(wp); }