1: #include <X/mit-copyright.h> 2: 3: /* $Header: XPeekEvent.c,v 10.4 86/02/01 15:37:48 tony Rel $ */ 4: /* Copyright Massachusetts Institute of Technology 1985 */ 5: 6: #include "XlibInternal.h" 7: 8: extern _QEvent *_qfree; 9: 10: /* Flush output and (wait for and) return the next event in the queue, 11: * BUT do not remove it from the queue. 12: */ 13: 14: XPeekEvent (event) 15: register XEvent *event; 16: { 17: register _QEvent *qelt; 18: register Display *dpy = _XlibCurrentDisplay; 19: 20: _XFlush (dpy); 21: if (qelt = dpy->head) { 22: *event = qelt->event; 23: return; 24: } 25: 26: while (1) { 27: _XRead (dpy, event, sizeof(XEvent)); 28: if (event->type == X_Error) 29: _XError (dpy, (XErrorEvent *) event); 30: else { /* it's an event packet */ 31: _XEnq (dpy, event); 32: return; 33: } 34: } 35: }