Sync OpenBSD patchset 1121:

Store client in tty struct directly instead of using a callback function
pointer.
This commit is contained in:
Tiago Cunha 2012-05-22 21:05:30 +00:00
parent fff7c0b276
commit 17da2f7d5f
4 changed files with 15 additions and 16 deletions

View File

@ -26,9 +26,8 @@
#include "tmux.h" #include "tmux.h"
void server_client_check_mouse(struct client *c, void server_client_check_mouse(struct client *, struct window_pane *,
struct window_pane *wp, struct mouse_event *mouse); struct mouse_event *);
void server_client_handle_key(int, struct mouse_event *, void *);
void server_client_repeat_timer(int, short, void *); void server_client_repeat_timer(int, short, void *);
void server_client_check_exit(struct client *); void server_client_check_exit(struct client *);
void server_client_check_redraw(struct client *); void server_client_check_redraw(struct client *);
@ -337,9 +336,8 @@ server_client_check_mouse(
/* Handle data key input from client. */ /* Handle data key input from client. */
void 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 session *s;
struct window *w; struct window *w;
struct window_pane *wp; 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 (key == KEYC_MOUSE) {
if (c->flags & CLIENT_READONLY) if (c->flags & CLIENT_READONLY)
return; return;
server_client_check_mouse(c, wp, mouse); server_client_check_mouse(c, wp, &c->tty.mouse);
return; return;
} }
@ -898,15 +896,13 @@ server_client_msg_identify(
if (!isatty(fd)) if (!isatty(fd))
return; return;
data->term[(sizeof data->term) - 1] = '\0'; 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) if (data->flags & IDENTIFY_UTF8)
c->tty.flags |= TTY_UTF8; c->tty.flags |= TTY_UTF8;
if (data->flags & IDENTIFY_256COLOURS) if (data->flags & IDENTIFY_256COLOURS)
c->tty.term_flags |= TERM_256COLOURS; c->tty.term_flags |= TERM_256COLOURS;
else if (data->flags & IDENTIFY_88COLOURS) else if (data->flags & IDENTIFY_88COLOURS)
c->tty.term_flags |= TERM_88COLOURS; c->tty.term_flags |= TERM_88COLOURS;
c->tty.key_callback = server_client_handle_key;
c->tty.key_data = c;
tty_resize(&c->tty); tty_resize(&c->tty);

10
tmux.h
View File

@ -1096,6 +1096,8 @@ struct tty_term {
LIST_HEAD(tty_terms, tty_term); LIST_HEAD(tty_terms, tty_term);
struct tty { struct tty {
struct client *client;
char *path; char *path;
u_int xterm_version; u_int xterm_version;
@ -1134,9 +1136,8 @@ struct tty {
int term_flags; int term_flags;
struct mouse_event mouse_event; struct mouse_event mouse;
void (*key_callback)(int, struct mouse_event *, void *);
void *key_data;
struct event key_timer; struct event key_timer;
struct tty_key *key_tree; 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_puts(struct tty *, const char *);
void tty_putc(struct tty *, u_char); void tty_putc(struct tty *, u_char);
void tty_pututf8(struct tty *, const struct grid_utf8 *); 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_resize(struct tty *);
int tty_set_size(struct tty *, u_int, u_int); int tty_set_size(struct tty *, u_int, u_int);
void tty_start_tty(struct tty *); void tty_start_tty(struct tty *);
@ -1760,6 +1761,7 @@ void server_update_socket(void);
void server_add_accept(int); void server_add_accept(int);
/* server-client.c */ /* server-client.c */
void server_client_handle_key(struct client *, int);
void server_client_create(int); void server_client_create(int);
int server_client_open(struct client *, struct session *, char **); int server_client_open(struct client *, struct session *, char **);
void server_client_lost(struct client *); void server_client_lost(struct client *);

View File

@ -580,7 +580,7 @@ handle_key:
evtimer_del(&tty->key_timer); evtimer_del(&tty->key_timer);
if (key != KEYC_NONE) 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; tty->flags &= ~TTY_ESCAPE;
return (1); return (1);
@ -607,7 +607,7 @@ tty_keys_callback(unused int fd, unused short events, void *data)
int int
tty_keys_mouse(struct tty *tty, const char *buf, size_t len, size_t *size) 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; struct utf8_data utf8data;
u_int i, value; u_int i, value;

3
tty.c
View File

@ -64,7 +64,7 @@ void tty_cell(struct tty *,
((ctx)->xoff == 0 && screen_size_x((ctx)->wp->screen) >= (tty)->sx) ((ctx)->xoff == 0 && screen_size_x((ctx)->wp->screen) >= (tty)->sx)
void void
tty_init(struct tty *tty, int fd, char *term) tty_init(struct tty *tty, struct client *c, int fd, char *term)
{ {
char *path; char *path;
@ -76,6 +76,7 @@ tty_init(struct tty *tty, int fd, char *term)
else else
tty->termname = xstrdup(term); tty->termname = xstrdup(term);
tty->fd = fd; tty->fd = fd;
tty->client = c;
if ((path = ttyname(fd)) == NULL) if ((path = ttyname(fd)) == NULL)
fatalx("ttyname failed"); fatalx("ttyname failed");