|
|
1.1 root 1: #include "copyright.h"
2:
3: /* $Header: XPending.c,v 11.10 87/09/11 08:05:32 toddb Exp $ */
4: /* Copyright Massachusetts Institute of Technology 1986 */
5:
6: #define NEED_EVENTS
7: #define NEED_REPLIES
8: #include "Xlibint.h"
9:
10: /* Read in any pending events and return the number of queued events. */
11:
12: int XPending (dpy)
13: register Display *dpy;
14: {
15: register int len;
16: int pend;
17: char buf[BUFSIZE];
18: register xReply *rep;
19:
20: LockDisplay(dpy);
21: _XFlush (dpy);
22: if (BytesReadable(dpy->fd, (char *) &pend) < 0)
23: (*_XIOErrorFunction)(dpy);
24: if ((len = pend) < sizeof(xReply)) {
25: UnlockDisplay(dpy);
26: return(dpy->qlen);
27: }
28: else if (len > BUFSIZE)
29: len = BUFSIZE;
30: len /= sizeof(xReply);
31: pend = len * sizeof(xReply);
32: _XRead (dpy, buf, (long) pend);
33: for (rep = (xReply *) buf; len > 0; rep++, len--) {
34: if (rep->generic.type == X_Error)
35: _XError(dpy, (xError *)rep);
36: else /* must be an event packet */
37: _XEnq(dpy, (xEvent *) rep);
38: }
39: UnlockDisplay(dpy);
40: return(dpy->qlen);
41: }
42:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.