mouse.h 1.7 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. 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*);
  54. extern void setmenucolor(uint32_t backcolor, uint32_t highcolor, uint32_t bordercolor, uint32_t textcolor, uint32_t seltextcolor);