src/filemanager/achown.c: cleanup.
[midnight-commander.git] / lib / tty / mouse.h
blob905248073cdc4c0068e789d7430090850ac037fd
2 /** \file mouse.h
3 * \brief Header: mouse managing
5 * Events received by clients of this library have their coordinates 0 based
6 */
8 #ifndef MC__MOUSE_H
9 #define MC__MOUSE_H
11 #ifdef HAVE_LIBGPM
12 /* GPM mouse support include file */
13 #include <gpm.h>
14 #endif /* !HAVE_LIBGPM */
17 /*** typedefs(not structures) and defined constants **********************************************/
19 #ifndef HAVE_LIBGPM
20 /* Equivalent definitions for non-GPM mouse support */
21 /* These lines are modified version from the lines appearing in the */
22 /* gpm.h include file of the Linux General Purpose Mouse server */
24 #define GPM_B_LEFT (1 << 2)
25 #define GPM_B_MIDDLE (1 << 1)
26 #define GPM_B_RIGHT (1 << 0)
28 #define GPM_BARE_EVENTS(ev) ((ev)&0xF)
29 #endif /* !HAVE_LIBGPM */
31 /* Mouse wheel events */
32 #ifndef GPM_B_DOWN
33 #define GPM_B_DOWN (1 << 5)
34 #endif
36 #ifndef GPM_B_UP
37 #define GPM_B_UP (1 << 4)
38 #endif
40 /*** enums ***************************************************************************************/
42 #ifndef HAVE_LIBGPM
43 /* Xterm mouse support supports only GPM_DOWN and GPM_UP */
44 /* If you use others make sure your code also works without them */
45 enum Gpm_Etype
47 GPM_MOVE = 1,
48 GPM_DRAG = 2, /* exactly one in four is active at a time */
49 GPM_DOWN = 4,
50 GPM_UP = 8,
53 GPM_SINGLE = 16, /* at most one in three is set */
54 GPM_DOUBLE = 32,
55 GPM_TRIPLE = 64,
57 GPM_MFLAG = 128, /* motion during click? */
58 GPM_HARD = 256 /* if set in the defaultMask, force an already
59 used event to pass over to another handler */
61 #endif /* !HAVE_LIBGPM */
63 /* Constants returned from the mouse callback */
64 enum
66 MOU_UNHANDLED = 0,
67 MOU_NORMAL,
68 MOU_REPEAT
71 /* Type of mouse support */
72 typedef enum
74 MOUSE_NONE, /* Not detected yet */
75 MOUSE_DISABLED, /* Explicitly disabled by -d */
76 MOUSE_GPM, /* Support using GPM on Linux */
77 MOUSE_XTERM, /* Support using xterm-style mouse reporting */
78 MOUSE_XTERM_NORMAL_TRACKING = MOUSE_XTERM,
79 MOUSE_XTERM_BUTTON_EVENT_TRACKING
80 } Mouse_Type;
82 /*** structures declarations (and typedefs of structures)*****************************************/
84 #ifndef HAVE_LIBGPM
85 typedef struct Gpm_Event
87 int buttons, x, y;
88 enum Gpm_Etype type;
89 } Gpm_Event;
90 #endif /* !HAVE_LIBGPM */
92 /* Mouse callback */
93 typedef int (*mouse_h) (Gpm_Event *, void *);
95 /*** global variables defined in .c file *********************************************************/
97 /* Type of the currently used mouse */
98 extern Mouse_Type use_mouse_p;
100 /* String indicating that a mouse event has occured, usually "\E[M" */
101 extern const char *xmouse_seq;
103 /*** declarations of public functions ************************************************************/
105 /* General (i.e. both for xterm and gpm) mouse support definitions */
107 void init_mouse (void);
108 void enable_mouse (void);
109 void disable_mouse (void);
111 void show_mouse_pointer (int x, int y);
113 /*** inline functions ****************************************************************************/
114 #endif /* MC_MOUSE_H */