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