mirror of
https://github.com/tmate-io/tmate-ssh-server.git
synced 2020-11-18 19:53:51 -08:00
Convert the key repeat timer to an event.
This commit is contained in:
parent
44d6a2c435
commit
80444436f3
@ -28,6 +28,7 @@
|
|||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
void server_client_handle_data(struct client *);
|
void server_client_handle_data(struct client *);
|
||||||
|
void server_client_repeat_timer(int, short, void *);
|
||||||
void server_client_check_redraw(struct client *);
|
void server_client_check_redraw(struct client *);
|
||||||
void server_client_set_title(struct client *);
|
void server_client_set_title(struct client *);
|
||||||
|
|
||||||
@ -41,7 +42,6 @@ void printflike2 server_client_msg_error(struct cmd_ctx *, const char *, ...);
|
|||||||
void printflike2 server_client_msg_print(struct cmd_ctx *, const char *, ...);
|
void printflike2 server_client_msg_print(struct cmd_ctx *, const char *, ...);
|
||||||
void printflike2 server_client_msg_info(struct cmd_ctx *, const char *, ...);
|
void printflike2 server_client_msg_info(struct cmd_ctx *, const char *, ...);
|
||||||
|
|
||||||
|
|
||||||
/* Create a new client. */
|
/* Create a new client. */
|
||||||
void
|
void
|
||||||
server_client_create(int fd)
|
server_client_create(int fd)
|
||||||
@ -84,6 +84,8 @@ server_client_create(int fd)
|
|||||||
c->prompt_buffer = NULL;
|
c->prompt_buffer = NULL;
|
||||||
c->prompt_index = 0;
|
c->prompt_index = 0;
|
||||||
|
|
||||||
|
evtimer_set(&c->repeat_timer, server_client_repeat_timer, c);
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||||
if (ARRAY_ITEM(&clients, i) == NULL) {
|
if (ARRAY_ITEM(&clients, i) == NULL) {
|
||||||
ARRAY_SET(&clients, i, c);
|
ARRAY_SET(&clients, i, c);
|
||||||
@ -119,6 +121,8 @@ server_client_lost(struct client *c)
|
|||||||
if (c->title != NULL)
|
if (c->title != NULL)
|
||||||
xfree(c->title);
|
xfree(c->title);
|
||||||
|
|
||||||
|
evtimer_del(&c->repeat_timer);
|
||||||
|
|
||||||
evtimer_del(&c->identify_timer);
|
evtimer_del(&c->identify_timer);
|
||||||
|
|
||||||
if (c->message_string != NULL)
|
if (c->message_string != NULL)
|
||||||
@ -264,21 +268,17 @@ server_client_handle_data(struct client *c)
|
|||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
struct screen *s;
|
struct screen *s;
|
||||||
struct options *oo;
|
struct options *oo;
|
||||||
struct timeval tv_add, tv_now;
|
struct timeval tv, tv_now;
|
||||||
struct key_binding *bd;
|
struct key_binding *bd;
|
||||||
struct keylist *keylist;
|
struct keylist *keylist;
|
||||||
struct mouse_event mouse;
|
struct mouse_event mouse;
|
||||||
int key, status, xtimeout, mode, isprefix;
|
int key, status, xtimeout, mode, isprefix;
|
||||||
u_int i;
|
u_int i;
|
||||||
|
|
||||||
/* Check and update repeat flag. */
|
/* Get the time for the activity timer. */
|
||||||
if (gettimeofday(&tv_now, NULL) != 0)
|
if (gettimeofday(&tv_now, NULL) != 0)
|
||||||
fatal("gettimeofday failed");
|
fatal("gettimeofday failed");
|
||||||
xtimeout = options_get_number(&c->session->options, "repeat-time");
|
xtimeout = options_get_number(&c->session->options, "repeat-time");
|
||||||
if (xtimeout != 0 && c->flags & CLIENT_REPEAT) {
|
|
||||||
if (timercmp(&tv_now, &c->repeat_timer, >))
|
|
||||||
c->flags &= ~(CLIENT_PREFIX|CLIENT_REPEAT);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Process keys. */
|
/* Process keys. */
|
||||||
keylist = options_get_data(&c->session->options, "prefix");
|
keylist = options_get_data(&c->session->options, "prefix");
|
||||||
@ -371,9 +371,10 @@ server_client_handle_data(struct client *c)
|
|||||||
if (xtimeout != 0 && bd->can_repeat) {
|
if (xtimeout != 0 && bd->can_repeat) {
|
||||||
c->flags |= CLIENT_PREFIX|CLIENT_REPEAT;
|
c->flags |= CLIENT_PREFIX|CLIENT_REPEAT;
|
||||||
|
|
||||||
tv_add.tv_sec = xtimeout / 1000;
|
tv.tv_sec = xtimeout / 1000;
|
||||||
tv_add.tv_usec = (xtimeout % 1000) * 1000L;
|
tv.tv_usec = (xtimeout % 1000) * 1000L;
|
||||||
timeradd(&tv_now, &tv_add, &c->repeat_timer);
|
evtimer_del(&c->repeat_timer);
|
||||||
|
evtimer_add(&c->repeat_timer, &tv);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Dispatch the command. */
|
/* Dispatch the command. */
|
||||||
@ -412,6 +413,16 @@ server_client_handle_data(struct client *c)
|
|||||||
tty_reset(&c->tty);
|
tty_reset(&c->tty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Repeat time callback. */
|
||||||
|
void
|
||||||
|
server_client_repeat_timer(unused int fd, unused short events, void *data)
|
||||||
|
{
|
||||||
|
struct client *c = data;
|
||||||
|
|
||||||
|
if (c->flags & CLIENT_REPEAT)
|
||||||
|
c->flags &= ~(CLIENT_PREFIX|CLIENT_REPEAT);
|
||||||
|
}
|
||||||
|
|
||||||
/* Check for client redraws. */
|
/* Check for client redraws. */
|
||||||
void
|
void
|
||||||
server_client_check_redraw(struct client *c)
|
server_client_check_redraw(struct client *c)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user