mouse.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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_NORMAL,
  51. MOU_REPEAT
  52. };
  53. /* Type of mouse support */
  54. typedef enum
  55. {
  56. MOUSE_NONE, /* Not detected yet */
  57. MOUSE_DISABLED, /* Explicitly disabled by -d */
  58. MOUSE_GPM, /* Support using GPM on Linux */
  59. MOUSE_XTERM, /* Support using xterm-style mouse reporting */
  60. MOUSE_XTERM_NORMAL_TRACKING = MOUSE_XTERM,
  61. MOUSE_XTERM_BUTTON_EVENT_TRACKING
  62. } Mouse_Type;
  63. /*** structures declarations (and typedefs of structures)*****************************************/
  64. #ifndef HAVE_LIBGPM
  65. typedef struct Gpm_Event
  66. {
  67. int buttons, x, y;
  68. enum Gpm_Etype type;
  69. } Gpm_Event;
  70. #endif /* !HAVE_LIBGPM */
  71. /* Mouse callback */
  72. typedef int (*mouse_h) (Gpm_Event *, void *);
  73. /*** global variables defined in .c file *********************************************************/
  74. /* Type of the currently used mouse */
  75. extern Mouse_Type use_mouse_p;
  76. /* String indicating that a mouse event has occured, usually "\E[M" */
  77. extern const char *xmouse_seq;
  78. /*** declarations of public functions ************************************************************/
  79. /* General (i.e. both for xterm and gpm) mouse support definitions */
  80. void init_mouse (void);
  81. void enable_mouse (void);
  82. void disable_mouse (void);
  83. void show_mouse_pointer (int x, int y);
  84. /*** inline functions ****************************************************************************/
  85. #endif /* MC_MOUSE_H */