|
|
1.1 ! root 1: #include "copyright.h" ! 2: ! 3: /* $Header: XPeekIfEv.c,v 11.9 87/09/11 08:09:07 toddb Exp $ */ ! 4: /* Copyright Massachusetts Institute of Technology 1986 */ ! 5: ! 6: #define NEED_EVENTS ! 7: #include "Xlibint.h" ! 8: ! 9: extern _XQEvent *_qfree; ! 10: ! 11: /* ! 12: * Flush output and (wait for and) return the next event in the queue ! 13: * that satisfies the predicate. ! 14: * BUT do not remove it from the queue. ! 15: */ ! 16: ! 17: XPeekIfEvent (dpy, event, predicate, arg) ! 18: register Display *dpy; ! 19: register XEvent *event; ! 20: Bool (*predicate)(); ! 21: char *arg; ! 22: { ! 23: register _XQEvent *qelt; ! 24: xEvent ev; ! 25: ! 26: LockDisplay(dpy); ! 27: _XFlush (dpy); ! 28: ! 29: qelt = dpy->head; ! 30: while (qelt) { ! 31: if ((*predicate)(dpy, &qelt->event, arg)) { ! 32: *event = qelt->event; ! 33: UnlockDisplay(dpy); ! 34: return; ! 35: } ! 36: qelt = qelt->next; ! 37: } ! 38: ! 39: /* ! 40: * if no match in queue, then block waiting for event, enqueing ! 41: * other events all the while. ! 42: */ ! 43: while (1) { ! 44: _XRead (dpy, (char *)&ev, (long)sizeof(xEvent)); ! 45: if (ev.u.u.type == X_Error) ! 46: _XError (dpy, (xError *) &ev); ! 47: else { /* it's an event packet */ ! 48: _XEnq (dpy, &ev); ! 49: if ((*predicate)(dpy, &dpy->tail->event, arg)) { ! 50: *event = dpy->tail->event; ! 51: UnlockDisplay(dpy); ! 52: return; ! 53: } ! 54: } ! 55: } ! 56: } ! 57:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.