Annotation of researchv9/X11/src/X.V11R1/lib/X/XWinEvent.c, revision 1.1.1.1

1.1       root        1: #include "copyright.h"
                      2: 
                      3: /* $Header: XWinEvent.c,v 11.12 87/09/11 08:08:27 toddb Exp $ */
                      4: /* Copyright    Massachusetts Institute of Technology    1985  */
                      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:  * for the given window matching one of the events in the mask.
                     15:  * Events earlier in the queue are not discarded.
                     16:  */
                     17: 
                     18: XWindowEvent (dpy, w, mask, event)
                     19:         register Display *dpy;
                     20:        Window w;               /* Selected window. */
                     21:        long mask;              /* Selected event mask. */
                     22:        register XEvent *event; /* XEvent to be filled in. */
                     23: {
                     24:        register _XQEvent *prev, *qelt;
                     25: 
                     26:         LockDisplay(dpy);
                     27:        _XFlush (dpy);
                     28:        for (prev = NULL, qelt = dpy->head;
                     29:             qelt && (qelt->event.type != KeymapNotify)
                     30:                  && (qelt->event.xany.window != w ||
                     31:                      !(_event_to_mask [qelt->event.type] & mask));
                     32:             qelt = (prev = qelt)->next) ;
                     33:        if (qelt) {
                     34:            *event = qelt->event;
                     35:            if (prev) {
                     36:                if ((prev->next = qelt->next) == NULL)
                     37:                    dpy->tail = prev;
                     38:            } else {
                     39:                if ((dpy->head = qelt->next) == NULL)
                     40:                    dpy->tail = NULL;
                     41:            }
                     42:            qelt->next = _qfree;
                     43:            _qfree = qelt;
                     44:            dpy->qlen--;
                     45:            UnlockDisplay(dpy);
                     46:            return;
                     47:        }
                     48:        while (1) {
                     49:            xEvent pe;          /* wire protocol event */
                     50:            _XRead (dpy, (char *)&pe, (long) sizeof(xEvent));
                     51:            /* go call through display to find proper event reformatter */
                     52:            (*dpy->event_vec[pe.u.u.type & 0177])(dpy, event, &pe);
                     53:            if (event->type == X_Error)
                     54:                _XError(dpy, (xError *) &pe);
                     55:            else if ((event->xany.window == w) 
                     56:                && (_event_to_mask[event->type] & mask)) {
                     57:                UnlockDisplay(dpy);
                     58:                return;
                     59:            } else
                     60:                _XEnq(dpy, &pe);
                     61:        }
                     62: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.