1
0

event.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #pragma src "/sys/src/libdraw"
  2. #pragma lib "libdraw.a"
  3. typedef struct Cursor Cursor;
  4. typedef struct Event Event;
  5. typedef struct Menu Menu;
  6. enum
  7. {
  8. Emouse = 1,
  9. Ekeyboard = 2,
  10. };
  11. enum
  12. {
  13. MAXSLAVE = 32,
  14. EMAXMSG = 128+8192, /* size of 9p header+data */
  15. };
  16. struct Mouse
  17. {
  18. int buttons; /* bit array: LMR=124 */
  19. Point xy;
  20. ulong msec;
  21. };
  22. struct Event
  23. {
  24. int kbdc;
  25. Mouse mouse;
  26. int n; /* number of characters in message */
  27. void *v; /* data unpacked by general event-handling function */
  28. uchar data[EMAXMSG]; /* message from an arbitrary file descriptor */
  29. };
  30. struct Menu
  31. {
  32. char **item;
  33. char *(*gen)(int);
  34. int lasthit;
  35. };
  36. /*
  37. * Events
  38. */
  39. extern void einit(ulong);
  40. extern ulong estart(ulong, int, int);
  41. extern ulong estartfn(ulong, int, int, int (*fn)(int, Event*, uchar*, int));
  42. extern ulong etimer(ulong, int);
  43. extern ulong event(Event*);
  44. extern ulong eread(ulong, Event*);
  45. extern Mouse emouse(void);
  46. extern int ekbd(void);
  47. extern int ecanread(ulong);
  48. extern int ecanmouse(void);
  49. extern int ecankbd(void);
  50. extern void eresized(int); /* supplied by user */
  51. extern int emenuhit(int, Mouse*, Menu*);
  52. extern int eatomouse(Mouse*, char*, int);
  53. extern Rectangle getrect(int, Mouse*);
  54. extern void esetcursor(Cursor*);
  55. extern void emoveto(Point);
  56. extern Rectangle egetrect(int, Mouse*);
  57. extern void edrawgetrect(Rectangle, int);
  58. extern int ereadmouse(Mouse*);
  59. extern int eatomouse(Mouse*, char*, int);