Massive moved some dirs from $(srcdir)/src into $(srcdir)/lib
[midnight-commander.git] / lib / tty / mouse.h
blob6d2c2b9fe8b8482fff54e6708f0e8e961c6eabae
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
13 /* GPM mouse support include file */
14 #include <gpm.h>
16 #else
18 /* Equivalent definitions for non-GPM mouse support */
19 /* These lines are modified version from the lines appearing in the */
20 /* gpm.h include file of the Linux General Purpose Mouse server */
22 #define GPM_B_LEFT (1 << 2)
23 #define GPM_B_MIDDLE (1 << 1)
24 #define GPM_B_RIGHT (1 << 0)
26 /* Xterm mouse support supports only GPM_DOWN and GPM_UP */
27 /* If you use others make sure your code also works without them */
28 enum Gpm_Etype {
29 GPM_MOVE = 1,
30 GPM_DRAG = 2, /* exactly one in four is active at a time */
31 GPM_DOWN = 4,
32 GPM_UP = 8,
34 #define GPM_BARE_EVENTS(ev) ((ev)&0xF)
36 GPM_SINGLE = 16, /* at most one in three is set */
37 GPM_DOUBLE = 32,
38 GPM_TRIPLE = 64,
40 GPM_MFLAG = 128, /* motion during click? */
41 GPM_HARD = 256 /* if set in the defaultMask, force an already
42 used event to pass over to another handler */
45 typedef struct Gpm_Event {
46 int buttons, x, y;
47 enum Gpm_Etype type;
48 } Gpm_Event;
50 #endif /* !HAVE_LIBGPM */
52 /* General (i.e. both for xterm and gpm) mouse support definitions */
54 /* Constants returned from the mouse callback */
55 enum { MOU_NORMAL, MOU_REPEAT };
57 /* Mouse callback */
58 typedef int (*mouse_h) (Gpm_Event *, void *);
60 /* Type of mouse support */
61 typedef enum {
62 MOUSE_NONE, /* Not detected yet */
63 MOUSE_DISABLED, /* Explicitly disabled by -d */
64 MOUSE_GPM, /* Support using GPM on Linux */
65 MOUSE_XTERM, /* Support using xterm-style mouse reporting */
66 MOUSE_XTERM_NORMAL_TRACKING = MOUSE_XTERM,
67 MOUSE_XTERM_BUTTON_EVENT_TRACKING
68 } Mouse_Type;
70 /* Type of the currently used mouse */
71 extern Mouse_Type use_mouse_p;
73 /* String indicating that a mouse event has occured, usually "\E[M" */
74 extern const char *xmouse_seq;
76 void init_mouse (void);
77 void enable_mouse (void);
78 void disable_mouse (void);
80 /* Mouse wheel events */
81 #ifndef GPM_B_DOWN
82 #define GPM_B_DOWN (1 << 5)
83 #endif
85 #ifndef GPM_B_UP
86 #define GPM_B_UP (1 << 4)
87 #endif
89 void show_mouse_pointer (int x, int y);
91 #endif /* MC_MOUSE_H */