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