diff --git a/server-client.c b/server-client.c index 449190fd..d1f72397 100644 --- a/server-client.c +++ b/server-client.c @@ -26,9 +26,8 @@ #include "tmux.h" -void server_client_check_mouse(struct client *c, - struct window_pane *wp, struct mouse_event *mouse); -void server_client_handle_key(int, struct mouse_event *, void *); +void server_client_check_mouse(struct client *, struct window_pane *, + struct mouse_event *); void server_client_repeat_timer(int, short, void *); void server_client_check_exit(struct client *); void server_client_check_redraw(struct client *); @@ -337,9 +336,8 @@ server_client_check_mouse( /* Handle data key input from client. */ void -server_client_handle_key(int key, struct mouse_event *mouse, void *data) +server_client_handle_key(struct client *c, int key) { - struct client *c = data; struct session *s; struct window *w; struct window_pane *wp; @@ -390,7 +388,7 @@ server_client_handle_key(int key, struct mouse_event *mouse, void *data) if (key == KEYC_MOUSE) { if (c->flags & CLIENT_READONLY) return; - server_client_check_mouse(c, wp, mouse); + server_client_check_mouse(c, wp, &c->tty.mouse); return; } @@ -898,15 +896,13 @@ server_client_msg_identify( if (!isatty(fd)) return; data->term[(sizeof data->term) - 1] = '\0'; - tty_init(&c->tty, fd, data->term); + tty_init(&c->tty, c, fd, data->term); if (data->flags & IDENTIFY_UTF8) c->tty.flags |= TTY_UTF8; if (data->flags & IDENTIFY_256COLOURS) c->tty.term_flags |= TERM_256COLOURS; else if (data->flags & IDENTIFY_88COLOURS) c->tty.term_flags |= TERM_88COLOURS; - c->tty.key_callback = server_client_handle_key; - c->tty.key_data = c; tty_resize(&c->tty); diff --git a/tmux.h b/tmux.h index b44f97e1..76c30330 100644 --- a/tmux.h +++ b/tmux.h @@ -1096,6 +1096,8 @@ struct tty_term { LIST_HEAD(tty_terms, tty_term); struct tty { + struct client *client; + char *path; u_int xterm_version; @@ -1134,9 +1136,8 @@ struct tty { int term_flags; - struct mouse_event mouse_event; - void (*key_callback)(int, struct mouse_event *, void *); - void *key_data; + struct mouse_event mouse; + struct event key_timer; struct tty_key *key_tree; }; @@ -1529,7 +1530,7 @@ void tty_putcode_ptr2(struct tty *, enum tty_code_code, const void *, const void void tty_puts(struct tty *, const char *); void tty_putc(struct tty *, u_char); void tty_pututf8(struct tty *, const struct grid_utf8 *); -void tty_init(struct tty *, int, char *); +void tty_init(struct tty *, struct client *, int, char *); int tty_resize(struct tty *); int tty_set_size(struct tty *, u_int, u_int); void tty_start_tty(struct tty *); @@ -1760,6 +1761,7 @@ void server_update_socket(void); void server_add_accept(int); /* server-client.c */ +void server_client_handle_key(struct client *, int); void server_client_create(int); int server_client_open(struct client *, struct session *, char **); void server_client_lost(struct client *); diff --git a/tty-keys.c b/tty-keys.c index 2cf8ff14..3469f84f 100644 --- a/tty-keys.c +++ b/tty-keys.c @@ -580,7 +580,7 @@ handle_key: evtimer_del(&tty->key_timer); if (key != KEYC_NONE) - tty->key_callback(key, &tty->mouse_event, tty->key_data); + server_client_handle_key(tty->client, key); tty->flags &= ~TTY_ESCAPE; return (1); @@ -607,7 +607,7 @@ tty_keys_callback(unused int fd, unused short events, void *data) int tty_keys_mouse(struct tty *tty, const char *buf, size_t len, size_t *size) { - struct mouse_event *m = &tty->mouse_event; + struct mouse_event *m = &tty->mouse; struct utf8_data utf8data; u_int i, value; diff --git a/tty.c b/tty.c index 49c93e06..1c0c7a6b 100644 --- a/tty.c +++ b/tty.c @@ -64,7 +64,7 @@ void tty_cell(struct tty *, ((ctx)->xoff == 0 && screen_size_x((ctx)->wp->screen) >= (tty)->sx) void -tty_init(struct tty *tty, int fd, char *term) +tty_init(struct tty *tty, struct client *c, int fd, char *term) { char *path; @@ -76,6 +76,7 @@ tty_init(struct tty *tty, int fd, char *term) else tty->termname = xstrdup(term); tty->fd = fd; + tty->client = c; if ((path = ttyname(fd)) == NULL) fatalx("ttyname failed");