event.h 1.8 KB

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