Annotation of researchv9/X11/src/X.V11R1/lib/X/XChkIfEv.c, revision 1.1

1.1     ! root        1: #include "copyright.h"
        !             2: 
        !             3: /* $Header: XChkIfEv.c,v 11.5 87/09/08 14:29:43 newman Exp $ */
        !             4: /* Copyright    Massachusetts Institute of Technology    1985, 1987    */
        !             5: #define NEED_EVENTS
        !             6: #include "Xlibint.h"
        !             7: 
        !             8: extern _XQEvent *_qfree;
        !             9: 
        !            10: /* 
        !            11:  * Flush output and return the next event in the queue matching the
        !            12:  * predicate.  Return whether such an event was found.
        !            13:  * Events earlier in the queue are not discarded.
        !            14:  */
        !            15: 
        !            16: Bool XCheckIfEvent (dpy, event, predicate, arg)
        !            17:         register Display *dpy;
        !            18:        Bool (*predicate)();            /* function to call */
        !            19:        register XEvent *event;         /* XEvent to be filled in. */
        !            20:        char *arg;
        !            21: {
        !            22:        register _XQEvent *prev, *qelt;
        !            23: 
        !            24:         LockDisplay(dpy);
        !            25:        _XFlush (dpy);
        !            26:        prev = NULL;
        !            27:        qelt = dpy->head;
        !            28:        while (qelt) {
        !            29:            if ((*predicate)(dpy, &qelt->event, arg)) {
        !            30:                *event = qelt->event;
        !            31:                if (prev) {
        !            32:                    if ((prev->next = qelt->next) == NULL)
        !            33:                        dpy->tail = prev;
        !            34:                } else {
        !            35:                    if ((dpy->head = qelt->next) == NULL)
        !            36:                     dpy->tail = NULL;
        !            37:                 }
        !            38:                qelt->next = _qfree;
        !            39:                _qfree = qelt;
        !            40:                dpy->qlen--;
        !            41:                UnlockDisplay(dpy);
        !            42:                return 1;
        !            43:                }
        !            44:                qelt = (prev = qelt)->next;
        !            45:        }
        !            46: 
        !            47:        UnlockDisplay(dpy);
        !            48:        return 0;
        !            49: }

unix.superglobalmegacorp.com

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