This source file includes following definitions.
- show_mouse_pointer
- init_mouse
- enable_mouse
- disable_mouse
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 #include <config.h>
33
34 #include <stdio.h>
35 #include <sys/types.h>
36 #include <unistd.h>
37
38 #include "lib/global.h"
39
40 #include "tty.h"
41 #include "tty-internal.h"
42 #include "mouse.h"
43 #include "key.h"
44
45
46
47 Mouse_Type use_mouse_p = MOUSE_NONE;
48 gboolean mouse_enabled = FALSE;
49 int mouse_fd = -1;
50 const char *xmouse_seq;
51 const char *xmouse_extended_seq;
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66 void
67 show_mouse_pointer (int x, int y)
68 {
69 #ifdef HAVE_LIBGPM
70 if (use_mouse_p == MOUSE_GPM)
71 Gpm_DrawPointer (x, y, gpm_consolefd);
72 #else
73 (void) x;
74 (void) y;
75 #endif
76 }
77
78
79
80 void
81 init_mouse (void)
82 {
83 switch (use_mouse_p)
84 {
85 #ifdef HAVE_LIBGPM
86 case MOUSE_NONE:
87 use_mouse_p = MOUSE_GPM;
88 break;
89 #endif
90
91 case MOUSE_XTERM_NORMAL_TRACKING:
92 case MOUSE_XTERM_BUTTON_EVENT_TRACKING:
93 if (xmouse_seq != NULL)
94 define_sequence (MCKEY_MOUSE, xmouse_seq, MCKEY_NOACTION);
95 if (xmouse_extended_seq != NULL)
96 define_sequence (MCKEY_EXTENDED_MOUSE, xmouse_extended_seq, MCKEY_NOACTION);
97 break;
98
99 default:
100 break;
101 }
102
103 enable_mouse ();
104 }
105
106
107
108 void
109 enable_mouse (void)
110 {
111 if (mouse_enabled)
112 return;
113
114 switch (use_mouse_p)
115 {
116 #ifdef HAVE_LIBGPM
117 case MOUSE_GPM:
118 {
119 Gpm_Connect conn;
120
121 conn.eventMask = ~GPM_MOVE;
122 conn.defaultMask = GPM_MOVE;
123 conn.minMod = 0;
124 conn.maxMod = 0;
125
126 mouse_fd = Gpm_Open (&conn, 0);
127 if (mouse_fd == -1)
128 {
129 use_mouse_p = MOUSE_NONE;
130 return;
131 }
132 mouse_enabled = TRUE;
133 }
134 break;
135 #endif
136
137 case MOUSE_XTERM_NORMAL_TRACKING:
138
139 printf (ESC_STR "[?1001s");
140
141
142 printf (ESC_STR "[?1000h");
143
144
145 printf (ESC_STR "[?1006h");
146
147 fflush (stdout);
148 mouse_enabled = TRUE;
149 break;
150
151 case MOUSE_XTERM_BUTTON_EVENT_TRACKING:
152
153 printf (ESC_STR "[?1001s");
154
155
156 printf (ESC_STR "[?1002h");
157
158
159 printf (ESC_STR "[?1006h");
160
161 fflush (stdout);
162 mouse_enabled = TRUE;
163 break;
164
165 default:
166 break;
167 }
168 }
169
170
171
172 void
173 disable_mouse (void)
174 {
175 if (!mouse_enabled)
176 return;
177
178 mouse_enabled = FALSE;
179
180 switch (use_mouse_p)
181 {
182 #ifdef HAVE_LIBGPM
183 case MOUSE_GPM:
184 Gpm_Close ();
185 break;
186 #endif
187 case MOUSE_XTERM_NORMAL_TRACKING:
188
189 printf (ESC_STR "[?1006l");
190
191
192 printf (ESC_STR "[?1000l");
193
194
195 printf (ESC_STR "[?1001r");
196
197 fflush (stdout);
198 break;
199 case MOUSE_XTERM_BUTTON_EVENT_TRACKING:
200
201 printf (ESC_STR "[?1006l");
202
203
204 printf (ESC_STR "[?1002l");
205
206
207 printf (ESC_STR "[?1001r");
208
209 fflush (stdout);
210 break;
211 default:
212 break;
213 }
214 }
215
216