event.h 1.8 KB

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