event.h 1.7 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. u32 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. u8 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(u32);
  46. extern u32 estart(u32, int, int);
  47. extern u32 estartfn(u32, int, int,
  48. int (*fn)(int, Event*, u8*, int));
  49. extern u32 etimer(u32, int);
  50. extern u32 event(Event*);
  51. extern u32 eread(u32, Event*);
  52. extern Mouse emouse(void);
  53. extern int ekbd(void);
  54. extern int ecanread(u32);
  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);