|
|
1.1 ! root 1: #include "copyright.h" ! 2: ! 3: /* $Header: XMaskEvent.c,v 11.14 87/09/11 08:05:11 toddb Exp $ */ ! 4: /* Copyright Massachusetts Institute of Technology 1986 */ ! 5: ! 6: #define NEED_EVENTS ! 7: #include "Xlibint.h" ! 8: ! 9: extern _XQEvent *_qfree; ! 10: extern long _event_to_mask[]; ! 11: ! 12: /* ! 13: * Flush output and (wait for and) return the next event in the queue ! 14: * matching one of the events in the mask. ! 15: * Events earlier in the queue are not discarded. ! 16: */ ! 17: ! 18: XMaskEvent (dpy, mask, event) ! 19: register Display *dpy; ! 20: unsigned long mask; /* Selected event mask. */ ! 21: register XEvent *event; /* XEvent to be filled in. */ ! 22: { ! 23: register _XQEvent *prev, *qelt; ! 24: ! 25: LockDisplay(dpy); ! 26: _XFlush (dpy); ! 27: for (prev = NULL, qelt = dpy->head; ! 28: qelt && !(_event_to_mask[qelt->event.type] & mask); ! 29: qelt = (prev = qelt)->next) ; ! 30: if (qelt) { ! 31: *event = qelt->event; ! 32: if (prev) { ! 33: if ((prev->next = qelt->next) == NULL) ! 34: dpy->tail = prev; ! 35: } else { ! 36: if ((dpy->head = qelt->next) == NULL) ! 37: dpy->tail = NULL; ! 38: } ! 39: qelt->next = _qfree; ! 40: _qfree = qelt; ! 41: dpy->qlen--; ! 42: UnlockDisplay(dpy); ! 43: return; ! 44: } ! 45: while (1) { ! 46: xEvent pe; /* wire protocol event */ ! 47: _XRead (dpy, (char *) &pe, (long)sizeof(xEvent)); ! 48: (*dpy->event_vec[pe.u.u.type & 0177])(dpy, event, &pe); ! 49: if (event->type == X_Error) ! 50: _XError(dpy, (xError *) &pe); ! 51: else if (_event_to_mask[event->type] & mask) { ! 52: UnlockDisplay (dpy); ! 53: return; ! 54: } ! 55: else ! 56: _XEnq(dpy, &pe); ! 57: } ! 58: } ! 59:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.