File:  [Research Unix] / researchv9 / X11 / src / X.V11R1 / lib / X / XChkIfEv.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:22:00 2018 UTC (8 years, 1 month ago) by root
Branches: belllabs, MAIN
CVS tags: researchv9-SUN3_old, researchv9-SUN3, HEAD
researchv9-SUN3(old)

#include "copyright.h"

/* $Header: /var/lib/cvsd/repos/research/researchv9/X11/src/X.V11R1/lib/X/XChkIfEv.c,v 1.1.1.1 2018/04/24 17:22:00 root Exp $ */
/* Copyright    Massachusetts Institute of Technology    1985, 1987	*/
#define NEED_EVENTS
#include "Xlibint.h"

extern _XQEvent *_qfree;

/* 
 * Flush output and return the next event in the queue matching the
 * predicate.  Return whether such an event was found.
 * Events earlier in the queue are not discarded.
 */

Bool XCheckIfEvent (dpy, event, predicate, arg)
        register Display *dpy;
	Bool (*predicate)();		/* function to call */
	register XEvent *event;		/* XEvent to be filled in. */
	char *arg;
{
 	register _XQEvent *prev, *qelt;

        LockDisplay(dpy);
	_XFlush (dpy);
	prev = NULL;
	qelt = dpy->head;
	while (qelt) {
	    if ((*predicate)(dpy, &qelt->event, arg)) {
		*event = qelt->event;
	        if (prev) {
	            if ((prev->next = qelt->next) == NULL)
	                dpy->tail = prev;
	        } else {
	            if ((dpy->head = qelt->next) == NULL)
                    dpy->tail = NULL;
                }
	        qelt->next = _qfree;
	        _qfree = qelt;
	        dpy->qlen--;
		UnlockDisplay(dpy);
		return 1;
		}
		qelt = (prev = qelt)->next;
	}

	UnlockDisplay(dpy);
	return 0;
}

unix.superglobalmegacorp.com

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