mouse.h 2.3 KB

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