summaryrefslogtreecommitdiff
path: root/usr.bin/tmux
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2012-05-22 14:32:29 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2012-05-22 14:32:29 +0000
commit6732d78d64ff6de2c569e337bd11ad6865dd9951 (patch)
tree3f3ad92f1210e06b834b016dde0d8a364d29a212 /usr.bin/tmux
parent7764b6f45347aa9e6c3d1342a6de254bfa823f9d (diff)
Store client in tty struct directly instead of using a callback function
pointer.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r--usr.bin/tmux/server-client.c16
-rw-r--r--usr.bin/tmux/tmux.h12
-rw-r--r--usr.bin/tmux/tty-keys.c6
-rw-r--r--usr.bin/tmux/tty.c5
4 files changed, 19 insertions, 20 deletions
diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c
index a0183e781af..ee9257b8fe1 100644
--- a/usr.bin/tmux/server-client.c
+++ b/usr.bin/tmux/server-client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server-client.c,v 1.73 2012/05/21 18:27:42 nicm Exp $ */
+/* $OpenBSD: server-client.c,v 1.74 2012/05/22 14:32:28 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -27,9 +27,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 *);
@@ -338,9 +337,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;
@@ -391,7 +389,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;
}
@@ -899,15 +897,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/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index 1768cf7d086..47f3375b24c 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.336 2012/05/22 14:11:30 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.337 2012/05/22 14:32:28 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -1100,6 +1100,8 @@ struct tty_term {
LIST_HEAD(tty_terms, tty_term);
struct tty {
+ struct client *client;
+
char *path;
u_int xterm_version;
@@ -1138,9 +1140,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;
};
@@ -1533,7 +1534,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 *);
@@ -1764,6 +1765,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/usr.bin/tmux/tty-keys.c b/usr.bin/tmux/tty-keys.c
index efecf4b0080..b8012f0c041 100644
--- a/usr.bin/tmux/tty-keys.c
+++ b/usr.bin/tmux/tty-keys.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty-keys.c,v 1.40 2012/05/22 14:11:30 nicm Exp $ */
+/* $OpenBSD: tty-keys.c,v 1.41 2012/05/22 14:32:28 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -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/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c
index 74655a5cdd2..61b1ec106f7 100644
--- a/usr.bin/tmux/tty.c
+++ b/usr.bin/tmux/tty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty.c,v 1.135 2012/05/22 09:37:54 nicm Exp $ */
+/* $OpenBSD: tty.c,v 1.136 2012/05/22 14:32:28 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -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");