1<?xml version="1.0" encoding="UTF-8" ?> 2<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" 3 "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"> 4<chapter id='Initialization_and_General_Programming_Information'> 5<title>Initialization and General Programming Information</title> 6<sect1 id='Extension_Header_Files'> 7<title>Extension Header Files</title> 8<para> 9The following include files are part of the Xkb standard: 10</para> 11<itemizedlist> 12 <listitem> 13 <para> 14<filename class="headerfile"><X11/XKBlib.h></filename> 15 </para> 16 <para><filename class="headerfile">XKBlib.h</filename> 17is the main header file for Xkb; it declares constants, types, and 18functions. 19 </para> 20 </listitem> 21 <listitem> 22 <para> 23<filename class="headerfile"><X11/extensions/XKBstr.h></filename> 24 </para> 25 <para> 26<filename class="headerfile">XKBstr.h</filename> declares types and 27constants for Xkb. It is included automatically from 28<filename class="headerfile"><X11/XKBlib.h></filename>; 29you should never need to reference it directly in your application code. 30 </para> 31 </listitem> 32 <listitem> 33 <para> 34<filename class="headerfile"><X11/extensions/XKB.h></filename> 35 </para> 36 <para> 37<filename class="headerfile">XKB.h</filename> 38defines constants for Xkb. It is included automatically from 39<filename class="headerfile"><X11/XKBstr.h></filename>; 40you should never need to reference it directly in your application code. 41 </para> 42 </listitem> 43 <listitem> 44 <para> 45<filename class="headerfile"><X11/extensions/XKBgeom.h></filename> 46 </para> 47 <para><filename class="headerfile">XKBgeom.h</filename> 48declares types, symbolic constants, and functions for manipulating 49keyboard geometry descriptions. 50 </para> 51 </listitem> 52</itemizedlist> 53</sect1> 54<sect1 id='Extension_Name'> 55<title>Extension Name</title> 56<indexterm significance="preferred" zone="Extension_Name"><primary><symbol>XkbName</symbol></primary></indexterm> 57<para> 58The name of the Xkb extension is given in 59<filename class="headerfile"><X11/extensions/Xkb.h></filename>: 60 61<programlisting> 62#define XkbName "XKEYBOARD" 63</programlisting> 64</para> 65 66<para> 67Most extensions to the X protocol are initialized by calling 68<function>XInitExtension</function> 69and passing the extension name. However, as explained in <link linkend="Initializing_the_Keyboard_Extension">section 2.4</link>, Xkb 70requires a more complex initialization sequence, and a client program should 71not call 72<function>XInitExtension</function> 73directly. 74</para> 75</sect1> 76<sect1 id='Determining_Library_Compatibility'> 77<title>Determining Library Compatibility</title> 78<para> 79If an application is dynamically linked, both the X server and the client-side 80X library must contain the Xkb extension in order for the client to use the Xkb 81extension capabilities. Therefore a dynamically linked application must check 82both the library and the server for compatibility before using Xkb function 83calls. A properly written program must check for compatibility between the 84version of the Xkb library that is dynamically loaded and the one used when the 85application was built. It must then check the server version for compatibility 86with the version of Xkb in the library. 87</para> 88<para> 89If your application is statically linked, you must still check for server 90compatibility and may check library compatibility. (It is possible to compile 91against one set of header files and link against a different, incompatible, 92version of the library, although this should not normally occur.) 93</para> 94<para> 95To determine the compatibility of a library at runtime, call 96<function>XkbLibraryVersion</function>. 97</para> 98<indexterm significance="preferred" zone="XkbLibraryVersion"><primary><function>XkbLibraryVersion</function></primary></indexterm> 99<funcsynopsis id="XkbLibraryVersion"> 100 <funcprototype> 101 <funcdef>Bool <function>XkbLibraryVersion</function></funcdef> 102<!-- ( 103<parameter>lib_major_in_out</parameter>, 104<parameter>lib_minor_in_out</parameter> 105) --> 106 107 <paramdef>int *<parameter>lib_major_in_out</parameter></paramdef> 108 <paramdef>int *<parameter>lib_minor_in_out</parameter></paramdef> 109 </funcprototype> 110</funcsynopsis> 111<variablelist> 112 <varlistentry> 113 <term> 114 <parameter>lib_major_in_out</parameter> 115 </term> 116 <listitem> 117 <para> 118 specifies and returns the major Xkb library version. 119 </para> 120 </listitem> 121 </varlistentry> 122 <varlistentry> 123 <term> 124 <parameter>lib_minor_in_out</parameter> 125 </term> 126 <listitem> 127 <para> 128 specifies and returns the minor Xkb library version. 129 </para> 130 </listitem> 131 </varlistentry> 132</variablelist> 133 134<para> 135Pass the symbolic value 136<symbol>XkbMajorVersion</symbol> 137in 138<parameter>lib_major_in_out</parameter> 139and 140<symbol>XkbMinorVersion</symbol> 141in 142<parameter>lib_minor_in_out</parameter>. 143These arguments represent the version of the library used at compile time. 144The 145<function>XkbLibraryVersion</function> 146function backfills the major and minor version numbers of the library used at 147run time in 148<parameter>lib_major_in_out</parameter> 149and 150<parameter>lib_minor_in_out</parameter>. 151If the versions of the compile time and run time libraries are compatible, 152<function>XkbLibraryVersion</function> 153returns 154<symbol>True</symbol>, 155otherwise, it returns 156<symbol>False</symbol>. 157</para> 158 159<para> 160In addition, in order to use the Xkb extension, you must ensure that the 161extension is present in the server and that the server supports the version of 162the extension expected by the client. Use 163<function>XkbQueryExtension</function> 164to do this, as described in the next section. 165</para> 166 167</sect1> 168<sect1 id='Initializing_the_Keyboard_Extension'> 169<title>Initializing the Keyboard Extension</title> 170<para> 171Call 172<function>XkbQueryExtension</function> 173to check for the presence and compatibility of the extension in the server and 174to initialize the extension. Because of potential version mismatches, you 175cannot use the generic extension mechanism functions 176(<function>XQueryExtension</function> 177and 178<function>XInitExtension</function>) 179for checking for the presence of, and initializing the Xkb extension. 180</para> 181 182<para> 183You must call 184<function>XkbQueryExtension</function> 185or 186<function>XkbOpenDisplay</function> 187before using any other Xkb library interfaces, unless such usage is explicitly 188allowed in the interface description in this document. The exceptions are: 189<function>XkbIgnoreExtension</function>, 190<function>XkbLibraryVersion</function>, 191and a handful of audible-bell functions. You should not use any other Xkb 192functions if the extension is not present or is uninitialized. In general, 193calls to Xkb library functions made prior to initializing the Xkb extension 194cause 195<errorname>BadAccess</errorname> 196protocol errors. 197<indexterm zone="Initializing_the_Keyboard_Extension"><primary>errors</primary> 198<secondary><errorname>BadAccess</errorname></secondary></indexterm> 199<indexterm zone="Initializing_the_Keyboard_Extension"> 200<primary><errorname>BadAccess</errorname></primary></indexterm> 201</para> 202 203<para> 204<function>XkbQueryExtension</function> 205both determines whether a compatible Xkb extension is present in the X server 206and initializes the extension when it is present. 207</para> 208 209<indexterm significance="preferred" zone="XkbQueryExtension"><primary><function>XkbQueryExtension</function></primary></indexterm> 210<funcsynopsis id="XkbQueryExtension"> 211 <funcprototype> 212 <funcdef>Bool <function>XkbQueryExtension</function></funcdef> 213<!-- ( 214<parameter>dpy, opcode_rtrn, event_rtrn, error_rtrn, major_in_out, minor_in_out</parameter> 215) --> 216 217 <paramdef>Display *<parameter>dpy</parameter></paramdef> 218 <paramdef>int *<parameter>opcode_rtrn</parameter></paramdef> 219 <paramdef>int *<parameter>event_rtrn</parameter></paramdef> 220 <paramdef>int *<parameter>error_rtrn</parameter></paramdef> 221 <paramdef>int *<parameter>major_in_out</parameter></paramdef> 222 <paramdef>int *<parameter>minor_in_out</parameter></paramdef> 223 </funcprototype> 224</funcsynopsis> 225<variablelist> 226 <varlistentry> 227 <term> 228 <parameter>dpy</parameter> 229 </term> 230 <listitem> 231 <para> 232 connection to the X server 233 </para> 234 </listitem> 235 </varlistentry> 236 <varlistentry> 237 <term> 238 <parameter>opcode_rtrn</parameter> 239 </term> 240 <listitem> 241 <para> 242 backfilled with the major extension opcode 243 </para> 244 </listitem> 245 </varlistentry> 246 <varlistentry> 247 <term> 248 <parameter>event_rtrn</parameter> 249 </term> 250 <listitem> 251 <para> 252 backfilled with the extension base event code 253 </para> 254 </listitem> 255 </varlistentry> 256 <varlistentry> 257 <term> 258 <parameter>error_rtrn</parameter> 259 </term> 260 <listitem> 261 <para> 262 backfilled with the extension base error code 263 </para> 264 </listitem> 265 </varlistentry> 266 <varlistentry> 267 <term> 268 <parameter>major_in_out</parameter> 269 </term> 270 <listitem> 271 <para> 272 compile time lib major version in, server major version out 273 </para> 274 </listitem> 275 </varlistentry> 276 <varlistentry> 277 <term> 278 <parameter>minor_in_out</parameter> 279 </term> 280 <listitem> 281 <para> 282 compile time lib min version in, server minor version out 283 </para> 284 </listitem> 285 </varlistentry> 286</variablelist> 287 288<para> 289The 290<function>XkbQueryExtension</function> 291function determines whether a compatible version of the X Keyboard Extension 292is present in the server. If a compatible extension is present, 293<function>XkbQueryExtension</function> 294returns 295<symbol>True</symbol>; 296otherwise, it returns 297<symbol>False</symbol>. 298</para> 299 300<para> 301If a compatible version of Xkb is present, 302<function>XkbQueryExtension</function> 303initializes the extension. It backfills the major opcode for the keyboard 304extension in 305<parameter>opcode_rtrn</parameter>, 306the base event code in 307<parameter>event_rtrn</parameter>, 308the base error code in 309<parameter>error_rtrn</parameter>, 310and the major and minor version numbers of the extension in 311<parameter>major_in_out</parameter> 312and 313<parameter>minor_in_out</parameter>. 314The major opcode is reported in the 315<structfield>req_major</structfield> 316fields of some Xkb events. For a discussion of the base event code, see 317<link linkend="Xkb_Event_Types">section 4.1</link>. 318</para> 319 320<para> 321As a convenience, you can use the function 322<function>XkbOpenDisplay</function> 323to perform these three tasks at once: open a connection to an X server, check 324for a compatible version of the Xkb extension in both the library and the 325server, and initialize the extension for use. 326</para> 327 328<indexterm significance="preferred" zone="XkbOpenDisplay"><primary><function>XkbOpenDisplay</function></primary></indexterm> 329<funcsynopsis id="XkbOpenDisplay"> 330 <funcprototype> 331 <funcdef>Display *<function>XkbOpenDisplay</function></funcdef> 332<!-- ( 333<parameter>display_name, event_rtrn, error_rtrn, major_in_out, minor_in_out, 334reason_rtrn)</parameter> --> 335 336 <paramdef>char *<parameter>display_name</parameter></paramdef> 337 <paramdef>int *<parameter>event_rtrn</parameter></paramdef> 338 <paramdef>int *<parameter>error_rtrn</parameter></paramdef> 339 <paramdef>int *<parameter>major_in_out</parameter></paramdef> 340 <paramdef>int *<parameter>minor_in_out</parameter></paramdef> 341 <paramdef>int *<parameter>reason_rtrn</parameter></paramdef> 342 </funcprototype> 343</funcsynopsis> 344<variablelist> 345 <varlistentry> 346 <term> 347 <parameter>display_name</parameter> 348 </term> 349 <listitem> 350 <para> 351 hardware display name, which determines the display and 352 communications domain to be used 353 </para> 354 </listitem> 355 </varlistentry> 356 <varlistentry> 357 <term> 358 <parameter>event_rtrn</parameter> 359 </term> 360 <listitem> 361 <para> 362 backfilled with the extension base event code 363 </para> 364 </listitem> 365 </varlistentry> 366 <varlistentry> 367 <term> 368 <parameter>error_rtrn</parameter> 369 </term> 370 <listitem> 371 <para> 372 backfilled with the extension base error code 373 </para> 374 </listitem> 375 </varlistentry> 376 <varlistentry> 377 <term> 378 <parameter>major_in_out</parameter> 379 </term> 380 <listitem> 381 <para> 382 compile time lib major version in, server major version out 383 </para> 384 </listitem> 385 </varlistentry> 386 <varlistentry> 387 <term> 388 <parameter>minor_in_out</parameter> 389 </term> 390 <listitem> 391 <para> 392 compile time lib minor version in, server minor version out 393 </para> 394 </listitem> 395 </varlistentry> 396 <varlistentry> 397 <term> 398 <parameter>reason_rtrn</parameter> 399 </term> 400 <listitem> 401 <para> 402 backfilled with a status code 403 </para> 404 </listitem> 405 </varlistentry> 406</variablelist> 407 408<para> 409<function>XkbOpenDisplay</function> 410is a convenience function that opens an X display connection and initializes 411the X keyboard extension. In all cases, upon return 412<parameter>reason_rtrn</parameter> 413contains a status value indicating success or the type of failure. If 414<parameter>major_in_out</parameter> 415and 416<parameter>minor_in_out</parameter> 417are not 418<symbol>NULL</symbol>, 419<function>XkbOpenDisplay</function> 420first calls 421<function>XkbLibraryVersion</function> 422to determine whether the client library is compatible, passing it the values 423pointed to by 424<parameter>major_in_out</parameter> 425and 426<parameter>minor_in_out</parameter>. 427If the library is incompatible, 428<function>XkbOpenDisplay</function> 429backfills 430<parameter>major_in_out</parameter> 431and 432<parameter>minor_in_out</parameter> 433with the major and minor extension versions of the library being used and 434returns 435<symbol>NULL</symbol>. 436If the library is compatible, 437<function>XkbOpenDisplay</function> 438next calls 439<function>XOpenDisplay</function> 440with the 441<parameter>display_name</parameter>. 442If this fails, the function returns 443<symbol>NULL</symbol>. 444If successful, 445<function>XkbOpenDisplay</function> 446calls 447<function>XkbQueryExtension</function> 448and 449backfills the major and minor Xkb server extension version numbers in 450<parameter>major_in_out</parameter> 451and 452<parameter>minor_in_out</parameter>. 453If the server extension version is not compatible with the library extension 454version or if the server extension is not present, 455<function>XkbOpenDisplay</function> 456closes the display and returns 457<symbol>NULL</symbol>. 458When successful, the function returns the display connection. 459</para> 460 461<para> 462The possible values for 463<parameter>reason_rtrn</parameter> are: 464</para> 465 466<itemizedlist> 467<listitem> 468 <para> 469<errorname>XkbOD_BadLibraryVersion</errorname> 470indicates 471<function>XkbLibraryVersion</function> 472returned 473<symbol>False</symbol>. 474 </para> 475</listitem> 476<listitem> 477 <para> 478<errorname>XkbOD_ConnectionRefused</errorname> 479indicates the display could not be opened. 480 </para> 481</listitem> 482<listitem> 483 <para> 484<errorname>XkbOD_BadServerVersion</errorname> 485indicates the library and the server have incompatible extension versions. 486 </para> 487</listitem> 488<listitem> 489 <para> 490<errorname>XkbOD_NonXkbServer</errorname> 491indicates the extension is not present in the X server. 492 </para> 493</listitem> 494<listitem> 495 <para> 496<errorname>XkbOD_Success</errorname> 497indicates that the function succeeded. 498 </para> 499</listitem> 500</itemizedlist> 501</sect1> 502 503<sect1 id='Disabling_the_Keyboard_Extension'> 504<title>Disabling the Keyboard Extension</title> 505<para> 506If a server supports the Xkb extension, the X library normally implements 507preXkb keyboard functions using the Xkb keyboard description and state. The 508server Xkb keyboard state may differ from the preXkb keyboard state. This 509difference does not affect most clients, but there are exceptions. To allow 510these clients to work properly, you may instruct the extension not to use Xkb 511functionality. 512</para> 513 514<para> 515Call 516<function>XkbIgnoreExtension</function> 517to prevent core X library keyboard functions from using the X Keyboard 518Extension. You must call 519<function>XkbIgnoreExtension</function> 520before you open a server connection; Xkb does not provide a way to enable or 521disable use of the extension once a connection is established. 522</para> 523 524<indexterm significance="preferred" zone="XkbIgnoreExtension"><primary><function>XkbIgnoreExtension</function></primary></indexterm> 525<funcsynopsis id="XkbIgnoreExtension"> 526 <funcprototype> 527 <funcdef>Bool <function>XkbIgnoreExtension</function></funcdef> 528<!-- ( 529<parameter>ignore</parameter> 530) --> 531 532 <paramdef>Bool <parameter>ignore</parameter></paramdef> 533 </funcprototype> 534</funcsynopsis> 535<variablelist> 536 <varlistentry> 537 <term> 538 <parameter>ignore</parameter> 539 </term> 540 <listitem> 541 <para> 542 <symbol>True</symbol> means ignore the extension 543 </para> 544 </listitem> 545 </varlistentry> 546</variablelist> 547 548<para> 549<function>XkbIgnoreExtension</function> 550tells the X library whether to use the X Keyboard Extension on any 551subsequently opened X display connections. If ignore is 552<symbol>True</symbol>, 553the library does not initialize the Xkb extension when it opens a new 554display. This forces the X server to use compatibility mode and communicate 555with the client using only core protocol requests and events. If ignore is 556<symbol>False</symbol>, 557the library treats subsequent calls to 558<function>XOpenDisplay</function> 559normally and uses Xkb extension requests, events, and state. Do not explicitly 560use Xkb on a connection for which it is disabled. 561<function>XkbIgnoreExtension</function> 562returns 563<symbol>False</symbol> 564if it was unable to apply the ignore request. 565</para> 566 567</sect1> 568<sect1 id='Protocol_Errors'> 569<title>Protocol Errors</title> 570<indexterm significance="preferred" zone="Protocol_Errors"> 571<primary>errors</primary></indexterm> 572 573<para> 574Many of the Xkb extension library functions described in this document can 575cause the X server to report an error, referred to in this document as a 576<errorname>Bad<replaceable>Xxx</replaceable></errorname> 577protocol error, where 578<replaceable>Xxx</replaceable> 579is some name. These errors are fielded in the normal manner, by the default 580Xlib error handler or one replacing it. Note that X protocol errors are not 581necessarily reported immediately because of the buffering of X protocol 582requests in Xlib and the server. 583</para> 584 585<para> 586<link linkend="table2.1">Table 2.1</link> 587lists the protocol errors that can be generated, and their causes. 588</para> 589 590<table id='table2.1' frame='topbot'> 591<title>Xkb Protocol Errors</title> 592<?dbfo keep-together="always" ?> 593<tgroup cols='2' align='left' colsep='0' rowsep='0'> 594<colspec colname='c1' colwidth='1.0*'/> 595<colspec colname='c2' colwidth='3.0*'/> 596<thead> 597 <row rowsep='1'> 598 <entry>Error</entry> 599 <entry>Cause</entry> 600 </row> 601</thead> 602<tbody> 603 <row> 604 <entry><errorname>BadAccess</errorname></entry> 605 <entry> 606<para> 607The Xkb extension has not been properly initialized 608</para> 609 </entry> 610 </row> 611 <row> 612 <entry><errorname>BadKeyboard</errorname></entry> 613 <entry> 614<para> 615The device specified was not a valid core or input extension device 616</para> 617 </entry> 618 </row> 619 <row> 620 <entry><errorname>BadImplementation</errorname></entry> 621 <entry> 622<para> 623Invalid reply from server 624</para> 625 </entry> 626 </row> 627 <row> 628 <entry><errorname>BadAlloc</errorname></entry> 629 <entry> 630<para> 631Unable to allocate storage 632</para> 633 </entry> 634 </row> 635 <row> 636 <entry><errorname>BadMatch</errorname></entry> 637 <entry> 638<para> 639A compatible version of Xkb was not available in the server or an argument has 640correct type and range, but is otherwise invalid 641</para> 642 </entry> 643 </row> 644 <row> 645 <entry><errorname>BadValue</errorname></entry> 646 <entry> 647<para> 648An argument is out of range 649</para> 650 </entry> 651 </row> 652 <row> 653 <entry><errorname>BadAtom</errorname></entry> 654 <entry> 655<para> 656A name is neither a valid Atom or 657<symbol>None</symbol> 658</para> 659 </entry> 660 </row> 661 <row> 662 <entry><errorname>BadDevice</errorname></entry> 663 <entry> 664<para> 665Device, Feedback Class, or Feedback ID invalid 666</para> 667 </entry> 668 </row> 669</tbody> 670</tgroup> 671</table> 672 673<para id='BadKeyboard'> 674<indexterm zone="BadKeyboard"><primary>errors</primary> 675<secondary><errorname>BadKeyboard</errorname></secondary></indexterm> 676<indexterm zone="BadKeyboard"> 677<primary><errorname>BadKeyboard</errorname></primary></indexterm> 678The Xkb extension adds a single protocol error, 679<errorname>BadKeyboard</errorname>, 680to the core protocol error set. This error code will be reported as the 681<parameter>error_rtrn</parameter> 682when 683<function>XkbQueryExtension</function> 684is called. When a 685<errorname>BadKeyboard</errorname> 686error is reported in an 687<structname>XErrorEvent</structname>, 688additional information is reported in the 689<structfield>resourceid</structfield> 690field. The most significant byte of the 691<structfield>resource_id</structfield> 692is a further refinement of the error cause, as defined in 693<link linkend="table2.2">Table 2.2</link>. The least 694significant byte will contain the device, class, or feedback ID as indicated in 695the table. 696</para> 697 698<table id='table2.2' frame='topbot'> 699<title><errorname>BadKeyboard</errorname> Protocol Error resource_id Values</title> 700<?dbfo keep-together="always" ?> 701<tgroup cols='4' align='left' colsep='0' rowsep='0'> 702<colspec colname='c1' colwidth='2.0*'/> 703<colspec colname='c2' colwidth='1.0*'/> 704<colspec colname='c3' colwidth='3.0*'/> 705<colspec colname='c4' colwidth='2.0*'/> 706<thead> 707 <row rowsep='1'> 708 <entry>high-order byte</entry> 709 <entry>value</entry> 710 <entry>meaning</entry> 711 <entry>low-order byte</entry> 712 </row> 713</thead> 714<tbody> 715 <row> 716 <entry><errorname>XkbErr_BadDevice</errorname></entry> 717 <entry>0xff</entry> 718 <entry> 719<para> 720device not found 721</para> 722 </entry> 723 <entry>device ID</entry> 724 </row> 725 <row> 726 <entry><errorname>XkbErr_BadClass</errorname></entry> 727 <entry>0xfe</entry> 728 <entry> 729<para> 730device found, but it is of the wrong class 731</para> 732 </entry> 733 <entry>class ID</entry> 734 </row> 735 <row> 736 <entry><errorname>XkbErr_BadId</errorname></entry> 737 <entry>0xfd</entry> 738 <entry> 739<para> 740device found, class ok, but device does not contain a feedback with the 741indicated ID 742</para> 743 </entry> 744 <entry>feedback ID</entry> 745 </row> 746</tbody> 747</tgroup> 748</table> 749</sect1> 750 751<sect1 id='Display_and_Device_Specifications_in_Function_Calls'> 752<title>Display and Device Specifications in Function Calls</title> 753<para> 754Where a connection to the server is passed as an argument (Display*) and an 755<type>XkbDescPtr</type> 756is also passed as an argument, the Display* argument must match the 757<structfield>dpy</structfield> 758field of the 759<structname>XkbDescRec</structname> 760pointed to by the 761<type>XkbDescPtr</type> 762argument, or else the 763<structfield>dpy</structfield> 764field of the 765<structname>XkbDescRec</structname> 766must be 767<symbol>NULL</symbol>. 768If they don’t match or the 769<structfield>dpy</structfield> 770field is not 771<symbol>NULL</symbol>, 772a 773<errorname>BadMatch</errorname> 774error is returned (either in the return value or a backfilled 775<type>Status</type> 776variable). Upon successful return, the 777<structfield>dpy</structfield> 778field of the 779<structname>XkbDescRec</structname> 780always contains the Display* value passed in. 781</para> 782 783<para> 784The Xkb extension can communicate with the X input extension if it is present. 785Consequently, there can potentially be more than one input device connected to 786the server. Most Xkb library calls that require communicating with the server 787involve both a server connection (Display * 788<structfield>dpy</structfield>) 789and a device identifier (unsigned int 790<structfield>device_spec</structfield>). 791In some cases, the device identifier is implicit and is taken as the 792<structfield>device_spec</structfield> 793field of an 794<structname>XkbDescRec</structname> 795structure passed as an argument. 796</para> 797 798<para id='XkbUseCoreKbd'> 799<indexterm significance="preferred" zone="XkbUseCoreKbd"><primary><symbol>XkbUseCoreKbd</symbol></primary></indexterm> 800The device identifier can specify any X input extension device with a 801<symbol>KeyClass</symbol> 802component, or it can specify the constant, 803<symbol>XkbUseCoreKbd</symbol>. 804The use of 805<symbol>XkbUseCoreKbd</symbol> 806allows applications to indicate the core keyboard without having to determine 807its device identifier. 808</para> 809 810<para> 811Where an Xkb device identifier is passed as an argument and an 812<type>XkbDescPtr</type> 813is also passed as an argument, if either the argument or the 814<structname>XkbDescRec</structname> 815<structfield>device_spec</structfield> 816field is 817<symbol>XkbUseCoreKbd</symbol>, 818and if the function returns successfully, the 819<type>XkbDescPtr</type> 820<structfield>device_spec</structfield> 821field will have been converted from 822<symbol>XkbUseCoreKbd</symbol> 823to a real Xkb device ID. If the function does not complete successfully, the 824<structfield>device_spec</structfield> 825field remains unchanged. Subsequently, the device id argument must match the 826<structfield>device_spec</structfield> 827field of the 828<type>XkbDescPtr</type> 829argument. If they don’t match, a 830<errorname>BadMatch</errorname> 831error is returned (either in the return value or a backfilled 832<type>Status</type> 833variable). 834</para> 835 836<para> 837When the Xkb extension in the server hands an application a device identifier 838to use for the keyboard, that ID is the input extension identifier for the 839device if the server supports the X Input Extension. If the server does not 840support the input extension, the meaning of the identifier is undefined — the 841only guarantee is that when you use 842<symbol>XkbUseCoreKbd</symbol>, 843<symbol>XkbUseCoreKbd</symbol> 844will work and the identifier returned by the server will refer to the core 845keyboard device. 846</para> 847</sect1> 848</chapter> 849