1: #include <X/mit-copyright.h>
2:
3: /* $Header: XNextEvent.c,v 10.4 86/02/01 15:37:26 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: */
12:
13: XNextEvent (event)
14: register XEvent *event;
15: {
16: register _QEvent *qelt;
17: register Display *dpy = _XlibCurrentDisplay;
18:
19: _XFlush (dpy);
20:
21: /* if the queue is empty, read as many events as possible
22: and enqueue them */
23: while (dpy->head == NULL) {
24: char buf[BUFSIZE];
25: int pend_not_register; /* because can't "&" a register variable */
26: register int pend;
27: register XRep *rep;
28:
29: /* find out how much data can be read */
30: if (ioctl(dpy->fd, FIONREAD, &pend_not_register) < 0)
31: _XIOError(dpy);
32: pend = pend_not_register;
33:
34: /* must read at least one XRep; if none is pending, then
35: we'll just block waiting for it */
36: if (pend < sizeof(XRep))
37: pend = sizeof (XRep);
38:
39: /* but we won't read more than the max buffer size */
40: if (pend > BUFSIZE)
41: pend = BUFSIZE;
42:
43: /* round down to an integral number of XReps */
44: pend = (pend / sizeof (XRep)) * sizeof (XRep);
45:
46: _XRead (dpy, buf, pend);
47: for (rep = (XRep *) buf; pend > 0; rep++, pend -= sizeof(XRep))
48: if (rep->code == X_Error)
49: _XError (dpy, (XErrorEvent *) rep);
50: else /* it's an event packet; enqueue it */
51: _XEnq (dpy, (XEvent *) rep);
52: }
53:
54: *event = (qelt = dpy->head)->event;
55:
56: /* move the head of the queue to the free list */
57: if ((dpy->head = qelt->next) == NULL)
58: dpy->tail = NULL;
59: qelt->next = _qfree;
60: _qfree = qelt;
61: dpy->qlen--;
62: }
Defined functions
XNextEvent
defined in line
13; used 34 times
- in /usr/src/new/X/XMenu/XMenuActivate.c line
246,
479
- in /usr/src/new/X/Xlib/XCreate.c line
211
- in /usr/src/new/X/Xlib/XCreateTerm.c line
225
- in /usr/src/new/X/bitmap/bitmap.c line
133,
383,
1342,
1438,
1466,
1544
- in /usr/src/new/X/bitmap/dialog.c line
141
- in /usr/src/new/X/comsat/comsat.c line
487
- in /usr/src/new/X/hacks/bee/main.c line
248
- in /usr/src/new/X/hacks/maze/maze.c line
165,
193
- in /usr/src/new/X/libnest/nest.c line
102
- in /usr/src/new/X/pikapix/pikapix.c line
108,
219
- in /usr/src/new/X/uwm/GetButton.c line
79
- in /usr/src/new/X/xclock/xclock.c line
470,
501
- in /usr/src/new/X/xdvi/dv.c line
905
- in /usr/src/new/X/xgedit/gx.c line
90,
100,
117
- in /usr/src/new/X/ximpv/impv.c line
543
- in /usr/src/new/X/xload/xload.c line
366
- in /usr/src/new/X/xnwm/xnwm.c line
959
- in /usr/src/new/X/xshell/xshell.c line
353
- in /usr/src/new/X/xterm/main.c line
513
- in /usr/src/new/X/xwd/xwd.c line
153
- in /usr/src/new/X/xwininfo/xwininfo.c line
153
- in /usr/src/new/X/xwm/GetButton.c line
41
- in /usr/src/new/X/xwud/xwud.c line
239