ch20.xml revision eb411b4b
1<chapter id='Server_Database_of_Keyboard_Components'> 2<title>Server Database of Keyboard Components</title> 3 4<para> 5The X server maintains a database of keyboard components, identified by 6component type. The database contains all the information necessary to build a 7complete keyboard description for a particular device, as well as to assemble 8partial descriptions. Table 20.1 identifies the component types and the type of 9information they contain. 10</para> 11 12<table frame='topbot'> 13<title>Server Database Keyboard Components</title> 14<?dbfo keep-together="always" ?> 15<tgroup cols='3' align='left' colsep='0' rowsep='0'> 16<colspec colname='c1' colwidth='1.0*'/> 17<colspec colname='c2' colwidth='1.0*'/> 18<colspec colname='c3' colwidth='1.5*'/> 19<thead> 20<row rowsep='1'> 21 <entry>Component Type</entry> 22 <entry>Component Primary Contents</entry> 23 <entry>May also contain</entry> 24 </row> 25</thead> 26<tbody> 27 <row> 28 <entry>Keymap</entry> 29 <entry> 30<para>Complete keyboard description</para> 31<para>Normally assembled using a complete component from each of the other types</para> 32 </entry> 33 <entry></entry> 34 </row> 35 <row> 36 <entry>Keycodes</entry> 37 <entry> 38<para>Symbolic name for each key</para> 39<para>Minimum and maximum legal keycodes</para> 40 </entry> 41 <entry> 42<para>Aliases for some keys</para> 43<para>Symbolic names for indicators</para> 44<para>Description of indicators physically present</para> 45 </entry> 46 </row> 47 <row> 48 <entry>Types</entry> 49 <entry>Key types</entry> 50 <entry> 51Real modifier bindings and symbolic names for some virtual modifiers 52 </entry> 53 </row> 54 <row> 55 <entry>Compatibility</entry> 56 <entry>Rules used to assign actions to keysyms</entry> 57 <entry> 58<para>Maps for some indicators</para> 59<para>Real modifier bindings and symbolic names for some virtual modifiers</para> 60 </entry> 61 </row> 62 <row> 63 <entry>Symbols</entry> 64 <entry> 65<para>Symbol mapping for keyboard keys</para> 66<para>Modifier mapping</para> 67<para>Symbolic names for groups</para> 68 </entry> 69 <entry> 70<para>Explicit actions and behaviors for some keys</para> 71<para>Real modifier bindings and symbolic names for some virtual modifiers</para> 72 </entry> 73 </row> 74 <row> 75 <entry>Geometry</entry> 76 <entry>Layout of the keyboard</entry> 77 <entry> 78<para>Aliases for some keys; overrides keycodes component aliases</para> 79<para>Symbolic names for some indicators</para> 80<para>Description of indicators physically present</para> 81 </entry> 82 </row> 83</tbody> 84</tgroup> 85</table> 86 87<para> 88While a keymap is a database entry for a complete keyboard description, and 89therefore logically different from the individual component database entries, 90the rules for processing keymap entries are identical to those for the 91individual components. In the discussion that follows, the term component is 92used to refer to either individual components or a keymap. 93</para> 94 95<para> 96There may be multiple entries for each of the component types. An entry may be 97either <emphasis> 98complete</emphasis> 99 or <emphasis> 100partial</emphasis> 101. Partial entries describe only a piece of the corresponding keyboard component 102and are designed to be combined with other entries of the same type to form a 103complete entry. 104</para> 105 106<para> 107For example, a partial symbols map might describe the differences between a 108common ASCII keyboard and some national layout. Such a partial map is not 109useful on its own because it does not include those symbols that are the same 110on both the ASCII and national layouts (such as function keys). On the other 111hand, this partial map can be used to configure <emphasis> 112any</emphasis> 113 ASCII keyboard to use a national layout. 114</para> 115 116<para> 117When a keyboard description is built, the components are processed in the order 118in which they appear in Table 20.1; later definitions override earlier ones. 119</para> 120 121<sect1 id='Component_Names'> 122<title>Component Names</title> 123 124<para> 125Component names have the form "<emphasis> 126class(member)</emphasis> 127" where <emphasis> 128class</emphasis> 129 describes a subset of the available components for a particular type and the 130optional <emphasis> 131member</emphasis> 132 identifies a specific component from that subset. For example, the name 133"atlantis(acme)" for a symbols component might specify the symbols used for the 134atlantis national keyboard layout by the vendor "acme." Each class has an 135optional <emphasis> 136default</emphasis> 137 member — references that specify a class but not a member refer to the 138default member of the class, if one exists. Xkb places no constraints on the 139interpretation of the class and member names used in component names. 140</para> 141 142<para> 143The <emphasis> 144class</emphasis> 145 and <emphasis> 146member</emphasis> 147 names are both specified using characters from the Latin-1 character set. Xkb 148implementations must accept all alphanumeric characters, minus (‘-’) and 149underscore (‘_’) in class or member names, and must not accept parentheses, 150plus, vertical bar, percent sign, asterisk, question mark, or white space. The 151use of other characters is implementation-dependent. 152</para> 153 154</sect1> 155<sect1 id='Listing_the_Known_Keyboard_Components'> 156<title>Listing the Known Keyboard Components</title> 157 158<para> 159You may ask the server for a list of components for one or more component 160types. The request takes the form of a set of patterns, one pattern for each of 161the component types, including a pattern for the complete keyboard description. 162To obtain this list, use <emphasis> 163XkbListComponents</emphasis> 164. 165</para> 166 167<informaltable frame='none'> 168<?dbfo keep-together="always" ?> 169<tgroup cols='1' align='left' colsep='0' rowsep='0'> 170<colspec colname='c1' colwidth='1.0*'/> 171<tbody> 172 <row> 173 <entry role='functiondecl'> 174XkbComponentListPtr<emphasis> 175 XkbListComponents</emphasis> 176(<emphasis> 177dpy</emphasis> 178, <emphasis> 179device_spec</emphasis> 180, <emphasis> 181ptrns</emphasis> 182, <emphasis> 183max_inout</emphasis> 184) 185 </entry> 186 </row> 187 <row> 188 <entry role='functionargdecl'> 189Display * <emphasis> 190 dpy</emphasis> 191; /* connection to X server */ 192 </entry> 193 </row> 194 <row> 195 <entry role='functionargdecl'> 196unsigned int <emphasis> 197device_spec</emphasis> 198; /* device ID, or <emphasis> 199XkbUseCoreKbd</emphasis> 200 */ 201 </entry> 202 </row> 203 <row> 204 <entry role='functionargdecl'> 205XkbComponentNamesPtr <emphasis> 206ptrns</emphasis> 207; /* namelist for components of interest */ 208 </entry> 209 </row> 210 <row> 211 <entry role='functionargdecl'> 212int * <emphasis> 213max_inout</emphasis> 214; /* max # returned names, # left over */ 215 </entry> 216</row> 217</tbody> 218</tgroup> 219</informaltable> 220 221<para> 222<emphasis> 223XkbListComponents</emphasis> 224 queries the server for a list of component names matching the patterns 225specified in <emphasis> 226ptrns</emphasis> 227. It waits for a reply and returns the matching component names in an <emphasis> 228XkbComponentListRec</emphasis> 229 structure. When you are done using the structure, you should free it using 230<emphasis> 231XkbFreeComponentList</emphasis> 232. <emphasis> 233device_spec</emphasis> 234 indicates a particular device in which the caller is interested. A server is 235allowed (but not required) to restrict its reply to portions of the database 236that are relevant for that particular device. 237</para> 238 239 240<para> 241<emphasis> 242ptrns</emphasis> 243 is a pointer to an <emphasis> 244XkbComponentNamesRec</emphasis> 245, described below. Each of the fields in <emphasis> 246ptrns</emphasis> 247 contains a pattern naming the components of interest. Each of the patterns is 248composed of characters from the ISO <emphasis> 249Latin1</emphasis> 250 encoding, but can contain only parentheses, the wildcard characters 251‘<emphasis> 252?</emphasis> 253’ and ‘<emphasis> 254*</emphasis> 255’, and characters permitted in a component class or member name (see section 25620.1). A pattern may be <emphasis> 257NULL</emphasis> 258, in which case no components for that type is returned. Pattern matches with 259component names are case sensitive. The ‘<emphasis> 260?</emphasis> 261’ wildcard matches any single character, except a left or right parenthesis; 262the ‘<emphasis> 263*</emphasis> 264’ wildcard matches any number of characters, except a left or right 265parenthesis. If an implementation allows additional characters in a component 266class or member name other than those required by the Xkb extension (see 267section 20.1), the result of comparing one of the additional characters to 268either of the wildcard characters is implementation-dependent. 269</para> 270 271 272<para> 273If a pattern contains illegal characters, the illegal characters are ignored. 274The matching process is carried out as if the illegal characters were omitted 275from the pattern. 276</para> 277 278 279<para> 280<emphasis> 281max_inout</emphasis> 282 is used to throttle the amount of data passed to and from the server. On 283input, it specifies the maximum number of names to be returned (the total 284number of names in all component categories). Upon return from <emphasis> 285XkbListComponents</emphasis> 286, <emphasis> 287max_inout</emphasis> 288 contains the number of names that matched the request but were not returned 289because of the limit. 290</para> 291 292 293<para> 294The component name patterns used to describe the request are passed to 295<emphasis> 296XkbListComponents</emphasis> 297 using an <emphasis> 298XkbComponentNamesRec</emphasis> 299 structure. This structure has no special allocation constraints or 300interrelationships with other structures; allocate and free this structure 301using standard <emphasis> 302malloc</emphasis> 303 and <emphasis> 304free</emphasis> 305 calls or their equivalent: 306</para> 307 308<para><programlisting> 309typedef struct _XkbComponentNames { 310 char * keymap; /* keymap names */ 311 char * keycodes; /* keycode names */ 312 char * types; /* type names */ 313 char * compat; /* compatibility map names */ 314 char * symbols; /* symbol names */ 315 char * geometry; /* geometry names */ 316} <emphasis>XkbComponentNamesRec</emphasis>, *XkbComponentNamesPtr; 317</programlisting></para> 318 319<para> 320<emphasis> 321XkbListComponents</emphasis> 322 returns a pointer to an <emphasis> 323XkbComponentListRec</emphasis> 324: 325</para> 326 327<para><programlisting> 328typedef struct _XkbComponentList { 329 int num_keymaps; /* number of entries in keymap */ 330 int num_keycodes; /* number of entries in keycodes */ 331 int num_types; /* number of entries in types */ 332 int num_compat; /* number of entries in compat */ 333 int num_symbols; /* number of entries in symbols */ 334 int num_geometry; /* number of entries in geometry; 335 XkbComponentNamePtr keymap; /* keymap names */ 336 XkbComponentNamePtr keycodes; /* keycode names */ 337 XkbComponentNamePtr types; /* type names */ 338 XkbComponentNamePtr compat; /* compatibility map names */ 339 XkbComponentNamePtr symbols; /* symbol names */ 340 XkbComponentNamePtr geometry; /* geometry names */ 341} <emphasis>XkbComponentListRec</emphasis>, *XkbComponentListPtr; 342</programlisting></para> 343 344<para><programlisting> 345typedef struct _XkbComponentName { 346 unsigned short flags; /* hints regarding component name */ 347 char * name; /* name of component */ 348} <emphasis>XkbComponentNameRec</emphasis>, *XkbComponentNamePtr; 349</programlisting></para> 350 351<para> 352Note that the structure used to specify patterns on input is an <emphasis> 353XkbComponentNamesRec</emphasis> 354, and that used to hold the individual component names upon return is an 355<emphasis> 356XkbComponentNameRec</emphasis> 357 (no trailing ‘s’ in Name). 358</para> 359 360 361<para> 362When you are done using the structure returned by <emphasis> 363XkbListComponents</emphasis> 364, free it using <emphasis> 365XkbFreeComponentList</emphasis> 366. 367</para> 368 369 370<informaltable frame='none'> 371<?dbfo keep-together="always" ?> 372<tgroup cols='1' align='left' colsep='0' rowsep='0'> 373<colspec colname='c1' colwidth='1.0*'/> 374<tbody> 375 <row> 376 <entry role='functiondecl'> 377void <emphasis> 378XkbFreeComponentList</emphasis> 379(list) 380 </entry> 381 </row> 382 <row> 383 <entry role='functionargdecl'> 384XkbComponentListPtr list; /* pointer to <emphasis> 385XkbComponentListRec</emphasis> 386 to free */ 387 </entry> 388</row> 389</tbody> 390</tgroup> 391</informaltable> 392 393 394</sect1> 395<sect1 id='Component_Hints'> 396<title>Component Hints</title> 397 398<para> 399A set of flags is associated with each component; these flags provide 400additional hints about the component’s use. These hints are designated by bit 401masks in the flags field of the <emphasis> 402XkbComponentNameRec</emphasis> 403 structures contained in the <emphasis> 404XkbComponentListRec</emphasis> 405 returned from <emphasis> 406XkbListComponents</emphasis> 407. The least significant byte of the flags field has the same meaning for all 408types of keyboard components; the interpretation of the most significant byte 409is dependent on the type of component. The flags bits are defined in Table 41020.2. The symbols hints in Table 20.2 apply only to partial symbols components 411(those with <emphasis> 412XkbLC_Partial</emphasis> 413 also set); full symbols components are assumed to specify all of the pieces. 414</para> 415 416 417<para> 418The alphanumeric, modifier, keypad or function keys symbols hints should 419describe the primary intent of the component designer and should not be simply 420an exhaustive list of the kinds of keys that are affected. For example, 421national keyboard layouts affect primarily alphanumeric keys, but many affect a 422few modifier keys as well; such mappings should set only the <emphasis> 423XkbLC_AlphanumericKeys</emphasis> 424 hint. In general, symbols components should set only one of the four flags 425(<emphasis> 426XkbLC_AlternateGroup</emphasis> 427 may be combined with any of the other flags). 428</para> 429 430<table frame='topbot'> 431<title>XkbComponentNameRec Flags Bits</title> 432<?dbfo keep-together="always" ?> 433<tgroup cols='4' align='left' colsep='0' rowsep='0'> 434<colspec colname='c1' colwidth='1.5*'/> 435<colspec colname='c2' colwidth='3.0*'/> 436<colspec colname='c3' colwidth='2.0*'/> 437<colspec colname='c4' colwidth='1.0*'/> 438<thead> 439<row rowsep='1'> 440 <entry>Component Type</entry> 441 <entry>Component Hints (flags)</entry> 442 <entry>Meaning</entry> 443 <entry>Value</entry> 444</row> 445</thead> 446<tbody> 447<row> 448 <entry>All Components</entry> 449 <entry><para><emphasis>XkbLC_Hidden</emphasis></para></entry> 450 <entry>Do not present to user</entry> 451 <entry>(1L<<0)</entry> 452</row> 453<row> 454 <entry></entry> 455 <entry><emphasis>XkbLC_Default</emphasis></entry> 456 <entry>Default member of class</entry> 457 <entry>(1L<<1)</entry> 458</row> 459<row> 460 <entry></entry> 461 <entry><emphasis>XkbLC_Partial</emphasis></entry> 462 <entry>Partial component</entry> 463 <entry>(1L<<2)</entry> 464</row> 465<row> 466 <entry>Keymap</entry> 467 <entry>none</entry> 468 <entry></entry> 469 <entry></entry> 470</row> 471<row> 472 <entry>Keycodes</entry> 473 <entry>none</entry> 474 <entry></entry> 475 <entry></entry> 476</row> 477<row> 478 <entry>Types</entry> 479 <entry>none</entry> 480 <entry></entry> 481 <entry></entry> 482</row> 483<row> 484 <entry>Compatibility</entry> 485 <entry>none</entry> 486 <entry></entry> 487 <entry></entry> 488</row> 489<row> 490 <entry>Symbols</entry> 491 <entry><emphasis>XkbLC_AlphanumericKeys</emphasis></entry> 492 <entry>Bindings primarily for alphanumeric keyboard section</entry> 493 <entry>(1L<<8)</entry> 494</row> 495<row> 496 <entry></entry> 497 <entry><emphasis>XkbLC_ModifierKeys</emphasis></entry> 498 <entry>Bindings primarily for modifier keys</entry> 499 <entry>(1L<<9)</entry> 500</row> 501<row> 502 <entry></entry> 503 <entry><emphasis>XkbLC_KeypadKeys</emphasis></entry> 504 <entry>Bindings primarily for numeric keypad keys</entry> 505 <entry>(1L<<10)</entry> 506</row> 507<row> 508 <entry></entry> 509 <entry><emphasis>XkbLC_FunctionKeys</emphasis></entry> 510 <entry>Bindings primarily for function keys</entry> 511 <entry>(1L<<11)</entry> 512</row> 513<row> 514 <entry></entry> 515 <entry><emphasis>XkbLC_AlternateGroup</emphasis></entry> 516 <entry>Bindings for an alternate group</entry> 517 <entry>(1L<<12)</entry> 518</row> 519<row> 520 <entry>Geometry</entry> 521 <entry>none</entry> 522 <entry></entry> 523 <entry></entry> 524 </row> 525</tbody> 526</tgroup> 527</table> 528 529</sect1> 530<sect1 id='Building_a_Keyboard_Description_Using_the_Server_Database'> 531<title>Building a Keyboard Description Using the Server Database</title> 532 533<para> 534A client may request that the server fetch one or more components from its 535database and use those components to build a new server keyboard description. 536The new keyboard description may be built from scratch, or it may be built 537starting with the current keyboard description for a particular device. Once 538the keyboard description is built, all or part of it may be returned to the 539client. The parts returned to the client need not include all of the parts used 540to build the description. At the time it requests the server to build a new 541keyboard description, a client may also request that the server use the new 542description internally to replace the current keyboard description for a 543specific device, in which case the behavior of the device changes accordingly. 544</para> 545 546 547<para> 548To build a new keyboard description from a set of named components, and to 549optionally have the server use the resulting description to replace an active 550one, use <emphasis> 551XkbGetKeyboardByName</emphasis> 552. 553</para> 554 555<informaltable frame='none'> 556<?dbfo keep-together="always" ?> 557<tgroup cols='1' align='left' colsep='0' rowsep='0'> 558<colspec colname='c1' colwidth='1.0*'/> 559<tbody> 560 <row> 561 <entry role='functiondecl'> 562XkbDescPtr <emphasis> 563XkbGetKeyboardByName</emphasis> 564(<emphasis> 565dpy</emphasis> 566, <emphasis> 567device_spec</emphasis> 568, <emphasis> 569names</emphasis> 570, <emphasis> 571want</emphasis> 572, <emphasis> 573need</emphasis> 574, <emphasis> 575load</emphasis> 576) 577 </entry> 578 </row> 579 <row> 580 <entry role='functionargdecl'> 581Display * <emphasis> 582 dpy</emphasis> 583; /* connection to X server */ 584 </entry> 585 </row> 586 <row> 587 <entry role='functionargdecl'> 588unsigned int <emphasis> 589device_spec</emphasis> 590; /* device ID, or <emphasis> 591XkbUseCoreKbd</emphasis> 592 */ 593 </entry> 594 </row> 595 <row> 596 <entry role='functionargdecl'> 597XkbComponentNamesPtr <emphasis> 598names</emphasis> 599; /* names of components to fetch */ 600 </entry> 601 </row> 602 <row> 603 <entry role='functionargdecl'> 604unsigned int <emphasis> 605want</emphasis> 606; /* desired structures in returned record */ 607 </entry> 608 </row> 609 <row> 610 <entry role='functionargdecl'> 611unsigned int <emphasis> 612need</emphasis> 613; /* mandatory structures in returned record */ 614 </entry> 615 </row> 616 <row> 617 <entry role='functionargdecl'> 618Bool <emphasis> 619load</emphasis> 620; /* <emphasis> 621True</emphasis> 622 => load into <emphasis> 623device_spec</emphasis> 624 */ 625 </entry> 626</row> 627</tbody> 628</tgroup> 629</informaltable> 630 631<para> 632<emphasis> 633names</emphasis> 634 contains a set of expressions describing the keyboard components the server 635should use to build the new keyboard description. <emphasis> 636want</emphasis> 637 and <emphasis> 638need</emphasis> 639 are bit fields describing the parts of the resulting keyboard description that 640should be present in the returned <emphasis> 641XkbDescRec</emphasis> 642. 643</para> 644 645 646<para> 647The individual fields in <emphasis> 648names</emphasis> 649 are <emphasis> 650component expressions</emphasis> 651 composed of keyboard component names (no wildcarding as may be used in 652<emphasis> 653XkbListComponents</emphasis> 654), the special component name symbol ‘%’, and the special operator 655characters ‘<emphasis> 656+</emphasis> 657’ and ‘<emphasis> 658|</emphasis> 659’. A component expression is parsed left to right, as follows: 660</para> 661 662<itemizedlist> 663<listitem> 664 <para> 665The special component name "<emphasis> 666computed</emphasis> 667" may be used in <emphasis> 668keycodes</emphasis> 669 component expressions and refers to a component consisting of a set of 670keycodes computed automatically by the server as needed. 671 </para> 672</listitem> 673<listitem> 674 <para> 675The special component name "<emphasis> 676canonical</emphasis> 677" may be used in <emphasis> 678types</emphasis> 679 component expressions and refers to a partial component defining the four 680standard key types: <emphasis> 681ALPHABETIC</emphasis> 682, <emphasis> 683ONE_LEVEL</emphasis> 684, <emphasis> 685TWO_LEVEL</emphasis> 686, and <emphasis> 687KEYPAD</emphasis> 688. 689 </para> 690</listitem> 691<listitem> 692 <para> 693The special component name ‘<emphasis> 694%</emphasis> 695’ refers to the keyboard description for the device specified in <emphasis> 696device_spec</emphasis> 697 or the keymap names component. If a keymap names component is specified that 698does not begin with ‘+’ or ‘|’ and does not contain ‘<emphasis> 699%</emphasis> 700’, then ‘<emphasis> 701%</emphasis> 702’ refers to the description generated by the keymap names component. 703Otherwise, it refers to the keyboard description for <emphasis> 704device_spec</emphasis> 705. 706 </para> 707</listitem> 708<listitem> 709 <para> 710The ‘<emphasis> 711+</emphasis> 712’ operator specifies that the following component should <emphasis> 713override</emphasis> 714 the currently assembled description; any definitions that are present in both 715components are taken from the second. 716 </para> 717</listitem> 718<listitem> 719 <para> 720The ‘<emphasis> 721|</emphasis> 722’ operator specifies that the next specified component should <emphasis> 723augment</emphasis> 724 the currently assembled description; any definitions that are present in both 725components are taken from the first. 726 </para> 727</listitem> 728<listitem> 729 <para> 730If the component expression begins with an operator, a leading ‘<emphasis> 731%</emphasis> 732’ is implied. 733 </para> 734</listitem> 735<listitem> 736 <para> 737If any unknown or illegal characters appear anywhere in the expression, the 738entire expression is invalid and is ignored. 739 </para> 740</listitem> 741</itemizedlist> 742 743<para> 744For example, if <emphasis> 745names->symbols</emphasis> 746 contained the expression "+de", it specifies that the default member of the 747"de" class of symbols should be applied to the current keyboard mapping, 748overriding any existing definitions (it could also be written "+de(default)"). 749</para> 750 751 752<para> 753Here is a slightly more involved example: the expression 754"acme(ascii)+de(basic)|iso9995-3" constructs a German (de) mapping for the 755ASCII keyboard supplied by the "acme" vendor. The new definition begins with 756the symbols for the ASCII keyboard for Acme (<emphasis> 757acme(ascii)</emphasis> 758), overrides them with definitions for the basic German keyboard (<emphasis> 759de(basic)</emphasis> 760), and then applies the definitions from the default iso9995-3 keyboard 761(<emphasis> 762iso9995-3</emphasis> 763) to any undefined keys or groups of keys (part three of the iso9995 standard 764defines a common set of bindings for the secondary group, but allows national 765layouts to override those definitions where necessary). 766</para> 767 768<note><para>The interpretation of the above expression components (acme, ascii, 769de, basic, iso9995-3) is not defined by Xkb; only the operations and their 770ordering are.</para></note> 771 772<para> 773Note that the presence of a keymap <emphasis> 774names</emphasis> 775 component that does not contain ‘<emphasis> 776%</emphasis> 777’ (either explicit or implied by virtue of an expression starting with an 778operator) indicates a description that is independent of the keyboard 779description for the device specified in <emphasis> 780device_spec</emphasis> 781. The same is true of requests in which the keymap names component is empty and 782all five other names components contain expressions void of references to 783‘<emphasis> 784%</emphasis> 785’. Requests of this form allow you to deal with keyboard definitions 786independent of any actual device. 787</para> 788 789 790<para> 791The server parses all non-<emphasis> 792NULL</emphasis> 793 fields in <emphasis> 794names</emphasis> 795 and uses them to build a keyboard description. However, before parsing the 796expressions in <emphasis> 797names</emphasis> 798, the server ORs the bits in <emphasis> 799want</emphasis> 800 and <emphasis> 801need</emphasis> 802 together and examines the result in relationship to the expressions in 803<emphasis> 804names</emphasis> 805. Table 20.3 identifies the components that are required for each of the 806possible bits in <emphasis> 807want</emphasis> 808 or <emphasis> 809need</emphasis> 810. If a required component has not been specified in the <emphasis> 811names</emphasis> 812 structure (the corresponding field is <emphasis> 813NULL</emphasis> 814), the server substitutes the expression "<emphasis> 815%</emphasis> 816", resulting in the component values being taken from <emphasis> 817device_spec</emphasis> 818. In addition, if <emphasis> 819load</emphasis> 820 is <emphasis> 821True</emphasis> 822, the server modifies <emphasis> 823names</emphasis> 824 if necessary (again using a "<emphasis> 825%</emphasis> 826" entry) to ensure all of the following fields are non-<emphasis> 827NULL</emphasis> 828: <emphasis> 829types</emphasis> 830, <emphasis> 831keycodes</emphasis> 832, <emphasis> 833symbols</emphasis> 834, and <emphasis> 835compat</emphasis> 836.<emphasis> 837</emphasis> 838</para> 839 840<table frame='topbot'> 841<title>Want and Need Mask Bits and Required Names Components</title> 842<?dbfo keep-together="always" ?> 843<tgroup cols='3' align='left' colsep='0' rowsep='0'> 844<colspec colname='c1' colwidth='2.4*'/> 845<colspec colname='c2' colwidth='2.6*'/> 846<colspec colname='c3' colwidth='1.0*'/> 847<thead> 848<row rowsep='1'> 849 <entry>want or need mask bit</entry> 850 <entry>Required names Components</entry> 851 <entry>value</entry> 852 </row> 853</thead> 854<tbody> 855 <row> 856 <entry>XkbGBN_TypesMask</entry> 857 <entry>Types</entry> 858 <entry>(1L<<0)</entry> 859 </row> 860 <row> 861 <entry>XkbGBN_CompatMapMask</entry> 862 <entry>Compat</entry> 863 <entry>(1L<<1)</entry> 864 </row> 865 <row> 866 <entry>XkbGBN_ClientSymbolsMask</entry> 867 <entry>Types + Symbols + Keycodes</entry> 868 <entry>(1L<<2)</entry> 869 </row> 870 <row> 871 <entry>XkbGBN_ServerSymbolsMask</entry> 872 <entry>Types + Symbols + Keycodes</entry> 873 <entry>(1L<<3)</entry> 874 </row> 875 <row> 876 <entry>XkbGBN_SymbolsMask</entry> 877 <entry>Symbols</entry> 878 <entry>(1L<<1)</entry> 879 </row> 880 <row> 881 <entry>XkbGBN_IndicatorMapMask</entry> 882 <entry>Compat</entry> 883 <entry>(1L<<4)</entry> 884 </row> 885 <row> 886 <entry>XkbGBN_KeyNamesMask</entry> 887 <entry>Keycodes</entry> 888 <entry>(1L<<5)</entry> 889 </row> 890 <row> 891 <entry>XkbGBN_GeometryMask</entry> 892 <entry>Geometry</entry> 893 <entry>(1L<<6)</entry> 894 </row> 895 <row> 896 <entry>XkbGBN_OtherNamesMask</entry> 897 <entry>Types + Symbols + Keycodes + Compat + Geometry</entry> 898 <entry>(1L<<7)</entry> 899 </row> 900 <row> 901 <entry>XkbGBN_AllComponentsMask</entry> 902 <entry></entry> 903 <entry>(0xff)</entry> 904 </row> 905</tbody> 906</tgroup> 907</table> 908 909<para> 910<emphasis> 911need</emphasis> 912 specifies a set of keyboard components that the server must be able to resolve 913in order for <emphasis> 914XkbGetKeyboardByName</emphasis> 915 to succeed; if any of the components specified in <emphasis> 916need</emphasis> 917 cannot be successfully resolved, <emphasis> 918XkbGetKeyboardByName</emphasis> 919 fails. 920</para> 921 922 923<para> 924<emphasis> 925want</emphasis> 926 specifies a set of keyboard components that the server should attempt to 927resolve, but that are not mandatory. If the server is unable to resolve any of 928these components, <emphasis> 929XkbGetKeyboardByName</emphasis> 930 still succeeds. Bits specified in <emphasis> 931want</emphasis> 932 that are also specified in <emphasis> 933need</emphasis> 934 have no effect in the context of <emphasis> 935want</emphasis> 936. 937</para> 938 939 940<para> 941If <emphasis> 942load</emphasis> 943 is <emphasis> 944True</emphasis> 945, the server updates its keyboard description for <emphasis> 946device_spec</emphasis> 947 to match the result of the keyboard description just built. If load is 948<emphasis> 949False</emphasis> 950, the server’s description for device <emphasis> 951device_spec</emphasis> 952 is not updated. In all cases, the parts specified by <emphasis> 953want</emphasis> 954 and <emphasis> 955need</emphasis> 956 from the just-built keyboard description are returned. 957</para> 958 959 960<para> 961The <emphasis> 962names</emphasis> 963 structure in an <emphasis> 964XkbDescRec</emphasis> 965 keyboard description record (see Chapter 18) contains one field for each of 966the five component types used to build a keyboard description. When a keyboard 967description is built from a set of database components, the corresponding 968fields in this <emphasis> 969names</emphasis> 970 structure are set to match the expressions used to build the component. 971</para> 972 973 974<para> 975The entire process of building a new keyboard description from the server 976database of components and returning all or part of it is diagrammed in Figure 97720.1: 978</para> 979 980<mediaobject> 981 <imageobject> <imagedata format="SVG" fileref="XKBlib-21.svg"/> 982 </imageobject> 983 <caption>Building a New Keyboard Description from the Server Database</caption> 984</mediaobject> 985 986<para> 987The information returned to the client in the <emphasis> 988XkbDescRec</emphasis> 989 is essentially the result of a series of calls to extract information from a 990fictitious device whose description matches the one just built. The calls 991corresponding to each of the mask bits are summarized in Table 20.4, together 992with the <emphasis> 993XkbDescRec</emphasis> 994 components that are filled in. 995</para> 996 997<table frame='topbot'> 998<title>XkbDescRec Components Returned for Values of Want & Needs</title> 999<?dbfo keep-together="always" ?> 1000<tgroup cols='3' align='left' colsep='0' rowsep='0'> 1001<colspec colname='c1' colwidth='1.0*'/> 1002<colspec colname='c2' colwidth='1.0*'/> 1003<colspec colname='c3' colwidth='1.0*'/> 1004<thead> 1005<row rowsep='1'> 1006 <entry>Request (want+need)</entry> 1007 <entry>Fills in Xkb components</entry> 1008 <entry>Equivalent Function Call</entry> 1009 </row> 1010</thead> 1011<tbody> 1012 <row> 1013 <entry>XkbGBN_TypesMask</entry> 1014 <entry>map.types</entry> 1015 <entry>XkbGetUpdatedMap(dpy, XkbTypesMask, Xkb)</entry> 1016 </row> 1017 <row> 1018 <entry>XkbGBN_ServerSymbolsMask</entry> 1019 <entry>server</entry> 1020 <entry>XkbGetUpdatedMap(dpy, XkbAllClientInfoMask, Xkb)</entry> 1021 </row> 1022 <row> 1023 <entry>XkbGBN_ClientSymbolsMask</entry> 1024 <entry>map, including map.types</entry> 1025 <entry>XkbGetUpdatedMap(dpy, XkbAllServerInfoMask, Xkb)</entry> 1026 </row> 1027 <row> 1028 <entry>XkbGBN_IndicatorMaps</entry> 1029 <entry>indicators</entry> 1030 <entry>XkbGetIndicatorMap(dpy, XkbAllIndicators, Xkb)</entry> 1031 </row> 1032 <row> 1033 <entry>XkbGBN_CompatMapMask</entry> 1034 <entry>compat</entry> 1035 <entry>XkbGetCompatMap(dpy, XkbAllCompatMask, Xkb)</entry> 1036 </row> 1037 <row> 1038 <entry>XkbGBN_GeometryMask</entry> 1039 <entry>geom</entry> 1040 <entry>XkbGetGeometry(dpy, Xkb)</entry> 1041 </row> 1042 <row> 1043 <entry>XkbGBN_KeyNamesMask</entry> 1044 <entry> 1045<para>names.keys</para> 1046<para>names.key_aliases</para> 1047 </entry> 1048 <entry> 1049XkbGetNames(dpy, XkbKeyNamesMask | XkbKeyAliasesMask, Xkb) 1050 </entry> 1051 </row> 1052 <row> 1053 <entry>XkbGBN_OtherNamesMask</entry> 1054 <entry> 1055<para>names.keycodes</para> 1056<para>names.geometry</para> 1057<para>names.symbols</para> 1058<para>names.types</para> 1059<para>map.types[*].lvl_names[*]</para> 1060<para>names.compat</para> 1061<para>names.vmods</para> 1062<para>names.indicators</para> 1063<para>names.groups</para> 1064<para>names.radio_groups</para> 1065<para>names.phys_symbols</para> 1066 </entry> 1067 <entry> 1068<para>XkbGetNames(dpy, XkbAllNamesMask &</para> 1069<para>~(XkbKeyNamesMask | XkbKeyAliasesMask),</para> 1070<para>Xkb)</para> 1071 </entry> 1072 </row> 1073</tbody> 1074</tgroup> 1075</table> 1076 1077<para> 1078There is no way to determine which components specified in <emphasis> 1079want</emphasis> 1080 (but not in <emphasis> 1081need</emphasis> 1082) were actually fetched, other than breaking the call into successive calls to 1083<emphasis> 1084XkbGetKeyboardByName</emphasis> 1085 and specifying individual components. 1086</para> 1087 1088 1089<para> 1090<emphasis> 1091XkbGetKeyboardByName</emphasis> 1092 always sets <emphasis> 1093min_key_code</emphasis> 1094 and <emphasis> 1095max_key_code</emphasis> 1096 in the returned <emphasis> 1097XkbDescRec</emphasis> 1098 structure. 1099</para> 1100 1101 1102<para> 1103<emphasis>XkbGetKeyboardByName</emphasis> 1104is synchronous; it sends the request to the server to build a new keyboard 1105description and waits for the reply. If successful, the return value is 1106non-<emphasis>NULL</emphasis>. 1107<emphasis>XkbGetKeyboardByName</emphasis> 1108generates a <emphasis>BadMatch</emphasis> 1109protocol error if errors are encountered when building the keyboard 1110description. 1111</para> 1112 1113 1114<para> 1115If you simply want to obtain information about the current keyboard device, 1116rather than generating a new keyboard description from elements in the server 1117database, use <emphasis> 1118XkbGetKeyboard</emphasis> 1119 (see section 6.2). 1120</para> 1121 1122<informaltable frame='none'> 1123<?dbfo keep-together="always" ?> 1124<tgroup cols='1' align='left' colsep='0' rowsep='0'> 1125<colspec colname='c1' colwidth='1.0*'/> 1126<tbody> 1127 <row> 1128 <entry role='functiondecl'> 1129XkbDescPtr <emphasis> 1130XkbGetKeyboard</emphasis> 1131(<emphasis> 1132dpy</emphasis> 1133, <emphasis> 1134which</emphasis> 1135, <emphasis> 1136device_spec</emphasis> 1137) 1138 </entry> 1139 </row> 1140 <row> 1141 <entry role='functionargdecl'> 1142Display * <emphasis> 1143 dpy</emphasis> 1144; /* connection to X server */ 1145 </entry> 1146 </row> 1147 <row> 1148 <entry role='functionargdecl'> 1149unsigned int<emphasis> 1150 which</emphasis> 1151; /* mask of components of <emphasis> 1152XkbDescRec</emphasis> 1153 of interest */ 1154 </entry> 1155 </row> 1156 <row> 1157 <entry role='functionargdecl'> 1158unsigned int <emphasis> 1159 device_spec</emphasis> 1160; /* device ID */ 1161 </entry> 1162</row> 1163</tbody> 1164</tgroup> 1165</informaltable> 1166 1167<para> 1168<emphasis> 1169XkbGetKeyboard</emphasis> 1170 is used to read the current description for one or more components of a 1171keyboard device. It calls <emphasis> 1172XkbGetKeyboardByName</emphasis> 1173 as follows: 1174</para> 1175 1176 1177<para> 1178<emphasis> 1179XkbGetKeyboardByName</emphasis> 1180(<emphasis> 1181dpy</emphasis> 1182, <emphasis> 1183device_spec</emphasis> 1184, <emphasis> 1185NULL</emphasis> 1186, <emphasis> 1187which</emphasis> 1188, <emphasis> 1189which</emphasis> 1190, <emphasis> 1191False</emphasis> 1192). 1193</para> 1194 1195</sect1> 1196</chapter> 1197