mouse.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. /* Mouse callback */
  30. typedef int (*mouse_h) (Gpm_Event *, void *);
  31. /*** enums ***************************************************************************************/
  32. #ifndef HAVE_LIBGPM
  33. /* Xterm mouse support supports only GPM_DOWN and GPM_UP */
  34. /* If you use others make sure your code also works without them */
  35. enum Gpm_Etype
  36. {
  37. GPM_MOVE = 1,
  38. GPM_DRAG = 2, /* exactly one in four is active at a time */
  39. GPM_DOWN = 4,
  40. GPM_UP = 8,
  41. GPM_SINGLE = 16, /* at most one in three is set */
  42. GPM_DOUBLE = 32,
  43. GPM_TRIPLE = 64,
  44. GPM_MFLAG = 128, /* motion during click? */
  45. GPM_HARD = 256 /* if set in the defaultMask, force an already
  46. used event to pass over to another handler */
  47. };
  48. #endif /* !HAVE_LIBGPM */
  49. /* Constants returned from the mouse callback */
  50. enum
  51. { MOU_NORMAL, MOU_REPEAT };
  52. /* Type of mouse support */
  53. typedef enum
  54. {
  55. MOUSE_NONE, /* Not detected yet */
  56. MOUSE_DISABLED, /* Explicitly disabled by -d */
  57. MOUSE_GPM, /* Support using GPM on Linux */
  58. MOUSE_XTERM, /* Support using xterm-style mouse reporting */
  59. MOUSE_XTERM_NORMAL_TRACKING = MOUSE_XTERM,
  60. MOUSE_XTERM_BUTTON_EVENT_TRACKING
  61. } Mouse_Type;
  62. /*** structures declarations (and typedefs of structures)*****************************************/
  63. #ifndef HAVE_LIBGPM
  64. typedef struct Gpm_Event
  65. {
  66. int buttons, x, y;
  67. enum Gpm_Etype type;
  68. } Gpm_Event;
  69. #endif /* !HAVE_LIBGPM */
  70. /*** global variables defined in .c file *********************************************************/
  71. /* Type of the currently used mouse */
  72. extern Mouse_Type use_mouse_p;
  73. /* String indicating that a mouse event has occured, usually "\E[M" */
  74. extern const char *xmouse_seq;
  75. /*** declarations of public functions ************************************************************/
  76. /* General (i.e. both for xterm and gpm) mouse support definitions */
  77. void init_mouse (void);
  78. void enable_mouse (void);
  79. void disable_mouse (void);
  80. void show_mouse_pointer (int x, int y);
  81. /*** inline functions ****************************************************************************/
  82. #endif /* MC_MOUSE_H */