mouse.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. typedef struct Channel Channel;
  10. typedef struct Cursor Cursor;
  11. typedef struct Menu Menu;
  12. typedef struct Mousectl Mousectl;
  13. /* as a way to get sort-of anon structs, we make the Mouse and Mousectl structs
  14. * interchangeable.
  15. */
  16. struct Mouse
  17. {
  18. int buttons; /* bit array: LMR=124 */
  19. Point xy;
  20. uint32_t msec;
  21. };
  22. struct Mousectl
  23. {
  24. //Mouse;
  25. int buttons; /* bit array: LMR=124 */
  26. Point xy;
  27. uint32_t msec;
  28. Channel *c; /* chan(Mouse) */
  29. Channel *resizec; /* chan(int)[2] */
  30. /* buffered in case client is waiting for a mouse action before handling resize */
  31. char *file;
  32. int mfd; /* to mouse file */
  33. int cfd; /* to cursor file */
  34. int pid; /* of slave proc */
  35. Image* image; /* of associated window/display */
  36. };
  37. struct Menu
  38. {
  39. char **item;
  40. char *(*gen)(int);
  41. int lasthit;
  42. };
  43. /*
  44. * Mouse
  45. */
  46. extern Mousectl* initmouse(char*, Image*);
  47. extern void moveto(Mousectl*, Point);
  48. extern int readmouse(Mousectl*);
  49. extern void closemouse(Mousectl*);
  50. extern void setcursor(Mousectl*, Cursor*);
  51. extern void drawgetrect(Rectangle, int);
  52. extern Rectangle getrect(int, Mousectl*);
  53. extern int menuhit(int, Mousectl*, Menu*, Screen*);