2 Copyright (C) 1994, 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2006,
3 2007 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
19 /* Events received by clients of this library have their coordinates 0 */
26 #include <sys/types.h>
32 #include "key.h" /* define sequence */
34 int mouse_enabled
= 0;
35 const char *xmouse_seq
;
38 void show_mouse_pointer (int x
, int y
)
40 if (use_mouse_p
== MOUSE_GPM
) {
41 Gpm_DrawPointer (x
, y
, gpm_consolefd
);
44 #endif /* HAVE_LIBGPM */
46 void init_mouse (void)
48 switch (use_mouse_p
) {
51 use_mouse_p
= MOUSE_GPM
;
53 #endif /* HAVE_LIBGPM */
54 case MOUSE_XTERM_NORMAL_TRACKING
:
55 case MOUSE_XTERM_BUTTON_EVENT_TRACKING
:
56 define_sequence (MCKEY_MOUSE
, xmouse_seq
, MCKEY_NOACTION
);
64 void enable_mouse (void)
70 switch (use_mouse_p
) {
77 conn
.eventMask
= ~GPM_MOVE
;
78 conn
.defaultMask
= GPM_MOVE
;
82 mouse_d
= Gpm_Open (&conn
, 0);
84 use_mouse_p
= MOUSE_NONE
;
90 #endif /* HAVE_LIBGPM */
91 case MOUSE_XTERM_NORMAL_TRACKING
:
92 /* save old highlight mouse tracking */
93 printf(ESC_STR
"[?1001s");
95 /* enable mouse tracking */
96 printf(ESC_STR
"[?1000h");
101 case MOUSE_XTERM_BUTTON_EVENT_TRACKING
:
102 /* save old highlight mouse tracking */
103 printf(ESC_STR
"[?1001s");
105 /* enable mouse tracking */
106 printf(ESC_STR
"[?1002h");
116 void disable_mouse (void)
118 if (!mouse_enabled
) {
124 switch (use_mouse_p
) {
130 case MOUSE_XTERM_NORMAL_TRACKING
:
131 /* disable mouse tracking */
132 printf(ESC_STR
"[?1000l");
134 /* restore old highlight mouse tracking */
135 printf(ESC_STR
"[?1001r");
139 case MOUSE_XTERM_BUTTON_EVENT_TRACKING
:
140 /* disable mouse tracking */
141 printf(ESC_STR
"[?1002l");
143 /* restore old highlight mouse tracking */
144 printf(ESC_STR
"[?1001r");