mouse.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. #pragma src "/sys/src/libdraw"
  10. typedef struct Channel Channel;
  11. typedef struct Cursor Cursor;
  12. typedef struct Menu Menu;
  13. typedef struct Mousectl Mousectl;
  14. /* as a way to get sort-of anon structs, we make the Mouse and Mousectl structs
  15. * interchangeable.
  16. */
  17. struct Mouse
  18. {
  19. int buttons; /* bit array: LMR=124 */
  20. Point xy;
  21. uint32_t msec;
  22. };
  23. struct Mousectl
  24. {
  25. //Mouse;
  26. int buttons; /* bit array: LMR=124 */
  27. Point xy;
  28. uint32_t msec;
  29. Channel *c; /* chan(Mouse) */
  30. Channel *resizec; /* chan(int)[2] */
  31. /* buffered in case client is waiting for a mouse action before handling resize */
  32. char *file;
  33. int mfd; /* to mouse file */
  34. int cfd; /* to cursor file */
  35. int pid; /* of slave proc */
  36. Image* image; /* of associated window/display */
  37. };
  38. struct Menu
  39. {
  40. char **item;
  41. char *(*gen)(int);
  42. int lasthit;
  43. };
  44. /*
  45. * Mouse
  46. */
  47. extern Mousectl* initmouse(char*, Image*);
  48. extern void moveto(Mousectl*, Point);
  49. extern int readmouse(Mousectl*);
  50. extern void closemouse(Mousectl*);
  51. extern void setcursor(Mousectl*, Cursor*);
  52. extern void drawgetrect(Rectangle, int);
  53. extern Rectangle getrect(int, Mousectl*);
  54. extern int menuhit(int, Mousectl*, Menu*, Screen*);