diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2012-05-22 14:11:31 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2012-05-22 14:11:31 +0000 |
commit | 7764b6f45347aa9e6c3d1342a6de254bfa823f9d (patch) | |
tree | c0b8399fad9c3e8ebc5882e00336f59fd2d2dd02 /usr.bin | |
parent | 9cca22000779cf6006e2aba6cfdd1f32569e8c09 (diff) |
Store mouse data in tty structure not on the stack.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tmux/tmux.h | 51 | ||||
-rw-r--r-- | usr.bin/tmux/tty-keys.c | 30 |
2 files changed, 40 insertions, 41 deletions
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 80e59fc2fd4..1768cf7d086 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.335 2012/05/22 11:35:37 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.336 2012/05/22 14:11:30 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -1048,6 +1048,29 @@ struct session { RB_HEAD(sessions, session); ARRAY_DECL(sessionslist, struct session *); +/* + * Mouse input. xterm mouse mode is fairly silly. Buttons are in the bottom two + * bits: 0 = button 1; 1 = button 2; 2 = button 3; 3 = buttons released. Bits + * 3, 4 and 5 are for keys. Bit 6 is set for dragging and 7 for mouse buttons 4 + * and 5. + */ +struct mouse_event { + u_int b; +#define MOUSE_1 0 +#define MOUSE_2 1 +#define MOUSE_3 2 +#define MOUSE_UP 3 +#define MOUSE_BUTTON 3 +#define MOUSE_SHIFT 4 +#define MOUSE_ESCAPE 8 +#define MOUSE_CTRL 16 +#define MOUSE_DRAG 32 +#define MOUSE_45 64 +#define MOUSE_RESIZE_PANE 128 /* marker for resizing */ + u_int x; + u_int y; +}; + /* TTY information. */ struct tty_key { char ch; @@ -1115,6 +1138,7 @@ struct tty { int term_flags; + struct mouse_event mouse_event; void (*key_callback)(int, struct mouse_event *, void *); void *key_data; struct event key_timer; @@ -1151,29 +1175,6 @@ struct tty_ctx { u_int last_width; }; -/* - * Mouse input. xterm mouse mode is fairly silly. Buttons are in the bottom two - * bits: 0 = button 1; 1 = button 2; 2 = button 3; 3 = buttons released. Bits - * 3, 4 and 5 are for keys. Bit 6 is set for dragging and 7 for mouse buttons 4 - * and 5. - */ -struct mouse_event { - u_int b; -#define MOUSE_1 0 -#define MOUSE_2 1 -#define MOUSE_3 2 -#define MOUSE_UP 3 -#define MOUSE_BUTTON 3 -#define MOUSE_SHIFT 4 -#define MOUSE_ESCAPE 8 -#define MOUSE_CTRL 16 -#define MOUSE_DRAG 32 -#define MOUSE_45 64 -#define MOUSE_RESIZE_PANE 128 /* marker for resizing */ - u_int x; - u_int y; -}; - /* Saved message entry. */ struct message_entry { char *msg; @@ -1224,7 +1225,7 @@ struct client { #define CLIENT_EXIT 0x4 #define CLIENT_REDRAW 0x8 #define CLIENT_STATUS 0x10 -#define CLIENT_REPEAT 0x20 /* allow command to repeat within repeat time */ +#define CLIENT_REPEAT 0x20 /* allow command to repeat within repeat time */ #define CLIENT_SUSPENDED 0x40 #define CLIENT_BAD 0x80 #define CLIENT_IDENTIFY 0x100 diff --git a/usr.bin/tmux/tty-keys.c b/usr.bin/tmux/tty-keys.c index 8e96d61c3a0..efecf4b0080 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.39 2012/04/22 05:21:40 nicm Exp $ */ +/* $OpenBSD: tty-keys.c,v 1.40 2012/05/22 14:11:30 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -40,8 +40,7 @@ struct tty_key *tty_keys_find1( struct tty_key *, const char *, size_t, size_t *); struct tty_key *tty_keys_find(struct tty *, const char *, size_t, size_t *); void tty_keys_callback(int, short, void *); -int tty_keys_mouse(struct tty *, - const char *, size_t, size_t *, struct mouse_event *); +int tty_keys_mouse(struct tty *, const char *, size_t, size_t *); int tty_keys_device(struct tty *, const char *, size_t, size_t *); struct tty_key_ent { @@ -434,13 +433,12 @@ tty_keys_find1(struct tty_key *tk, const char *buf, size_t len, size_t *size) int tty_keys_next(struct tty *tty) { - struct tty_key *tk; - struct timeval tv; - struct mouse_event mouse; - const char *buf; - size_t len, size; - cc_t bspace; - int key, delay; + struct tty_key *tk; + struct timeval tv; + const char *buf; + size_t len, size; + cc_t bspace; + int key, delay; buf = EVBUFFER_DATA(tty->event->input); len = EVBUFFER_LENGTH(tty->event->input); @@ -477,7 +475,7 @@ tty_keys_next(struct tty *tty) } /* Is this a mouse key press? */ - switch (tty_keys_mouse(tty, buf, len, &size, &mouse)) { + switch (tty_keys_mouse(tty, buf, len, &size)) { case 0: /* yes */ evbuffer_drain(tty->event->input, size); key = KEYC_MOUSE; @@ -582,7 +580,7 @@ handle_key: evtimer_del(&tty->key_timer); if (key != KEYC_NONE) - tty->key_callback(key, &mouse, tty->key_data); + tty->key_callback(key, &tty->mouse_event, tty->key_data); tty->flags &= ~TTY_ESCAPE; return (1); @@ -607,11 +605,11 @@ tty_keys_callback(unused int fd, unused short events, void *data) * (probably a mouse sequence but need more data). */ int -tty_keys_mouse(struct tty *tty, - const char *buf, size_t len, size_t *size, struct mouse_event *m) +tty_keys_mouse(struct tty *tty, const char *buf, size_t len, size_t *size) { - struct utf8_data utf8data; - u_int i, value; + struct mouse_event *m = &tty->mouse_event; + struct utf8_data utf8data; + u_int i, value; /* * Standard mouse sequences are \033[M followed by three characters |