ebfbf8c693e6abc8c94a3e7de7d18a1314641a81
[platform/upstream/libX11.git] / man / XIfEvent.man
1 .\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
2 .\"
3 .\" Permission is hereby granted, free of charge, to any person obtaining
4 .\" a copy of this software and associated documentation files (the
5 .\" "Software"), to deal in the Software without restriction, including
6 .\" without limitation the rights to use, copy, modify, merge, publish,
7 .\" distribute, sublicense, and/or sell copies of the Software, and to
8 .\" permit persons to whom the Software is furnished to do so, subject to
9 .\" the following conditions:
10 .\"
11 .\" The above copyright notice and this permission notice shall be included
12 .\" in all copies or substantial portions of the Software.
13 .\"
14 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 .\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 .\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 .\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 .\" OTHER DEALINGS IN THE SOFTWARE.
21 .\"
22 .\" Except as contained in this notice, the name of the X Consortium shall
23 .\" not be used in advertising or otherwise to promote the sale, use or
24 .\" other dealings in this Software without prior written authorization
25 .\" from the X Consortium.
26 .\"
27 .\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
28 .\" Digital Equipment Corporation
29 .\"
30 .\" Portions Copyright \(co 1990, 1991 by
31 .\" Tektronix, Inc.
32 .\"
33 .\" Permission to use, copy, modify and distribute this documentation for
34 .\" any purpose and without fee is hereby granted, provided that the above
35 .\" copyright notice appears in all copies and that both that copyright notice
36 .\" and this permission notice appear in all copies, and that the names of
37 .\" Digital and Tektronix not be used in in advertising or publicity pertaining
38 .\" to this documentation without specific, written prior permission.
39 .\" Digital and Tektronix makes no representations about the suitability
40 .\" of this documentation for any purpose.
41 .\" It is provided ``as is'' without express or implied warranty.
42 .\" 
43 .\"
44 .ds xT X Toolkit Intrinsics \- C Language Interface
45 .ds xW Athena X Widgets \- C Language X Toolkit Interface
46 .ds xL Xlib \- C Language X Interface
47 .ds xC Inter-Client Communication Conventions Manual
48 .na
49 .de Ds
50 .nf
51 .\\$1D \\$2 \\$1
52 .ft 1
53 .\".ps \\n(PS
54 .\".if \\n(VS>=40 .vs \\n(VSu
55 .\".if \\n(VS<=39 .vs \\n(VSp
56 ..
57 .de De
58 .ce 0
59 .if \\n(BD .DF
60 .nr BD 0
61 .in \\n(OIu
62 .if \\n(TM .ls 2
63 .sp \\n(DDu
64 .fi
65 ..
66 .de FD
67 .LP
68 .KS
69 .TA .5i 3i
70 .ta .5i 3i
71 .nf
72 ..
73 .de FN
74 .fi
75 .KE
76 .LP
77 ..
78 .de IN          \" send an index entry to the stderr
79 ..
80 .de C{
81 .KS
82 .nf
83 .D
84 .\"
85 .\"     choose appropriate monospace font
86 .\"     the imagen conditional, 480,
87 .\"     may be changed to L if LB is too
88 .\"     heavy for your eyes...
89 .\"
90 .ie "\\*(.T"480" .ft L
91 .el .ie "\\*(.T"300" .ft L
92 .el .ie "\\*(.T"202" .ft PO
93 .el .ie "\\*(.T"aps" .ft CW
94 .el .ft R
95 .ps \\n(PS
96 .ie \\n(VS>40 .vs \\n(VSu
97 .el .vs \\n(VSp
98 ..
99 .de C}
100 .DE
101 .R
102 ..
103 .de Pn
104 .ie t \\$1\fB\^\\$2\^\fR\\$3
105 .el \\$1\fI\^\\$2\^\fP\\$3
106 ..
107 .de ZN
108 .ie t \fB\^\\$1\^\fR\\$2
109 .el \fI\^\\$1\^\fP\\$2
110 ..
111 .de hN
112 .ie t <\fB\\$1\fR>\\$2
113 .el <\fI\\$1\fP>\\$2
114 ..
115 .de NT
116 .ne 7
117 .ds NO Note
118 .if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
119 .if \\n(.$ .if !'\\$1'C' .ds NO \\$1
120 .ie n .sp
121 .el .sp 10p
122 .TB
123 .ce
124 \\*(NO
125 .ie n .sp
126 .el .sp 5p
127 .if '\\$1'C' .ce 99
128 .if '\\$2'C' .ce 99
129 .in +5n
130 .ll -5n
131 .R
132 ..
133 .               \" Note End -- doug kraft 3/85
134 .de NE
135 .ce 0
136 .in -5n
137 .ll +5n
138 .ie n .sp
139 .el .sp 10p
140 ..
141 .ny0
142 .TH XIfEvent __libmansuffix__ __xorgversion__ "XLIB FUNCTIONS"
143 .SH NAME
144 XIfEvent, XCheckIfEvent, XPeekIfEvent \- check the event queue with a predicate procedure
145 .SH SYNTAX
146 .HP
147 int XIfEvent\^(\^Display *\fIdisplay\fP\^, XEvent *\fIevent_return\fP\^, Bool
148 (\^*\fIpredicate\fP\^)\^(\^)\^, XPointer \fIarg\fP\^); 
149 .HP
150 Bool XCheckIfEvent\^(\^Display *\fIdisplay\fP\^, XEvent *\fIevent_return\fP\^,
151 Bool (\^*\fIpredicate\fP\^)\^(\^)\^, XPointer \fIarg\fP\^); 
152 .HP
153 int XPeekIfEvent\^(\^Display *\fIdisplay\fP\^, XEvent *\fIevent_return\fP\^,
154 Bool (\^*\fIpredicate\fP\^)\^(\^)\^, XPointer \fIarg\fP\^); 
155 .SH ARGUMENTS
156 .IP \fIarg\fP 1i
157 Specifies the user-supplied argument that will be passed to the predicate procedure.
158 .IP \fIdisplay\fP 1i
159 Specifies the connection to the X server.
160 .ds Ev \ either a copy of or 
161 .IP \fIevent_return\fP 1i
162 Returns\*(Ev the matched event's associated structure.
163 .IP \fIpredicate\fP 1i
164 Specifies the procedure that is to be called to determine
165 if the next event in the queue matches what you want.
166 .SH DESCRIPTION
167 The
168 .ZN XIfEvent
169 function completes only when the specified predicate
170 procedure returns 
171 .ZN True 
172 for an event, 
173 which indicates an event in the queue matches.
174 .ZN XIfEvent
175 flushes the output buffer if it blocks waiting for additional events.
176 .ZN XIfEvent
177 removes the matching event from the queue 
178 and copies the structure into the client-supplied
179 .ZN XEvent
180 structure.
181 .LP
182 When the predicate procedure finds a match,
183 .ZN XCheckIfEvent
184 copies the matched event into the client-supplied
185 .ZN XEvent
186 structure and returns 
187 .ZN True .
188 (This event is removed from the queue.)
189 If the predicate procedure finds no match,
190 .ZN XCheckIfEvent
191 returns
192 .ZN False ,
193 and the output buffer will have been flushed.
194 All earlier events stored in the queue are not discarded.
195 .LP
196 The
197 .ZN XPeekIfEvent
198 function returns only when the specified predicate
199 procedure returns 
200 .ZN True
201 for an event.
202 After the predicate procedure finds a match,
203 .ZN XPeekIfEvent
204 copies the matched event into the client-supplied
205 .ZN XEvent
206 structure without removing the event from the queue.
207 .ZN XPeekIfEvent
208 flushes the output buffer if it blocks waiting for additional events.
209 .LP
210 Each of these functions requires you to pass a predicate procedure that 
211 determines if an event matches what you want.
212 Your predicate procedure must decide if the event is useful
213 without calling any Xlib functions.
214 If the predicate directly or indirectly causes the state of the event queue
215 to change, the result is not defined.
216 If Xlib has been initialized for threads, the predicate is called with
217 the display locked and the result of a call by the predicate to any
218 Xlib function that locks the display is not defined unless the caller
219 has first called
220 .ZN XLockDisplay .
221 .LP
222 The predicate procedure and its associated arguments are:
223 .HP
224 Bool (\^*\fIpredicate\fP\^)\^(\^Display *\fIdisplay\fP, XEvent *\fIevent\fP, XPointer \fIarg\fP\^)
225 .IP \fIdisplay\fP 1i
226 Specifies the connection to the X server.
227 .IP \fIevent\fP 1i
228 Specifies the
229 .ZN XEvent
230 structure.
231 .IP \fIarg\fP 1i
232 Specifies the argument passed in from the 
233 .ZN XIfEvent ,
234 .ZN XCheckIfEvent ,
235 or
236 .ZN XPeekIfEvent 
237 function.
238 .LP
239 The predicate procedure is called once for each
240 event in the queue until it finds a match. 
241 After finding a match, the predicate procedure must return 
242 .ZN True .
243 If it did not find a match, it must return
244 .ZN False .
245 .SH "SEE ALSO"
246 XAnyEvent(__libmansuffix__),
247 XNextEvent(__libmansuffix__),
248 XPutBackEvent(__libmansuffix__)
249 XSendEvent(__libmansuffix__)
250 .br
251 \fI\*(xL\fP