mouse.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. struct Mouse
  15. {
  16. int buttons; /* bit array: LMR=124 */
  17. Point xy;
  18. uint32_t msec;
  19. };
  20. struct Mousectl
  21. {
  22. Mouse;
  23. Channel *c; /* chan(Mouse) */
  24. Channel *resizec; /* chan(int)[2] */
  25. /* buffered in case client is waiting for a mouse action before handling resize */
  26. char *file;
  27. int mfd; /* to mouse file */
  28. int cfd; /* to cursor file */
  29. int pid; /* of slave proc */
  30. Image* image; /* of associated window/display */
  31. };
  32. struct Menu
  33. {
  34. char **item;
  35. char *(*gen)(int);
  36. int lasthit;
  37. };
  38. /*
  39. * Mouse
  40. */
  41. extern Mousectl* initmouse(char*, Image*);
  42. extern void moveto(Mousectl*, Point);
  43. extern int readmouse(Mousectl*);
  44. extern void closemouse(Mousectl*);
  45. extern void setcursor(Mousectl*, Cursor*);
  46. extern void drawgetrect(Rectangle, int);
  47. extern Rectangle getrect(int, Mousectl*);
  48. extern int menuhit(int, Mousectl*, Menu*, Screen*);