mouse.h 3.3 KB

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