8 #include "x11-memdraw.h"
11 * Should change this to support etimer and estartfn again.
12 * The main eread() would prepare a select mask from the keys
13 * and then call select() to wait for input. Then it would read an
14 * event from the readied fd and return it. Use XCheckWindowEvent
15 * to poll the X connection.
21 return eread(~0UL, e);
27 /* avoid generating a message if there's nothing to show. */
28 /* this test isn't perfect, though; could do flushimage(display, 0) then call extract */
29 /* also: make sure we don't interfere if we're multiprocessing the display */
31 /* if locking is being done by program, this means it can't depend on automatic flush in emouse() etc. */
32 if(canqlock(&display->qlock)){
33 if(display->bufp > display->buf)
34 flushimage(display, 1);
35 unlockdisplay(display);
38 if(display->bufp > display->buf)
39 flushimage(display, 1);
43 eread(ulong keys, Event *e)
54 xmask |= MouseMask|StructureNotifyMask;
56 xmask |= KeyPressMask;
57 if((r = _xtoplan9kbd(nil)) >= 0){
63 xmask |= EnterWindowMask|LeaveWindowMask;
65 XSelectInput(_x.display, _x.drawable, xmask);
67 XWindowEvent(_x.display, _x.drawable, xmask, &xevent);
71 _xexpose(&xevent, _x.display);
74 if(_xdestroy(&xevent, _x.display))
75 postnote(PNGROUP, getpgrp(), "hangup");
78 if(_xconfigure(&xevent, _x.display))
84 if(_xtoplan9mouse(_x.display, &xevent, &e->mouse) < 0)
88 e->kbdc = _xtoplan9kbd(&xevent);
100 keys &= ~(Emouse|Ekeyboard);
102 fprint(2, "unknown keys in einit\n");
112 eread(Ekeyboard, &e);
146 if(XCheckWindowEvent(_x.display, _x.drawable, MouseMask, &xe)){
147 if(_xtoplan9mouse(_x.display, &xe, &m) < 0)
149 XPutBackEvent(_x.display, &xe);
162 if((r = _xtoplan9kbd(nil)) >= 0){
163 _xtoplan9kbd((XEvent*)-1);
167 if(XCheckWindowEvent(_x.display, _x.drawable, KeyPressMask, &xe)){
168 if(_xtoplan9kbd(&xe) == -1)
170 XPutBackEvent(_x.display, &xe);
183 esetcursor(Cursor *c)