4 Copyright (C) 1994-2016
5 Free Software Foundation, Inc.
8 Andrew Borodin <aborodin@vmail.ru>, 2009.
10 This file is part of the Midnight Commander.
12 The Midnight Commander is free software: you can redistribute it
13 and/or modify it under the terms of the GNU General Public License as
14 published by the Free Software Foundation, either version 3 of the License,
15 or (at your option) any later version.
17 The Midnight Commander is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program. If not, see <http://www.gnu.org/licenses/>.
27 * \brief Source: mouse managing
29 * Events received by clients of this library have their coordinates 0 based
35 #include <sys/types.h>
38 #include "lib/global.h"
41 #include "tty-internal.h" /* mouse_enabled */
43 #include "key.h" /* define sequence */
45 /*** global variables ****************************************************************************/
47 Mouse_Type use_mouse_p
= MOUSE_NONE
;
48 gboolean mouse_enabled
= FALSE
;
49 int mouse_fd
= -1; /* for when gpm_fd changes to < 0 and the old one must be cleared from select_set */
50 const char *xmouse_seq
;
51 const char *xmouse_extended_seq
;
53 /*** file scope macro definitions ****************************************************************/
55 /*** file scope type declarations ****************************************************************/
57 /*** file scope variables ************************************************************************/
59 /*** file scope functions ************************************************************************/
60 /* --------------------------------------------------------------------------------------------- */
62 /* --------------------------------------------------------------------------------------------- */
63 /*** public functions ****************************************************************************/
64 /* --------------------------------------------------------------------------------------------- */
67 show_mouse_pointer (int x
, int y
)
70 if (use_mouse_p
== MOUSE_GPM
)
71 Gpm_DrawPointer (x
, y
, gpm_consolefd
);
75 #endif /* HAVE_LIBGPM */
78 /* --------------------------------------------------------------------------------------------- */
87 use_mouse_p
= MOUSE_GPM
;
89 #endif /* HAVE_LIBGPM */
91 case MOUSE_XTERM_NORMAL_TRACKING
:
92 case MOUSE_XTERM_BUTTON_EVENT_TRACKING
:
93 define_sequence (MCKEY_MOUSE
, xmouse_seq
, MCKEY_NOACTION
);
94 define_sequence (MCKEY_EXTENDED_MOUSE
, xmouse_extended_seq
, MCKEY_NOACTION
);
104 /* --------------------------------------------------------------------------------------------- */
119 conn
.eventMask
= ~GPM_MOVE
;
120 conn
.defaultMask
= GPM_MOVE
;
124 mouse_fd
= Gpm_Open (&conn
, 0);
127 use_mouse_p
= MOUSE_NONE
;
130 mouse_enabled
= TRUE
;
133 #endif /* HAVE_LIBGPM */
135 case MOUSE_XTERM_NORMAL_TRACKING
:
136 /* save old highlight mouse tracking */
137 printf (ESC_STR
"[?1001s");
139 /* enable mouse tracking */
140 printf (ESC_STR
"[?1000h");
142 /* enable SGR extended mouse reporting */
143 printf (ESC_STR
"[?1006h");
146 mouse_enabled
= TRUE
;
149 case MOUSE_XTERM_BUTTON_EVENT_TRACKING
:
150 /* save old highlight mouse tracking */
151 printf (ESC_STR
"[?1001s");
153 /* enable mouse tracking */
154 printf (ESC_STR
"[?1002h");
156 /* enable SGR extended mouse reporting */
157 printf (ESC_STR
"[?1006h");
160 mouse_enabled
= TRUE
;
168 /* --------------------------------------------------------------------------------------------- */
176 mouse_enabled
= FALSE
;
185 case MOUSE_XTERM_NORMAL_TRACKING
:
186 /* disable SGR extended mouse reporting */
187 printf (ESC_STR
"[?1006l");
189 /* disable mouse tracking */
190 printf (ESC_STR
"[?1000l");
192 /* restore old highlight mouse tracking */
193 printf (ESC_STR
"[?1001r");
197 case MOUSE_XTERM_BUTTON_EVENT_TRACKING
:
198 /* disable SGR extended mouse reporting */
199 printf (ESC_STR
"[?1006l");
201 /* disable mouse tracking */
202 printf (ESC_STR
"[?1002l");
204 /* restore old highlight mouse tracking */
205 printf (ESC_STR
"[?1001r");
214 /* --------------------------------------------------------------------------------------------- */