2 * Copyright 1985, 1987, 1998 The Open Group
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 * OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
17 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 * Except as contained in this notice, the name of The Open Group shall not be
21 * used in advertising or otherwise to promote the sale, use or other dealings
22 * in this Software without prior written authorization from The Open Group.
27 * Copyright 2002-2003 Red Hat Inc., Durham, North Carolina.
29 * All Rights Reserved.
31 * Permission is hereby granted, free of charge, to any person obtaining
32 * a copy of this software and associated documentation files (the
33 * "Software"), to deal in the Software without restriction, including
34 * without limitation on the rights to use, copy, modify, merge,
35 * publish, distribute, sublicense, and/or sell copies of the Software,
36 * and to permit persons to whom the Software is furnished to do so,
37 * subject to the following conditions:
39 * The above copyright notice and this permission notice (including the
40 * next paragraph) shall be included in all copies or substantial
41 * portions of the Software.
43 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
44 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
45 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
46 * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
47 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
48 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
49 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
54 * This file provides a #XCheckNotMaskEvent function that is derived
55 * from the standard Xlib XCheckMaskEvent function. */
57 #ifdef HAVE_DMX_CONFIG_H
58 #include <dmx-config.h>
62 #include "ChkNotMaskEv.h"
64 extern long const _Xevent_to_mask
[];
66 /** Check existing events in queue to find if any match. If so, return.
67 * If not, flush buffer and see if any more events are readable. If one
68 * matches, return. If all else fails, tell the user no events found.
71 XCheckNotMaskEvent(Display
* dpy
, long mask
, XEvent
* event
)
73 register _XQEvent
*prev
, *qelt
;
74 unsigned long qe_serial
= 0;
75 int n
; /* time through count */
79 for (n
= 3; --n
>= 0;) {
80 for (qelt
= prev
? prev
->next
: dpy
->head
;
81 qelt
; prev
= qelt
, qelt
= qelt
->next
) {
82 if (qelt
->event
.type
>= LASTEvent
83 || !(_Xevent_to_mask
[qelt
->event
.type
] & mask
)) {
85 _XDeq(dpy
, prev
, qelt
);
91 qe_serial
= prev
->qserial_num
;
94 _XEventsQueued(dpy
, QueuedAfterReading
);
100 if (prev
&& prev
->qserial_num
!= qe_serial
)
101 /* another thread has snatched this event */