1
0

mouse.h 1003 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #pragma src "/sys/src/libdraw"
  2. typedef struct Channel Channel;
  3. typedef struct Cursor Cursor;
  4. typedef struct Menu Menu;
  5. typedef struct Mousectl Mousectl;
  6. struct Mouse
  7. {
  8. int buttons; /* bit array: LMR=124 */
  9. Point xy;
  10. ulong msec;
  11. };
  12. struct Mousectl
  13. {
  14. Mouse;
  15. Channel *c; /* chan(Mouse) */
  16. Channel *resizec; /* chan(int)[2] */
  17. /* buffered in case client is waiting for a mouse action before handling resize */
  18. char *file;
  19. int mfd; /* to mouse file */
  20. int cfd; /* to cursor file */
  21. int pid; /* of slave proc */
  22. Image* image; /* of associated window/display */
  23. };
  24. struct Menu
  25. {
  26. char **item;
  27. char *(*gen)(int);
  28. int lasthit;
  29. };
  30. /*
  31. * Mouse
  32. */
  33. extern Mousectl* initmouse(char*, Image*);
  34. extern void moveto(Mousectl*, Point);
  35. extern int readmouse(Mousectl*);
  36. extern void closemouse(Mousectl*);
  37. extern void setcursor(Mousectl*, Cursor*);
  38. extern void drawgetrect(Rectangle, int);
  39. extern Rectangle getrect(int, Mousectl*);
  40. extern int menuhit(int, Mousectl*, Menu*, Screen*);