4 Copyright (C) 1994, 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2006,
6 The Free Software Foundation, Inc.
9 Andrew Borodin <aborodin@vmail.ru>, 2009.
11 This file is part of the Midnight Commander.
13 The Midnight Commander is free software: you can redistribute it
14 and/or modify it under the terms of the GNU General Public License as
15 published by the Free Software Foundation, either version 3 of the License,
16 or (at your option) any later version.
18 The Midnight Commander is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program. If not, see <http://www.gnu.org/licenses/>.
28 * \brief Source: mouse managing
30 * Events received by clients of this library have their coordinates 0 based
36 #include <sys/types.h>
39 #include "lib/global.h"
42 #include "tty-internal.h" /* mouse_enabled */
44 #include "key.h" /* define sequence */
46 /*** global variables ****************************************************************************/
48 Mouse_Type use_mouse_p
= MOUSE_NONE
;
49 gboolean mouse_enabled
= FALSE
;
50 const char *xmouse_seq
;
52 /*** file scope macro definitions ****************************************************************/
54 /*** file scope type declarations ****************************************************************/
56 /*** file scope variables ************************************************************************/
58 /*** file scope functions ************************************************************************/
59 /* --------------------------------------------------------------------------------------------- */
61 /* --------------------------------------------------------------------------------------------- */
62 /*** public functions ****************************************************************************/
63 /* --------------------------------------------------------------------------------------------- */
66 show_mouse_pointer (int x
, int y
)
69 if (use_mouse_p
== MOUSE_GPM
)
70 Gpm_DrawPointer (x
, y
, gpm_consolefd
);
74 #endif /* HAVE_LIBGPM */
77 /* --------------------------------------------------------------------------------------------- */
86 use_mouse_p
= MOUSE_GPM
;
88 #endif /* HAVE_LIBGPM */
90 case MOUSE_XTERM_NORMAL_TRACKING
:
91 case MOUSE_XTERM_BUTTON_EVENT_TRACKING
:
92 define_sequence (MCKEY_MOUSE
, xmouse_seq
, MCKEY_NOACTION
);
102 /* --------------------------------------------------------------------------------------------- */
118 conn
.eventMask
= ~GPM_MOVE
;
119 conn
.defaultMask
= GPM_MOVE
;
123 mouse_d
= Gpm_Open (&conn
, 0);
126 use_mouse_p
= MOUSE_NONE
;
129 mouse_enabled
= TRUE
;
132 #endif /* HAVE_LIBGPM */
134 case MOUSE_XTERM_NORMAL_TRACKING
:
135 /* save old highlight mouse tracking */
136 printf (ESC_STR
"[?1001s");
138 /* enable mouse tracking */
139 printf (ESC_STR
"[?1000h");
141 /* enable urxvt extended mouse coordinate reporting */
142 printf (ESC_STR
"[?1015h");
145 mouse_enabled
= TRUE
;
148 case MOUSE_XTERM_BUTTON_EVENT_TRACKING
:
149 /* save old highlight mouse tracking */
150 printf (ESC_STR
"[?1001s");
152 /* enable mouse tracking */
153 printf (ESC_STR
"[?1002h");
155 /* enable urxvt extended mouse coordinate reporting */
156 printf (ESC_STR
"[?1015h");
159 mouse_enabled
= TRUE
;
167 /* --------------------------------------------------------------------------------------------- */
175 mouse_enabled
= FALSE
;
184 case MOUSE_XTERM_NORMAL_TRACKING
:
185 /* disable urxvt extended mouse coordinate reporting */
186 printf (ESC_STR
"[?1015l");
188 /* disable mouse tracking */
189 printf (ESC_STR
"[?1000l");
191 /* restore old highlight mouse tracking */
192 printf (ESC_STR
"[?1001r");
196 case MOUSE_XTERM_BUTTON_EVENT_TRACKING
:
197 /* disable urxvt extended mouse coordinate reporting */
198 printf (ESC_STR
"[?1015l");
200 /* disable mouse tracking */
201 printf (ESC_STR
"[?1002l");
203 /* restore old highlight mouse tracking */
204 printf (ESC_STR
"[?1001r");
213 /* --------------------------------------------------------------------------------------------- */