mirror of
https://github.com/tmux/tmux.git
synced 2024-12-12 17:38:48 +00:00
Make session_update_activity more useful and use it in more places.
This commit is contained in:
parent
675def0396
commit
57cc4d45d5
@ -135,7 +135,7 @@ cmd_attach_session(struct cmd_q *cmdq, const char *tflag, int dflag, int rflag,
|
||||
c->session = s;
|
||||
status_timer_start(c);
|
||||
notify_attached_session_changed(c);
|
||||
session_update_activity(s);
|
||||
session_update_activity(s, NULL);
|
||||
server_redraw_client(c);
|
||||
s->curw->flags &= ~WINLINK_ALERTFLAGS;
|
||||
} else {
|
||||
@ -180,7 +180,7 @@ cmd_attach_session(struct cmd_q *cmdq, const char *tflag, int dflag, int rflag,
|
||||
c->session = s;
|
||||
status_timer_start(c);
|
||||
notify_attached_session_changed(c);
|
||||
session_update_activity(s);
|
||||
session_update_activity(s, NULL);
|
||||
server_redraw_client(c);
|
||||
s->curw->flags &= ~WINLINK_ALERTFLAGS;
|
||||
|
||||
|
@ -277,7 +277,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
c->session = s;
|
||||
status_timer_start(c);
|
||||
notify_attached_session_changed(c);
|
||||
session_update_activity(s);
|
||||
session_update_activity(s, NULL);
|
||||
server_redraw_client(c);
|
||||
}
|
||||
recalculate_sizes();
|
||||
|
@ -128,7 +128,7 @@ cmd_switch_client_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
c->last_session = c->session;
|
||||
c->session = s;
|
||||
status_timer_start(c);
|
||||
session_update_activity(s);
|
||||
session_update_activity(s, NULL);
|
||||
|
||||
recalculate_sizes();
|
||||
server_check_unattached();
|
||||
|
@ -561,9 +561,7 @@ server_client_handle_key(struct client *c, int key)
|
||||
/* Update the activity timer. */
|
||||
if (gettimeofday(&c->activity_time, NULL) != 0)
|
||||
fatal("gettimeofday failed");
|
||||
memcpy(&s->last_activity_time, &s->activity_time,
|
||||
sizeof s->last_activity_time);
|
||||
memcpy(&s->activity_time, &c->activity_time, sizeof s->activity_time);
|
||||
session_update_activity(s, &c->activity_time);
|
||||
|
||||
/* Number keys jump to pane in identify mode. */
|
||||
if (c->flags & CLIENT_IDENTIFY && key >= '0' && key <= '9') {
|
||||
@ -981,6 +979,7 @@ server_client_msg_dispatch(struct client *c)
|
||||
struct msg_stdin_data stdindata;
|
||||
const char *data;
|
||||
ssize_t n, datalen;
|
||||
struct session *s;
|
||||
|
||||
if ((n = imsg_read(&c->ibuf)) == -1 || n == 0)
|
||||
return (-1);
|
||||
@ -1064,11 +1063,12 @@ server_client_msg_dispatch(struct client *c)
|
||||
|
||||
if (c->tty.fd == -1) /* exited in the meantime */
|
||||
break;
|
||||
s = c->session;
|
||||
|
||||
if (gettimeofday(&c->activity_time, NULL) != 0)
|
||||
fatal("gettimeofday");
|
||||
if (c->session != NULL)
|
||||
session_update_activity(c->session);
|
||||
if (s != NULL)
|
||||
session_update_activity(s, &c->activity_time);
|
||||
|
||||
tty_start_tty(&c->tty);
|
||||
server_redraw_client(c);
|
||||
|
@ -421,7 +421,7 @@ server_destroy_session(struct session *s)
|
||||
c->session = s_new;
|
||||
status_timer_start(c);
|
||||
notify_attached_session_changed(c);
|
||||
session_update_activity(s_new);
|
||||
session_update_activity(s_new, NULL);
|
||||
server_redraw_client(c);
|
||||
}
|
||||
}
|
||||
|
21
session.c
21
session.c
@ -112,10 +112,6 @@ session_create(const char *name, int argc, char **argv, const char *path,
|
||||
s->references = 1;
|
||||
s->flags = 0;
|
||||
|
||||
if (gettimeofday(&s->creation_time, NULL) != 0)
|
||||
fatal("gettimeofday failed");
|
||||
session_update_activity(s);
|
||||
|
||||
s->cwd = dup(cwd);
|
||||
|
||||
s->curw = NULL;
|
||||
@ -133,6 +129,10 @@ session_create(const char *name, int argc, char **argv, const char *path,
|
||||
memcpy(s->tio, tio, sizeof *s->tio);
|
||||
}
|
||||
|
||||
if (gettimeofday(&s->creation_time, NULL) != 0)
|
||||
fatal("gettimeofday failed");
|
||||
session_update_activity(s, &s->creation_time);
|
||||
|
||||
s->sx = sx;
|
||||
s->sy = sy;
|
||||
|
||||
@ -224,12 +224,17 @@ session_check_name(const char *name)
|
||||
return (*name != '\0' && name[strcspn(name, ":.")] == '\0');
|
||||
}
|
||||
|
||||
/* Update session active time. */
|
||||
/* Update activity time. */
|
||||
void
|
||||
session_update_activity(struct session *s)
|
||||
session_update_activity(struct session *s, struct timeval *from)
|
||||
{
|
||||
if (gettimeofday(&s->activity_time, NULL) != 0)
|
||||
fatal("gettimeofday");
|
||||
struct timeval *last = &s->last_activity_time;
|
||||
|
||||
memcpy(last, &s->activity_time, sizeof *last);
|
||||
if (from == NULL)
|
||||
gettimeofday(&s->activity_time, NULL);
|
||||
else
|
||||
memcpy(&s->activity_time, from, sizeof s->activity_time);
|
||||
}
|
||||
|
||||
/* Find the next usable session. */
|
||||
|
2
tmux.h
2
tmux.h
@ -2248,7 +2248,7 @@ struct session *session_create(const char *, int, char **, const char *,
|
||||
void session_destroy(struct session *);
|
||||
void session_unref(struct session *);
|
||||
int session_check_name(const char *);
|
||||
void session_update_activity(struct session *);
|
||||
void session_update_activity(struct session *, struct timeval *);
|
||||
struct session *session_next_session(struct session *);
|
||||
struct session *session_previous_session(struct session *);
|
||||
struct winlink *session_new(struct session *, const char *, int, char **,
|
||||
|
Loading…
Reference in New Issue
Block a user