CH11.xml revision eb411b4b
1e9fcaa8aSmrg<?xml version="1.0" encoding="UTF-8" ?>
2e9fcaa8aSmrg<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
3e9fcaa8aSmrg	  "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd">
4eb411b4bSmrg<chapter id='Event_Handling_Functions'>
5e9fcaa8aSmrg<title>Event Handling Functions</title>
6e9fcaa8aSmrg
7e9fcaa8aSmrg<para>
8e9fcaa8aSmrgThis chapter discusses the Xlib functions you can use to:
9e9fcaa8aSmrg</para>
10e9fcaa8aSmrg<itemizedlist>
11e9fcaa8aSmrg  <listitem><para>Select events</para></listitem>
12e9fcaa8aSmrg  <listitem><para>Handle the output buffer and the event queue</para></listitem>
13e9fcaa8aSmrg  <listitem><para>Select events from the event queue</para></listitem>
14e9fcaa8aSmrg  <listitem><para>Send and get events</para></listitem>
15e9fcaa8aSmrg  <listitem><para>Handle protocol errors</para></listitem>
16e9fcaa8aSmrg</itemizedlist>
17e9fcaa8aSmrg<note><para>
18e9fcaa8aSmrgSome toolkits use their own event-handling functions and do not allow you to
19e9fcaa8aSmrginterchange these event-handling functions with those in Xlib. For further
20e9fcaa8aSmrginformation, see the documentation supplied with the toolkit.
21e9fcaa8aSmrg</para></note>
22e9fcaa8aSmrg
23e9fcaa8aSmrg<para>
24e9fcaa8aSmrgMost applications simply are event loops: they wait for an event, decide what to do with it,
25e9fcaa8aSmrgexecute some amount of code that results in changes to the display, and then wait for the next
26e9fcaa8aSmrgevent.
27e9fcaa8aSmrg</para>
28e9fcaa8aSmrg
29e9fcaa8aSmrg<sect1 id="Selecting_Events">
30e9fcaa8aSmrg<title>Selecting Events</title>
31e9fcaa8aSmrg<!-- .XS -->
32e9fcaa8aSmrg<!-- (SN Selecting Events  -->
33e9fcaa8aSmrg<!-- .XE -->
34e9fcaa8aSmrg<para>
35e9fcaa8aSmrg<!-- .LP -->
36e9fcaa8aSmrgThere are two ways to select the events you want reported to your client
37e9fcaa8aSmrgapplication.
38e9fcaa8aSmrgOne way is to set the event_mask member of the
39e9fcaa8aSmrg<structname>XSetWindowAttributes</structname>
40e9fcaa8aSmrgstructure when you call
41eb411b4bSmrg<xref linkend='XCreateWindow' xrefstyle='select: title'/>
42e9fcaa8aSmrgand
43eb411b4bSmrg<xref linkend='XChangeWindowAttributes' xrefstyle='select: title'/>.
44e9fcaa8aSmrgAnother way is to use
45eb411b4bSmrg<xref linkend='XSelectInput' xrefstyle='select: title'/>.
46eb411b4bSmrg</para>
47e9fcaa8aSmrg<indexterm significance="preferred"><primary>XSelectInput</primary></indexterm>
48e9fcaa8aSmrg<!-- .sM -->
49eb411b4bSmrg<funcsynopsis id='XSelectInput'>
50e9fcaa8aSmrg<funcprototype>
51e9fcaa8aSmrg  <funcdef><function>XSelectInput</function></funcdef>
52e9fcaa8aSmrg  <paramdef>Display<parameter> *display</parameter></paramdef>
53e9fcaa8aSmrg  <paramdef>Window<parameter> w</parameter></paramdef>
54e9fcaa8aSmrg  <paramdef>long<parameter> event_mask</parameter></paramdef>
55e9fcaa8aSmrg</funcprototype>
56e9fcaa8aSmrg</funcsynopsis>
57e9fcaa8aSmrg<!-- .FN	 -->
58e9fcaa8aSmrg<variablelist>
59e9fcaa8aSmrg  <varlistentry>
60e9fcaa8aSmrg    <term>
61e9fcaa8aSmrg      <emphasis remap='I'>display</emphasis>
62e9fcaa8aSmrg    </term>
63e9fcaa8aSmrg    <listitem>
64e9fcaa8aSmrg      <para>
65e9fcaa8aSmrgSpecifies the connection to the X server.
66e9fcaa8aSmrg<!-- .ds Wi whose events you are interested in -->
67e9fcaa8aSmrg      </para>
68e9fcaa8aSmrg    </listitem>
69e9fcaa8aSmrg  </varlistentry>
70e9fcaa8aSmrg  <varlistentry>
71e9fcaa8aSmrg    <term>
72e9fcaa8aSmrg      <emphasis remap='I'>w</emphasis>
73e9fcaa8aSmrg    </term>
74e9fcaa8aSmrg    <listitem>
75e9fcaa8aSmrg      <para>
76e9fcaa8aSmrgSpecifies the window (Wi.
77e9fcaa8aSmrg      </para>
78e9fcaa8aSmrg    </listitem>
79e9fcaa8aSmrg  </varlistentry>
80e9fcaa8aSmrg  <varlistentry>
81e9fcaa8aSmrg    <term>
82e9fcaa8aSmrg      <emphasis remap='I'>event_mask</emphasis>
83e9fcaa8aSmrg    </term>
84e9fcaa8aSmrg    <listitem>
85e9fcaa8aSmrg      <para>
86e9fcaa8aSmrgSpecifies the event mask.
87e9fcaa8aSmrg    </para>
88e9fcaa8aSmrg  </listitem>
89e9fcaa8aSmrg  </varlistentry>
90e9fcaa8aSmrg</variablelist>
91e9fcaa8aSmrg<para>
92e9fcaa8aSmrg<!-- .LP -->
93e9fcaa8aSmrg<!-- .eM  -->
94e9fcaa8aSmrgThe
95eb411b4bSmrg<xref linkend='XSelectInput' xrefstyle='select: title'/>
96e9fcaa8aSmrgfunction requests that the X server report the events associated with the 
97e9fcaa8aSmrgspecified event mask.
98e9fcaa8aSmrgInitially, X will not report any of these events.
99e9fcaa8aSmrgEvents are reported relative to a window.
100e9fcaa8aSmrgIf a window is not interested in a device event, it usually propagates to
101e9fcaa8aSmrgthe closest ancestor that is interested,
102e9fcaa8aSmrgunless the do_not_propagate mask prohibits it.
103e9fcaa8aSmrg<indexterm><primary>Event</primary><secondary>propagation</secondary></indexterm>
104e9fcaa8aSmrg</para>
105e9fcaa8aSmrg<para>
106e9fcaa8aSmrg<!-- .LP -->
107e9fcaa8aSmrgSetting the event-mask attribute of a window overrides any previous call
108e9fcaa8aSmrgfor the same window but not for other clients.
109e9fcaa8aSmrgMultiple clients can select for the same events on the same window
110e9fcaa8aSmrgwith the following restrictions:
111e9fcaa8aSmrg</para>
112e9fcaa8aSmrg<itemizedlist>
113e9fcaa8aSmrg  <listitem>
114e9fcaa8aSmrg    <para>
115e9fcaa8aSmrgMultiple clients can select events on the same window because their event masks
116e9fcaa8aSmrgare disjoint.
117e9fcaa8aSmrgWhen the X server generates an event, it reports it
118e9fcaa8aSmrgto all interested clients.
119e9fcaa8aSmrg    </para>
120e9fcaa8aSmrg  </listitem>
121e9fcaa8aSmrg  <listitem>
122e9fcaa8aSmrg    <para>
123e9fcaa8aSmrgOnly one client at a time can select
124e9fcaa8aSmrg<symbol>CirculateRequest</symbol>,
125e9fcaa8aSmrg<symbol>ConfigureRequest</symbol>,
126e9fcaa8aSmrgor
127e9fcaa8aSmrg<symbol>MapRequest</symbol>
128e9fcaa8aSmrgevents, which are associated with
129e9fcaa8aSmrgthe event mask
130e9fcaa8aSmrg<symbol>SubstructureRedirectMask</symbol>.
131e9fcaa8aSmrg    </para>
132e9fcaa8aSmrg  </listitem>
133e9fcaa8aSmrg  <listitem>
134e9fcaa8aSmrg    <para>
135e9fcaa8aSmrgOnly one client at a time can select
136e9fcaa8aSmrga
137e9fcaa8aSmrg<symbol>ResizeRequest</symbol>
138e9fcaa8aSmrgevent, which is associated with
139e9fcaa8aSmrgthe event mask
140e9fcaa8aSmrg<symbol>ResizeRedirectMask</symbol>.
141e9fcaa8aSmrg    </para>
142e9fcaa8aSmrg  </listitem>
143e9fcaa8aSmrg  <listitem>
144e9fcaa8aSmrg    <para>
145e9fcaa8aSmrgOnly one client at a time can select a 
146e9fcaa8aSmrg<symbol>ButtonPress</symbol>
147e9fcaa8aSmrgevent, which is associated with
148e9fcaa8aSmrgthe event mask
149e9fcaa8aSmrg<symbol>ButtonPressMask</symbol>.
150e9fcaa8aSmrg    </para>
151e9fcaa8aSmrg  </listitem>
152e9fcaa8aSmrg</itemizedlist>
153e9fcaa8aSmrg<para>
154e9fcaa8aSmrg<!-- .LP -->
155e9fcaa8aSmrgThe server reports the event to all interested clients.
156e9fcaa8aSmrg</para>
157e9fcaa8aSmrg<para>
158e9fcaa8aSmrg<!-- .LP -->
159eb411b4bSmrg<xref linkend='XSelectInput' xrefstyle='select: title'/>
160e9fcaa8aSmrgcan generate a
161e9fcaa8aSmrg<errorname>BadWindow</errorname>
162e9fcaa8aSmrgerror.
163e9fcaa8aSmrg</para>
164e9fcaa8aSmrg</sect1>
165e9fcaa8aSmrg<sect1 id="Handling_the_Output_Buffer">
166e9fcaa8aSmrg<title>Handling the Output Buffer</title>
167e9fcaa8aSmrg<!-- .XS -->
168e9fcaa8aSmrg<!-- (SN Handling the Output Buffer -->
169e9fcaa8aSmrg<!-- .XE -->
170e9fcaa8aSmrg<para>
171e9fcaa8aSmrg<!-- .LP -->
172e9fcaa8aSmrgThe output buffer is an area used by Xlib to store requests.
173e9fcaa8aSmrgThe functions described in this section flush the output buffer
174e9fcaa8aSmrgif the function would block or not return an event.
175e9fcaa8aSmrgThat is, all requests residing in the output buffer that
176e9fcaa8aSmrghave not yet been sent are transmitted to the X server.
177e9fcaa8aSmrgThese functions differ in the additional tasks they might perform.
178e9fcaa8aSmrg</para>
179e9fcaa8aSmrg<para>
180e9fcaa8aSmrg<!-- .LP -->
181e9fcaa8aSmrg<!-- .sp -->
182e9fcaa8aSmrgTo flush the output buffer, use 
183eb411b4bSmrg<xref linkend='XFlush' xrefstyle='select: title'/>.
184eb411b4bSmrg</para>
185e9fcaa8aSmrg<indexterm significance="preferred"><primary>XFlush</primary></indexterm>
186e9fcaa8aSmrg<!-- .sM -->
187eb411b4bSmrg<funcsynopsis id='XFlush'>
188e9fcaa8aSmrg<funcprototype>
189e9fcaa8aSmrg  <funcdef><function>XFlush</function></funcdef>
190e9fcaa8aSmrg  <paramdef>Display<parameter> *display</parameter></paramdef>
191e9fcaa8aSmrg</funcprototype>
192e9fcaa8aSmrg</funcsynopsis>
193e9fcaa8aSmrg<!-- .FN -->
194e9fcaa8aSmrg<variablelist>
195e9fcaa8aSmrg  <varlistentry>
196e9fcaa8aSmrg    <term>
197e9fcaa8aSmrg      <emphasis remap='I'>display</emphasis>
198e9fcaa8aSmrg    </term>
199e9fcaa8aSmrg    <listitem>
200e9fcaa8aSmrg      <para>
201e9fcaa8aSmrgSpecifies the connection to the X server.
202e9fcaa8aSmrg    </para>
203e9fcaa8aSmrg  </listitem>
204e9fcaa8aSmrg  </varlistentry>
205e9fcaa8aSmrg</variablelist>
206e9fcaa8aSmrg<para>
207e9fcaa8aSmrg<!-- .LP -->
208e9fcaa8aSmrg<!-- .eM -->
209e9fcaa8aSmrgThe
210eb411b4bSmrg<xref linkend='XFlush' xrefstyle='select: title'/>
211e9fcaa8aSmrgfunction
212e9fcaa8aSmrgflushes the output buffer.
213e9fcaa8aSmrgMost client applications need not use this function because the output
214e9fcaa8aSmrgbuffer is automatically flushed as needed by calls to
215eb411b4bSmrg<xref linkend='XPending' xrefstyle='select: title'/>,
216eb411b4bSmrg<xref linkend='XNextEvent' xrefstyle='select: title'/>,
217e9fcaa8aSmrgand
218eb411b4bSmrg<xref linkend='XWindowEvent' xrefstyle='select: title'/>.
219e9fcaa8aSmrg<indexterm><primary>XPending</primary></indexterm>
220e9fcaa8aSmrg<indexterm><primary>XNextEvent</primary></indexterm>
221e9fcaa8aSmrg<indexterm><primary>XWindowEvent</primary></indexterm>
222e9fcaa8aSmrgEvents generated by the server may be enqueued into the library's event queue.
223e9fcaa8aSmrg</para>
224e9fcaa8aSmrg<para>
225e9fcaa8aSmrg<!-- .LP -->
226e9fcaa8aSmrg<!-- .sp -->
227e9fcaa8aSmrgTo flush the output buffer and then wait until all requests have been processed,
228e9fcaa8aSmrguse 
229eb411b4bSmrg<xref linkend='XSync' xrefstyle='select: title'/>.
230eb411b4bSmrg</para>
231e9fcaa8aSmrg<indexterm significance="preferred"><primary>XSync</primary></indexterm>
232e9fcaa8aSmrg<!-- .sM -->
233eb411b4bSmrg<funcsynopsis id='XSync'>
234e9fcaa8aSmrg<funcprototype>
235e9fcaa8aSmrg  <funcdef><function>XSync</function></funcdef>
236e9fcaa8aSmrg  <paramdef>Display<parameter> *display</parameter></paramdef>
237e9fcaa8aSmrg  <paramdef>Bool<parameter> discard</parameter></paramdef>
238e9fcaa8aSmrg</funcprototype>
239e9fcaa8aSmrg</funcsynopsis>
240e9fcaa8aSmrg<!-- .FN -->
241e9fcaa8aSmrg<variablelist>
242e9fcaa8aSmrg  <varlistentry>
243e9fcaa8aSmrg    <term>
244e9fcaa8aSmrg      <emphasis remap='I'>display</emphasis>
245e9fcaa8aSmrg    </term>
246e9fcaa8aSmrg    <listitem>
247e9fcaa8aSmrg      <para>
248e9fcaa8aSmrgSpecifies the connection to the X server.
249e9fcaa8aSmrg      </para>
250e9fcaa8aSmrg    </listitem>
251e9fcaa8aSmrg  </varlistentry>
252e9fcaa8aSmrg  <varlistentry>
253e9fcaa8aSmrg    <term>
254e9fcaa8aSmrg      <emphasis remap='I'>discard</emphasis>
255e9fcaa8aSmrg    </term>
256e9fcaa8aSmrg    <listitem>
257e9fcaa8aSmrg      <para>
258e9fcaa8aSmrgSpecifies a Boolean value that indicates whether 
259eb411b4bSmrg<xref linkend='XSync' xrefstyle='select: title'/>
260e9fcaa8aSmrgdiscards all events on the event queue.
261e9fcaa8aSmrg    </para>
262e9fcaa8aSmrg  </listitem>
263e9fcaa8aSmrg  </varlistentry>
264e9fcaa8aSmrg</variablelist>
265e9fcaa8aSmrg<para>
266e9fcaa8aSmrg<!-- .LP -->
267e9fcaa8aSmrg<!-- .eM -->
268e9fcaa8aSmrgThe
269eb411b4bSmrg<xref linkend='XSync' xrefstyle='select: title'/>
270e9fcaa8aSmrgfunction
271e9fcaa8aSmrgflushes the output buffer and then waits until all requests have been received
272e9fcaa8aSmrgand processed by the X server.
273e9fcaa8aSmrgAny errors generated must be handled by the error handler.
274e9fcaa8aSmrgFor each protocol error received by Xlib,
275eb411b4bSmrg<xref linkend='XSync' xrefstyle='select: title'/>
2766cc2b21fSmrgcalls the client application's error handling routine
2776cc2b21fSmrg(see <link linkend="Using_the_Default_Error_Handlers">section 11.8.2</link>).
278e9fcaa8aSmrgAny events generated by the server are enqueued into the library's 
279e9fcaa8aSmrgevent queue.
280e9fcaa8aSmrg</para>
281e9fcaa8aSmrg<para>
282e9fcaa8aSmrg<!-- .LP -->
283e9fcaa8aSmrgFinally, if you passed 
284e9fcaa8aSmrg<symbol>False</symbol>,
285eb411b4bSmrg<xref linkend='XSync' xrefstyle='select: title'/>
286e9fcaa8aSmrgdoes not discard the events in the queue.
287e9fcaa8aSmrgIf you passed 
288e9fcaa8aSmrg<symbol>True</symbol>,
289eb411b4bSmrg<xref linkend='XSync' xrefstyle='select: title'/>
290e9fcaa8aSmrgdiscards all events in the queue,
291e9fcaa8aSmrgincluding those events that were on the queue before
292eb411b4bSmrg<xref linkend='XSync' xrefstyle='select: title'/>
293e9fcaa8aSmrgwas called.
294e9fcaa8aSmrgClient applications seldom need to call
295eb411b4bSmrg<xref linkend='XSync' xrefstyle='select: title'/>.
296e9fcaa8aSmrg</para>
297e9fcaa8aSmrg</sect1>
298e9fcaa8aSmrg<sect1 id="Event_Queue_Management">
299e9fcaa8aSmrg<title>Event Queue Management</title>
300e9fcaa8aSmrg<!-- .XS -->
301e9fcaa8aSmrg<!-- (SN Event Queue Management -->
302e9fcaa8aSmrg<!-- .XE -->
303e9fcaa8aSmrg<para>
304e9fcaa8aSmrg<!-- .LP -->
305e9fcaa8aSmrgXlib maintains an event queue.
306e9fcaa8aSmrgHowever, the operating system also may be buffering data 
307e9fcaa8aSmrgin its network connection that is not yet read into the event queue.
308e9fcaa8aSmrg</para>
309e9fcaa8aSmrg<para>
310e9fcaa8aSmrg<!-- .LP -->
311e9fcaa8aSmrg<!-- .sp -->
312e9fcaa8aSmrgTo check the number of events in the event queue, use
313eb411b4bSmrg<xref linkend='XEventsQueued' xrefstyle='select: title'/>.
314eb411b4bSmrg</para>
315e9fcaa8aSmrg<indexterm significance="preferred"><primary>XEventsQueued</primary></indexterm>
316e9fcaa8aSmrg<!-- .sM -->
317eb411b4bSmrg<funcsynopsis id='XEventsQueued'>
318e9fcaa8aSmrg<funcprototype>
319e9fcaa8aSmrg  <funcdef>int <function>XEventsQueued</function></funcdef>
320e9fcaa8aSmrg  <paramdef>Display<parameter> *display</parameter></paramdef>
321e9fcaa8aSmrg  <paramdef>int<parameter> mode</parameter></paramdef>
322e9fcaa8aSmrg</funcprototype>
323e9fcaa8aSmrg</funcsynopsis>
324e9fcaa8aSmrg<!-- .FN -->
325e9fcaa8aSmrg<variablelist>
326e9fcaa8aSmrg  <varlistentry>
327e9fcaa8aSmrg    <term>
328e9fcaa8aSmrg      <emphasis remap='I'>display</emphasis>
329e9fcaa8aSmrg    </term>
330e9fcaa8aSmrg    <listitem>
331e9fcaa8aSmrg      <para>
332e9fcaa8aSmrgSpecifies the connection to the X server.
333e9fcaa8aSmrg      </para>
334e9fcaa8aSmrg    </listitem>
335e9fcaa8aSmrg  </varlistentry>
336e9fcaa8aSmrg  <varlistentry>
337e9fcaa8aSmrg    <term>
338e9fcaa8aSmrg      <emphasis remap='I'>mode</emphasis>
339e9fcaa8aSmrg    </term>
340e9fcaa8aSmrg    <listitem>
341e9fcaa8aSmrg      <para>
342e9fcaa8aSmrgSpecifies the mode.
343e9fcaa8aSmrgYou can pass
344e9fcaa8aSmrg<symbol>QueuedAlready</symbol>,
345e9fcaa8aSmrg<symbol>QueuedAfterFlush</symbol>,
346e9fcaa8aSmrgor
347e9fcaa8aSmrg<symbol>QueuedAfterReading</symbol>.
348e9fcaa8aSmrg    </para>
349e9fcaa8aSmrg  </listitem>
350e9fcaa8aSmrg  </varlistentry>
351e9fcaa8aSmrg</variablelist>
352e9fcaa8aSmrg<para>
353e9fcaa8aSmrg<!-- .LP -->
354e9fcaa8aSmrg<!-- .eM -->
355e9fcaa8aSmrgIf mode is 
356e9fcaa8aSmrg<symbol>QueuedAlready</symbol>,
357eb411b4bSmrg<xref linkend='XEventsQueued' xrefstyle='select: title'/>
358e9fcaa8aSmrgreturns the number of events
359e9fcaa8aSmrgalready in the event queue (and never performs a system call).
360e9fcaa8aSmrgIf mode is 
361e9fcaa8aSmrg<symbol>QueuedAfterFlush</symbol>,
362eb411b4bSmrg<xref linkend='XEventsQueued' xrefstyle='select: title'/>
363e9fcaa8aSmrgreturns the number of events already in the queue if the number is nonzero.
364e9fcaa8aSmrgIf there are no events in the queue, 
365eb411b4bSmrg<xref linkend='XEventsQueued' xrefstyle='select: title'/>
366e9fcaa8aSmrgflushes the output buffer, 
367e9fcaa8aSmrgattempts to read more events out of the application's connection,
368e9fcaa8aSmrgand returns the number read.
369e9fcaa8aSmrgIf mode is 
370e9fcaa8aSmrg<symbol>QueuedAfterReading</symbol>,
371eb411b4bSmrg<xref linkend='XEventsQueued' xrefstyle='select: title'/>
372e9fcaa8aSmrgreturns the number of events already in the queue if the number is nonzero. 
373e9fcaa8aSmrgIf there are no events in the queue, 
374eb411b4bSmrg<xref linkend='XEventsQueued' xrefstyle='select: title'/>
375e9fcaa8aSmrgattempts to read more events out of the application's connection 
376e9fcaa8aSmrgwithout flushing the output buffer and returns the number read.
377e9fcaa8aSmrg</para>
378e9fcaa8aSmrg<para>
379e9fcaa8aSmrg<!-- .LP -->
380eb411b4bSmrg<xref linkend='XEventsQueued' xrefstyle='select: title'/>
381e9fcaa8aSmrgalways returns immediately without I/O if there are events already in the
382e9fcaa8aSmrgqueue.
383eb411b4bSmrg<xref linkend='XEventsQueued' xrefstyle='select: title'/>
384e9fcaa8aSmrgwith mode 
385e9fcaa8aSmrg<symbol>QueuedAfterFlush</symbol>
386e9fcaa8aSmrgis identical in behavior to
387eb411b4bSmrg<xref linkend='XPending' xrefstyle='select: title'/>.
388eb411b4bSmrg<xref linkend='XEventsQueued' xrefstyle='select: title'/>
389e9fcaa8aSmrgwith mode
390e9fcaa8aSmrg<symbol>QueuedAlready</symbol>
391e9fcaa8aSmrgis identical to the
392eb411b4bSmrg<xref linkend='XQLength' xrefstyle='select: title'/>
393e9fcaa8aSmrgfunction.
394e9fcaa8aSmrg</para>
395e9fcaa8aSmrg<para>
396e9fcaa8aSmrg<!-- .LP -->
397e9fcaa8aSmrg<!-- .sp -->
398e9fcaa8aSmrgTo return the number of events that are pending, use 
399eb411b4bSmrg<xref linkend='XPending' xrefstyle='select: title'/>.
400eb411b4bSmrg</para>
401e9fcaa8aSmrg<indexterm significance="preferred"><primary>XPending</primary></indexterm>
402e9fcaa8aSmrg<!-- .sM -->
403eb411b4bSmrg<funcsynopsis id='XPending'>
404e9fcaa8aSmrg<funcprototype>
405e9fcaa8aSmrg  <funcdef>int <function>XPending</function></funcdef>
406e9fcaa8aSmrg  <paramdef>Display<parameter> *display</parameter></paramdef>
407e9fcaa8aSmrg</funcprototype>
408e9fcaa8aSmrg</funcsynopsis>
409e9fcaa8aSmrg<!-- .FN	 -->
410e9fcaa8aSmrg<variablelist>
411e9fcaa8aSmrg  <varlistentry>
412e9fcaa8aSmrg    <term>
413e9fcaa8aSmrg      <emphasis remap='I'>display</emphasis>
414e9fcaa8aSmrg    </term>
415e9fcaa8aSmrg    <listitem>
416e9fcaa8aSmrg      <para>
417e9fcaa8aSmrgSpecifies the connection to the X server.
418e9fcaa8aSmrg    </para>
419e9fcaa8aSmrg  </listitem>
420e9fcaa8aSmrg  </varlistentry>
421e9fcaa8aSmrg</variablelist>
422e9fcaa8aSmrg<para>
423e9fcaa8aSmrg<!-- .LP -->
424e9fcaa8aSmrg<!-- .eM -->
425e9fcaa8aSmrgThe
426eb411b4bSmrg<xref linkend='XPending' xrefstyle='select: title'/>
427e9fcaa8aSmrgfunction returns the number of events that have been received from the
428e9fcaa8aSmrgX server but have not been removed from the event queue.
429eb411b4bSmrg<xref linkend='XPending' xrefstyle='select: title'/>
430e9fcaa8aSmrgis identical to
431eb411b4bSmrg<xref linkend='XEventsQueued' xrefstyle='select: title'/>
432e9fcaa8aSmrgwith the mode
433e9fcaa8aSmrg<symbol>QueuedAfterFlush</symbol>
434e9fcaa8aSmrgspecified.
435e9fcaa8aSmrg</para>
436e9fcaa8aSmrg</sect1>
437e9fcaa8aSmrg<sect1 id="Manipulating_the_Event_Queue">
438e9fcaa8aSmrg<title>Manipulating the Event Queue</title>
439e9fcaa8aSmrg<!-- .XS -->
440e9fcaa8aSmrg<!-- (SN Manipulating the Event Queue  -->
441e9fcaa8aSmrg<!-- .XE -->
442e9fcaa8aSmrg<para>
443e9fcaa8aSmrg<!-- .LP -->
444e9fcaa8aSmrgXlib provides functions that let you manipulate the event queue.
445e9fcaa8aSmrgThis section discusses how to:
446e9fcaa8aSmrg</para>
447e9fcaa8aSmrg<itemizedlist>
448e9fcaa8aSmrg  <listitem>
449e9fcaa8aSmrg    <para>
450e9fcaa8aSmrgObtain events, in order, and remove them from the queue
451e9fcaa8aSmrg    </para>
452e9fcaa8aSmrg  </listitem>
453e9fcaa8aSmrg  <listitem>
454e9fcaa8aSmrg    <para>
455e9fcaa8aSmrgPeek at events in the queue without removing them
456e9fcaa8aSmrg    </para>
457e9fcaa8aSmrg  </listitem>
458e9fcaa8aSmrg  <listitem>
459e9fcaa8aSmrg    <para>
460e9fcaa8aSmrgObtain events that match the event mask or the arbitrary
461e9fcaa8aSmrgpredicate procedures that you provide
462e9fcaa8aSmrg    </para>
463e9fcaa8aSmrg  </listitem>
464e9fcaa8aSmrg</itemizedlist>
465e9fcaa8aSmrg<sect2 id="Returning_the_Next_Event">
466e9fcaa8aSmrg<title>Returning the Next Event</title>
467e9fcaa8aSmrg<!-- .XS -->
468e9fcaa8aSmrg<!-- (SN Returning the Next Event -->
469e9fcaa8aSmrg<!-- .XE -->
470e9fcaa8aSmrg<para>
471e9fcaa8aSmrg<!-- .LP -->
472e9fcaa8aSmrgTo get the next event and remove it from the queue, use
473eb411b4bSmrg<xref linkend='XNextEvent' xrefstyle='select: title'/>.
474eb411b4bSmrg</para>
475e9fcaa8aSmrg<indexterm significance="preferred"><primary>XNextEvent</primary></indexterm>
476e9fcaa8aSmrg<!-- .sM -->
477eb411b4bSmrg<funcsynopsis id='XNextEvent'>
478e9fcaa8aSmrg<funcprototype>
479e9fcaa8aSmrg  <funcdef><function>XNextEvent</function></funcdef>
480e9fcaa8aSmrg  <paramdef>Display<parameter> *display</parameter></paramdef>
481e9fcaa8aSmrg  <paramdef>XEvent<parameter> *event_return</parameter></paramdef>
482e9fcaa8aSmrg</funcprototype>
483e9fcaa8aSmrg</funcsynopsis>
484e9fcaa8aSmrg<!-- .FN -->
485e9fcaa8aSmrg<variablelist>
486e9fcaa8aSmrg  <varlistentry>
487e9fcaa8aSmrg    <term>
488e9fcaa8aSmrg      <emphasis remap='I'>display</emphasis>
489e9fcaa8aSmrg    </term>
490e9fcaa8aSmrg    <listitem>
491e9fcaa8aSmrg      <para>
492e9fcaa8aSmrgSpecifies the connection to the X server.
493e9fcaa8aSmrg      </para>
494e9fcaa8aSmrg    </listitem>
495e9fcaa8aSmrg  </varlistentry>
496e9fcaa8aSmrg  <varlistentry>
497e9fcaa8aSmrg    <term>
498e9fcaa8aSmrg      <emphasis remap='I'>event_return</emphasis>
499e9fcaa8aSmrg    </term>
500e9fcaa8aSmrg    <listitem>
501e9fcaa8aSmrg      <para>
502e9fcaa8aSmrgReturns the next event in the queue.
503e9fcaa8aSmrg    </para>
504e9fcaa8aSmrg  </listitem>
505e9fcaa8aSmrg  </varlistentry>
506e9fcaa8aSmrg</variablelist>
507e9fcaa8aSmrg<para>
508e9fcaa8aSmrg<!-- .LP -->
509e9fcaa8aSmrg<!-- .eM -->
510e9fcaa8aSmrgThe
511eb411b4bSmrg<xref linkend='XNextEvent' xrefstyle='select: title'/>
512e9fcaa8aSmrgfunction copies the first event from the event queue into the specified
513e9fcaa8aSmrg<structname>XEvent</structname>
514e9fcaa8aSmrgstructure and then removes it from the queue.
515e9fcaa8aSmrgIf the event queue is empty,
516eb411b4bSmrg<xref linkend='XNextEvent' xrefstyle='select: title'/>
517e9fcaa8aSmrgflushes the output buffer and blocks until an event is received.
518e9fcaa8aSmrg</para>
519e9fcaa8aSmrg<para>
520e9fcaa8aSmrg<!-- .LP -->
521e9fcaa8aSmrg<!-- .sp -->
522e9fcaa8aSmrgTo peek at the event queue, use
523eb411b4bSmrg<xref linkend='XPeekEvent' xrefstyle='select: title'/>.
524eb411b4bSmrg</para>
525e9fcaa8aSmrg<indexterm significance="preferred"><primary>XPeekEvent</primary></indexterm>
526e9fcaa8aSmrg<!-- .sM -->
527eb411b4bSmrg<funcsynopsis id='XPeekEvent'>
528e9fcaa8aSmrg<funcprototype>
529e9fcaa8aSmrg  <funcdef><function>XPeekEvent</function></funcdef>
530e9fcaa8aSmrg  <paramdef>Display<parameter> *display</parameter></paramdef>
531e9fcaa8aSmrg  <paramdef>XEvent<parameter> *event_return</parameter></paramdef>
532e9fcaa8aSmrg</funcprototype>
533e9fcaa8aSmrg</funcsynopsis>
534e9fcaa8aSmrg<!-- .FN -->
535e9fcaa8aSmrg<variablelist>
536e9fcaa8aSmrg  <varlistentry>
537e9fcaa8aSmrg    <term>
538e9fcaa8aSmrg      <emphasis remap='I'>display</emphasis>
539e9fcaa8aSmrg    </term>
540e9fcaa8aSmrg    <listitem>
541e9fcaa8aSmrg      <para>
542e9fcaa8aSmrgSpecifies the connection to the X server.
543e9fcaa8aSmrg      </para>
544e9fcaa8aSmrg    </listitem>
545e9fcaa8aSmrg  </varlistentry>
546e9fcaa8aSmrg  <varlistentry>
547e9fcaa8aSmrg    <term>
548e9fcaa8aSmrg      <emphasis remap='I'>event_return</emphasis>
549e9fcaa8aSmrg    </term>
550e9fcaa8aSmrg    <listitem>
551e9fcaa8aSmrg      <para>
552e9fcaa8aSmrgReturns a copy of the matched event's associated structure.
553e9fcaa8aSmrg    </para>
554e9fcaa8aSmrg  </listitem>
555e9fcaa8aSmrg  </varlistentry>
556e9fcaa8aSmrg</variablelist>
557e9fcaa8aSmrg<para>
558e9fcaa8aSmrg<!-- .LP -->
559e9fcaa8aSmrg<!-- .eM -->
560e9fcaa8aSmrgThe
561eb411b4bSmrg<xref linkend='XPeekEvent' xrefstyle='select: title'/>
562e9fcaa8aSmrgfunction returns the first event from the event queue,
563e9fcaa8aSmrgbut it does not remove the event from the queue.
564e9fcaa8aSmrgIf the queue is empty,
565eb411b4bSmrg<xref linkend='XPeekEvent' xrefstyle='select: title'/>
566e9fcaa8aSmrgflushes the output buffer and blocks until an event is received.
567e9fcaa8aSmrgIt then copies the event into the client-supplied
568e9fcaa8aSmrg<structname>XEvent</structname>
569e9fcaa8aSmrgstructure without removing it from the event queue.
570e9fcaa8aSmrg</para>
571e9fcaa8aSmrg</sect2>
572e9fcaa8aSmrg<sect2 id="Selecting_Events_Using_a_Predicate_Procedure">
573e9fcaa8aSmrg<title>Selecting Events Using a Predicate Procedure</title>
574e9fcaa8aSmrg<!-- .XS -->
575e9fcaa8aSmrg<!-- (SN Selecting Events Using a Predicate Procedure -->
576e9fcaa8aSmrg<!-- .XE -->
577e9fcaa8aSmrg<para>
578e9fcaa8aSmrg<!-- .LP -->
579e9fcaa8aSmrgEach of the functions discussed in this section requires you to
580e9fcaa8aSmrgpass a predicate procedure that determines if an event matches 
581e9fcaa8aSmrgwhat you want.
582e9fcaa8aSmrgYour predicate procedure must decide if the event is useful
583e9fcaa8aSmrgwithout calling any Xlib functions.
584e9fcaa8aSmrgIf the predicate directly or indirectly causes the state of the event queue
585e9fcaa8aSmrgto change, the result is not defined.
586e9fcaa8aSmrgIf Xlib has been initialized for threads, the predicate is called with
587e9fcaa8aSmrgthe display locked and the result of a call by the predicate to any
588e9fcaa8aSmrgXlib function that locks the display is not defined unless the caller
589e9fcaa8aSmrghas first called
590e9fcaa8aSmrg<function>XLockDisplay</function>.
591e9fcaa8aSmrg</para>
592e9fcaa8aSmrg<para>
593e9fcaa8aSmrg<!-- .LP -->
594e9fcaa8aSmrgThe predicate procedure and its associated arguments are:
595eb411b4bSmrg</para>
596e9fcaa8aSmrg<!-- .sM -->
597e9fcaa8aSmrg<funcsynopsis>
598e9fcaa8aSmrg<funcprototype>
599e9fcaa8aSmrg  <funcdef><type>Bool</type></funcdef>
600e9fcaa8aSmrg  <paramdef>Display<parameter> *display</parameter></paramdef>
601e9fcaa8aSmrg  <paramdef>XEvent<parameter> *event</parameter></paramdef>
602e9fcaa8aSmrg  <paramdef>XPointer<parameter> arg</parameter></paramdef>
603e9fcaa8aSmrg</funcprototype>
604e9fcaa8aSmrg</funcsynopsis>
605e9fcaa8aSmrg<!-- .FN -->
606e9fcaa8aSmrg<variablelist>
607e9fcaa8aSmrg  <varlistentry>
608e9fcaa8aSmrg    <term>
609e9fcaa8aSmrg      <emphasis remap='I'>display</emphasis>
610e9fcaa8aSmrg    </term>
611e9fcaa8aSmrg    <listitem>
612e9fcaa8aSmrg      <para>
613e9fcaa8aSmrgSpecifies the connection to the X server.
614e9fcaa8aSmrg      </para>
615e9fcaa8aSmrg    </listitem>
616e9fcaa8aSmrg  </varlistentry>
617e9fcaa8aSmrg  <varlistentry>
618e9fcaa8aSmrg    <term>
619e9fcaa8aSmrg      <emphasis remap='I'>event</emphasis>
620e9fcaa8aSmrg    </term>
621e9fcaa8aSmrg    <listitem>
622e9fcaa8aSmrg      <para>
623e9fcaa8aSmrgSpecifies the
624e9fcaa8aSmrg<structname>XEvent</structname>
625e9fcaa8aSmrgstructure.
626e9fcaa8aSmrg      </para>
627e9fcaa8aSmrg    </listitem>
628e9fcaa8aSmrg  </varlistentry>
629e9fcaa8aSmrg  <varlistentry>
630e9fcaa8aSmrg    <term>
631e9fcaa8aSmrg      <emphasis remap='I'>arg</emphasis>
632e9fcaa8aSmrg    </term>
633e9fcaa8aSmrg    <listitem>
634e9fcaa8aSmrg      <para>
635e9fcaa8aSmrgSpecifies the argument passed in from the 
636eb411b4bSmrg<xref linkend='XIfEvent' xrefstyle='select: title'/>,
637eb411b4bSmrg<xref linkend='XCheckIfEvent' xrefstyle='select: title'/>,
638e9fcaa8aSmrgor
639eb411b4bSmrg<xref linkend='XPeekIfEvent' xrefstyle='select: title'/>
640e9fcaa8aSmrgfunction.
641e9fcaa8aSmrg    </para>
642e9fcaa8aSmrg  </listitem>
643e9fcaa8aSmrg  </varlistentry>
644e9fcaa8aSmrg</variablelist>
645e9fcaa8aSmrg<para>
646e9fcaa8aSmrg<!-- .LP -->
647e9fcaa8aSmrg<!-- .eM -->
648e9fcaa8aSmrgThe predicate procedure is called once for each
649e9fcaa8aSmrgevent in the queue until it finds a match. 
650e9fcaa8aSmrgAfter finding a match, the predicate procedure must return 
651e9fcaa8aSmrg<symbol>True</symbol>.
652e9fcaa8aSmrgIf it did not find a match, it must return
653e9fcaa8aSmrg<symbol>False</symbol>.
654e9fcaa8aSmrg</para>
655e9fcaa8aSmrg<para>
656e9fcaa8aSmrg<!-- .LP -->
657e9fcaa8aSmrg<!-- .sp -->
658e9fcaa8aSmrgTo check the event queue for a matching event
659e9fcaa8aSmrgand, if found, remove the event from the queue, use
660eb411b4bSmrg<xref linkend='XIfEvent' xrefstyle='select: title'/>.
661eb411b4bSmrg</para>
662e9fcaa8aSmrg<indexterm significance="preferred"><primary>XIfEvent</primary></indexterm>
663e9fcaa8aSmrg<!-- .sM -->
664eb411b4bSmrg<funcsynopsis id='XIfEvent'>
665e9fcaa8aSmrg<funcprototype>
666e9fcaa8aSmrg  <funcdef><function>XIfEvent</function></funcdef>
667e9fcaa8aSmrg  <paramdef>Display<parameter> *display</parameter></paramdef>
668e9fcaa8aSmrg  <paramdef>XEvent<parameter> *event_return</parameter></paramdef>
669e9fcaa8aSmrg  <paramdef>Bool<parameter> (*predicate)()</parameter></paramdef>
670e9fcaa8aSmrg  <paramdef>XPointer<parameter> arg</parameter></paramdef>
671e9fcaa8aSmrg</funcprototype>
672e9fcaa8aSmrg</funcsynopsis>
673e9fcaa8aSmrg<!-- .FN -->
674e9fcaa8aSmrg<variablelist>
675e9fcaa8aSmrg  <varlistentry>
676e9fcaa8aSmrg    <term>
677e9fcaa8aSmrg      <emphasis remap='I'>display</emphasis>
678e9fcaa8aSmrg    </term>
679e9fcaa8aSmrg    <listitem>
680e9fcaa8aSmrg      <para>
681e9fcaa8aSmrgSpecifies the connection to the X server.
682e9fcaa8aSmrg      </para>
683e9fcaa8aSmrg    </listitem>
684e9fcaa8aSmrg  </varlistentry>
685e9fcaa8aSmrg  <varlistentry>
686e9fcaa8aSmrg    <term>
687e9fcaa8aSmrg      <emphasis remap='I'>event_return</emphasis>
688e9fcaa8aSmrg    </term>
689e9fcaa8aSmrg    <listitem>
690e9fcaa8aSmrg      <para>
691e9fcaa8aSmrgReturns the matched event's associated structure.
692e9fcaa8aSmrg      </para>
693e9fcaa8aSmrg    </listitem>
694e9fcaa8aSmrg  </varlistentry>
695e9fcaa8aSmrg  <varlistentry>
696e9fcaa8aSmrg    <term>
697e9fcaa8aSmrg      <emphasis remap='I'>predicate</emphasis>
698e9fcaa8aSmrg    </term>
699e9fcaa8aSmrg    <listitem>
700e9fcaa8aSmrg      <para>
701e9fcaa8aSmrgSpecifies the procedure that is to be called to determine
702e9fcaa8aSmrgif the next event in the queue matches what you want.
703e9fcaa8aSmrg      </para>
704e9fcaa8aSmrg    </listitem>
705e9fcaa8aSmrg  </varlistentry>
706e9fcaa8aSmrg  <varlistentry>
707e9fcaa8aSmrg    <term>
708e9fcaa8aSmrg      <emphasis remap='I'>arg</emphasis>
709e9fcaa8aSmrg    </term>
710e9fcaa8aSmrg    <listitem>
711e9fcaa8aSmrg      <para>
712e9fcaa8aSmrgSpecifies the user-supplied argument that will be passed to the predicate procedure.
713e9fcaa8aSmrg    </para>
714e9fcaa8aSmrg  </listitem>
715e9fcaa8aSmrg  </varlistentry>
716e9fcaa8aSmrg</variablelist>
717e9fcaa8aSmrg<para>
718e9fcaa8aSmrg<!-- .LP -->
719e9fcaa8aSmrg<!-- .eM -->
720e9fcaa8aSmrgThe
721eb411b4bSmrg<xref linkend='XIfEvent' xrefstyle='select: title'/>
722e9fcaa8aSmrgfunction completes only when the specified predicate
723e9fcaa8aSmrgprocedure returns 
724e9fcaa8aSmrg<symbol>True</symbol>
725e9fcaa8aSmrgfor an event, 
726e9fcaa8aSmrgwhich indicates an event in the queue matches.
727eb411b4bSmrg<xref linkend='XIfEvent' xrefstyle='select: title'/>
728e9fcaa8aSmrgflushes the output buffer if it blocks waiting for additional events.
729eb411b4bSmrg<xref linkend='XIfEvent' xrefstyle='select: title'/>
730e9fcaa8aSmrgremoves the matching event from the queue 
731e9fcaa8aSmrgand copies the structure into the client-supplied
732e9fcaa8aSmrg<structname>XEvent</structname>
733e9fcaa8aSmrgstructure.
734e9fcaa8aSmrg</para>
735e9fcaa8aSmrg<para>
736e9fcaa8aSmrg<!-- .LP -->
737e9fcaa8aSmrg<!-- .sp -->
738e9fcaa8aSmrgTo check the event queue for a matching event without blocking, use
739eb411b4bSmrg<xref linkend='XCheckIfEvent' xrefstyle='select: title'/>.
740eb411b4bSmrg</para>
741e9fcaa8aSmrg<indexterm significance="preferred"><primary>XCheckIfEvent</primary></indexterm>
742e9fcaa8aSmrg<!-- .sM -->
743eb411b4bSmrg<funcsynopsis id='XCheckIfEvent'>
744e9fcaa8aSmrg<funcprototype>
745e9fcaa8aSmrg  <funcdef>Bool <function>XCheckIfEvent</function></funcdef>
746e9fcaa8aSmrg  <paramdef>Display<parameter> *display</parameter></paramdef>
747e9fcaa8aSmrg  <paramdef>XEvent<parameter> *event_return</parameter></paramdef>
748e9fcaa8aSmrg  <paramdef>Bool<parameter> (*predicate)()</parameter></paramdef>
749e9fcaa8aSmrg  <paramdef>XPointer<parameter> arg</parameter></paramdef>
750e9fcaa8aSmrg</funcprototype>
751e9fcaa8aSmrg</funcsynopsis>
752e9fcaa8aSmrg<!-- .FN -->
753e9fcaa8aSmrg<variablelist>
754e9fcaa8aSmrg  <varlistentry>
755e9fcaa8aSmrg    <term>
756e9fcaa8aSmrg      <emphasis remap='I'>display</emphasis>
757e9fcaa8aSmrg    </term>
758e9fcaa8aSmrg    <listitem>
759e9fcaa8aSmrg      <para>
760e9fcaa8aSmrgSpecifies the connection to the X server.
761e9fcaa8aSmrg      </para>
762e9fcaa8aSmrg    </listitem>
763e9fcaa8aSmrg  </varlistentry>
764e9fcaa8aSmrg  <varlistentry>
765e9fcaa8aSmrg    <term>
766e9fcaa8aSmrg      <emphasis remap='I'>event_return</emphasis>
767e9fcaa8aSmrg    </term>
768e9fcaa8aSmrg    <listitem>
769e9fcaa8aSmrg      <para>
770e9fcaa8aSmrgReturns a copy of the matched event's associated structure.
771e9fcaa8aSmrg      </para>
772e9fcaa8aSmrg    </listitem>
773e9fcaa8aSmrg  </varlistentry>
774e9fcaa8aSmrg  <varlistentry>
775e9fcaa8aSmrg    <term>
776e9fcaa8aSmrg      <emphasis remap='I'>predicate</emphasis>
777e9fcaa8aSmrg    </term>
778e9fcaa8aSmrg    <listitem>
779e9fcaa8aSmrg      <para>
780e9fcaa8aSmrgSpecifies the procedure that is to be called to determine
781e9fcaa8aSmrgif the next event in the queue matches what you want.
782e9fcaa8aSmrg      </para>
783e9fcaa8aSmrg    </listitem>
784e9fcaa8aSmrg  </varlistentry>
785e9fcaa8aSmrg  <varlistentry>
786e9fcaa8aSmrg    <term>
787e9fcaa8aSmrg      <emphasis remap='I'>arg</emphasis>
788e9fcaa8aSmrg    </term>
789e9fcaa8aSmrg    <listitem>
790e9fcaa8aSmrg      <para>
791e9fcaa8aSmrgSpecifies the user-supplied argument that will be passed to the predicate procedure.
792e9fcaa8aSmrg    </para>
793e9fcaa8aSmrg  </listitem>
794e9fcaa8aSmrg  </varlistentry>
795e9fcaa8aSmrg</variablelist>
796e9fcaa8aSmrg<para>
797e9fcaa8aSmrg<!-- .LP -->
798e9fcaa8aSmrg<!-- .eM -->
799e9fcaa8aSmrgWhen the predicate procedure finds a match,
800eb411b4bSmrg<xref linkend='XCheckIfEvent' xrefstyle='select: title'/>
801e9fcaa8aSmrgcopies the matched event into the client-supplied
802e9fcaa8aSmrg<structname>XEvent</structname>
803e9fcaa8aSmrgstructure and returns 
804e9fcaa8aSmrg<symbol>True</symbol>.
805e9fcaa8aSmrg(This event is removed from the queue.)
806e9fcaa8aSmrgIf the predicate procedure finds no match,
807eb411b4bSmrg<xref linkend='XCheckIfEvent' xrefstyle='select: title'/>
808e9fcaa8aSmrgreturns
809e9fcaa8aSmrg<symbol>False</symbol>,
810e9fcaa8aSmrgand the output buffer will have been flushed.
811e9fcaa8aSmrgAll earlier events stored in the queue are not discarded.
812e9fcaa8aSmrg</para>
813e9fcaa8aSmrg<para>
814e9fcaa8aSmrg<!-- .LP -->
815e9fcaa8aSmrg<!-- .sp -->
816e9fcaa8aSmrgTo check the event queue for a matching event
817e9fcaa8aSmrgwithout removing the event from the queue, use
818eb411b4bSmrg<xref linkend='XPeekIfEvent' xrefstyle='select: title'/>.
819eb411b4bSmrg</para>
820e9fcaa8aSmrg<indexterm significance="preferred"><primary>XPeekIfEvent</primary></indexterm>
821e9fcaa8aSmrg<!-- .sM -->
822eb411b4bSmrg<funcsynopsis id='XPeekIfEvent'>
823e9fcaa8aSmrg<funcprototype>
824e9fcaa8aSmrg  <funcdef><function>XPeekIfEvent</function></funcdef>
825e9fcaa8aSmrg  <paramdef>Display<parameter> *display</parameter></paramdef>
826e9fcaa8aSmrg  <paramdef>XEvent<parameter> *event_return</parameter></paramdef>
827e9fcaa8aSmrg  <paramdef>Bool<parameter> (*predicate)()</parameter></paramdef>
828e9fcaa8aSmrg  <paramdef>XPointer<parameter> arg</parameter></paramdef>
829e9fcaa8aSmrg</funcprototype>
830e9fcaa8aSmrg</funcsynopsis>
831e9fcaa8aSmrg<!-- .FN -->
832e9fcaa8aSmrg<variablelist>
833e9fcaa8aSmrg  <varlistentry>
834e9fcaa8aSmrg    <term>
835e9fcaa8aSmrg      <emphasis remap='I'>display</emphasis>
836e9fcaa8aSmrg    </term>
837e9fcaa8aSmrg    <listitem>
838e9fcaa8aSmrg      <para>
839e9fcaa8aSmrgSpecifies the connection to the X server.
840e9fcaa8aSmrg      </para>
841e9fcaa8aSmrg    </listitem>
842e9fcaa8aSmrg  </varlistentry>
843e9fcaa8aSmrg  <varlistentry>
844e9fcaa8aSmrg    <term>
845e9fcaa8aSmrg      <emphasis remap='I'>event_return</emphasis>
846e9fcaa8aSmrg    </term>
847e9fcaa8aSmrg    <listitem>
848e9fcaa8aSmrg      <para>
849e9fcaa8aSmrgReturns a copy of the matched event's associated structure.
850e9fcaa8aSmrg      </para>
851e9fcaa8aSmrg    </listitem>
852e9fcaa8aSmrg  </varlistentry>
853e9fcaa8aSmrg  <varlistentry>
854e9fcaa8aSmrg    <term>
855e9fcaa8aSmrg      <emphasis remap='I'>predicate</emphasis>
856e9fcaa8aSmrg    </term>
857e9fcaa8aSmrg    <listitem>
858e9fcaa8aSmrg      <para>
859e9fcaa8aSmrgSpecifies the procedure that is to be called to determine
860e9fcaa8aSmrgif the next event in the queue matches what you want.
861e9fcaa8aSmrg      </para>
862e9fcaa8aSmrg    </listitem>
863e9fcaa8aSmrg  </varlistentry>
864e9fcaa8aSmrg  <varlistentry>
865e9fcaa8aSmrg    <term>
866e9fcaa8aSmrg      <emphasis remap='I'>arg</emphasis>
867e9fcaa8aSmrg    </term>
868e9fcaa8aSmrg    <listitem>
869e9fcaa8aSmrg      <para>
870e9fcaa8aSmrgSpecifies the user-supplied argument that will be passed to the predicate procedure.
871e9fcaa8aSmrg    </para>
872e9fcaa8aSmrg  </listitem>
873e9fcaa8aSmrg  </varlistentry>
874e9fcaa8aSmrg</variablelist>
875e9fcaa8aSmrg<para>
876e9fcaa8aSmrg<!-- .LP -->
877e9fcaa8aSmrg<!-- .eM -->
878e9fcaa8aSmrgThe
879eb411b4bSmrg<xref linkend='XPeekIfEvent' xrefstyle='select: title'/>
880e9fcaa8aSmrgfunction returns only when the specified predicate
881e9fcaa8aSmrgprocedure returns 
882e9fcaa8aSmrg<symbol>True</symbol>
883e9fcaa8aSmrgfor an event.
884e9fcaa8aSmrgAfter the predicate procedure finds a match,
885eb411b4bSmrg<xref linkend='XPeekIfEvent' xrefstyle='select: title'/>
886e9fcaa8aSmrgcopies the matched event into the client-supplied
887e9fcaa8aSmrg<structname>XEvent</structname>
888e9fcaa8aSmrgstructure without removing the event from the queue.
889eb411b4bSmrg<xref linkend='XPeekIfEvent' xrefstyle='select: title'/>
890e9fcaa8aSmrgflushes the output buffer if it blocks waiting for additional events.
891e9fcaa8aSmrg</para>
892e9fcaa8aSmrg</sect2>
893e9fcaa8aSmrg<sect2 id="Selecting_Events_Using_a_Window_or_Event_Mask">
894e9fcaa8aSmrg<title>Selecting Events Using a Window or Event Mask</title>
895e9fcaa8aSmrg<!-- .XS -->
896e9fcaa8aSmrg<!-- (SN Selecting Events Using a Window or Event Mask -->
897e9fcaa8aSmrg<!-- .XE -->
898e9fcaa8aSmrg<para>
899e9fcaa8aSmrg<!-- .LP -->
900e9fcaa8aSmrgThe functions discussed in this section let you select events by window 
901e9fcaa8aSmrgor event types, allowing you to process events out of order.
902e9fcaa8aSmrg</para>
903e9fcaa8aSmrg<para>
904e9fcaa8aSmrg<!-- .LP -->
905e9fcaa8aSmrg<!-- .sp -->
906e9fcaa8aSmrgTo remove the next event that matches both a window and an event mask, use
907eb411b4bSmrg<xref linkend='XWindowEvent' xrefstyle='select: title'/>.
908eb411b4bSmrg</para>
909e9fcaa8aSmrg<indexterm significance="preferred"><primary>XWindowEvent</primary></indexterm>
910e9fcaa8aSmrg<!-- .sM -->
911eb411b4bSmrg<funcsynopsis id='XWindowEvent'>
912e9fcaa8aSmrg<funcprototype>
913e9fcaa8aSmrg  <funcdef><function>XWindowEvent</function></funcdef>
914e9fcaa8aSmrg  <paramdef>Display<parameter> *display</parameter></paramdef>
915e9fcaa8aSmrg  <paramdef>Window<parameter> w</parameter></paramdef>
916e9fcaa8aSmrg  <paramdef>long<parameter> event_mask</parameter></paramdef>
917e9fcaa8aSmrg  <paramdef>XEvent<parameter> *event_return</parameter></paramdef>
918e9fcaa8aSmrg</funcprototype>
919e9fcaa8aSmrg</funcsynopsis>
920e9fcaa8aSmrg<!-- .FN -->
921e9fcaa8aSmrg<variablelist>
922e9fcaa8aSmrg  <varlistentry>
923e9fcaa8aSmrg    <term>
924e9fcaa8aSmrg      <emphasis remap='I'>display</emphasis>
925e9fcaa8aSmrg    </term>
926e9fcaa8aSmrg    <listitem>
927e9fcaa8aSmrg      <para>
928e9fcaa8aSmrgSpecifies the connection to the X server.
929e9fcaa8aSmrg<!-- .ds Wi whose events you are interested in -->
930e9fcaa8aSmrg      </para>
931e9fcaa8aSmrg    </listitem>
932e9fcaa8aSmrg  </varlistentry>
933e9fcaa8aSmrg  <varlistentry>
934e9fcaa8aSmrg    <term>
935e9fcaa8aSmrg      <emphasis remap='I'>w</emphasis>
936e9fcaa8aSmrg    </term>
937e9fcaa8aSmrg    <listitem>
938e9fcaa8aSmrg      <para>
939e9fcaa8aSmrgSpecifies the window (Wi.
940e9fcaa8aSmrg      </para>
941e9fcaa8aSmrg    </listitem>
942e9fcaa8aSmrg  </varlistentry>
943e9fcaa8aSmrg  <varlistentry>
944e9fcaa8aSmrg    <term>
945e9fcaa8aSmrg      <emphasis remap='I'>event_mask</emphasis>
946e9fcaa8aSmrg    </term>
947e9fcaa8aSmrg    <listitem>
948e9fcaa8aSmrg      <para>
949e9fcaa8aSmrgSpecifies the event mask.
950e9fcaa8aSmrg      </para>
951e9fcaa8aSmrg    </listitem>
952e9fcaa8aSmrg  </varlistentry>
953e9fcaa8aSmrg  <varlistentry>
954e9fcaa8aSmrg    <term>
955e9fcaa8aSmrg      <emphasis remap='I'>event_return</emphasis>
956e9fcaa8aSmrg    </term>
957e9fcaa8aSmrg    <listitem>
958e9fcaa8aSmrg      <para>
959e9fcaa8aSmrgReturns the matched event's associated structure.
960e9fcaa8aSmrg    </para>
961e9fcaa8aSmrg  </listitem>
962e9fcaa8aSmrg  </varlistentry>
963e9fcaa8aSmrg</variablelist>
964e9fcaa8aSmrg<para>
965e9fcaa8aSmrg<!-- .LP -->
966e9fcaa8aSmrg<!-- .eM -->
967e9fcaa8aSmrgThe
968eb411b4bSmrg<xref linkend='XWindowEvent' xrefstyle='select: title'/>
969e9fcaa8aSmrgfunction searches the event queue for an event that matches both the specified
970e9fcaa8aSmrgwindow and event mask.
971e9fcaa8aSmrgWhen it finds a match,
972eb411b4bSmrg<xref linkend='XWindowEvent' xrefstyle='select: title'/>
973e9fcaa8aSmrgremoves that event from the queue and copies it into the specified
974e9fcaa8aSmrg<structname>XEvent</structname>
975e9fcaa8aSmrgstructure.
976e9fcaa8aSmrgThe other events stored in the queue are not discarded.
977e9fcaa8aSmrgIf a matching event is not in the queue,
978eb411b4bSmrg<xref linkend='XWindowEvent' xrefstyle='select: title'/>
979e9fcaa8aSmrgflushes the output buffer and blocks until one is received.
980e9fcaa8aSmrg</para>
981e9fcaa8aSmrg<para>
982e9fcaa8aSmrg<!-- .LP -->
983e9fcaa8aSmrg<!-- .sp -->
984e9fcaa8aSmrgTo remove the next event that matches both a window and an event mask (if any),
985e9fcaa8aSmrguse
986eb411b4bSmrg<xref linkend='XCheckWindowEvent' xrefstyle='select: title'/>.
987e9fcaa8aSmrg<indexterm><primary>XCheckWindowEvent</primary></indexterm>
988e9fcaa8aSmrgThis function is similar to
989eb411b4bSmrg<xref linkend='XWindowEvent' xrefstyle='select: title'/>
990e9fcaa8aSmrgexcept that it never blocks and it returns a 
991e9fcaa8aSmrg<type>Bool</type>
992e9fcaa8aSmrgindicating if the event was returned.
993eb411b4bSmrg</para>
994e9fcaa8aSmrg<indexterm significance="preferred"><primary>XCheckWindowEvent</primary></indexterm>
995e9fcaa8aSmrg<!-- .sM -->
996eb411b4bSmrg<funcsynopsis id='XCheckWindowEvent'>
997e9fcaa8aSmrg<funcprototype>
998e9fcaa8aSmrg  <funcdef>Bool <function>XCheckWindowEvent</function></funcdef>
999e9fcaa8aSmrg  <paramdef>Display<parameter> *display</parameter></paramdef>
1000e9fcaa8aSmrg  <paramdef>Window<parameter> w</parameter></paramdef>
1001e9fcaa8aSmrg  <paramdef>long<parameter> event_mask</parameter></paramdef>
1002e9fcaa8aSmrg  <paramdef>XEvent<parameter> *event_return</parameter></paramdef>
1003e9fcaa8aSmrg</funcprototype>
1004e9fcaa8aSmrg</funcsynopsis>
1005e9fcaa8aSmrg<!-- .FN -->
1006e9fcaa8aSmrg<variablelist>
1007e9fcaa8aSmrg  <varlistentry>
1008e9fcaa8aSmrg    <term>
1009e9fcaa8aSmrg      <emphasis remap='I'>display</emphasis>
1010e9fcaa8aSmrg    </term>
1011e9fcaa8aSmrg    <listitem>
1012e9fcaa8aSmrg      <para>
1013e9fcaa8aSmrgSpecifies the connection to the X server.
1014e9fcaa8aSmrg<!-- .ds Wi whose events you are interested in -->
1015e9fcaa8aSmrg      </para>
1016e9fcaa8aSmrg    </listitem>
1017e9fcaa8aSmrg  </varlistentry>
1018e9fcaa8aSmrg  <varlistentry>
1019e9fcaa8aSmrg    <term>
1020e9fcaa8aSmrg      <emphasis remap='I'>w</emphasis>
1021e9fcaa8aSmrg    </term>
1022e9fcaa8aSmrg    <listitem>
1023e9fcaa8aSmrg      <para>
1024e9fcaa8aSmrgSpecifies the window (Wi.
1025e9fcaa8aSmrg      </para>
1026e9fcaa8aSmrg    </listitem>
1027e9fcaa8aSmrg  </varlistentry>
1028e9fcaa8aSmrg  <varlistentry>
1029e9fcaa8aSmrg    <term>
1030e9fcaa8aSmrg      <emphasis remap='I'>event_mask</emphasis>
1031e9fcaa8aSmrg    </term>
1032e9fcaa8aSmrg    <listitem>
1033e9fcaa8aSmrg      <para>
1034e9fcaa8aSmrgSpecifies the event mask.
1035e9fcaa8aSmrg      </para>
1036e9fcaa8aSmrg    </listitem>
1037e9fcaa8aSmrg  </varlistentry>
1038e9fcaa8aSmrg  <varlistentry>
1039e9fcaa8aSmrg    <term>
1040e9fcaa8aSmrg      <emphasis remap='I'>event_return</emphasis>
1041e9fcaa8aSmrg    </term>
1042e9fcaa8aSmrg    <listitem>
1043e9fcaa8aSmrg      <para>
1044e9fcaa8aSmrgReturns the matched event's associated structure.
1045e9fcaa8aSmrg    </para>
1046e9fcaa8aSmrg  </listitem>
1047e9fcaa8aSmrg  </varlistentry>
1048e9fcaa8aSmrg</variablelist>
1049e9fcaa8aSmrg<para>
1050e9fcaa8aSmrg<!-- .LP -->
1051e9fcaa8aSmrg<!-- .eM -->
1052e9fcaa8aSmrgThe
1053eb411b4bSmrg<xref linkend='XCheckWindowEvent' xrefstyle='select: title'/>
1054e9fcaa8aSmrgfunction searches the event queue and then the events available 
1055e9fcaa8aSmrgon the server connection for the first event that matches the specified window
1056e9fcaa8aSmrgand event mask.
1057e9fcaa8aSmrgIf it finds a match,
1058eb411b4bSmrg<xref linkend='XCheckWindowEvent' xrefstyle='select: title'/>
1059e9fcaa8aSmrgremoves that event, copies it into the specified
1060e9fcaa8aSmrg<structname>XEvent</structname>
1061e9fcaa8aSmrgstructure, and returns
1062e9fcaa8aSmrg<symbol>True</symbol>.
1063e9fcaa8aSmrgThe other events stored in the queue are not discarded.
1064e9fcaa8aSmrgIf the event you requested is not available,
1065eb411b4bSmrg<xref linkend='XCheckWindowEvent' xrefstyle='select: title'/>
1066e9fcaa8aSmrgreturns
1067e9fcaa8aSmrg<symbol>False</symbol>,
1068e9fcaa8aSmrgand the output buffer will have been flushed.
1069e9fcaa8aSmrg</para>
1070e9fcaa8aSmrg<para>
1071e9fcaa8aSmrg<!-- .LP -->
1072e9fcaa8aSmrg<!-- .sp -->
1073e9fcaa8aSmrgTo remove the next event that matches an event mask, use
1074eb411b4bSmrg<xref linkend='XMaskEvent' xrefstyle='select: title'/>.
1075eb411b4bSmrg</para>
1076e9fcaa8aSmrg<indexterm significance="preferred"><primary>XMaskEvent</primary></indexterm>
1077e9fcaa8aSmrg<!-- .sM -->
1078eb411b4bSmrg<funcsynopsis id='XMaskEvent'>
1079e9fcaa8aSmrg<funcprototype>
1080e9fcaa8aSmrg  <funcdef><function>XMaskEvent</function></funcdef>
1081e9fcaa8aSmrg  <paramdef>Display<parameter> *display</parameter></paramdef>
1082e9fcaa8aSmrg  <paramdef>long<parameter> event_mask</parameter></paramdef>
1083e9fcaa8aSmrg  <paramdef>XEvent<parameter> *event_return</parameter></paramdef>
1084e9fcaa8aSmrg</funcprototype>
1085e9fcaa8aSmrg</funcsynopsis>
1086e9fcaa8aSmrg<!-- .FN -->
1087e9fcaa8aSmrg<variablelist>
1088e9fcaa8aSmrg  <varlistentry>
1089e9fcaa8aSmrg    <term>
1090e9fcaa8aSmrg      <emphasis remap='I'>display</emphasis>
1091e9fcaa8aSmrg    </term>
1092e9fcaa8aSmrg    <listitem>
1093e9fcaa8aSmrg      <para>
1094e9fcaa8aSmrgSpecifies the connection to the X server.
1095e9fcaa8aSmrg      </para>
1096e9fcaa8aSmrg    </listitem>
1097e9fcaa8aSmrg  </varlistentry>
1098e9fcaa8aSmrg  <varlistentry>
1099e9fcaa8aSmrg    <term>
1100e9fcaa8aSmrg      <emphasis remap='I'>event_mask</emphasis>
1101e9fcaa8aSmrg    </term>
1102e9fcaa8aSmrg    <listitem>
1103e9fcaa8aSmrg      <para>
1104e9fcaa8aSmrgSpecifies the event mask.
1105e9fcaa8aSmrg      </para>
1106e9fcaa8aSmrg    </listitem>
1107e9fcaa8aSmrg  </varlistentry>
1108e9fcaa8aSmrg  <varlistentry>
1109e9fcaa8aSmrg    <term>
1110e9fcaa8aSmrg      <emphasis remap='I'>event_return</emphasis>
1111e9fcaa8aSmrg    </term>
1112e9fcaa8aSmrg    <listitem>
1113e9fcaa8aSmrg      <para>
1114e9fcaa8aSmrgReturns the matched event's associated structure.
1115e9fcaa8aSmrg    </para>
1116e9fcaa8aSmrg  </listitem>
1117e9fcaa8aSmrg  </varlistentry>
1118e9fcaa8aSmrg</variablelist>
1119e9fcaa8aSmrg<para>
1120e9fcaa8aSmrg<!-- .LP -->
1121e9fcaa8aSmrg<!-- .eM -->
1122e9fcaa8aSmrgThe
1123eb411b4bSmrg<xref linkend='XMaskEvent' xrefstyle='select: title'/>
1124e9fcaa8aSmrgfunction searches the event queue for the events associated with the 
1125e9fcaa8aSmrgspecified mask.
1126e9fcaa8aSmrgWhen it finds a match,
1127eb411b4bSmrg<xref linkend='XMaskEvent' xrefstyle='select: title'/>
1128e9fcaa8aSmrgremoves that event and copies it into the specified
1129e9fcaa8aSmrg<structname>XEvent</structname>
1130e9fcaa8aSmrgstructure.
1131e9fcaa8aSmrgThe other events stored in the queue are not discarded.
1132e9fcaa8aSmrgIf the event you requested is not in the queue,
1133eb411b4bSmrg<xref linkend='XMaskEvent' xrefstyle='select: title'/>
1134e9fcaa8aSmrgflushes the output buffer and blocks until one is received.
1135e9fcaa8aSmrg</para>
1136e9fcaa8aSmrg<para>
1137e9fcaa8aSmrg<!-- .LP -->
1138e9fcaa8aSmrg<!-- .sp -->
1139e9fcaa8aSmrgTo return and remove the next event that matches an event mask (if any), use
1140eb411b4bSmrg<xref linkend='XCheckMaskEvent' xrefstyle='select: title'/>.
1141e9fcaa8aSmrgThis function is similar to 
1142eb411b4bSmrg<xref linkend='XMaskEvent' xrefstyle='select: title'/>
1143e9fcaa8aSmrgexcept that it never blocks and it returns a 
1144e9fcaa8aSmrg<type>Bool</type>
1145e9fcaa8aSmrgindicating if the event was returned.
1146eb411b4bSmrg</para>
1147e9fcaa8aSmrg<indexterm significance="preferred"><primary>XCheckMaskEvent</primary></indexterm>
1148e9fcaa8aSmrg<!-- .sM -->
1149eb411b4bSmrg<funcsynopsis id='XCheckMaskEvent'>
1150e9fcaa8aSmrg<funcprototype>
1151e9fcaa8aSmrg  <funcdef>Bool <function>XCheckMaskEvent</function></funcdef>
1152e9fcaa8aSmrg  <paramdef>Display<parameter> *display</parameter></paramdef>
1153e9fcaa8aSmrg  <paramdef>long<parameter> event_mask</parameter></paramdef>
1154e9fcaa8aSmrg  <paramdef>XEvent<parameter> *event_return</parameter></paramdef>
1155e9fcaa8aSmrg</funcprototype>
1156e9fcaa8aSmrg</funcsynopsis>
1157e9fcaa8aSmrg<!-- .FN -->
1158e9fcaa8aSmrg<variablelist>
1159e9fcaa8aSmrg  <varlistentry>
1160e9fcaa8aSmrg    <term>
1161e9fcaa8aSmrg      <emphasis remap='I'>display</emphasis>
1162e9fcaa8aSmrg    </term>
1163e9fcaa8aSmrg    <listitem>
1164e9fcaa8aSmrg      <para>
1165e9fcaa8aSmrgSpecifies the connection to the X server.
1166e9fcaa8aSmrg      </para>
1167e9fcaa8aSmrg    </listitem>
1168e9fcaa8aSmrg  </varlistentry>
1169e9fcaa8aSmrg  <varlistentry>
1170e9fcaa8aSmrg    <term>
1171e9fcaa8aSmrg      <emphasis remap='I'>event_mask</emphasis>
1172e9fcaa8aSmrg    </term>
1173e9fcaa8aSmrg    <listitem>
1174e9fcaa8aSmrg      <para>
1175e9fcaa8aSmrgSpecifies the event mask.
1176e9fcaa8aSmrg      </para>
1177e9fcaa8aSmrg    </listitem>
1178e9fcaa8aSmrg  </varlistentry>
1179e9fcaa8aSmrg  <varlistentry>
1180e9fcaa8aSmrg    <term>
1181e9fcaa8aSmrg      <emphasis remap='I'>event_return</emphasis>
1182e9fcaa8aSmrg    </term>
1183e9fcaa8aSmrg    <listitem>
1184e9fcaa8aSmrg      <para>
1185e9fcaa8aSmrgReturns the matched event's associated structure.
1186e9fcaa8aSmrg    </para>
1187e9fcaa8aSmrg  </listitem>
1188e9fcaa8aSmrg  </varlistentry>
1189e9fcaa8aSmrg</variablelist>
1190e9fcaa8aSmrg<para>
1191e9fcaa8aSmrg<!-- .LP -->
1192e9fcaa8aSmrg<!-- .eM -->
1193e9fcaa8aSmrgThe
1194eb411b4bSmrg<xref linkend='XCheckMaskEvent' xrefstyle='select: title'/>
1195e9fcaa8aSmrgfunction searches the event queue and then any events available on the
1196e9fcaa8aSmrgserver connection for the first event that matches the specified mask.
1197e9fcaa8aSmrgIf it finds a match,
1198eb411b4bSmrg<xref linkend='XCheckMaskEvent' xrefstyle='select: title'/>
1199e9fcaa8aSmrgremoves that event, copies it into the specified
1200e9fcaa8aSmrg<structname>XEvent</structname>
1201e9fcaa8aSmrgstructure, and returns
1202e9fcaa8aSmrg<symbol>True</symbol>.
1203e9fcaa8aSmrgThe other events stored in the queue are not discarded.
1204e9fcaa8aSmrgIf the event you requested is not available,
1205eb411b4bSmrg<xref linkend='XCheckMaskEvent' xrefstyle='select: title'/>
1206e9fcaa8aSmrgreturns
1207e9fcaa8aSmrg<symbol>False</symbol>,
1208e9fcaa8aSmrgand the output buffer will have been flushed.
1209e9fcaa8aSmrg</para>
1210e9fcaa8aSmrg<para>
1211e9fcaa8aSmrg<!-- .LP -->
1212e9fcaa8aSmrg<!-- .sp  -->
1213e9fcaa8aSmrgTo return and remove the next event in the queue that matches an event type, use
1214eb411b4bSmrg<xref linkend='XCheckTypedEvent' xrefstyle='select: title'/>.
1215eb411b4bSmrg</para>
1216e9fcaa8aSmrg<indexterm significance="preferred"><primary>XCheckTypedEvent</primary></indexterm>
1217e9fcaa8aSmrg<!-- .sM -->
1218eb411b4bSmrg<funcsynopsis id='XCheckTypedEvent'>
1219e9fcaa8aSmrg<funcprototype>
1220e9fcaa8aSmrg  <funcdef>Bool <function>XCheckTypedEvent</function></funcdef>
1221e9fcaa8aSmrg  <paramdef>Display<parameter> *display</parameter></paramdef>
1222e9fcaa8aSmrg  <paramdef>int<parameter> event_type</parameter></paramdef>
1223e9fcaa8aSmrg  <paramdef>XEvent<parameter> *event_return</parameter></paramdef>
1224e9fcaa8aSmrg</funcprototype>
1225e9fcaa8aSmrg</funcsynopsis>
1226e9fcaa8aSmrg<!-- .FN -->
1227e9fcaa8aSmrg<variablelist>
1228e9fcaa8aSmrg  <varlistentry>
1229e9fcaa8aSmrg    <term>
1230e9fcaa8aSmrg      <emphasis remap='I'>display</emphasis>
1231e9fcaa8aSmrg    </term>
1232e9fcaa8aSmrg    <listitem>
1233e9fcaa8aSmrg      <para>
1234e9fcaa8aSmrgSpecifies the connection to the X server.
1235e9fcaa8aSmrg      </para>
1236e9fcaa8aSmrg    </listitem>
1237e9fcaa8aSmrg  </varlistentry>
1238e9fcaa8aSmrg  <varlistentry>
1239e9fcaa8aSmrg    <term>
1240e9fcaa8aSmrg      <emphasis remap='I'>event_type</emphasis>
1241e9fcaa8aSmrg    </term>
1242e9fcaa8aSmrg    <listitem>
1243e9fcaa8aSmrg      <para>
1244e9fcaa8aSmrgSpecifies the event type to be compared.
1245e9fcaa8aSmrg
1246e9fcaa8aSmrg      </para>
1247e9fcaa8aSmrg    </listitem>
1248e9fcaa8aSmrg  </varlistentry>
1249e9fcaa8aSmrg  <varlistentry>
1250e9fcaa8aSmrg    <term>
1251e9fcaa8aSmrg      <emphasis remap='I'>event_return</emphasis>
1252e9fcaa8aSmrg    </term>
1253e9fcaa8aSmrg    <listitem>
1254e9fcaa8aSmrg      <para>
1255e9fcaa8aSmrgReturns the matched event's associated structure.
1256e9fcaa8aSmrg    </para>
1257e9fcaa8aSmrg  </listitem>
1258e9fcaa8aSmrg  </varlistentry>
1259e9fcaa8aSmrg</variablelist>
1260e9fcaa8aSmrg<para>
1261e9fcaa8aSmrg<!-- .LP -->
1262e9fcaa8aSmrg<!-- .eM -->
1263e9fcaa8aSmrgThe
1264eb411b4bSmrg<xref linkend='XCheckTypedEvent' xrefstyle='select: title'/>
1265e9fcaa8aSmrgfunction searches the event queue and then any events available  
1266e9fcaa8aSmrgon the server connection for the first event that matches the specified type.
1267e9fcaa8aSmrgIf it finds a match,
1268eb411b4bSmrg<xref linkend='XCheckTypedEvent' xrefstyle='select: title'/>
1269e9fcaa8aSmrgremoves that event, copies it into the specified
1270e9fcaa8aSmrg<structname>XEvent</structname>
1271e9fcaa8aSmrgstructure, and returns
1272e9fcaa8aSmrg<symbol>True</symbol>.
1273e9fcaa8aSmrgThe other events in the queue are not discarded.
1274e9fcaa8aSmrgIf the event is not available,
1275eb411b4bSmrg<xref linkend='XCheckTypedEvent' xrefstyle='select: title'/>
1276e9fcaa8aSmrgreturns
1277e9fcaa8aSmrg<symbol>False</symbol>,
1278e9fcaa8aSmrgand the output buffer will have been flushed.
1279e9fcaa8aSmrg</para>
1280e9fcaa8aSmrg<para>
1281e9fcaa8aSmrg<!-- .LP -->
1282e9fcaa8aSmrg<!-- .sp -->
1283e9fcaa8aSmrgTo return and remove the next event in the queue that matches an event type 
1284e9fcaa8aSmrgand a window, use
1285eb411b4bSmrg<xref linkend='XCheckTypedWindowEvent' xrefstyle='select: title'/>.
1286eb411b4bSmrg</para>
1287e9fcaa8aSmrg<indexterm significance="preferred"><primary>XCheckTypedWindowEvent</primary></indexterm>
1288e9fcaa8aSmrg<!-- .sM -->
1289eb411b4bSmrg<funcsynopsis id='XCheckTypedWindowEvent'>
1290e9fcaa8aSmrg<funcprototype>
1291e9fcaa8aSmrg  <funcdef>Bool <function>XCheckTypedWindowEvent</function></funcdef>
1292e9fcaa8aSmrg  <paramdef>Display<parameter> *display</parameter></paramdef>
1293e9fcaa8aSmrg  <paramdef>Window<parameter> w</parameter></paramdef>
1294e9fcaa8aSmrg  <paramdef>int<parameter> event_type</parameter></paramdef>
1295e9fcaa8aSmrg  <paramdef>XEvent<parameter> *event_return</parameter></paramdef>
1296e9fcaa8aSmrg</funcprototype>
1297e9fcaa8aSmrg</funcsynopsis>
1298e9fcaa8aSmrg<!-- .FN -->
1299e9fcaa8aSmrg<variablelist>
1300e9fcaa8aSmrg  <varlistentry>
1301e9fcaa8aSmrg    <term>
1302e9fcaa8aSmrg      <emphasis remap='I'>display</emphasis>
1303e9fcaa8aSmrg    </term>
1304e9fcaa8aSmrg    <listitem>
1305e9fcaa8aSmrg      <para>
1306e9fcaa8aSmrgSpecifies the connection to the X server.
1307e9fcaa8aSmrg      </para>
1308e9fcaa8aSmrg    </listitem>
1309e9fcaa8aSmrg  </varlistentry>
1310e9fcaa8aSmrg  <varlistentry>
1311e9fcaa8aSmrg    <term>
1312e9fcaa8aSmrg      <emphasis remap='I'>w</emphasis>
1313e9fcaa8aSmrg    </term>
1314e9fcaa8aSmrg    <listitem>
1315e9fcaa8aSmrg      <para>
1316e9fcaa8aSmrgSpecifies the window.
1317e9fcaa8aSmrg      </para>
1318e9fcaa8aSmrg    </listitem>
1319e9fcaa8aSmrg  </varlistentry>
1320e9fcaa8aSmrg  <varlistentry>
1321e9fcaa8aSmrg    <term>
1322e9fcaa8aSmrg      <emphasis remap='I'>event_type</emphasis>
1323e9fcaa8aSmrg    </term>
1324e9fcaa8aSmrg    <listitem>
1325e9fcaa8aSmrg      <para>
1326e9fcaa8aSmrgSpecifies the event type to be compared.
1327e9fcaa8aSmrg
1328e9fcaa8aSmrg      </para>
1329e9fcaa8aSmrg    </listitem>
1330e9fcaa8aSmrg  </varlistentry>
1331e9fcaa8aSmrg  <varlistentry>
1332e9fcaa8aSmrg    <term>
1333e9fcaa8aSmrg      <emphasis remap='I'>event_return</emphasis>
1334e9fcaa8aSmrg    </term>
1335e9fcaa8aSmrg    <listitem>
1336e9fcaa8aSmrg      <para>
1337e9fcaa8aSmrgReturns the matched event's associated structure.
1338e9fcaa8aSmrg    </para>
1339e9fcaa8aSmrg  </listitem>
1340e9fcaa8aSmrg  </varlistentry>
1341e9fcaa8aSmrg</variablelist>
1342e9fcaa8aSmrg<para>
1343e9fcaa8aSmrg<!-- .LP -->
1344e9fcaa8aSmrg<!-- .eM -->
1345e9fcaa8aSmrgThe
1346eb411b4bSmrg<xref linkend='XCheckTypedWindowEvent' xrefstyle='select: title'/>
1347e9fcaa8aSmrgfunction searches the event queue and then any events available  
1348e9fcaa8aSmrgon the server connection for the first event that matches the specified
1349e9fcaa8aSmrgtype and window.
1350e9fcaa8aSmrgIf it finds a match,
1351eb411b4bSmrg<xref linkend='XCheckTypedWindowEvent' xrefstyle='select: title'/>
1352e9fcaa8aSmrgremoves the event from the queue, copies it into the specified
1353e9fcaa8aSmrg<structname>XEvent</structname>
1354e9fcaa8aSmrgstructure, and returns
1355e9fcaa8aSmrg<symbol>True</symbol>.
1356e9fcaa8aSmrgThe other events in the queue are not discarded.
1357e9fcaa8aSmrgIf the event is not available,
1358eb411b4bSmrg<xref linkend='XCheckTypedWindowEvent' xrefstyle='select: title'/>
1359e9fcaa8aSmrgreturns
1360e9fcaa8aSmrg<symbol>False</symbol>,
1361e9fcaa8aSmrgand the output buffer will have been flushed.
1362e9fcaa8aSmrg</para>
1363e9fcaa8aSmrg</sect2>
1364e9fcaa8aSmrg</sect1>
1365e9fcaa8aSmrg<sect1 id="Putting_an_Event_Back_into_the_Queue">
1366e9fcaa8aSmrg<title>Putting an Event Back into the Queue</title>
1367e9fcaa8aSmrg<!-- .XS -->
1368e9fcaa8aSmrg<!-- (SN Putting an Event Back into the Queue  -->
1369e9fcaa8aSmrg<!-- .XE -->
1370e9fcaa8aSmrg<para>
1371e9fcaa8aSmrg<!-- .LP -->
1372e9fcaa8aSmrgTo push an event back into the event queue, use
1373eb411b4bSmrg<xref linkend='XPutBackEvent' xrefstyle='select: title'/>.
1374eb411b4bSmrg</para>
1375e9fcaa8aSmrg<indexterm significance="preferred"><primary>XPutBackEvent</primary></indexterm>
1376e9fcaa8aSmrg<!-- .sM -->
1377eb411b4bSmrg<funcsynopsis id='XPutBackEvent'>
1378e9fcaa8aSmrg<funcprototype>
1379e9fcaa8aSmrg  <funcdef><function>XPutBackEvent</function></funcdef>
1380e9fcaa8aSmrg  <paramdef>Display<parameter> *display</parameter></paramdef>
1381e9fcaa8aSmrg  <paramdef>XEvent<parameter> *event</parameter></paramdef>
1382e9fcaa8aSmrg</funcprototype>
1383e9fcaa8aSmrg</funcsynopsis>
1384e9fcaa8aSmrg<!-- .FN -->
1385e9fcaa8aSmrg<variablelist>
1386e9fcaa8aSmrg  <varlistentry>
1387e9fcaa8aSmrg    <term>
1388e9fcaa8aSmrg      <emphasis remap='I'>display</emphasis>
1389e9fcaa8aSmrg    </term>
1390e9fcaa8aSmrg    <listitem>
1391e9fcaa8aSmrg      <para>
1392e9fcaa8aSmrgSpecifies the connection to the X server.
1393e9fcaa8aSmrg      </para>
1394e9fcaa8aSmrg    </listitem>
1395e9fcaa8aSmrg  </varlistentry>
1396e9fcaa8aSmrg  <varlistentry>
1397e9fcaa8aSmrg    <term>
1398e9fcaa8aSmrg      <emphasis remap='I'>event</emphasis>
1399e9fcaa8aSmrg    </term>
1400e9fcaa8aSmrg    <listitem>
1401e9fcaa8aSmrg      <para>
1402e9fcaa8aSmrgSpecifies the event.
1403e9fcaa8aSmrg    </para>
1404e9fcaa8aSmrg  </listitem>
1405e9fcaa8aSmrg  </varlistentry>
1406e9fcaa8aSmrg</variablelist>
1407e9fcaa8aSmrg<para>
1408e9fcaa8aSmrg<!-- .LP -->
1409e9fcaa8aSmrg<!-- .eM  -->
1410e9fcaa8aSmrgThe
1411eb411b4bSmrg<xref linkend='XPutBackEvent' xrefstyle='select: title'/>
1412e9fcaa8aSmrgfunction pushes an event back onto the head of the display's event queue
1413e9fcaa8aSmrgby copying the event into the queue.
1414e9fcaa8aSmrgThis can be useful if you read an event and then decide that you
1415e9fcaa8aSmrgwould rather deal with it later.
1416e9fcaa8aSmrgThere is no limit to the number of times in succession that you can call
1417eb411b4bSmrg<xref linkend='XPutBackEvent' xrefstyle='select: title'/>.
1418e9fcaa8aSmrg</para>
1419e9fcaa8aSmrg</sect1>
1420e9fcaa8aSmrg<sect1 id="Sending_Events_to_Other_Applications">
1421e9fcaa8aSmrg<title>Sending Events to Other Applications</title>
1422e9fcaa8aSmrg<!-- .XS -->
1423e9fcaa8aSmrg<!-- (SN Sending Events to Other Applications -->
1424e9fcaa8aSmrg<!-- .XE -->
1425e9fcaa8aSmrg<para>
1426e9fcaa8aSmrg<!-- .LP -->
1427e9fcaa8aSmrgTo send an event to a specified window, use
1428eb411b4bSmrg<xref linkend='XSendEvent' xrefstyle='select: title'/>.
1429e9fcaa8aSmrg<indexterm><primary>XSendEvent</primary></indexterm>
1430e9fcaa8aSmrgThis function is often used in selection processing.
1431e9fcaa8aSmrgFor example, the owner of a selection should use
1432eb411b4bSmrg<xref linkend='XSendEvent' xrefstyle='select: title'/>
1433e9fcaa8aSmrgto send a
1434e9fcaa8aSmrg<symbol>SelectionNotify</symbol>
1435e9fcaa8aSmrgevent to a requestor when a selection has been converted 
1436e9fcaa8aSmrgand stored as a property.
1437eb411b4bSmrg</para>
1438e9fcaa8aSmrg<indexterm significance="preferred"><primary>XSendEvent</primary></indexterm>
1439e9fcaa8aSmrg<!-- .sM -->
1440eb411b4bSmrg<funcsynopsis id='XSendEvent'>
1441e9fcaa8aSmrg<funcprototype>
1442e9fcaa8aSmrg  <funcdef>Status <function>XSendEvent</function></funcdef>
1443e9fcaa8aSmrg  <paramdef>Display<parameter> *display</parameter></paramdef>
1444e9fcaa8aSmrg  <paramdef>Window<parameter> w</parameter></paramdef>
1445e9fcaa8aSmrg  <paramdef>Bool<parameter> propagate</parameter></paramdef>
1446e9fcaa8aSmrg  <paramdef>long<parameter> event_mask</parameter></paramdef>
1447e9fcaa8aSmrg  <paramdef>XEvent<parameter> *event_send</parameter></paramdef>
1448e9fcaa8aSmrg</funcprototype>
1449e9fcaa8aSmrg</funcsynopsis>
1450e9fcaa8aSmrg<!-- .FN -->
1451e9fcaa8aSmrg<variablelist>
1452e9fcaa8aSmrg  <varlistentry>
1453e9fcaa8aSmrg    <term>
1454e9fcaa8aSmrg      <emphasis remap='I'>display</emphasis>
1455e9fcaa8aSmrg    </term>
1456e9fcaa8aSmrg    <listitem>
1457e9fcaa8aSmrg      <para>
1458e9fcaa8aSmrgSpecifies the connection to the X server.
1459e9fcaa8aSmrg      </para>
1460e9fcaa8aSmrg    </listitem>
1461e9fcaa8aSmrg  </varlistentry>
1462e9fcaa8aSmrg  <varlistentry>
1463e9fcaa8aSmrg    <term>
1464e9fcaa8aSmrg      <emphasis remap='I'>w</emphasis>
1465e9fcaa8aSmrg    </term>
1466e9fcaa8aSmrg    <listitem>
1467e9fcaa8aSmrg      <para>
1468e9fcaa8aSmrgSpecifies the window the event is to be sent to, or
1469e9fcaa8aSmrg<symbol>PointerWindow</symbol>,
1470e9fcaa8aSmrgor
1471e9fcaa8aSmrg<symbol>InputFocus</symbol>.
1472e9fcaa8aSmrg      </para>
1473e9fcaa8aSmrg    </listitem>
1474e9fcaa8aSmrg  </varlistentry>
1475e9fcaa8aSmrg  <varlistentry>
1476e9fcaa8aSmrg    <term>
1477e9fcaa8aSmrg      <emphasis remap='I'>propagate</emphasis>
1478e9fcaa8aSmrg    </term>
1479e9fcaa8aSmrg    <listitem>
1480e9fcaa8aSmrg      <para>
1481e9fcaa8aSmrgSpecifies a Boolean value.
1482e9fcaa8aSmrg      </para>
1483e9fcaa8aSmrg    </listitem>
1484e9fcaa8aSmrg  </varlistentry>
1485e9fcaa8aSmrg  <varlistentry>
1486e9fcaa8aSmrg    <term>
1487e9fcaa8aSmrg      <emphasis remap='I'>event_mask</emphasis>
1488e9fcaa8aSmrg    </term>
1489e9fcaa8aSmrg    <listitem>
1490e9fcaa8aSmrg      <para>
1491e9fcaa8aSmrgSpecifies the event mask.
1492e9fcaa8aSmrg      </para>
1493e9fcaa8aSmrg    </listitem>
1494e9fcaa8aSmrg  </varlistentry>
1495e9fcaa8aSmrg  <varlistentry>
1496e9fcaa8aSmrg    <term>
1497e9fcaa8aSmrg      <emphasis remap='I'>event_send</emphasis>
1498e9fcaa8aSmrg    </term>
1499e9fcaa8aSmrg    <listitem>
1500e9fcaa8aSmrg      <para>
1501e9fcaa8aSmrgSpecifies the event that is to be sent.
1502e9fcaa8aSmrg    </para>
1503e9fcaa8aSmrg  </listitem>
1504e9fcaa8aSmrg  </varlistentry>
1505e9fcaa8aSmrg</variablelist>
1506e9fcaa8aSmrg<para>
1507e9fcaa8aSmrg<!-- .LP -->
1508e9fcaa8aSmrg<!-- .eM -->
1509e9fcaa8aSmrgThe
1510eb411b4bSmrg<xref linkend='XSendEvent' xrefstyle='select: title'/>
1511e9fcaa8aSmrgfunction identifies the destination window, 
1512e9fcaa8aSmrgdetermines which clients should receive the specified events, 
1513e9fcaa8aSmrgand ignores any active grabs.
1514e9fcaa8aSmrgThis function requires you to pass an event mask.
1515e9fcaa8aSmrgFor a discussion of the valid event mask names,
15166cc2b21fSmrgsee <link linkend="Event_Masks">section 10.3</link>.
1517e9fcaa8aSmrgThis function uses the w argument to identify the destination window as follows:
1518e9fcaa8aSmrg</para>
1519e9fcaa8aSmrg<itemizedlist>
1520e9fcaa8aSmrg  <listitem>
1521e9fcaa8aSmrg    <para>
1522e9fcaa8aSmrgIf w is
1523e9fcaa8aSmrg<symbol>PointerWindow</symbol>,
1524e9fcaa8aSmrgthe destination window is the window that contains the pointer.
1525e9fcaa8aSmrg    </para>
1526e9fcaa8aSmrg  </listitem>
1527e9fcaa8aSmrg  <listitem>
1528e9fcaa8aSmrg    <para>
1529e9fcaa8aSmrgIf w is
1530e9fcaa8aSmrg<symbol>InputFocus</symbol>
1531e9fcaa8aSmrgand if the focus window contains the pointer, 
1532e9fcaa8aSmrgthe destination window is the window that contains the pointer; 
1533e9fcaa8aSmrgotherwise, the destination window is the focus window.
1534e9fcaa8aSmrg    </para>
1535e9fcaa8aSmrg  </listitem>
1536e9fcaa8aSmrg</itemizedlist>
1537e9fcaa8aSmrg<para>
1538e9fcaa8aSmrg<!-- .LP -->
1539e9fcaa8aSmrgTo determine which clients should receive the specified events,
1540eb411b4bSmrg<xref linkend='XSendEvent' xrefstyle='select: title'/>
1541e9fcaa8aSmrguses the propagate argument as follows:
1542e9fcaa8aSmrg</para>
1543e9fcaa8aSmrg<itemizedlist>
1544e9fcaa8aSmrg  <listitem>
1545e9fcaa8aSmrg    <para>
1546e9fcaa8aSmrgIf event_mask is the empty set,
1547e9fcaa8aSmrgthe event is sent to the client that created the destination window.
1548e9fcaa8aSmrgIf that client no longer exists,
1549e9fcaa8aSmrgno event is sent.
1550e9fcaa8aSmrg    </para>
1551e9fcaa8aSmrg  </listitem>
1552e9fcaa8aSmrg  <listitem>
1553e9fcaa8aSmrg    <para>
1554e9fcaa8aSmrgIf propagate is 
1555e9fcaa8aSmrg<symbol>False</symbol>,
1556e9fcaa8aSmrgthe event is sent to every client selecting on destination any of the event
1557e9fcaa8aSmrgtypes in the event_mask argument.
1558e9fcaa8aSmrg    </para>
1559e9fcaa8aSmrg  </listitem>
1560e9fcaa8aSmrg  <listitem>
1561e9fcaa8aSmrg    <para>
1562e9fcaa8aSmrgIf propagate is 
1563e9fcaa8aSmrg<symbol>True</symbol>
1564e9fcaa8aSmrgand no clients have selected on destination any of
1565e9fcaa8aSmrgthe event types in event-mask, the destination is replaced with the
1566e9fcaa8aSmrgclosest ancestor of destination for which some client has selected a
1567e9fcaa8aSmrgtype in event-mask and for which no intervening window has that type in its
1568e9fcaa8aSmrgdo-not-propagate-mask. 
1569e9fcaa8aSmrgIf no such window exists or if the window is
1570e9fcaa8aSmrgan ancestor of the focus window and 
1571e9fcaa8aSmrg<symbol>InputFocus</symbol>
1572e9fcaa8aSmrgwas originally specified
1573e9fcaa8aSmrgas the destination, the event is not sent to any clients.
1574e9fcaa8aSmrgOtherwise, the event is reported to every client selecting on the final
1575e9fcaa8aSmrgdestination any of the types specified in event_mask.
1576e9fcaa8aSmrg    </para>
1577e9fcaa8aSmrg  </listitem>
1578e9fcaa8aSmrg</itemizedlist>
1579e9fcaa8aSmrg<para>
1580e9fcaa8aSmrg<!-- .LP -->
1581e9fcaa8aSmrgThe event in the
1582e9fcaa8aSmrg<structname>XEvent</structname>
1583e9fcaa8aSmrgstructure must be one of the core events or one of the events
1584e9fcaa8aSmrgdefined by an extension (or a 
1585e9fcaa8aSmrg<errorname>BadValue</errorname>
1586e9fcaa8aSmrgerror results) so that the X server can correctly byte-swap 
1587e9fcaa8aSmrgthe contents as necessary.  
1588e9fcaa8aSmrgThe contents of the event are
1589e9fcaa8aSmrgotherwise unaltered and unchecked by the X server except to force send_event to
1590e9fcaa8aSmrg<symbol>True</symbol>
1591e9fcaa8aSmrgin the forwarded event and to set the serial number in the event correctly;
1592e9fcaa8aSmrgtherefore these fields
1593e9fcaa8aSmrgand the display field are ignored by
1594eb411b4bSmrg<xref linkend='XSendEvent' xrefstyle='select: title'/>.
1595e9fcaa8aSmrg</para>
1596e9fcaa8aSmrg<para>
1597e9fcaa8aSmrg<!-- .LP -->
1598eb411b4bSmrg<xref linkend='XSendEvent' xrefstyle='select: title'/>
1599e9fcaa8aSmrgreturns zero if the conversion to wire protocol format failed
1600e9fcaa8aSmrgand returns nonzero otherwise.
1601e9fcaa8aSmrg</para>
1602e9fcaa8aSmrg<para>
1603e9fcaa8aSmrg<!-- .LP -->
1604eb411b4bSmrg<xref linkend='XSendEvent' xrefstyle='select: title'/>
1605e9fcaa8aSmrgcan generate
1606e9fcaa8aSmrg<errorname>BadValue</errorname>
1607e9fcaa8aSmrgand 
1608e9fcaa8aSmrg<errorname>BadWindow</errorname>
1609e9fcaa8aSmrgerrors.
1610e9fcaa8aSmrg</para>
1611e9fcaa8aSmrg</sect1>
1612e9fcaa8aSmrg<sect1 id="Getting_Pointer_Motion_History">
1613e9fcaa8aSmrg<title>Getting Pointer Motion History</title>
1614e9fcaa8aSmrg<!-- .XS -->
1615e9fcaa8aSmrg<!-- (SN Getting Pointer Motion History -->
1616e9fcaa8aSmrg<!-- .XE -->
1617e9fcaa8aSmrg<para>
1618e9fcaa8aSmrg<!-- .LP -->
1619e9fcaa8aSmrgSome X server implementations will maintain a more complete
1620e9fcaa8aSmrghistory of pointer motion than is reported by event notification.
1621e9fcaa8aSmrgThe pointer position at each pointer hardware interrupt may be
1622e9fcaa8aSmrgstored in a buffer for later retrieval.
1623e9fcaa8aSmrgThis buffer is called the motion history buffer.
1624e9fcaa8aSmrgFor example, a few applications, such as paint programs,
1625e9fcaa8aSmrgwant to have a precise history of where the pointer
1626e9fcaa8aSmrgtraveled. 
1627e9fcaa8aSmrgHowever, this historical information is highly excessive for most applications.
1628e9fcaa8aSmrg</para>
1629e9fcaa8aSmrg<para>
1630e9fcaa8aSmrg<!-- .LP -->
1631e9fcaa8aSmrg<!-- .sp -->
1632e9fcaa8aSmrgTo determine the approximate maximum number of elements in the motion buffer, 
1633e9fcaa8aSmrguse
1634e9fcaa8aSmrg<function>XDisplayMotionBufferSize</function>.
1635eb411b4bSmrg</para>
1636e9fcaa8aSmrg<indexterm significance="preferred"><primary>XDisplayMotionBufferSize</primary></indexterm>
1637e9fcaa8aSmrg<!-- .sM -->
1638eb411b4bSmrg<funcsynopsis id='XGetMotionEvents'>
1639e9fcaa8aSmrg<funcprototype>
1640e9fcaa8aSmrg  <funcdef>unsigned <type>long</type></funcdef>
1641e9fcaa8aSmrg  <paramdef>Display<parameter> *display</parameter></paramdef>
1642e9fcaa8aSmrg</funcprototype>
1643e9fcaa8aSmrg</funcsynopsis>
1644e9fcaa8aSmrg<!-- .FN -->
1645e9fcaa8aSmrg<variablelist>
1646e9fcaa8aSmrg  <varlistentry>
1647e9fcaa8aSmrg    <term>
1648e9fcaa8aSmrg      <emphasis remap='I'>display</emphasis>
1649e9fcaa8aSmrg    </term>
1650e9fcaa8aSmrg    <listitem>
1651e9fcaa8aSmrg      <para>
1652e9fcaa8aSmrgSpecifies the connection to the X server.
1653e9fcaa8aSmrg    </para>
1654e9fcaa8aSmrg  </listitem>
1655e9fcaa8aSmrg  </varlistentry>
1656e9fcaa8aSmrg</variablelist>
1657e9fcaa8aSmrg<para>
1658e9fcaa8aSmrg<!-- .LP -->
1659e9fcaa8aSmrg<!-- .eM -->
1660e9fcaa8aSmrgThe server may retain the recent history of the pointer motion
1661e9fcaa8aSmrgand do so to a finer granularity than is reported by
1662e9fcaa8aSmrg<symbol>MotionNotify</symbol>
1663e9fcaa8aSmrgevents.
1664e9fcaa8aSmrgThe
1665eb411b4bSmrg<xref linkend='XGetMotionEvents' xrefstyle='select: title'/>
1666e9fcaa8aSmrgfunction makes this history available.
1667e9fcaa8aSmrg</para>
1668e9fcaa8aSmrg<para>
1669e9fcaa8aSmrg<!-- .LP -->
1670e9fcaa8aSmrg<!-- .sp -->
1671e9fcaa8aSmrgTo get the motion history for a specified window and time, use
1672eb411b4bSmrg<xref linkend='XGetMotionEvents' xrefstyle='select: title'/>.
1673eb411b4bSmrg</para>
1674e9fcaa8aSmrg<indexterm significance="preferred"><primary>XGetMotionEvents</primary></indexterm>
1675e9fcaa8aSmrg<!-- .sM -->
16766cc2b21fSmrg<funcsynopsis id='xgetmotionevents'>
1677e9fcaa8aSmrg<funcprototype>
1678e9fcaa8aSmrg  <funcdef>XTimeCoord *<function>XGetMotionEvents</function></funcdef>
1679e9fcaa8aSmrg  <paramdef>Display<parameter> *display</parameter></paramdef>
1680e9fcaa8aSmrg  <paramdef>Window<parameter> w</parameter></paramdef>
1681e9fcaa8aSmrg  <paramdef>Timestart,<parameter> stop</parameter></paramdef>
1682e9fcaa8aSmrg  <paramdef>int<parameter> *nevents_return</parameter></paramdef>
1683e9fcaa8aSmrg</funcprototype>
1684e9fcaa8aSmrg</funcsynopsis>
1685e9fcaa8aSmrg<!-- .FN -->
1686e9fcaa8aSmrg<variablelist>
1687e9fcaa8aSmrg  <varlistentry>
1688e9fcaa8aSmrg    <term>
1689e9fcaa8aSmrg      <emphasis remap='I'>display</emphasis>
1690e9fcaa8aSmrg    </term>
1691e9fcaa8aSmrg    <listitem>
1692e9fcaa8aSmrg      <para>
1693e9fcaa8aSmrgSpecifies the connection to the X server.
1694e9fcaa8aSmrg      </para>
1695e9fcaa8aSmrg    </listitem>
1696e9fcaa8aSmrg  </varlistentry>
1697e9fcaa8aSmrg  <varlistentry>
1698e9fcaa8aSmrg    <term>
1699e9fcaa8aSmrg      <emphasis remap='I'>w</emphasis>
1700e9fcaa8aSmrg    </term>
1701e9fcaa8aSmrg    <listitem>
1702e9fcaa8aSmrg      <para>
1703e9fcaa8aSmrgSpecifies the window.
1704e9fcaa8aSmrg      </para>
1705e9fcaa8aSmrg    </listitem>
1706e9fcaa8aSmrg  </varlistentry>
1707e9fcaa8aSmrg  <varlistentry>
1708e9fcaa8aSmrg    <term>
1709e9fcaa8aSmrg      <emphasis remap='I'>start</emphasis>
1710e9fcaa8aSmrg    </term>
1711e9fcaa8aSmrg    <listitem>
1712e9fcaa8aSmrg      <para>
1713e9fcaa8aSmrg<!-- .br -->
1714e9fcaa8aSmrg<!-- .ns -->
1715e9fcaa8aSmrg      </para>
1716e9fcaa8aSmrg    </listitem>
1717e9fcaa8aSmrg  </varlistentry>
1718e9fcaa8aSmrg  <varlistentry>
1719e9fcaa8aSmrg    <term>
1720e9fcaa8aSmrg      <emphasis remap='I'>stop</emphasis>
1721e9fcaa8aSmrg    </term>
1722e9fcaa8aSmrg    <listitem>
1723e9fcaa8aSmrg      <para>
1724e9fcaa8aSmrgSpecify the time interval in which the events are returned from the motion
1725e9fcaa8aSmrghistory buffer.
1726e9fcaa8aSmrgYou can pass a timestamp or
1727e9fcaa8aSmrg<symbol>CurrentTime</symbol>.
1728e9fcaa8aSmrg      </para>
1729e9fcaa8aSmrg    </listitem>
1730e9fcaa8aSmrg  </varlistentry>
1731e9fcaa8aSmrg  <varlistentry>
1732e9fcaa8aSmrg    <term>
1733e9fcaa8aSmrg      <emphasis remap='I'>nevents_return</emphasis>
1734e9fcaa8aSmrg    </term>
1735e9fcaa8aSmrg    <listitem>
1736e9fcaa8aSmrg      <para>
1737e9fcaa8aSmrgReturns the number of events from the motion history buffer.
1738e9fcaa8aSmrg    </para>
1739e9fcaa8aSmrg  </listitem>
1740e9fcaa8aSmrg  </varlistentry>
1741e9fcaa8aSmrg</variablelist>
1742e9fcaa8aSmrg<para>
1743e9fcaa8aSmrg<!-- .LP -->
1744e9fcaa8aSmrg<!-- .eM -->
1745e9fcaa8aSmrgThe
1746eb411b4bSmrg<xref linkend='XGetMotionEvents' xrefstyle='select: title'/>
1747e9fcaa8aSmrgfunction returns all events in the motion history buffer that fall between the
1748e9fcaa8aSmrgspecified start and stop times, inclusive, and that have coordinates
1749e9fcaa8aSmrgthat lie within the specified window (including its borders) at its present
1750e9fcaa8aSmrgplacement.
1751e9fcaa8aSmrgIf the server does not support motion history, 
1752e9fcaa8aSmrgif the start time is later than the stop time,
1753e9fcaa8aSmrgor if the start time is in the future, 
1754e9fcaa8aSmrgno events are returned;
1755eb411b4bSmrg<xref linkend='XGetMotionEvents' xrefstyle='select: title'/>
1756e9fcaa8aSmrgreturns NULL.
1757e9fcaa8aSmrgIf the stop time is in the future, it is equivalent to specifying
1758e9fcaa8aSmrg<symbol>CurrentTime</symbol>.
1759e9fcaa8aSmrgThe return type for this function is a structure defined as follows:
1760e9fcaa8aSmrg</para>
1761e9fcaa8aSmrg<para>
1762e9fcaa8aSmrg<!-- .LP -->
1763e9fcaa8aSmrg<indexterm significance="preferred"><primary>XTimeCoord</primary></indexterm>
1764e9fcaa8aSmrg<!-- .sM -->
1765e9fcaa8aSmrg<literallayout class="monospaced">
1766e9fcaa8aSmrg<!-- .TA .5i -->
1767e9fcaa8aSmrg<!-- .ta .5i -->
1768e9fcaa8aSmrgtypedef struct {
1769e9fcaa8aSmrg	Time time;
1770e9fcaa8aSmrg	short x, y;
1771e9fcaa8aSmrg} XTimeCoord;
1772e9fcaa8aSmrg</literallayout>
1773e9fcaa8aSmrg</para>
1774e9fcaa8aSmrg<para>
1775e9fcaa8aSmrg<!-- .LP -->
1776e9fcaa8aSmrg<!-- .eM -->
1777e9fcaa8aSmrgThe time member is set to the time, in milliseconds. 
1778e9fcaa8aSmrgThe x and y members are set to the coordinates of the pointer and
1779e9fcaa8aSmrgare reported relative to the origin
1780e9fcaa8aSmrgof the specified window.
1781e9fcaa8aSmrgTo free the data returned from this call, use
1782eb411b4bSmrg<xref linkend='XFree' xrefstyle='select: title'/>.
1783e9fcaa8aSmrg</para>
1784e9fcaa8aSmrg<para>
1785e9fcaa8aSmrg<!-- .LP -->
1786eb411b4bSmrg<xref linkend='XGetMotionEvents' xrefstyle='select: title'/>
1787e9fcaa8aSmrgcan generate a
1788e9fcaa8aSmrg<errorname>BadWindow</errorname>
1789e9fcaa8aSmrgerror.
1790e9fcaa8aSmrg</para>
1791e9fcaa8aSmrg</sect1>
1792e9fcaa8aSmrg<sect1 id="Handling_Protocol_Errors">
1793e9fcaa8aSmrg<title>Handling Protocol Errors</title>
1794e9fcaa8aSmrg<!-- .XS -->
1795e9fcaa8aSmrg<!-- (SN Handling Protocol Errors -->
1796e9fcaa8aSmrg<!-- .XE -->
1797e9fcaa8aSmrg<para>
1798e9fcaa8aSmrg<!-- .LP -->
1799e9fcaa8aSmrgXlib provides functions that you can use to enable or disable synchronization
1800e9fcaa8aSmrgand to use the default error handlers.
1801e9fcaa8aSmrg</para>
1802e9fcaa8aSmrg<sect2 id="Enabling_or_Disabling_Synchronization">
1803e9fcaa8aSmrg<title>Enabling or Disabling Synchronization</title>
1804e9fcaa8aSmrg<!-- .XS -->
1805e9fcaa8aSmrg<!-- (SN Enabling or Disabling Synchronization  -->
1806e9fcaa8aSmrg<!-- .XE -->
1807e9fcaa8aSmrg<para>
1808e9fcaa8aSmrg<!-- .LP -->
1809e9fcaa8aSmrgWhen debugging X applications, 
1810e9fcaa8aSmrgit often is very convenient to require Xlib to behave synchronously
1811e9fcaa8aSmrgso that errors are reported as they occur.
1812e9fcaa8aSmrgThe following function lets you disable or enable synchronous behavior.
1813e9fcaa8aSmrgNote that graphics may occur 30 or more times more slowly when 
1814e9fcaa8aSmrgsynchronization is enabled.
1815e9fcaa8aSmrg<indexterm><primary>_Xdebug</primary></indexterm>
1816e9fcaa8aSmrgOn <acronym>POSIX</acronym>-conformant systems,
1817e9fcaa8aSmrgthere is also a global variable 
1818e9fcaa8aSmrg<varname>_Xdebug</varname>
1819e9fcaa8aSmrgthat, if set to nonzero before starting a program under a debugger, will force
1820e9fcaa8aSmrgsynchronous library behavior.
1821e9fcaa8aSmrg</para>
1822e9fcaa8aSmrg<para>
1823e9fcaa8aSmrg<!-- .LP -->
1824e9fcaa8aSmrgAfter completing their work,
1825e9fcaa8aSmrgall Xlib functions that generate protocol requests call what is known as
1826e9fcaa8aSmrgan after function.
1827eb411b4bSmrg<xref linkend='XSetAfterFunction' xrefstyle='select: title'/>
1828e9fcaa8aSmrgsets which function is to be called.
1829eb411b4bSmrg</para>
1830e9fcaa8aSmrg<indexterm significance="preferred"><primary>XSetAfterFunction</primary></indexterm>
1831e9fcaa8aSmrg<!-- .sM -->
1832eb411b4bSmrg<funcsynopsis id='XSetAfterFunction'>
1833e9fcaa8aSmrg<funcprototype>
1834e9fcaa8aSmrg  <funcdef><type>int</type></funcdef>
1835e9fcaa8aSmrg  <paramdef>Display<parameter> *display</parameter></paramdef>
1836e9fcaa8aSmrg  <paramdef>int<parameter> (*procedure)()</parameter></paramdef>
1837e9fcaa8aSmrg</funcprototype>
1838e9fcaa8aSmrg</funcsynopsis>
1839e9fcaa8aSmrg<!-- .FN -->
1840e9fcaa8aSmrg<variablelist>
1841e9fcaa8aSmrg  <varlistentry>
1842e9fcaa8aSmrg    <term>
1843e9fcaa8aSmrg      <emphasis remap='I'>display</emphasis>
1844e9fcaa8aSmrg    </term>
1845e9fcaa8aSmrg    <listitem>
1846e9fcaa8aSmrg      <para>
1847e9fcaa8aSmrgSpecifies the connection to the X server.
1848e9fcaa8aSmrg      </para>
1849e9fcaa8aSmrg    </listitem>
1850e9fcaa8aSmrg  </varlistentry>
1851e9fcaa8aSmrg  <varlistentry>
1852e9fcaa8aSmrg    <term>
1853e9fcaa8aSmrg      <emphasis remap='I'>procedure</emphasis>
1854e9fcaa8aSmrg    </term>
1855e9fcaa8aSmrg    <listitem>
1856e9fcaa8aSmrg      <para>
1857e9fcaa8aSmrgSpecifies the procedure to be called.
1858e9fcaa8aSmrg    </para>
1859e9fcaa8aSmrg  </listitem>
1860e9fcaa8aSmrg  </varlistentry>
1861e9fcaa8aSmrg</variablelist>
1862e9fcaa8aSmrg<para>
1863e9fcaa8aSmrg<!-- .LP -->
1864e9fcaa8aSmrg<!-- .eM -->
1865e9fcaa8aSmrgThe specified procedure is called with only a display pointer.
1866eb411b4bSmrg<xref linkend='XSetAfterFunction' xrefstyle='select: title'/>
1867e9fcaa8aSmrgreturns the previous after function.
1868e9fcaa8aSmrg</para>
1869e9fcaa8aSmrg<para>
1870e9fcaa8aSmrg<!-- .LP -->
1871e9fcaa8aSmrgTo enable or disable synchronization, use 
1872e9fcaa8aSmrg<function>XSynchronize</function>.
1873eb411b4bSmrg</para>
1874e9fcaa8aSmrg<indexterm><primary>Debugging</primary><secondary>synchronous mode</secondary></indexterm>
1875e9fcaa8aSmrg<indexterm significance="preferred"><primary>XSynchronize</primary></indexterm>
1876e9fcaa8aSmrg<!-- .sM -->
18776cc2b21fSmrg<funcsynopsis id='xsynchronize'>
1878e9fcaa8aSmrg<funcprototype>
1879e9fcaa8aSmrg  <funcdef><type>int</type></funcdef>
1880e9fcaa8aSmrg  <paramdef>Display<parameter> *display</parameter></paramdef>
1881e9fcaa8aSmrg  <paramdef>Bool<parameter> onoff</parameter></paramdef>
1882e9fcaa8aSmrg</funcprototype>
1883e9fcaa8aSmrg</funcsynopsis>
1884e9fcaa8aSmrg<!-- .FN -->
1885e9fcaa8aSmrg<variablelist>
1886e9fcaa8aSmrg  <varlistentry>
1887e9fcaa8aSmrg    <term>
1888e9fcaa8aSmrg      <emphasis remap='I'>display</emphasis>
1889e9fcaa8aSmrg    </term>
1890e9fcaa8aSmrg    <listitem>
1891e9fcaa8aSmrg      <para>
1892e9fcaa8aSmrgSpecifies the connection to the X server.
1893e9fcaa8aSmrg      </para>
1894e9fcaa8aSmrg    </listitem>
1895e9fcaa8aSmrg  </varlistentry>
1896e9fcaa8aSmrg  <varlistentry>
1897e9fcaa8aSmrg    <term>
1898e9fcaa8aSmrg      <emphasis remap='I'>onoff</emphasis>
1899e9fcaa8aSmrg    </term>
1900e9fcaa8aSmrg    <listitem>
1901e9fcaa8aSmrg      <para>
1902e9fcaa8aSmrgSpecifies a Boolean value that indicates whether to enable 
1903e9fcaa8aSmrgor disable synchronization.
1904e9fcaa8aSmrg    </para>
1905e9fcaa8aSmrg  </listitem>
1906e9fcaa8aSmrg  </varlistentry>
1907e9fcaa8aSmrg</variablelist>
1908e9fcaa8aSmrg<para>
1909e9fcaa8aSmrg<!-- .LP -->
1910e9fcaa8aSmrg<!-- .eM -->
1911e9fcaa8aSmrgThe
1912e9fcaa8aSmrg<function>XSynchronize</function>
1913e9fcaa8aSmrgfunction returns 
1914e9fcaa8aSmrgthe previous after function.
1915e9fcaa8aSmrgIf onoff is 
1916e9fcaa8aSmrg<symbol>True</symbol>,
1917e9fcaa8aSmrg<function>XSynchronize</function>
1918e9fcaa8aSmrgturns on synchronous behavior.
1919e9fcaa8aSmrgIf onoff is
1920e9fcaa8aSmrg<symbol>False</symbol>,
1921e9fcaa8aSmrg<function>XSynchronize</function>
1922e9fcaa8aSmrgturns off synchronous behavior.
1923e9fcaa8aSmrg</para>
1924e9fcaa8aSmrg</sect2>
1925e9fcaa8aSmrg<sect2 id="Using_the_Default_Error_Handlers">
1926e9fcaa8aSmrg<title>Using the Default Error Handlers</title>
1927e9fcaa8aSmrg<!-- .XS -->
1928e9fcaa8aSmrg<!-- (SN Using the Default Error Handlers  -->
1929e9fcaa8aSmrg<!-- .XE -->
1930e9fcaa8aSmrg<para>
1931e9fcaa8aSmrg<!-- .LP -->
1932e9fcaa8aSmrg<indexterm><primary>Debugging</primary><secondary>error handlers</secondary></indexterm>
1933e9fcaa8aSmrg<indexterm><primary>Error</primary><secondary>handlers</secondary></indexterm>
1934e9fcaa8aSmrgThere are two default error handlers in Xlib: 
1935e9fcaa8aSmrgone to handle typically fatal conditions (for example, 
1936e9fcaa8aSmrgthe connection to a display server dying because a machine crashed) 
1937e9fcaa8aSmrgand one to handle protocol errors from the X server.
1938e9fcaa8aSmrgThese error handlers can be changed to user-supplied routines if you
1939e9fcaa8aSmrgprefer your own error handling and can be changed as often as you like.
1940e9fcaa8aSmrgIf either function is passed a NULL pointer, it will
1941e9fcaa8aSmrgreinvoke the default handler.
1942e9fcaa8aSmrgThe action of the default handlers is to print an explanatory
1943e9fcaa8aSmrgmessage and exit.
1944e9fcaa8aSmrg</para>
1945e9fcaa8aSmrg<para>
1946e9fcaa8aSmrg<!-- .LP -->
1947e9fcaa8aSmrg<!-- .sp -->
1948e9fcaa8aSmrgTo set the error handler, use
1949eb411b4bSmrg<xref linkend='XSetErrorHandler' xrefstyle='select: title'/>.
1950eb411b4bSmrg</para>
1951e9fcaa8aSmrg<indexterm significance="preferred"><primary>XSetErrorHandler</primary></indexterm>
1952e9fcaa8aSmrg<!-- .sM -->
1953eb411b4bSmrg<funcsynopsis id='XSetErrorHandler'>
1954e9fcaa8aSmrg<funcprototype>
1955e9fcaa8aSmrg  <funcdef>int *<function>XSetErrorHandler</function></funcdef>
1956e9fcaa8aSmrg  <paramdef>int <parameter> *handler</parameter></paramdef>
1957e9fcaa8aSmrg</funcprototype>
1958e9fcaa8aSmrg</funcsynopsis>
1959e9fcaa8aSmrg<!-- .FN -->
1960e9fcaa8aSmrg<variablelist>
1961e9fcaa8aSmrg  <varlistentry>
1962e9fcaa8aSmrg    <term>
1963e9fcaa8aSmrg      <emphasis remap='I'>handler</emphasis>
1964e9fcaa8aSmrg    </term>
1965e9fcaa8aSmrg    <listitem>
1966e9fcaa8aSmrg      <para>
1967e9fcaa8aSmrgSpecifies the program's supplied error handler.
1968e9fcaa8aSmrg    </para>
1969e9fcaa8aSmrg  </listitem>
1970e9fcaa8aSmrg  </varlistentry>
1971e9fcaa8aSmrg</variablelist>
1972e9fcaa8aSmrg<para>
1973e9fcaa8aSmrg<!-- .LP -->
1974e9fcaa8aSmrg<!-- .eM  -->
1975e9fcaa8aSmrgXlib generally calls the program's
1976e9fcaa8aSmrgsupplied error handler whenever an error is received.
1977e9fcaa8aSmrgIt is not called on
1978e9fcaa8aSmrg<errorname>BadName</errorname>
1979e9fcaa8aSmrgerrors from
1980e9fcaa8aSmrg<systemitem>OpenFont</systemitem>,
1981e9fcaa8aSmrg<systemitem>LookupColor</systemitem>,
1982e9fcaa8aSmrgor
1983e9fcaa8aSmrg<systemitem>AllocNamedColor</systemitem>
1984e9fcaa8aSmrgprotocol requests or on
1985e9fcaa8aSmrg<errorname>BadFont</errorname>
1986e9fcaa8aSmrgerrors from a
1987e9fcaa8aSmrg<systemitem>QueryFont</systemitem>
1988e9fcaa8aSmrgprotocol request.
1989e9fcaa8aSmrgThese errors generally are reflected back to the program through the
1990e9fcaa8aSmrgprocedural interface.
1991e9fcaa8aSmrgBecause this condition is not assumed to be fatal, 
1992e9fcaa8aSmrgit is acceptable for your error handler to return;
1993e9fcaa8aSmrgthe returned value is ignored.
1994e9fcaa8aSmrgHowever, the error handler should not
1995e9fcaa8aSmrgcall any functions (directly or indirectly) on the display
1996e9fcaa8aSmrgthat will generate protocol requests or that will look for input events.
1997e9fcaa8aSmrgThe previous error handler is returned.
1998e9fcaa8aSmrg</para>
1999e9fcaa8aSmrg<para>
2000e9fcaa8aSmrg<!-- .LP -->
2001e9fcaa8aSmrgThe 
2002e9fcaa8aSmrg<structname>XErrorEvent</structname>
2003e9fcaa8aSmrgstructure contains:
2004e9fcaa8aSmrg<indexterm><primary>Debugging</primary><secondary>error event</secondary></indexterm>
2005e9fcaa8aSmrg</para>
2006e9fcaa8aSmrg<para>
2007e9fcaa8aSmrg<!-- .LP -->
2008e9fcaa8aSmrg<indexterm significance="preferred"><primary>XErrorEvent</primary></indexterm>
2009e9fcaa8aSmrg<literallayout class="monospaced">
2010e9fcaa8aSmrg<!-- .TA .5i 2.5i -->
2011e9fcaa8aSmrg<!-- .ta .5i 2.5i -->
2012e9fcaa8aSmrgtypedef struct {
2013e9fcaa8aSmrg	int type;
2014e9fcaa8aSmrg	Display *display;	/* Display the event was read from */
2015e9fcaa8aSmrg	unsigned long serial;		/* serial number of failed request */
2016e9fcaa8aSmrg	unsigned char error_code;	/* error code of failed request */
2017e9fcaa8aSmrg	unsigned char request_code;	/* Major op-code of failed request */
2018e9fcaa8aSmrg	unsigned char minor_code;	/* Minor op-code of failed request */
2019e9fcaa8aSmrg	XID resourceid;		/* resource id */
2020e9fcaa8aSmrg} XErrorEvent;
2021e9fcaa8aSmrg</literallayout>
2022e9fcaa8aSmrg</para>
2023e9fcaa8aSmrg<para>
2024e9fcaa8aSmrg<!-- .LP -->
2025e9fcaa8aSmrg<indexterm><primary>Serial Number</primary></indexterm>
2026e9fcaa8aSmrgThe serial member is the number of requests, starting from one, 
2027e9fcaa8aSmrgsent over the network connection since it was opened. 
2028e9fcaa8aSmrgIt is the number that was the value of 
2029e9fcaa8aSmrg<function>NextRequest</function>
2030e9fcaa8aSmrgimmediately before the failing call was made.  
2031e9fcaa8aSmrgThe request_code member is a protocol request
2032e9fcaa8aSmrgof the procedure that failed, as defined in 
20336cc2b21fSmrg<filename class="headerfile">&lt;X11/Xproto.h&gt;</filename>.
2034e9fcaa8aSmrgThe following error codes can be returned by the functions described in this
2035e9fcaa8aSmrgchapter:
2036e9fcaa8aSmrg</para>
2037e9fcaa8aSmrg<!-- .br -->
2038e9fcaa8aSmrg<!-- .ne 13 -->
2039e9fcaa8aSmrg<indexterm><primary>Debugging</primary><secondary>error numbers</secondary></indexterm>
2040e9fcaa8aSmrg<indexterm><primary>Error</primary><secondary>codes</secondary></indexterm>
2041e9fcaa8aSmrg<!-- .\".CP T 3 -->
2042e9fcaa8aSmrg<!-- .\"Error Codes -->
2043e9fcaa8aSmrg<indexterm significance="preferred"><primary>BadAccess</primary></indexterm>
2044e9fcaa8aSmrg<indexterm significance="preferred"><primary>BadAlloc</primary></indexterm>
2045e9fcaa8aSmrg<indexterm significance="preferred"><primary>BadAtom</primary></indexterm>
2046e9fcaa8aSmrg<indexterm significance="preferred"><primary>BadColor</primary></indexterm>
2047e9fcaa8aSmrg<indexterm significance="preferred"><primary>BadCursor</primary></indexterm>
2048e9fcaa8aSmrg<indexterm significance="preferred"><primary>BadDrawable</primary></indexterm>
2049e9fcaa8aSmrg<indexterm significance="preferred"><primary>BadFont</primary></indexterm>
2050e9fcaa8aSmrg<indexterm significance="preferred"><primary>BadGC</primary></indexterm>
2051e9fcaa8aSmrg<indexterm significance="preferred"><primary>BadIDChoice</primary></indexterm>
2052eb411b4bSmrg<informaltable frame='topbot'>
2053eb411b4bSmrg  <?dbfo keep-together="auto" ?>
2054eb411b4bSmrg  <tgroup cols='2' align='left' colsep='0' rowsep='0'>
2055eb411b4bSmrg  <colspec colname='c1' colwidth='1.0*'/>
2056eb411b4bSmrg  <colspec colname='c2' colwidth='3.5*'/>
2057e9fcaa8aSmrg  <thead>
2058eb411b4bSmrg    <row rowsep='1'>
2059e9fcaa8aSmrg      <entry>Error Code</entry>
2060e9fcaa8aSmrg      <entry>Description</entry>
2061e9fcaa8aSmrg    </row>
2062e9fcaa8aSmrg  </thead>
2063e9fcaa8aSmrg  <tbody>
2064e9fcaa8aSmrg    <row>
20656cc2b21fSmrg      <entry><errorname id='BadAccess'>BadAccess</errorname></entry>
2066eb411b4bSmrg      <entry>
2067eb411b4bSmrg      <para>A client attempts to grab a key/button combination already grabbed
2068eb411b4bSmrg      by another client.</para>
2069eb411b4bSmrg      <para>A client attempts to free a colormap entry that it had not already allocated
2070eb411b4bSmrg      or to free an entry in a colormap that was created with all entries writable.</para>
2071eb411b4bSmrg      <para>A client attempts to store into a read-only or unallocated colormap entry.</para>
2072eb411b4bSmrg      <para>A client attempts to modify the access control list from other than the local
2073eb411b4bSmrg      (or otherwise authorized) host.</para>
2074eb411b4bSmrg      <para>A client attempts to select an event type that another client
2075eb411b4bSmrg      has already selected.</para>
2076eb411b4bSmrg      </entry>
2077e9fcaa8aSmrg    </row>
2078e9fcaa8aSmrg    <row>
20796cc2b21fSmrg      <entry><errorname id='BadAlloc'>BadAlloc</errorname></entry>
2080e9fcaa8aSmrg      <entry>The server fails to allocate the requested resource.
2081e9fcaa8aSmrg      Note that the explicit listing of
2082e9fcaa8aSmrg      <errorname>BadAlloc</errorname>
2083e9fcaa8aSmrg      errors in requests only covers allocation errors at a very coarse level
2084e9fcaa8aSmrg      and is not intended to (nor can it in practice hope to) cover all cases of
2085e9fcaa8aSmrg      a server running out of allocation space in the middle of service.
2086e9fcaa8aSmrg      The semantics when a server runs out of allocation space are left unspecified,
2087e9fcaa8aSmrg      but a server may generate a
2088e9fcaa8aSmrg      <errorname>BadAlloc</errorname>
2089e9fcaa8aSmrg      error on any request for this reason,
2090e9fcaa8aSmrg      and clients should be prepared to receive such errors and handle or discard
2091e9fcaa8aSmrg      them.</entry>
2092e9fcaa8aSmrg    </row>
2093e9fcaa8aSmrg    <row>
20946cc2b21fSmrg      <entry><errorname id='BadAtom'>BadAtom</errorname></entry>
2095e9fcaa8aSmrg      <entry>A value for an atom argument does not name a defined atom.</entry>
2096e9fcaa8aSmrg    </row>
2097e9fcaa8aSmrg    <row>
20986cc2b21fSmrg      <entry><errorname id='BadColor'>BadColor</errorname></entry>
2099e9fcaa8aSmrg      <entry>A value for a colormap argument does not name a defined colormap.</entry>
2100e9fcaa8aSmrg    </row>
2101e9fcaa8aSmrg    <row>
21026cc2b21fSmrg      <entry><errorname id='BadCursor'>BadCursor</errorname></entry>
2103e9fcaa8aSmrg      <entry>A value for a cursor argument does not name a defined cursor.</entry>
2104e9fcaa8aSmrg    </row>
2105e9fcaa8aSmrg    <row>
21066cc2b21fSmrg      <entry><errorname id='BadDrawable'>BadDrawable</errorname></entry>
2107e9fcaa8aSmrg      <entry>A value for a drawable argument does not name a defined window or pixmap.</entry>
2108e9fcaa8aSmrg    </row>
2109e9fcaa8aSmrg    <row>
21106cc2b21fSmrg      <entry><errorname id='BadFont'>BadFont</errorname></entry>
2111e9fcaa8aSmrg      <entry>A value for a font argument does not name a defined font (or, in some cases,
2112e9fcaa8aSmrg      <type>GContext</type>).</entry>
2113e9fcaa8aSmrg    </row>
2114e9fcaa8aSmrg    <row>
21156cc2b21fSmrg      <entry><errorname id='BadGC'>BadGC</errorname></entry>
2116e9fcaa8aSmrg      <entry>A value for a
2117e9fcaa8aSmrg      <type>GContext</type>
2118e9fcaa8aSmrg      argument does not name a defined 
2119e9fcaa8aSmrg      <type>GContext</type>.</entry>
2120e9fcaa8aSmrg    </row>
2121e9fcaa8aSmrg    <row>
21226cc2b21fSmrg      <entry><errorname id='BadIDChoice'>BadIDChoice</errorname></entry>
2123e9fcaa8aSmrg      <entry>The value chosen for a resource identifier either is not included in the
2124e9fcaa8aSmrg      range assigned to the client or is already in use.
2125e9fcaa8aSmrg      Under normal circumstances,
2126e9fcaa8aSmrg      this cannot occur and should be considered a server or Xlib error.</entry>
2127e9fcaa8aSmrg    </row>
2128e9fcaa8aSmrg    <row>
21296cc2b21fSmrg      <entry><errorname id='BadImplementation'>BadImplementation</errorname></entry>
2130e9fcaa8aSmrg      <entry>The server does not implement some aspect of the request.
2131e9fcaa8aSmrg      A server that generates this error for a core request is deficient.
2132e9fcaa8aSmrg      As such, this error is not listed for any of the requests,
2133e9fcaa8aSmrg      but clients should be prepared to receive such errors
2134e9fcaa8aSmrg      and handle or discard them.</entry>
2135e9fcaa8aSmrg    </row>
2136e9fcaa8aSmrg    <row>
21376cc2b21fSmrg      <entry><errorname id='BadLength'>BadLength</errorname></entry>
2138eb411b4bSmrg      <entry><para>The length of a request is shorter or longer than that required to
2139e9fcaa8aSmrg      contain the arguments.
2140eb411b4bSmrg      This is an internal Xlib or server error.</para>
2141eb411b4bSmrg      <para>The length of a request exceeds the maximum length accepted by the server.</para>
2142eb411b4bSmrg      </entry>
2143e9fcaa8aSmrg    </row>
2144e9fcaa8aSmrg    <row>
21456cc2b21fSmrg      <entry><errorname id='BadMatch'>BadMatch</errorname></entry>
2146eb411b4bSmrg      <entry><para>In a graphics request,
2147eb411b4bSmrg      the root and depth of the graphics context do not match those of the drawable.</para>
2148eb411b4bSmrg      <para>An <symbol>InputOnly</symbol> window is used as a drawable.</para>
2149eb411b4bSmrg      <para>Some argument or pair of arguments has the correct type and range,
2150eb411b4bSmrg      but it fails to match in some other way required by the request.</para>
2151eb411b4bSmrg      <para>An <symbol>InputOnly</symbol>
2152eb411b4bSmrg      window lacks this attribute.</para>
2153eb411b4bSmrg      </entry>
2154e9fcaa8aSmrg    </row>
2155e9fcaa8aSmrg    <row>
21566cc2b21fSmrg      <entry><errorname id='BadName'>BadName</errorname></entry>
2157e9fcaa8aSmrg      <entry>A font or color of the specified name does not exist.</entry>
2158e9fcaa8aSmrg    </row>
2159e9fcaa8aSmrg    <row>
21606cc2b21fSmrg      <entry><errorname id='BadPixmap'>BadPixmap</errorname></entry>
2161e9fcaa8aSmrg      <entry>A value for a pixmap argument does not name a defined pixmap.</entry>
2162e9fcaa8aSmrg    </row>
2163e9fcaa8aSmrg    <row>
21646cc2b21fSmrg      <entry><errorname id='BadRequest'>BadRequest</errorname></entry>
2165e9fcaa8aSmrg      <entry>The major or minor opcode does not specify a valid request.
2166e9fcaa8aSmrg      This usually is an Xlib or server error.</entry>
2167e9fcaa8aSmrg    </row>
2168e9fcaa8aSmrg    <row>
21696cc2b21fSmrg      <entry><errorname id='BadValue'>BadValue</errorname></entry>
2170e9fcaa8aSmrg      <entry>Some numeric value falls outside of the range of values accepted
2171e9fcaa8aSmrg      by the request.
2172e9fcaa8aSmrg      Unless a specific range is specified for an argument,
2173e9fcaa8aSmrg      the full range defined by the argument's type is accepted.
2174e9fcaa8aSmrg      Any argument defined as a set of alternatives typically can generate
2175e9fcaa8aSmrg      this error (due to the encoding).</entry>
2176e9fcaa8aSmrg    </row>
2177e9fcaa8aSmrg    <row>
21786cc2b21fSmrg      <entry><errorname id='BadWindow'>BadWindow</errorname></entry>
2179e9fcaa8aSmrg      <entry>A value for a window argument does not name a defined window.</entry>
2180e9fcaa8aSmrg    </row>
2181e9fcaa8aSmrg  </tbody>
2182e9fcaa8aSmrg  </tgroup>
2183e9fcaa8aSmrg</informaltable>
2184e9fcaa8aSmrg
2185e9fcaa8aSmrg<indexterm significance="preferred"><primary>BadImplementation</primary></indexterm>
2186e9fcaa8aSmrg<indexterm significance="preferred"><primary>BadLength</primary></indexterm>
2187e9fcaa8aSmrg<indexterm significance="preferred"><primary>BadMatch</primary></indexterm>
2188e9fcaa8aSmrg<indexterm significance="preferred"><primary>BadName</primary></indexterm>
2189e9fcaa8aSmrg<indexterm significance="preferred"><primary>BadPixmap</primary></indexterm>
2190e9fcaa8aSmrg<indexterm significance="preferred"><primary>BadRequest</primary></indexterm>
2191e9fcaa8aSmrg<indexterm significance="preferred"><primary>BadValue</primary></indexterm>
2192e9fcaa8aSmrg<indexterm significance="preferred"><primary>BadWindow</primary></indexterm>
2193e9fcaa8aSmrg<!-- .NT Note -->
2194e9fcaa8aSmrg
2195e9fcaa8aSmrg<note>
2196e9fcaa8aSmrg<para>
2197e9fcaa8aSmrgThe 
2198e9fcaa8aSmrg<errorname>BadAtom</errorname>,
2199e9fcaa8aSmrg<errorname>BadColor</errorname>,
2200e9fcaa8aSmrg<errorname>BadCursor</errorname>,
2201e9fcaa8aSmrg<errorname>BadDrawable</errorname>,
2202e9fcaa8aSmrg<errorname>BadFont</errorname>,
2203e9fcaa8aSmrg<errorname>BadGC</errorname>,
2204e9fcaa8aSmrg<errorname>BadPixmap</errorname>,
2205e9fcaa8aSmrgand 
2206e9fcaa8aSmrg<errorname>BadWindow</errorname>
2207e9fcaa8aSmrgerrors are also used when the argument type is extended by a set of
2208e9fcaa8aSmrgfixed alternatives.
2209e9fcaa8aSmrg</para>
2210e9fcaa8aSmrg</note>
2211e9fcaa8aSmrg
2212e9fcaa8aSmrg<!-- .NE -->
2213e9fcaa8aSmrg<!-- .sp -->
2214e9fcaa8aSmrg<para>
2215e9fcaa8aSmrg<!-- .LP -->
2216e9fcaa8aSmrgTo obtain textual descriptions of the specified error code, use 
2217eb411b4bSmrg<xref linkend='XGetErrorText' xrefstyle='select: title'/>.
2218eb411b4bSmrg</para>
2219e9fcaa8aSmrg<indexterm significance="preferred"><primary>XGetErrorText</primary></indexterm>
2220e9fcaa8aSmrg<indexterm><primary>Debugging</primary><secondary>error message strings</secondary></indexterm>
2221e9fcaa8aSmrg<!-- .sM -->
2222eb411b4bSmrg<funcsynopsis id='XGetErrorText'>
2223e9fcaa8aSmrg<funcprototype>
2224e9fcaa8aSmrg  <funcdef><function>XGetErrorText</function></funcdef>
2225e9fcaa8aSmrg  <paramdef>Display<parameter> *display</parameter></paramdef>
2226e9fcaa8aSmrg  <paramdef>int<parameter> code</parameter></paramdef>
2227e9fcaa8aSmrg  <paramdef>char<parameter> *buffer_return</parameter></paramdef>
2228e9fcaa8aSmrg  <paramdef>int<parameter> length</parameter></paramdef>
2229e9fcaa8aSmrg</funcprototype>
2230e9fcaa8aSmrg</funcsynopsis>
2231e9fcaa8aSmrg<!-- .FN -->
2232e9fcaa8aSmrg<variablelist>
2233e9fcaa8aSmrg  <varlistentry>
2234e9fcaa8aSmrg    <term>
2235e9fcaa8aSmrg      <emphasis remap='I'>display</emphasis>
2236e9fcaa8aSmrg    </term>
2237e9fcaa8aSmrg    <listitem>
2238e9fcaa8aSmrg      <para>
2239e9fcaa8aSmrgSpecifies the connection to the X server.
2240e9fcaa8aSmrg      </para>
2241e9fcaa8aSmrg    </listitem>
2242e9fcaa8aSmrg  </varlistentry>
2243e9fcaa8aSmrg  <varlistentry>
2244e9fcaa8aSmrg    <term>
2245e9fcaa8aSmrg      <emphasis remap='I'>code</emphasis>
2246e9fcaa8aSmrg    </term>
2247e9fcaa8aSmrg    <listitem>
2248e9fcaa8aSmrg      <para>
2249e9fcaa8aSmrgSpecifies the error code for which you want to obtain a description.
2250e9fcaa8aSmrg      </para>
2251e9fcaa8aSmrg    </listitem>
2252e9fcaa8aSmrg  </varlistentry>
2253e9fcaa8aSmrg  <varlistentry>
2254e9fcaa8aSmrg    <term>
2255e9fcaa8aSmrg      <emphasis remap='I'>buffer_return</emphasis>
2256e9fcaa8aSmrg    </term>
2257e9fcaa8aSmrg    <listitem>
2258e9fcaa8aSmrg      <para>
2259e9fcaa8aSmrgReturns the error description.
2260e9fcaa8aSmrg      </para>
2261e9fcaa8aSmrg    </listitem>
2262e9fcaa8aSmrg  </varlistentry>
2263e9fcaa8aSmrg  <varlistentry>
2264e9fcaa8aSmrg    <term>
2265e9fcaa8aSmrg      <emphasis remap='I'>length</emphasis>
2266e9fcaa8aSmrg    </term>
2267e9fcaa8aSmrg    <listitem>
2268e9fcaa8aSmrg      <para>
2269e9fcaa8aSmrgSpecifies the size of the buffer.
2270e9fcaa8aSmrg    </para>
2271e9fcaa8aSmrg  </listitem>
2272e9fcaa8aSmrg  </varlistentry>
2273e9fcaa8aSmrg</variablelist>
2274e9fcaa8aSmrg<para>
2275e9fcaa8aSmrg<!-- .LP -->
2276e9fcaa8aSmrg<!-- .eM  -->
2277e9fcaa8aSmrgThe
2278eb411b4bSmrg<xref linkend='XGetErrorText' xrefstyle='select: title'/>
2279e9fcaa8aSmrgfunction copies a null-terminated string describing the specified error code
2280e9fcaa8aSmrginto the specified buffer.
2281e9fcaa8aSmrgThe returned text is in the encoding of the current locale.
2282e9fcaa8aSmrgIt is recommended that you use this function to obtain an error description
2283e9fcaa8aSmrgbecause extensions to Xlib may define their own error codes
2284e9fcaa8aSmrgand error strings.
2285e9fcaa8aSmrg</para>
2286e9fcaa8aSmrg<para>
2287e9fcaa8aSmrg<!-- .LP -->
2288e9fcaa8aSmrg<!-- .sp -->
2289e9fcaa8aSmrgTo obtain error messages from the error database, use
2290eb411b4bSmrg<xref linkend='XGetErrorDatabaseText' xrefstyle='select: title'/>.
2291eb411b4bSmrg</para>
2292e9fcaa8aSmrg<indexterm significance="preferred"><primary>XGetErrorDatabaseText</primary></indexterm>
2293e9fcaa8aSmrg<!-- .sM -->
2294eb411b4bSmrg<funcsynopsis id='XGetErrorDatabaseText'>
2295e9fcaa8aSmrg<funcprototype>
2296e9fcaa8aSmrg  <funcdef><function>XGetErrorDatabaseText</function></funcdef>
2297e9fcaa8aSmrg  <paramdef>Display<parameter> *display</parameter></paramdef>
2298e9fcaa8aSmrg  <paramdef>char*name,<parameter> *message</parameter></paramdef>
2299e9fcaa8aSmrg  <paramdef>char<parameter> *default_string</parameter></paramdef>
2300e9fcaa8aSmrg  <paramdef>char<parameter> *buffer_return</parameter></paramdef>
2301e9fcaa8aSmrg  <paramdef>int<parameter> length</parameter></paramdef>
2302e9fcaa8aSmrg</funcprototype>
2303e9fcaa8aSmrg</funcsynopsis>
2304e9fcaa8aSmrg<!-- .FN -->
2305e9fcaa8aSmrg<variablelist>
2306e9fcaa8aSmrg  <varlistentry>
2307e9fcaa8aSmrg    <term>
2308e9fcaa8aSmrg      <emphasis remap='I'>display</emphasis>
2309e9fcaa8aSmrg    </term>
2310e9fcaa8aSmrg    <listitem>
2311e9fcaa8aSmrg      <para>
2312e9fcaa8aSmrgSpecifies the connection to the X server.
2313e9fcaa8aSmrg      </para>
2314e9fcaa8aSmrg    </listitem>
2315e9fcaa8aSmrg  </varlistentry>
2316e9fcaa8aSmrg  <varlistentry>
2317e9fcaa8aSmrg    <term>
2318e9fcaa8aSmrg      <emphasis remap='I'>name</emphasis>
2319e9fcaa8aSmrg    </term>
2320e9fcaa8aSmrg    <listitem>
2321e9fcaa8aSmrg      <para>
2322e9fcaa8aSmrgSpecifies the name of the application.
2323e9fcaa8aSmrg      </para>
2324e9fcaa8aSmrg    </listitem>
2325e9fcaa8aSmrg  </varlistentry>
2326e9fcaa8aSmrg  <varlistentry>
2327e9fcaa8aSmrg    <term>
2328e9fcaa8aSmrg      <emphasis remap='I'>message</emphasis>
2329e9fcaa8aSmrg    </term>
2330e9fcaa8aSmrg    <listitem>
2331e9fcaa8aSmrg      <para>
2332e9fcaa8aSmrgSpecifies the type of the error message.
2333e9fcaa8aSmrg      </para>
2334e9fcaa8aSmrg    </listitem>
2335e9fcaa8aSmrg  </varlistentry>
2336e9fcaa8aSmrg  <varlistentry>
2337e9fcaa8aSmrg    <term>
2338e9fcaa8aSmrg      <emphasis remap='I'>default_string</emphasis>
2339e9fcaa8aSmrg    </term>
2340e9fcaa8aSmrg    <listitem>
2341e9fcaa8aSmrg      <para>
2342e9fcaa8aSmrgSpecifies the default error message if none is found in the database.
2343e9fcaa8aSmrg      </para>
2344e9fcaa8aSmrg    </listitem>
2345e9fcaa8aSmrg  </varlistentry>
2346e9fcaa8aSmrg  <varlistentry>
2347e9fcaa8aSmrg    <term>
2348e9fcaa8aSmrg      <emphasis remap='I'>buffer_return</emphasis>
2349e9fcaa8aSmrg    </term>
2350e9fcaa8aSmrg    <listitem>
2351e9fcaa8aSmrg      <para>
2352e9fcaa8aSmrgReturns the error description.
2353e9fcaa8aSmrg      </para>
2354e9fcaa8aSmrg    </listitem>
2355e9fcaa8aSmrg  </varlistentry>
2356e9fcaa8aSmrg  <varlistentry>
2357e9fcaa8aSmrg    <term>
2358e9fcaa8aSmrg      <emphasis remap='I'>length</emphasis>
2359e9fcaa8aSmrg    </term>
2360e9fcaa8aSmrg    <listitem>
2361e9fcaa8aSmrg      <para>
2362e9fcaa8aSmrgSpecifies the size of the buffer.
2363e9fcaa8aSmrg    </para>
2364e9fcaa8aSmrg  </listitem>
2365e9fcaa8aSmrg  </varlistentry>
2366e9fcaa8aSmrg</variablelist>
2367e9fcaa8aSmrg<para>
2368e9fcaa8aSmrg<!-- .LP -->
2369e9fcaa8aSmrg<!-- .eM -->
2370e9fcaa8aSmrgThe
2371eb411b4bSmrg<xref linkend='XGetErrorDatabaseText' xrefstyle='select: title'/>
2372e9fcaa8aSmrgfunction returns a null-terminated message
2373e9fcaa8aSmrg(or the default message) from the error message
2374e9fcaa8aSmrgdatabase.
2375e9fcaa8aSmrgXlib uses this function internally to look up its error messages.
2376e9fcaa8aSmrgThe text in the default_string argument is assumed
2377e9fcaa8aSmrgto be in the encoding of the current locale,
2378e9fcaa8aSmrgand the text stored in the buffer_return argument
2379e9fcaa8aSmrgis in the encoding of the current locale.
2380e9fcaa8aSmrg</para>
2381e9fcaa8aSmrg<para>
2382e9fcaa8aSmrg<!-- .LP -->
2383e9fcaa8aSmrgThe name argument should generally be the name of your application.
2384e9fcaa8aSmrgThe message argument should indicate which type of error message you want.
2385e9fcaa8aSmrgIf the name and message are not in the Host Portable Character Encoding,
2386e9fcaa8aSmrgthe result is implementation-dependent.
2387e9fcaa8aSmrgXlib uses three predefined ``application names'' to report errors.
2388e9fcaa8aSmrgIn these names,
2389e9fcaa8aSmrguppercase and lowercase matter.
2390e9fcaa8aSmrg<variablelist>
2391e9fcaa8aSmrg  <varlistentry>
2392e9fcaa8aSmrg    <term>
2393e9fcaa8aSmrg      XProtoError
2394e9fcaa8aSmrg    </term>
2395e9fcaa8aSmrg    <listitem>
2396e9fcaa8aSmrg      <para>
2397e9fcaa8aSmrgThe protocol error number is used as a string for the message argument.
2398e9fcaa8aSmrg      </para>
2399e9fcaa8aSmrg    </listitem>
2400e9fcaa8aSmrg  </varlistentry>
2401e9fcaa8aSmrg  <varlistentry>
2402e9fcaa8aSmrg    <term>
2403e9fcaa8aSmrg      XlibMessage
2404e9fcaa8aSmrg    </term>
2405e9fcaa8aSmrg    <listitem>
2406e9fcaa8aSmrg      <para>
2407e9fcaa8aSmrgThese are the message strings that are used internally by the library.
2408e9fcaa8aSmrg      </para>
2409e9fcaa8aSmrg    </listitem>
2410e9fcaa8aSmrg  </varlistentry>
2411e9fcaa8aSmrg  <varlistentry>
2412e9fcaa8aSmrg    <term>
2413e9fcaa8aSmrg      XRequest
2414e9fcaa8aSmrg    </term>
2415e9fcaa8aSmrg    <listitem>
2416e9fcaa8aSmrg      <para>
2417e9fcaa8aSmrgFor a core protocol request,
2418e9fcaa8aSmrgthe major request protocol number is used for the message argument.
2419e9fcaa8aSmrgFor an extension request,
2420e9fcaa8aSmrgthe extension name (as given by
2421e9fcaa8aSmrg<function>InitExtension</function>)
2422e9fcaa8aSmrgfollowed by a period (.) and the minor request protocol number 
2423e9fcaa8aSmrgis used for the message argument.
2424e9fcaa8aSmrgIf no string is found in the error database,
2425e9fcaa8aSmrgthe default_string is returned to the buffer argument.
2426e9fcaa8aSmrg    </para>
2427e9fcaa8aSmrg  </listitem>
2428e9fcaa8aSmrg  </varlistentry>
2429e9fcaa8aSmrg</variablelist>
2430e9fcaa8aSmrg</para>
2431e9fcaa8aSmrg<para>
2432e9fcaa8aSmrg<!-- .LP -->
2433e9fcaa8aSmrg<!-- .sp -->
2434e9fcaa8aSmrgTo report an error to the user when the requested display does not exist, use
2435eb411b4bSmrg<xref linkend='XDisplayName' xrefstyle='select: title'/>.
2436eb411b4bSmrg</para>
2437e9fcaa8aSmrg<indexterm significance="preferred"><primary>XDisplayName</primary></indexterm>
2438e9fcaa8aSmrg<!-- .sM -->
2439eb411b4bSmrg<funcsynopsis id='XDisplayName'>
2440e9fcaa8aSmrg<funcprototype>
2441e9fcaa8aSmrg  <funcdef>char *<function>XDisplayName</function></funcdef>
2442e9fcaa8aSmrg  <paramdef>char<parameter> *string</parameter></paramdef>
2443e9fcaa8aSmrg</funcprototype>
2444e9fcaa8aSmrg</funcsynopsis>
2445e9fcaa8aSmrg<!-- .FN -->
2446e9fcaa8aSmrg<variablelist>
2447e9fcaa8aSmrg  <varlistentry>
2448e9fcaa8aSmrg    <term>
2449e9fcaa8aSmrg      <emphasis remap='I'>string</emphasis>
2450e9fcaa8aSmrg    </term>
2451e9fcaa8aSmrg    <listitem>
2452e9fcaa8aSmrg      <para>
2453e9fcaa8aSmrgSpecifies the character string.
2454e9fcaa8aSmrg    </para>
2455e9fcaa8aSmrg  </listitem>
2456e9fcaa8aSmrg  </varlistentry>
2457e9fcaa8aSmrg</variablelist>
2458e9fcaa8aSmrg<para>
2459e9fcaa8aSmrg<!-- .LP -->
2460e9fcaa8aSmrg<!-- .eM -->
2461e9fcaa8aSmrgThe
2462eb411b4bSmrg<xref linkend='XDisplayName' xrefstyle='select: title'/>
2463e9fcaa8aSmrgfunction returns the name of the display that 
2464eb411b4bSmrg<xref linkend='XOpenDisplay' xrefstyle='select: title'/>
2465e9fcaa8aSmrgwould attempt to use.
2466e9fcaa8aSmrgIf a NULL string is specified,
2467eb411b4bSmrg<xref linkend='XDisplayName' xrefstyle='select: title'/>
2468e9fcaa8aSmrglooks in the environment for the display and returns the display name that
2469eb411b4bSmrg<xref linkend='XOpenDisplay' xrefstyle='select: title'/>
2470e9fcaa8aSmrgwould attempt to use.
2471e9fcaa8aSmrgThis makes it easier to report to the user precisely which display the
2472e9fcaa8aSmrgprogram attempted to open when the initial connection attempt failed.
2473e9fcaa8aSmrg</para>
2474e9fcaa8aSmrg<para>
2475e9fcaa8aSmrg<!-- .LP -->
2476e9fcaa8aSmrg<!-- .sp -->
2477e9fcaa8aSmrgTo handle fatal I/O errors, use
2478e9fcaa8aSmrg<function>XSetIOErrorHandler</function>.
2479eb411b4bSmrg</para>
2480e9fcaa8aSmrg<indexterm significance="preferred"><primary>XSetIOErrorHandler</primary></indexterm>
2481e9fcaa8aSmrg<!-- .sM -->
24826cc2b21fSmrg<funcsynopsis id='xsetioerrorhandler'>
2483e9fcaa8aSmrg<funcprototype>
2484e9fcaa8aSmrg  <funcdef><type>int</type></funcdef>
2485e9fcaa8aSmrg  <paramdef>int(*handler)(Display<parameter> *)</parameter></paramdef>
2486e9fcaa8aSmrg</funcprototype>
2487e9fcaa8aSmrg</funcsynopsis>
2488e9fcaa8aSmrg<!-- .FN -->
2489e9fcaa8aSmrg<variablelist>
2490e9fcaa8aSmrg  <varlistentry>
2491e9fcaa8aSmrg    <term>
2492e9fcaa8aSmrg      <emphasis remap='I'>handler</emphasis>
2493e9fcaa8aSmrg    </term>
2494e9fcaa8aSmrg    <listitem>
2495e9fcaa8aSmrg      <para>
2496e9fcaa8aSmrgSpecifies the program's supplied error handler.
2497e9fcaa8aSmrg    </para>
2498e9fcaa8aSmrg  </listitem>
2499e9fcaa8aSmrg  </varlistentry>
2500e9fcaa8aSmrg</variablelist>
2501e9fcaa8aSmrg<para>
2502e9fcaa8aSmrg<!-- .LP -->
2503e9fcaa8aSmrg<!-- .eM -->
2504e9fcaa8aSmrgThe
2505e9fcaa8aSmrg<function>XSetIOErrorHandler</function>
2506e9fcaa8aSmrgsets the fatal I/O error handler.
2507e9fcaa8aSmrgXlib calls the program's supplied error handler if any sort of system call
2508e9fcaa8aSmrgerror occurs (for example, the connection to the server was lost).
2509e9fcaa8aSmrgThis is assumed to be a fatal condition,
2510e9fcaa8aSmrgand the called routine should not return.
2511e9fcaa8aSmrgIf the I/O error handler does return,
2512e9fcaa8aSmrgthe client process exits.
2513e9fcaa8aSmrg</para>
2514e9fcaa8aSmrg<para>
2515e9fcaa8aSmrg<!-- .LP -->
2516e9fcaa8aSmrgNote that the previous error handler is returned.
2517e9fcaa8aSmrg<!-- .bp -->
2518e9fcaa8aSmrg
2519e9fcaa8aSmrg</para>
2520e9fcaa8aSmrg</sect2>
2521e9fcaa8aSmrg</sect1>
2522e9fcaa8aSmrg</chapter>
2523