mirror of
https://github.com/tmux/tmux.git
synced 2024-11-16 09:28:51 +00:00
Sync OpenBSD patchset 1120:
Store mouse data in tty structure not on the stack.
This commit is contained in:
parent
5cc4961fd2
commit
fff7c0b276
47
tmux.h
47
tmux.h
@ -1044,6 +1044,29 @@ struct session {
|
|||||||
RB_HEAD(sessions, session);
|
RB_HEAD(sessions, session);
|
||||||
ARRAY_DECL(sessionslist, struct 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. */
|
/* TTY information. */
|
||||||
struct tty_key {
|
struct tty_key {
|
||||||
char ch;
|
char ch;
|
||||||
@ -1111,6 +1134,7 @@ struct tty {
|
|||||||
|
|
||||||
int term_flags;
|
int term_flags;
|
||||||
|
|
||||||
|
struct mouse_event mouse_event;
|
||||||
void (*key_callback)(int, struct mouse_event *, void *);
|
void (*key_callback)(int, struct mouse_event *, void *);
|
||||||
void *key_data;
|
void *key_data;
|
||||||
struct event key_timer;
|
struct event key_timer;
|
||||||
@ -1147,29 +1171,6 @@ struct tty_ctx {
|
|||||||
u_int last_width;
|
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. */
|
/* Saved message entry. */
|
||||||
struct message_entry {
|
struct message_entry {
|
||||||
char *msg;
|
char *msg;
|
||||||
|
12
tty-keys.c
12
tty-keys.c
@ -40,8 +40,7 @@ struct tty_key *tty_keys_find1(
|
|||||||
struct tty_key *, const char *, size_t, size_t *);
|
struct tty_key *, const char *, size_t, size_t *);
|
||||||
struct tty_key *tty_keys_find(struct tty *, 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 *);
|
void tty_keys_callback(int, short, void *);
|
||||||
int tty_keys_mouse(struct tty *,
|
int tty_keys_mouse(struct tty *, const char *, size_t, size_t *);
|
||||||
const char *, size_t, size_t *, struct mouse_event *);
|
|
||||||
int tty_keys_device(struct tty *, const char *, size_t, size_t *);
|
int tty_keys_device(struct tty *, const char *, size_t, size_t *);
|
||||||
|
|
||||||
struct tty_key_ent {
|
struct tty_key_ent {
|
||||||
@ -436,7 +435,6 @@ tty_keys_next(struct tty *tty)
|
|||||||
{
|
{
|
||||||
struct tty_key *tk;
|
struct tty_key *tk;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
struct mouse_event mouse;
|
|
||||||
const char *buf;
|
const char *buf;
|
||||||
size_t len, size;
|
size_t len, size;
|
||||||
cc_t bspace;
|
cc_t bspace;
|
||||||
@ -477,7 +475,7 @@ tty_keys_next(struct tty *tty)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Is this a mouse key press? */
|
/* 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 */
|
case 0: /* yes */
|
||||||
evbuffer_drain(tty->event->input, size);
|
evbuffer_drain(tty->event->input, size);
|
||||||
key = KEYC_MOUSE;
|
key = KEYC_MOUSE;
|
||||||
@ -582,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, &mouse, tty->key_data);
|
tty->key_callback(key, &tty->mouse_event, tty->key_data);
|
||||||
|
|
||||||
tty->flags &= ~TTY_ESCAPE;
|
tty->flags &= ~TTY_ESCAPE;
|
||||||
return (1);
|
return (1);
|
||||||
@ -607,9 +605,9 @@ tty_keys_callback(unused int fd, unused short events, void *data)
|
|||||||
* (probably a mouse sequence but need more data).
|
* (probably a mouse sequence but need more data).
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
tty_keys_mouse(struct tty *tty,
|
tty_keys_mouse(struct tty *tty, const char *buf, size_t len, size_t *size)
|
||||||
const char *buf, size_t len, size_t *size, struct mouse_event *m)
|
|
||||||
{
|
{
|
||||||
|
struct mouse_event *m = &tty->mouse_event;
|
||||||
struct utf8_data utf8data;
|
struct utf8_data utf8data;
|
||||||
u_int i, value;
|
u_int i, value;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user