1 #ifndef EL__TERMINAL_MOUSE_H
2 #define EL__TERMINAL_MOUSE_H
7 /* The mouse reporting button byte looks like:
15 * || 3 release OR wheel up [rxvt]
16 * || 4 wheel down [rxvt]
19 * 1 normalclick (makes sure the whole thing is >= ' ')
21 * 3 mouse wheel move [xterm]
22 * then in bb is 0 for up and 1 for down
24 * What we translate it to:
38 * +---------> drag flag (valid only for B_UP)
40 * (TODO: doubleclick facility? --pasky)
42 * Let me introduce to the wonderful world of X terminals and their handling of
43 * mouse wheel now. First, one sad fact: reasonable mouse wheel reporting
44 * support has only xterm itself (from everything I tried) - it is relatively
45 * elegant, it shouldn't confuse existing applications too much and it is
46 * generally non-conflicting with the old behaviour.
48 * All other terminals are doing absolutely terrible things, making it hell on
49 * the hearth to support mouse wheels. rxvt will send the buttons as succeeding
50 * button numbers (3, 4) in normal sequences, but that has a little problem -
51 * button 3 is also alias for button release; welcome to the wonderful world of
52 * X11. But at least, rxvt will send only "press" sequence, but no release
53 * sequence (it really doesn't make sense for wheels anyway, does it?). That
54 * has the advantage that you can do some heuristic (see below) to at least
55 * partially pace with this terrible thing.
57 * But now, let's see another nice pair of wonderful terminals: aterm and
58 * Eterm. They emit same braindead sequence for wheel up/down as rxvt, but
59 * that's not all. Yes, you guessed it - they send even the release sequence
60 * (immediatelly after press sequence) for the wheels. So, you will see
63 * old glasses - <button1 press> <release> <release> <release>
64 * new glasses - <button1 press> <wheelup press> <wheelup press> <wheelup press>
65 * smartglasses1-<button1 press> <release> <wheelup press> <wheelup press>
66 * smartglasses2-<button1 press> <release> <wheelup press> <release>
68 * But with smartglasses2, you will have a problem with rxvt when someone will
69 * move the wheel multiple times - only half of the times it will be recorded.
73 * When user presses some button and then moves the wheel, action for button
74 * release will be done and when he will release the button, action for the
75 * wheel will be done. That's unfortunately inevitable in order to work under
79 struct term_event_mouse
{
89 #define B_WHEEL_DOWN 4
98 #define mouse_get_action(mouse_) ((mouse_)->button & BM_ACT)
99 #define mouse_action_is(mouse_, value) (mouse_get_action(mouse_) == (value))
101 #define mouse_get_button(mouse_) ((mouse_)->button & BM_BUTT)
102 #define mouse_button_is(mouse_, value) (mouse_get_button(mouse_) == (value))
103 #define mouse_wheeling(mouse_) (mouse_get_button(mouse_) >= B_WHEEL_UP)
105 #define mouse_is_in_box(mouse_, box) \
106 is_in_box(box, (mouse_)->x, (mouse_)->y)
108 #define set_mouse(mouse_, x_, y_, button_) do { \
109 (mouse_)->x = (x_); \
110 (mouse_)->y = (y_); \
111 (mouse_)->button = (button_); \
114 void send_mouse_init_sequence(int h
);
115 void send_mouse_done_sequence(int h
);
116 void disable_mouse(void);
117 void enable_mouse(void);
118 void toggle_mouse(void);
119 int decode_terminal_mouse_escape_sequence(struct itrm
*itrm
, struct term_event
*ev
, int el
, int v
);