10f8248bfSmrg<?xml version="1.0" encoding="UTF-8" ?> 20f8248bfSmrg<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" 30f8248bfSmrg "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"> 4eb411b4bSmrg<chapter id='Initialization_and_General_Programming_Information'> 5e9fcaa8aSmrg<title>Initialization and General Programming Information</title> 6eb411b4bSmrg<sect1 id='Extension_Header_Files'> 7e9fcaa8aSmrg<title>Extension Header Files</title> 8e9fcaa8aSmrg<para> 9e9fcaa8aSmrgThe following include files are part of the Xkb standard: 10e9fcaa8aSmrg</para> 11e9fcaa8aSmrg<itemizedlist> 12e9fcaa8aSmrg <listitem> 13e9fcaa8aSmrg <para> 140f8248bfSmrg<filename class="headerfile"><X11/XKBlib.h></filename> 15e9fcaa8aSmrg </para> 160f8248bfSmrg <para><filename class="headerfile">XKBlib.h</filename> 17e9fcaa8aSmrgis the main header file for Xkb; it declares constants, types, and 18e9fcaa8aSmrgfunctions. 19e9fcaa8aSmrg </para> 20e9fcaa8aSmrg </listitem> 21e9fcaa8aSmrg <listitem> 22e9fcaa8aSmrg <para> 230f8248bfSmrg<filename class="headerfile"><X11/extensions/XKBstr.h></filename> 24e9fcaa8aSmrg </para> 25e9fcaa8aSmrg <para> 260f8248bfSmrg<filename class="headerfile">XKBstr.h</filename> declares types and 27e9fcaa8aSmrgconstants for Xkb. It is included automatically from 280f8248bfSmrg<filename class="headerfile"><X11/XKBlib.h></filename>; 290f8248bfSmrgyou should never need to reference it directly in your application code. 30e9fcaa8aSmrg </para> 31e9fcaa8aSmrg </listitem> 32e9fcaa8aSmrg <listitem> 33e9fcaa8aSmrg <para> 340f8248bfSmrg<filename class="headerfile"><X11/extensions/XKB.h></filename> 35e9fcaa8aSmrg </para> 36e9fcaa8aSmrg <para> 370f8248bfSmrg<filename class="headerfile">XKB.h</filename> 380f8248bfSmrgdefines constants for Xkb. It is included automatically from 390f8248bfSmrg<filename class="headerfile"><X11/XKBstr.h></filename>; 400f8248bfSmrgyou should never need to reference it directly in your application code. 41e9fcaa8aSmrg </para> 42e9fcaa8aSmrg </listitem> 43e9fcaa8aSmrg <listitem> 44e9fcaa8aSmrg <para> 450f8248bfSmrg<filename class="headerfile"><X11/extensions/XKBgeom.h></filename> 46e9fcaa8aSmrg </para> 470f8248bfSmrg <para><filename class="headerfile">XKBgeom.h</filename> 48e9fcaa8aSmrgdeclares types, symbolic constants, and functions for manipulating 49e9fcaa8aSmrgkeyboard geometry descriptions. 50e9fcaa8aSmrg </para> 51e9fcaa8aSmrg </listitem> 52e9fcaa8aSmrg</itemizedlist> 53e9fcaa8aSmrg</sect1> 54eb411b4bSmrg<sect1 id='Extension_Name'> 55e9fcaa8aSmrg<title>Extension Name</title> 560f8248bfSmrg<indexterm significance="preferred" zone="Extension_Name"><primary><symbol>XkbName</symbol></primary></indexterm> 57e9fcaa8aSmrg<para> 580f8248bfSmrgThe name of the Xkb extension is given in 590f8248bfSmrg<filename class="headerfile"><X11/extensions/Xkb.h></filename>: 60e9fcaa8aSmrg 610f8248bfSmrg<programlisting> 620f8248bfSmrg#define XkbName "XKEYBOARD" 630f8248bfSmrg</programlisting> 64e9fcaa8aSmrg</para> 65e9fcaa8aSmrg 66e9fcaa8aSmrg<para> 670f8248bfSmrgMost extensions to the X protocol are initialized by calling 680f8248bfSmrg<function>XInitExtension</function> 690f8248bfSmrgand passing the extension name. However, as explained in <link linkend="Initializing_the_Keyboard_Extension">section 2.4</link>, Xkb 70e9fcaa8aSmrgrequires a more complex initialization sequence, and a client program should 710f8248bfSmrgnot call 720f8248bfSmrg<function>XInitExtension</function> 730f8248bfSmrgdirectly. 74e9fcaa8aSmrg</para> 75e9fcaa8aSmrg</sect1> 76eb411b4bSmrg<sect1 id='Determining_Library_Compatibility'> 77e9fcaa8aSmrg<title>Determining Library Compatibility</title> 78e9fcaa8aSmrg<para> 79e9fcaa8aSmrgIf an application is dynamically linked, both the X server and the client-side 80e9fcaa8aSmrgX library must contain the Xkb extension in order for the client to use the Xkb 81e9fcaa8aSmrgextension capabilities. Therefore a dynamically linked application must check 82e9fcaa8aSmrgboth the library and the server for compatibility before using Xkb function 83e9fcaa8aSmrgcalls. A properly written program must check for compatibility between the 84e9fcaa8aSmrgversion of the Xkb library that is dynamically loaded and the one used when the 85e9fcaa8aSmrgapplication was built. It must then check the server version for compatibility 86e9fcaa8aSmrgwith the version of Xkb in the library. 87e9fcaa8aSmrg</para> 88e9fcaa8aSmrg<para> 89e9fcaa8aSmrgIf your application is statically linked, you must still check for server 90e9fcaa8aSmrgcompatibility and may check library compatibility. (It is possible to compile 91e9fcaa8aSmrgagainst one set of header files and link against a different, incompatible, 92e9fcaa8aSmrgversion of the library, although this should not normally occur.) 93e9fcaa8aSmrg</para> 94e9fcaa8aSmrg<para> 950f8248bfSmrgTo determine the compatibility of a library at runtime, call 960f8248bfSmrg<function>XkbLibraryVersion</function>. 97e9fcaa8aSmrg</para> 980f8248bfSmrg<indexterm significance="preferred" zone="XkbLibraryVersion"><primary><function>XkbLibraryVersion</function></primary></indexterm> 990f8248bfSmrg<funcsynopsis id="XkbLibraryVersion"> 1000f8248bfSmrg <funcprototype> 1010f8248bfSmrg <funcdef>Bool <function>XkbLibraryVersion</function></funcdef> 1020f8248bfSmrg<!-- ( 1030f8248bfSmrg<parameter>lib_major_in_out</parameter>, 1040f8248bfSmrg<parameter>lib_minor_in_out</parameter> 1050f8248bfSmrg) --> 1060f8248bfSmrg 1070f8248bfSmrg <paramdef>int *<parameter>lib_major_in_out</parameter></paramdef> 1080f8248bfSmrg <paramdef>int *<parameter>lib_minor_in_out</parameter></paramdef> 1090f8248bfSmrg </funcprototype> 1100f8248bfSmrg</funcsynopsis> 1110f8248bfSmrg<variablelist> 1120f8248bfSmrg <varlistentry> 1130f8248bfSmrg <term> 1140f8248bfSmrg <parameter>lib_major_in_out</parameter> 1150f8248bfSmrg </term> 1160f8248bfSmrg <listitem> 1170f8248bfSmrg <para> 1180f8248bfSmrg specifies and returns the major Xkb library version. 1190f8248bfSmrg </para> 1200f8248bfSmrg </listitem> 1210f8248bfSmrg </varlistentry> 1220f8248bfSmrg <varlistentry> 1230f8248bfSmrg <term> 1240f8248bfSmrg <parameter>lib_minor_in_out</parameter> 1250f8248bfSmrg </term> 1260f8248bfSmrg <listitem> 1270f8248bfSmrg <para> 1280f8248bfSmrg specifies and returns the minor Xkb library version. 1290f8248bfSmrg </para> 1300f8248bfSmrg </listitem> 1310f8248bfSmrg </varlistentry> 1320f8248bfSmrg</variablelist> 1330f8248bfSmrg 1340f8248bfSmrg<para> 1350f8248bfSmrgPass the symbolic value 1360f8248bfSmrg<symbol>XkbMajorVersion</symbol> 1370f8248bfSmrgin 1380f8248bfSmrg<parameter>lib_major_in_out</parameter> 1390f8248bfSmrgand 1400f8248bfSmrg<symbol>XkbMinorVersion</symbol> 1410f8248bfSmrgin 1420f8248bfSmrg<parameter>lib_minor_in_out</parameter>. 1430f8248bfSmrgThese arguments represent the version of the library used at compile time. 1440f8248bfSmrgThe 1450f8248bfSmrg<function>XkbLibraryVersion</function> 146e9fcaa8aSmrgfunction backfills the major and minor version numbers of the library used at 1470f8248bfSmrgrun time in 1480f8248bfSmrg<parameter>lib_major_in_out</parameter> 1490f8248bfSmrgand 1500f8248bfSmrg<parameter>lib_minor_in_out</parameter>. 1510f8248bfSmrgIf the versions of the compile time and run time libraries are compatible, 1520f8248bfSmrg<function>XkbLibraryVersion</function> 1530f8248bfSmrgreturns 1540f8248bfSmrg<symbol>True</symbol>, 1550f8248bfSmrgotherwise, it returns 1560f8248bfSmrg<symbol>False</symbol>. 157e9fcaa8aSmrg</para> 158e9fcaa8aSmrg 159e9fcaa8aSmrg<para> 160e9fcaa8aSmrgIn addition, in order to use the Xkb extension, you must ensure that the 161e9fcaa8aSmrgextension is present in the server and that the server supports the version of 1620f8248bfSmrgthe extension expected by the client. Use 1630f8248bfSmrg<function>XkbQueryExtension</function> 1640f8248bfSmrgto do this, as described in the next section. 165e9fcaa8aSmrg</para> 166e9fcaa8aSmrg 167e9fcaa8aSmrg</sect1> 168eb411b4bSmrg<sect1 id='Initializing_the_Keyboard_Extension'> 169e9fcaa8aSmrg<title>Initializing the Keyboard Extension</title> 170e9fcaa8aSmrg<para> 1710f8248bfSmrgCall 1720f8248bfSmrg<function>XkbQueryExtension</function> 1730f8248bfSmrgto check for the presence and compatibility of the extension in the server and 174e9fcaa8aSmrgto initialize the extension. Because of potential version mismatches, you 1750f8248bfSmrgcannot use the generic extension mechanism functions 1760f8248bfSmrg(<function>XQueryExtension</function> 1770f8248bfSmrgand 1780f8248bfSmrg<function>XInitExtension</function>) 1790f8248bfSmrgfor checking for the presence of, and initializing the Xkb extension. 180e9fcaa8aSmrg</para> 181e9fcaa8aSmrg 182e9fcaa8aSmrg<para> 1830f8248bfSmrgYou must call 1840f8248bfSmrg<function>XkbQueryExtension</function> 1850f8248bfSmrgor 1860f8248bfSmrg<function>XkbOpenDisplay</function> 1870f8248bfSmrgbefore using any other Xkb library interfaces, unless such usage is explicitly 188e9fcaa8aSmrgallowed in the interface description in this document. The exceptions are: 1890f8248bfSmrg<function>XkbIgnoreExtension</function>, 1900f8248bfSmrg<function>XkbLibraryVersion</function>, 1910f8248bfSmrgand a handful of audible-bell functions. You should not use any other Xkb 192e9fcaa8aSmrgfunctions if the extension is not present or is uninitialized. In general, 193e9fcaa8aSmrgcalls to Xkb library functions made prior to initializing the Xkb extension 1940f8248bfSmrgcause 1950f8248bfSmrg<errorname>BadAccess</errorname> 1960f8248bfSmrgprotocol errors. 1970f8248bfSmrg<indexterm zone="Initializing_the_Keyboard_Extension"><primary>errors</primary> 1980f8248bfSmrg<secondary><errorname>BadAccess</errorname></secondary></indexterm> 1990f8248bfSmrg<indexterm zone="Initializing_the_Keyboard_Extension"> 2000f8248bfSmrg<primary><errorname>BadAccess</errorname></primary></indexterm> 201e9fcaa8aSmrg</para> 202e9fcaa8aSmrg 203e9fcaa8aSmrg<para> 2040f8248bfSmrg<function>XkbQueryExtension</function> 2050f8248bfSmrgboth determines whether a compatible Xkb extension is present in the X server 206e9fcaa8aSmrgand initializes the extension when it is present. 207e9fcaa8aSmrg</para> 208e9fcaa8aSmrg 2090f8248bfSmrg<indexterm significance="preferred" zone="XkbQueryExtension"><primary><function>XkbQueryExtension</function></primary></indexterm> 2100f8248bfSmrg<funcsynopsis id="XkbQueryExtension"> 2110f8248bfSmrg <funcprototype> 2120f8248bfSmrg <funcdef>Bool <function>XkbQueryExtension</function></funcdef> 2130f8248bfSmrg<!-- ( 2140f8248bfSmrg<parameter>dpy, opcode_rtrn, event_rtrn, error_rtrn, major_in_out, minor_in_out</parameter> 2150f8248bfSmrg) --> 2160f8248bfSmrg 2170f8248bfSmrg <paramdef>Display *<parameter>dpy</parameter></paramdef> 2180f8248bfSmrg <paramdef>int *<parameter>opcode_rtrn</parameter></paramdef> 2190f8248bfSmrg <paramdef>int *<parameter>event_rtrn</parameter></paramdef> 2200f8248bfSmrg <paramdef>int *<parameter>error_rtrn</parameter></paramdef> 2210f8248bfSmrg <paramdef>int *<parameter>major_in_out</parameter></paramdef> 2220f8248bfSmrg <paramdef>int *<parameter>minor_in_out</parameter></paramdef> 2230f8248bfSmrg </funcprototype> 2240f8248bfSmrg</funcsynopsis> 2250f8248bfSmrg<variablelist> 2260f8248bfSmrg <varlistentry> 2270f8248bfSmrg <term> 2280f8248bfSmrg <parameter>dpy</parameter> 2290f8248bfSmrg </term> 2300f8248bfSmrg <listitem> 2310f8248bfSmrg <para> 2320f8248bfSmrg connection to the X server 2330f8248bfSmrg </para> 2340f8248bfSmrg </listitem> 2350f8248bfSmrg </varlistentry> 2360f8248bfSmrg <varlistentry> 2370f8248bfSmrg <term> 2380f8248bfSmrg <parameter>opcode_rtrn</parameter> 2390f8248bfSmrg </term> 2400f8248bfSmrg <listitem> 2410f8248bfSmrg <para> 2420f8248bfSmrg backfilled with the major extension opcode 2430f8248bfSmrg </para> 2440f8248bfSmrg </listitem> 2450f8248bfSmrg </varlistentry> 2460f8248bfSmrg <varlistentry> 2470f8248bfSmrg <term> 2480f8248bfSmrg <parameter>event_rtrn</parameter> 2490f8248bfSmrg </term> 2500f8248bfSmrg <listitem> 2510f8248bfSmrg <para> 2520f8248bfSmrg backfilled with the extension base event code 2530f8248bfSmrg </para> 2540f8248bfSmrg </listitem> 2550f8248bfSmrg </varlistentry> 2560f8248bfSmrg <varlistentry> 2570f8248bfSmrg <term> 2580f8248bfSmrg <parameter>error_rtrn</parameter> 2590f8248bfSmrg </term> 2600f8248bfSmrg <listitem> 2610f8248bfSmrg <para> 2620f8248bfSmrg backfilled with the extension base error code 2630f8248bfSmrg </para> 2640f8248bfSmrg </listitem> 2650f8248bfSmrg </varlistentry> 2660f8248bfSmrg <varlistentry> 2670f8248bfSmrg <term> 2680f8248bfSmrg <parameter>major_in_out</parameter> 2690f8248bfSmrg </term> 2700f8248bfSmrg <listitem> 2710f8248bfSmrg <para> 2720f8248bfSmrg compile time lib major version in, server major version out 2730f8248bfSmrg </para> 2740f8248bfSmrg </listitem> 2750f8248bfSmrg </varlistentry> 2760f8248bfSmrg <varlistentry> 2770f8248bfSmrg <term> 2780f8248bfSmrg <parameter>minor_in_out</parameter> 2790f8248bfSmrg </term> 2800f8248bfSmrg <listitem> 2810f8248bfSmrg <para> 2820f8248bfSmrg compile time lib min version in, server minor version out 2830f8248bfSmrg </para> 2840f8248bfSmrg </listitem> 2850f8248bfSmrg </varlistentry> 2860f8248bfSmrg</variablelist> 2870f8248bfSmrg 2880f8248bfSmrg<para> 2890f8248bfSmrgThe 2900f8248bfSmrg<function>XkbQueryExtension</function> 2910f8248bfSmrgfunction determines whether a compatible version of the X Keyboard Extension 2920f8248bfSmrgis present in the server. If a compatible extension is present, 2930f8248bfSmrg<function>XkbQueryExtension</function> 2940f8248bfSmrgreturns 2950f8248bfSmrg<symbol>True</symbol>; 2960f8248bfSmrgotherwise, it returns 2970f8248bfSmrg<symbol>False</symbol>. 2980f8248bfSmrg</para> 2990f8248bfSmrg 3000f8248bfSmrg<para> 3010f8248bfSmrgIf a compatible version of Xkb is present, 3020f8248bfSmrg<function>XkbQueryExtension</function> 3030f8248bfSmrginitializes the extension. It backfills the major opcode for the keyboard 3040f8248bfSmrgextension in 3050f8248bfSmrg<parameter>opcode_rtrn</parameter>, 3060f8248bfSmrgthe base event code in 3070f8248bfSmrg<parameter>event_rtrn</parameter>, 3080f8248bfSmrgthe base error code in 3090f8248bfSmrg<parameter>error_rtrn</parameter>, 3100f8248bfSmrgand the major and minor version numbers of the extension in 3110f8248bfSmrg<parameter>major_in_out</parameter> 3120f8248bfSmrgand 3130f8248bfSmrg<parameter>minor_in_out</parameter>. 3140f8248bfSmrgThe major opcode is reported in the 3150f8248bfSmrg<structfield>req_major</structfield> 3160f8248bfSmrgfields of some Xkb events. For a discussion of the base event code, see 3170f8248bfSmrg<link linkend="Xkb_Event_Types">section 4.1</link>. 3180f8248bfSmrg</para> 3190f8248bfSmrg 3200f8248bfSmrg<para> 3210f8248bfSmrgAs a convenience, you can use the function 3220f8248bfSmrg<function>XkbOpenDisplay</function> 3230f8248bfSmrgto perform these three tasks at once: open a connection to an X server, check 324e9fcaa8aSmrgfor a compatible version of the Xkb extension in both the library and the 325e9fcaa8aSmrgserver, and initialize the extension for use. 326e9fcaa8aSmrg</para> 327e9fcaa8aSmrg 3280f8248bfSmrg<indexterm significance="preferred" zone="XkbOpenDisplay"><primary><function>XkbOpenDisplay</function></primary></indexterm> 3290f8248bfSmrg<funcsynopsis id="XkbOpenDisplay"> 3300f8248bfSmrg <funcprototype> 3310f8248bfSmrg <funcdef>Display *<function>XkbOpenDisplay</function></funcdef> 3320f8248bfSmrg<!-- ( 3330f8248bfSmrg<parameter>display_name, event_rtrn, error_rtrn, major_in_out, minor_in_out, 3340f8248bfSmrgreason_rtrn)</parameter> --> 3350f8248bfSmrg 3360f8248bfSmrg <paramdef>char *<parameter>display_name</parameter></paramdef> 3370f8248bfSmrg <paramdef>int *<parameter>event_rtrn</parameter></paramdef> 3380f8248bfSmrg <paramdef>int *<parameter>error_rtrn</parameter></paramdef> 3390f8248bfSmrg <paramdef>int *<parameter>major_in_out</parameter></paramdef> 3400f8248bfSmrg <paramdef>int *<parameter>minor_in_out</parameter></paramdef> 3410f8248bfSmrg <paramdef>int *<parameter>reason_rtrn</parameter></paramdef> 3420f8248bfSmrg </funcprototype> 3430f8248bfSmrg</funcsynopsis> 3440f8248bfSmrg<variablelist> 3450f8248bfSmrg <varlistentry> 3460f8248bfSmrg <term> 3470f8248bfSmrg <parameter>display_name</parameter> 3480f8248bfSmrg </term> 3490f8248bfSmrg <listitem> 3500f8248bfSmrg <para> 3510f8248bfSmrg hardware display name, which determines the display and 3520f8248bfSmrg communications domain to be used 3530f8248bfSmrg </para> 3540f8248bfSmrg </listitem> 3550f8248bfSmrg </varlistentry> 3560f8248bfSmrg <varlistentry> 3570f8248bfSmrg <term> 3580f8248bfSmrg <parameter>event_rtrn</parameter> 3590f8248bfSmrg </term> 3600f8248bfSmrg <listitem> 3610f8248bfSmrg <para> 3620f8248bfSmrg backfilled with the extension base event code 3630f8248bfSmrg </para> 3640f8248bfSmrg </listitem> 3650f8248bfSmrg </varlistentry> 3660f8248bfSmrg <varlistentry> 3670f8248bfSmrg <term> 3680f8248bfSmrg <parameter>error_rtrn</parameter> 3690f8248bfSmrg </term> 3700f8248bfSmrg <listitem> 3710f8248bfSmrg <para> 3720f8248bfSmrg backfilled with the extension base error code 3730f8248bfSmrg </para> 3740f8248bfSmrg </listitem> 3750f8248bfSmrg </varlistentry> 3760f8248bfSmrg <varlistentry> 3770f8248bfSmrg <term> 3780f8248bfSmrg <parameter>major_in_out</parameter> 3790f8248bfSmrg </term> 3800f8248bfSmrg <listitem> 3810f8248bfSmrg <para> 3820f8248bfSmrg compile time lib major version in, server major version out 3830f8248bfSmrg </para> 3840f8248bfSmrg </listitem> 3850f8248bfSmrg </varlistentry> 3860f8248bfSmrg <varlistentry> 3870f8248bfSmrg <term> 3880f8248bfSmrg <parameter>minor_in_out</parameter> 3890f8248bfSmrg </term> 3900f8248bfSmrg <listitem> 3910f8248bfSmrg <para> 3920f8248bfSmrg compile time lib minor version in, server minor version out 3930f8248bfSmrg </para> 3940f8248bfSmrg </listitem> 3950f8248bfSmrg </varlistentry> 3960f8248bfSmrg <varlistentry> 3970f8248bfSmrg <term> 3980f8248bfSmrg <parameter>reason_rtrn</parameter> 3990f8248bfSmrg </term> 4000f8248bfSmrg <listitem> 4010f8248bfSmrg <para> 4020f8248bfSmrg backfilled with a status code 4030f8248bfSmrg </para> 4040f8248bfSmrg </listitem> 4050f8248bfSmrg </varlistentry> 4060f8248bfSmrg</variablelist> 407e9fcaa8aSmrg 408e9fcaa8aSmrg<para> 4090f8248bfSmrg<function>XkbOpenDisplay</function> 410e9fcaa8aSmrgis a convenience function that opens an X display connection and initializes 4110f8248bfSmrgthe X keyboard extension. In all cases, upon return 4120f8248bfSmrg<parameter>reason_rtrn</parameter> 4130f8248bfSmrgcontains a status value indicating success or the type of failure. If 4140f8248bfSmrg<parameter>major_in_out</parameter> 4150f8248bfSmrgand 4160f8248bfSmrg<parameter>minor_in_out</parameter> 4170f8248bfSmrgare not 4180f8248bfSmrg<symbol>NULL</symbol>, 4190f8248bfSmrg<function>XkbOpenDisplay</function> 4200f8248bfSmrgfirst calls 4210f8248bfSmrg<function>XkbLibraryVersion</function> 4220f8248bfSmrgto determine whether the client library is compatible, passing it the values 4230f8248bfSmrgpointed to by 4240f8248bfSmrg<parameter>major_in_out</parameter> 4250f8248bfSmrgand 4260f8248bfSmrg<parameter>minor_in_out</parameter>. 4270f8248bfSmrgIf the library is incompatible, 4280f8248bfSmrg<function>XkbOpenDisplay</function> 4290f8248bfSmrgbackfills 4300f8248bfSmrg<parameter>major_in_out</parameter> 4310f8248bfSmrgand 4320f8248bfSmrg<parameter>minor_in_out</parameter> 4330f8248bfSmrgwith the major and minor extension versions of the library being used and 4340f8248bfSmrgreturns 4350f8248bfSmrg<symbol>NULL</symbol>. 4360f8248bfSmrgIf the library is compatible, 4370f8248bfSmrg<function>XkbOpenDisplay</function> 4380f8248bfSmrgnext calls 4390f8248bfSmrg<function>XOpenDisplay</function> 4400f8248bfSmrgwith the 4410f8248bfSmrg<parameter>display_name</parameter>. 4420f8248bfSmrgIf this fails, the function returns 4430f8248bfSmrg<symbol>NULL</symbol>. 4440f8248bfSmrgIf successful, 4450f8248bfSmrg<function>XkbOpenDisplay</function> 4460f8248bfSmrgcalls 4470f8248bfSmrg<function>XkbQueryExtension</function> 4480f8248bfSmrgand 4490f8248bfSmrgbackfills the major and minor Xkb server extension version numbers in 4500f8248bfSmrg<parameter>major_in_out</parameter> 4510f8248bfSmrgand 4520f8248bfSmrg<parameter>minor_in_out</parameter>. 453e9fcaa8aSmrgIf the server extension version is not compatible with the library extension 4540f8248bfSmrgversion or if the server extension is not present, 4550f8248bfSmrg<function>XkbOpenDisplay</function> 4560f8248bfSmrgcloses the display and returns 4570f8248bfSmrg<symbol>NULL</symbol>. 4580f8248bfSmrgWhen successful, the function returns the display connection. 459e9fcaa8aSmrg</para> 460e9fcaa8aSmrg 461e9fcaa8aSmrg<para> 4620f8248bfSmrgThe possible values for 4630f8248bfSmrg<parameter>reason_rtrn</parameter> are: 464e9fcaa8aSmrg</para> 465e9fcaa8aSmrg 466e9fcaa8aSmrg<itemizedlist> 467e9fcaa8aSmrg<listitem> 468e9fcaa8aSmrg <para> 4690f8248bfSmrg<errorname>XkbOD_BadLibraryVersion</errorname> 4700f8248bfSmrgindicates 4710f8248bfSmrg<function>XkbLibraryVersion</function> 4720f8248bfSmrgreturned 4730f8248bfSmrg<symbol>False</symbol>. 474e9fcaa8aSmrg </para> 475e9fcaa8aSmrg</listitem> 476e9fcaa8aSmrg<listitem> 477e9fcaa8aSmrg <para> 4780f8248bfSmrg<errorname>XkbOD_ConnectionRefused</errorname> 4790f8248bfSmrgindicates the display could not be opened. 480e9fcaa8aSmrg </para> 481e9fcaa8aSmrg</listitem> 482e9fcaa8aSmrg<listitem> 483e9fcaa8aSmrg <para> 4840f8248bfSmrg<errorname>XkbOD_BadServerVersion</errorname> 4850f8248bfSmrgindicates the library and the server have incompatible extension versions. 486e9fcaa8aSmrg </para> 487e9fcaa8aSmrg</listitem> 488e9fcaa8aSmrg<listitem> 489e9fcaa8aSmrg <para> 4900f8248bfSmrg<errorname>XkbOD_NonXkbServer</errorname> 4910f8248bfSmrgindicates the extension is not present in the X server. 492e9fcaa8aSmrg </para> 493e9fcaa8aSmrg</listitem> 494e9fcaa8aSmrg<listitem> 495e9fcaa8aSmrg <para> 4960f8248bfSmrg<errorname>XkbOD_Success</errorname> 4970f8248bfSmrgindicates that the function succeeded. 498e9fcaa8aSmrg </para> 499e9fcaa8aSmrg</listitem> 500e9fcaa8aSmrg</itemizedlist> 501e9fcaa8aSmrg</sect1> 502e9fcaa8aSmrg 503eb411b4bSmrg<sect1 id='Disabling_the_Keyboard_Extension'> 504e9fcaa8aSmrg<title>Disabling the Keyboard Extension</title> 505e9fcaa8aSmrg<para> 506e9fcaa8aSmrgIf a server supports the Xkb extension, the X library normally implements 507e9fcaa8aSmrgpreXkb keyboard functions using the Xkb keyboard description and state. The 508e9fcaa8aSmrgserver Xkb keyboard state may differ from the preXkb keyboard state. This 509e9fcaa8aSmrgdifference does not affect most clients, but there are exceptions. To allow 510e9fcaa8aSmrgthese clients to work properly, you may instruct the extension not to use Xkb 511e9fcaa8aSmrgfunctionality. 512e9fcaa8aSmrg</para> 513e9fcaa8aSmrg 514e9fcaa8aSmrg<para> 5150f8248bfSmrgCall 5160f8248bfSmrg<function>XkbIgnoreExtension</function> 5170f8248bfSmrgto prevent core X library keyboard functions from using the X Keyboard 5180f8248bfSmrgExtension. You must call 5190f8248bfSmrg<function>XkbIgnoreExtension</function> 5200f8248bfSmrgbefore you open a server connection; Xkb does not provide a way to enable or 521e9fcaa8aSmrgdisable use of the extension once a connection is established. 522e9fcaa8aSmrg</para> 523e9fcaa8aSmrg 5240f8248bfSmrg<indexterm significance="preferred" zone="XkbIgnoreExtension"><primary><function>XkbIgnoreExtension</function></primary></indexterm> 5250f8248bfSmrg<funcsynopsis id="XkbIgnoreExtension"> 5260f8248bfSmrg <funcprototype> 5270f8248bfSmrg <funcdef>Bool <function>XkbIgnoreExtension</function></funcdef> 5280f8248bfSmrg<!-- ( 5290f8248bfSmrg<parameter>ignore</parameter> 5300f8248bfSmrg) --> 5310f8248bfSmrg 5320f8248bfSmrg <paramdef>Bool <parameter>ignore</parameter></paramdef> 5330f8248bfSmrg </funcprototype> 5340f8248bfSmrg</funcsynopsis> 5350f8248bfSmrg<variablelist> 5360f8248bfSmrg <varlistentry> 5370f8248bfSmrg <term> 5380f8248bfSmrg <parameter>ignore</parameter> 5390f8248bfSmrg </term> 5400f8248bfSmrg <listitem> 5410f8248bfSmrg <para> 5420f8248bfSmrg <symbol>True</symbol> means ignore the extension 5430f8248bfSmrg </para> 5440f8248bfSmrg </listitem> 5450f8248bfSmrg </varlistentry> 5460f8248bfSmrg</variablelist> 547e9fcaa8aSmrg 548e9fcaa8aSmrg<para> 5490f8248bfSmrg<function>XkbIgnoreExtension</function> 5500f8248bfSmrgtells the X library whether to use the X Keyboard Extension on any 5510f8248bfSmrgsubsequently opened X display connections. If ignore is 5520f8248bfSmrg<symbol>True</symbol>, 5530f8248bfSmrgthe library does not initialize the Xkb extension when it opens a new 554e9fcaa8aSmrgdisplay. This forces the X server to use compatibility mode and communicate 555e9fcaa8aSmrgwith the client using only core protocol requests and events. If ignore is 5560f8248bfSmrg<symbol>False</symbol>, 5570f8248bfSmrgthe library treats subsequent calls to 5580f8248bfSmrg<function>XOpenDisplay</function> 5590f8248bfSmrgnormally and uses Xkb extension requests, events, and state. Do not explicitly 5600f8248bfSmrguse Xkb on a connection for which it is disabled. 5610f8248bfSmrg<function>XkbIgnoreExtension</function> 5620f8248bfSmrgreturns 5630f8248bfSmrg<symbol>False</symbol> 5640f8248bfSmrgif it was unable to apply the ignore request. 565e9fcaa8aSmrg</para> 566e9fcaa8aSmrg 567e9fcaa8aSmrg</sect1> 568eb411b4bSmrg<sect1 id='Protocol_Errors'> 569e9fcaa8aSmrg<title>Protocol Errors</title> 5700f8248bfSmrg<indexterm significance="preferred" zone="Protocol_Errors"> 5710f8248bfSmrg<primary>errors</primary></indexterm> 5720f8248bfSmrg 573e9fcaa8aSmrg<para> 574e9fcaa8aSmrgMany of the Xkb extension library functions described in this document can 575e9fcaa8aSmrgcause the X server to report an error, referred to in this document as a 5760f8248bfSmrg<errorname>Bad<replaceable>Xxx</replaceable></errorname> 5770f8248bfSmrgprotocol error, where 5780f8248bfSmrg<replaceable>Xxx</replaceable> 5790f8248bfSmrgis some name. These errors are fielded in the normal manner, by the default 580e9fcaa8aSmrgXlib error handler or one replacing it. Note that X protocol errors are not 581e9fcaa8aSmrgnecessarily reported immediately because of the buffering of X protocol 582e9fcaa8aSmrgrequests in Xlib and the server. 583e9fcaa8aSmrg</para> 584e9fcaa8aSmrg 585e9fcaa8aSmrg<para> 5860f8248bfSmrg<link linkend="table2.1">Table 2.1</link> 5870f8248bfSmrglists the protocol errors that can be generated, and their causes. 588e9fcaa8aSmrg</para> 589e9fcaa8aSmrg 5900f8248bfSmrg<table id='table2.1' frame='topbot'> 591e9fcaa8aSmrg<title>Xkb Protocol Errors</title> 592eb411b4bSmrg<?dbfo keep-together="always" ?> 593eb411b4bSmrg<tgroup cols='2' align='left' colsep='0' rowsep='0'> 594eb411b4bSmrg<colspec colname='c1' colwidth='1.0*'/> 595eb411b4bSmrg<colspec colname='c2' colwidth='3.0*'/> 596e9fcaa8aSmrg<thead> 597e9fcaa8aSmrg <row rowsep='1'> 598e9fcaa8aSmrg <entry>Error</entry> 599e9fcaa8aSmrg <entry>Cause</entry> 600e9fcaa8aSmrg </row> 601e9fcaa8aSmrg</thead> 602e9fcaa8aSmrg<tbody> 603eb411b4bSmrg <row> 6040f8248bfSmrg <entry><errorname>BadAccess</errorname></entry> 605e9fcaa8aSmrg <entry> 606e9fcaa8aSmrg<para> 607e9fcaa8aSmrgThe Xkb extension has not been properly initialized 608e9fcaa8aSmrg</para> 609e9fcaa8aSmrg </entry> 610e9fcaa8aSmrg </row> 611eb411b4bSmrg <row> 6120f8248bfSmrg <entry><errorname>BadKeyboard</errorname></entry> 613e9fcaa8aSmrg <entry> 614e9fcaa8aSmrg<para> 615e9fcaa8aSmrgThe device specified was not a valid core or input extension device 616e9fcaa8aSmrg</para> 617e9fcaa8aSmrg </entry> 618e9fcaa8aSmrg </row> 619eb411b4bSmrg <row> 6200f8248bfSmrg <entry><errorname>BadImplementation</errorname></entry> 621e9fcaa8aSmrg <entry> 622e9fcaa8aSmrg<para> 623e9fcaa8aSmrgInvalid reply from server 624e9fcaa8aSmrg</para> 625e9fcaa8aSmrg </entry> 626e9fcaa8aSmrg </row> 627eb411b4bSmrg <row> 6280f8248bfSmrg <entry><errorname>BadAlloc</errorname></entry> 629e9fcaa8aSmrg <entry> 630e9fcaa8aSmrg<para> 631e9fcaa8aSmrgUnable to allocate storage 632e9fcaa8aSmrg</para> 633e9fcaa8aSmrg </entry> 634e9fcaa8aSmrg </row> 635eb411b4bSmrg <row> 6360f8248bfSmrg <entry><errorname>BadMatch</errorname></entry> 637e9fcaa8aSmrg <entry> 638e9fcaa8aSmrg<para> 639e9fcaa8aSmrgA compatible version of Xkb was not available in the server or an argument has 640e9fcaa8aSmrgcorrect type and range, but is otherwise invalid 641e9fcaa8aSmrg</para> 642e9fcaa8aSmrg </entry> 643e9fcaa8aSmrg </row> 644eb411b4bSmrg <row> 6450f8248bfSmrg <entry><errorname>BadValue</errorname></entry> 646e9fcaa8aSmrg <entry> 647e9fcaa8aSmrg<para> 648e9fcaa8aSmrgAn argument is out of range 649e9fcaa8aSmrg</para> 650e9fcaa8aSmrg </entry> 651e9fcaa8aSmrg </row> 652eb411b4bSmrg <row> 6530f8248bfSmrg <entry><errorname>BadAtom</errorname></entry> 654e9fcaa8aSmrg <entry> 655e9fcaa8aSmrg<para> 6560f8248bfSmrgA name is neither a valid Atom or 6570f8248bfSmrg<symbol>None</symbol> 658e9fcaa8aSmrg</para> 659e9fcaa8aSmrg </entry> 660e9fcaa8aSmrg </row> 661eb411b4bSmrg <row> 6620f8248bfSmrg <entry><errorname>BadDevice</errorname></entry> 663e9fcaa8aSmrg <entry> 664e9fcaa8aSmrg<para> 665e9fcaa8aSmrgDevice, Feedback Class, or Feedback ID invalid 666e9fcaa8aSmrg</para> 667e9fcaa8aSmrg </entry> 668e9fcaa8aSmrg </row> 669e9fcaa8aSmrg</tbody> 670e9fcaa8aSmrg</tgroup> 671e9fcaa8aSmrg</table> 672e9fcaa8aSmrg 6730f8248bfSmrg<para id='BadKeyboard'> 6740f8248bfSmrg<indexterm zone="BadKeyboard"><primary>errors</primary> 6750f8248bfSmrg<secondary><errorname>BadKeyboard</errorname></secondary></indexterm> 6760f8248bfSmrg<indexterm zone="BadKeyboard"> 6770f8248bfSmrg<primary><errorname>BadKeyboard</errorname></primary></indexterm> 6780f8248bfSmrgThe Xkb extension adds a single protocol error, 6790f8248bfSmrg<errorname>BadKeyboard</errorname>, 6800f8248bfSmrgto the core protocol error set. This error code will be reported as the 6810f8248bfSmrg<parameter>error_rtrn</parameter> 6820f8248bfSmrgwhen 6830f8248bfSmrg<function>XkbQueryExtension</function> 6840f8248bfSmrgis called. When a 6850f8248bfSmrg<errorname>BadKeyboard</errorname> 6860f8248bfSmrgerror is reported in an 6870f8248bfSmrg<structname>XErrorEvent</structname>, 6880f8248bfSmrgadditional information is reported in the 6890f8248bfSmrg<structfield>resourceid</structfield> 6900f8248bfSmrgfield. The most significant byte of the 6910f8248bfSmrg<structfield>resource_id</structfield> 6920f8248bfSmrgis a further refinement of the error cause, as defined in 6930f8248bfSmrg<link linkend="table2.2">Table 2.2</link>. The least 694e9fcaa8aSmrgsignificant byte will contain the device, class, or feedback ID as indicated in 695e9fcaa8aSmrgthe table. 696e9fcaa8aSmrg</para> 697e9fcaa8aSmrg 6980f8248bfSmrg<table id='table2.2' frame='topbot'> 6990f8248bfSmrg<title><errorname>BadKeyboard</errorname> Protocol Error resource_id Values</title> 700eb411b4bSmrg<?dbfo keep-together="always" ?> 701eb411b4bSmrg<tgroup cols='4' align='left' colsep='0' rowsep='0'> 702eb411b4bSmrg<colspec colname='c1' colwidth='2.0*'/> 703eb411b4bSmrg<colspec colname='c2' colwidth='1.0*'/> 704eb411b4bSmrg<colspec colname='c3' colwidth='3.0*'/> 705eb411b4bSmrg<colspec colname='c4' colwidth='2.0*'/> 706e9fcaa8aSmrg<thead> 707eb411b4bSmrg <row rowsep='1'> 708e9fcaa8aSmrg <entry>high-order byte</entry> 709e9fcaa8aSmrg <entry>value</entry> 710e9fcaa8aSmrg <entry>meaning</entry> 711e9fcaa8aSmrg <entry>low-order byte</entry> 712e9fcaa8aSmrg </row> 713e9fcaa8aSmrg</thead> 714e9fcaa8aSmrg<tbody> 715eb411b4bSmrg <row> 7160f8248bfSmrg <entry><errorname>XkbErr_BadDevice</errorname></entry> 717e9fcaa8aSmrg <entry>0xff</entry> 718e9fcaa8aSmrg <entry> 719e9fcaa8aSmrg<para> 720e9fcaa8aSmrgdevice not found 721e9fcaa8aSmrg</para> 722e9fcaa8aSmrg </entry> 723e9fcaa8aSmrg <entry>device ID</entry> 724e9fcaa8aSmrg </row> 725eb411b4bSmrg <row> 7260f8248bfSmrg <entry><errorname>XkbErr_BadClass</errorname></entry> 727e9fcaa8aSmrg <entry>0xfe</entry> 728e9fcaa8aSmrg <entry> 729e9fcaa8aSmrg<para> 730e9fcaa8aSmrgdevice found, but it is of the wrong class 731e9fcaa8aSmrg</para> 732e9fcaa8aSmrg </entry> 733e9fcaa8aSmrg <entry>class ID</entry> 734e9fcaa8aSmrg </row> 735eb411b4bSmrg <row> 7360f8248bfSmrg <entry><errorname>XkbErr_BadId</errorname></entry> 737e9fcaa8aSmrg <entry>0xfd</entry> 738e9fcaa8aSmrg <entry> 739e9fcaa8aSmrg<para> 740e9fcaa8aSmrgdevice found, class ok, but device does not contain a feedback with the 741e9fcaa8aSmrgindicated ID 742e9fcaa8aSmrg</para> 743e9fcaa8aSmrg </entry> 744e9fcaa8aSmrg <entry>feedback ID</entry> 745e9fcaa8aSmrg </row> 746e9fcaa8aSmrg</tbody> 747e9fcaa8aSmrg</tgroup> 748e9fcaa8aSmrg</table> 749e9fcaa8aSmrg</sect1> 750e9fcaa8aSmrg 751eb411b4bSmrg<sect1 id='Display_and_Device_Specifications_in_Function_Calls'> 752e9fcaa8aSmrg<title>Display and Device Specifications in Function Calls</title> 753e9fcaa8aSmrg<para> 754e9fcaa8aSmrgWhere a connection to the server is passed as an argument (Display*) and an 7550f8248bfSmrg<type>XkbDescPtr</type> 7560f8248bfSmrgis also passed as an argument, the Display* argument must match the 7570f8248bfSmrg<structfield>dpy</structfield> 7580f8248bfSmrgfield of the 7590f8248bfSmrg<structname>XkbDescRec</structname> 7600f8248bfSmrgpointed to by the 7610f8248bfSmrg<type>XkbDescPtr</type> 7620f8248bfSmrgargument, or else the 7630f8248bfSmrg<structfield>dpy</structfield> 7640f8248bfSmrgfield of the 7650f8248bfSmrg<structname>XkbDescRec</structname> 7660f8248bfSmrgmust be 7670f8248bfSmrg<symbol>NULL</symbol>. 7680f8248bfSmrgIf they don’t match or the 7690f8248bfSmrg<structfield>dpy</structfield> 7700f8248bfSmrgfield is not 7710f8248bfSmrg<symbol>NULL</symbol>, 7720f8248bfSmrga 7730f8248bfSmrg<errorname>BadMatch</errorname> 7740f8248bfSmrgerror is returned (either in the return value or a backfilled 7750f8248bfSmrg<type>Status</type> 7760f8248bfSmrgvariable). Upon successful return, the 7770f8248bfSmrg<structfield>dpy</structfield> 7780f8248bfSmrgfield of the 7790f8248bfSmrg<structname>XkbDescRec</structname> 7800f8248bfSmrgalways contains the Display* value passed in. 781e9fcaa8aSmrg</para> 782e9fcaa8aSmrg 783e9fcaa8aSmrg<para> 784e9fcaa8aSmrgThe Xkb extension can communicate with the X input extension if it is present. 785e9fcaa8aSmrgConsequently, there can potentially be more than one input device connected to 786e9fcaa8aSmrgthe server. Most Xkb library calls that require communicating with the server 7870f8248bfSmrginvolve both a server connection (Display * 7880f8248bfSmrg<structfield>dpy</structfield>) 7890f8248bfSmrgand a device identifier (unsigned int 7900f8248bfSmrg<structfield>device_spec</structfield>). 7910f8248bfSmrgIn some cases, the device identifier is implicit and is taken as the 7920f8248bfSmrg<structfield>device_spec</structfield> 7930f8248bfSmrgfield of an 7940f8248bfSmrg<structname>XkbDescRec</structname> 7950f8248bfSmrgstructure passed as an argument. 7960f8248bfSmrg</para> 7970f8248bfSmrg 7980f8248bfSmrg<para id='XkbUseCoreKbd'> 7990f8248bfSmrg<indexterm significance="preferred" zone="XkbUseCoreKbd"><primary><symbol>XkbUseCoreKbd</symbol></primary></indexterm> 8000f8248bfSmrgThe device identifier can specify any X input extension device with a 8010f8248bfSmrg<symbol>KeyClass</symbol> 8020f8248bfSmrgcomponent, or it can specify the constant, 8030f8248bfSmrg<symbol>XkbUseCoreKbd</symbol>. 8040f8248bfSmrgThe use of 8050f8248bfSmrg<symbol>XkbUseCoreKbd</symbol> 8060f8248bfSmrgallows applications to indicate the core keyboard without having to determine 807e9fcaa8aSmrgits device identifier. 808e9fcaa8aSmrg</para> 809e9fcaa8aSmrg 810e9fcaa8aSmrg<para> 8110f8248bfSmrgWhere an Xkb device identifier is passed as an argument and an 8120f8248bfSmrg<type>XkbDescPtr</type> 8130f8248bfSmrgis also passed as an argument, if either the argument or the 8140f8248bfSmrg<structname>XkbDescRec</structname> 8150f8248bfSmrg<structfield>device_spec</structfield> 8160f8248bfSmrgfield is 8170f8248bfSmrg<symbol>XkbUseCoreKbd</symbol>, 8180f8248bfSmrgand if the function returns successfully, the 8190f8248bfSmrg<type>XkbDescPtr</type> 8200f8248bfSmrg<structfield>device_spec</structfield> 8210f8248bfSmrgfield will have been converted from 8220f8248bfSmrg<symbol>XkbUseCoreKbd</symbol> 8230f8248bfSmrgto a real Xkb device ID. If the function does not complete successfully, the 8240f8248bfSmrg<structfield>device_spec</structfield> 8250f8248bfSmrgfield remains unchanged. Subsequently, the device id argument must match the 8260f8248bfSmrg<structfield>device_spec</structfield> 8270f8248bfSmrgfield of the 8280f8248bfSmrg<type>XkbDescPtr</type> 8290f8248bfSmrgargument. If they don’t match, a 8300f8248bfSmrg<errorname>BadMatch</errorname> 8310f8248bfSmrgerror is returned (either in the return value or a backfilled 8320f8248bfSmrg<type>Status</type> 8330f8248bfSmrgvariable). 834e9fcaa8aSmrg</para> 835e9fcaa8aSmrg 836e9fcaa8aSmrg<para> 837e9fcaa8aSmrgWhen the Xkb extension in the server hands an application a device identifier 838e9fcaa8aSmrgto use for the keyboard, that ID is the input extension identifier for the 839e9fcaa8aSmrgdevice if the server supports the X Input Extension. If the server does not 840e9fcaa8aSmrgsupport the input extension, the meaning of the identifier is undefined — the 8410f8248bfSmrgonly guarantee is that when you use 8420f8248bfSmrg<symbol>XkbUseCoreKbd</symbol>, 8430f8248bfSmrg<symbol>XkbUseCoreKbd</symbol> 8440f8248bfSmrgwill work and the identifier returned by the server will refer to the core 845e9fcaa8aSmrgkeyboard device. 846e9fcaa8aSmrg</para> 847e9fcaa8aSmrg</sect1> 848e9fcaa8aSmrg</chapter> 849