1 2<chapter id='Interactions_Between_XKB_and_the_Core_Protocol'> 3<title>Interactions Between XKB and the Core Protocol</title> 4 5<para> 6In addition to providing a number of new requests, XKB replaces or extends 7existing core protocol requests and events. Some aspects of the this extension, 8such as the ability to lock any key or modifier, are visible even to clients 9that are unaware of the XKB extension. Other capabilities, such as control of 10keysym selection on a per-key basis, are available only to XKB-aware clients. 11</para> 12 13 14<para> 15Though they do not have access to some advanced extension capabilities, the XKB 16extension includes compatibility mechanisms to ensure that non-XKB clients 17behave as expected and operate at least as well with an XKB-capable server as 18they do today. 19</para> 20 21 22<para> 23There are a few significant areas in which XKB state and mapping differences 24might be visible to XKB-unaware clients: 25</para> 26 27<itemizedlist> 28<listitem> 29 <para>The core protocol uses a modifier to choose between two keyboard 30groups, while this extension provides explicit support for multiple groups. 31 </para> 32</listitem> 33<listitem> 34 <para>The order of the symbols associated with any given key by XKB might not 35match the ordering demanded by the core protocol. 36 </para> 37</listitem> 38</itemizedlist> 39 40<para> 41To minimize problems that might result from these differences, XKB includes 42ways to specify the correspondence between core protocol and XKB modifiers and 43symbols. 44</para> 45 46 47<para> 48This section describes the differences between the core X protocol’s notion 49of a keyboard mapping and XKB and explains the ways they can interact. 50</para> 51 52<sect1 id='Group_Compatibility_Map'> 53<title>Group Compatibility Map</title> 54 55<para> 56As described in <link linkend='Keyboard_State'>Keyboard 57State</link>, the current keyboard group is reported to XKB-aware clients in 58bits 13-14 of the state field of many core protocol events. XKB-unaware clients 59cannot interpret those bits, but they might use a keyboard modifier to 60implement support for a single keyboard group. To ensure that pre-XKB clients 61continue to work when XKB is present, XKB makes it possible to map an XKB state 62field, which includes both keyboard group and modifier state into a pre-XKB 63state field which contains only modifiers. 64</para> 65 66 67<para> 68A keyboard description includes one <emphasis> 69group compatibility map</emphasis> 70 per keyboard group (four in all). Each such map is a modifier definition (i.e. 71specifies both real and virtual modifiers) which specifies the modifiers to be 72set in the compatibility states when the corresponding keyboard group is 73active. Here are a few examples to illustrate the application of the group 74compatibility map: 75</para> 76 77<informaltable frame='topbot'> 78<?dbfo keep-together="always" ?> 79<tgroup cols='6' align='left' colsep='0' rowsep='0'> 80<colspec colname='c1' colwidth='1.0*'/> 81<colspec colname='c2' colwidth='2.0*'/> 82<colspec colname='c3' colwidth='1.5*'/> 83<colspec colname='c4' colwidth='2.2*'/> 84<colspec colname='c5' colwidth='1.5*'/> 85<colspec colname='c6' colwidth='2.0*'/> 86<thead> 87 <row rowsep='1'> 88 <entry>Group</entry> 89 <entry>GroupCompat Map</entry> 90 <entry>Effective Modifiers</entry> 91 <entry> State for XKB Clients</entry> 92 <entry>Compatibility Modifiers</entry> 93 <entry>State for non-XKB Clients</entry> 94 </row> 95</thead> 96<tbody> 97 <row> 98 <entry>1</entry> 99 <entry>Group1=None</entry> 100 <entry>Shift</entry> 101 <entry>x00xxxxx00000001</entry> 102 <entry>Shift</entry> 103 <entry>xxxxxxxx00000001</entry> 104 </row> 105 <row> 106 <entry>2</entry> 107 <entry>Group2=Mod3</entry> 108 <entry>None</entry> 109 <entry>x01xxxxx00000000</entry> 110 <entry>Mod3</entry> 111 <entry>xxxxxxxx00100000</entry> 112 </row> 113 <row> 114 <entry>3</entry> 115 <entry>Group3=Mod2</entry> 116 <entry>Shift</entry> 117 <entry>x10xxxxx00000001</entry> 118 <entry>Shift+Mod2</entry> 119 <entry>xxxxxxxx00010001</entry> 120 </row> 121 <row> 122 <entry>4</entry> 123 <entry>Group4=None</entry> 124 <entry>Control</entry> 125 <entry>x11xxxxx00000100</entry> 126 <entry>Control</entry> 127 <entry>xxxxxxxx00000100</entry> 128 </row> 129</tbody> 130</tgroup> 131</informaltable> 132 133<para> 134Note that non-XKB clients (i.e. clients that are linked with a version of the X 135library that does not support XKB) cannot detect the fact that <emphasis> 136Group4</emphasis> 137 is active in this example because the group compatibility map for <emphasis> 138Group4</emphasis> 139 does not specify any modifiers. 140</para> 141 142 143<sect2 id='Setting_a_Passive_Grab_for_an_XKB_State'> 144<title>Setting a Passive Grab for an XKB State</title> 145 146<para> 147The fact that the <emphasis> 148state</emphasis> 149 field of an event might look different when XKB is present can cause problems 150with passive grabs. Existing clients specify the modifiers they wish to grab 151using the rules defined by the core protocol, which use a normal modifier to 152indicate keyboard group. If we used an XKB state field, the high bits of the 153state field would be non-zero whenever the keyboard was in any group other than 154<emphasis> 155Group1</emphasis> 156, and none of the passive grabs set by clients could ever be triggered. 157</para> 158 159 160<para> 161To avoid this behavior, the X server normally uses the compatibility grab state 162to decide whether or not to activate a passive grab, even for XKB-aware 163clients. The group compatibility map attempts to encode the keyboard group in 164one or more modifiers of the compatibility state, so existing clients continue 165to work exactly the way they do today. By default, there is no way to directly 166specify a keyboard group in a <emphasis> 167Grabbed</emphasis> 168 or <emphasis> 169GrabButton</emphasis> 170 request, but groups can be specified indirectly by correctly adjusting the 171group compatibility map. 172</para> 173 174 175<para> 176Clients that wish to specify an XKB keyboard state, including a separate 177keyboard group, can set the <emphasis> 178GrabsUseXKBState</emphasis> 179 per-client flag which indicates that all subsequent key and button grabs from 180the requesting clients are specified using an XKB state. 181</para> 182 183 184<para> 185Whether the XKB or core state should be used to trigger a grab is determined by 186the setting of the <emphasis> 187GrabsUseXKBState</emphasis> 188 flag for the requesting client at the time the key or button is grabbed. There 189is no way to change the state to be used for a grab that is already registered 190or for grabs that are set by some other client. 191</para> 192 193 194</sect2> 195</sect1> 196<sect1 id='Changing_the_Keyboard_Mapping_Using_the_Core_Protocol'> 197<title>Changing the Keyboard Mapping Using the Core Protocol</title> 198 199<para> 200An XKB keyboard description includes a lot of information that is not present 201in the core protocol description of a keyboard. Whenever a client remaps the 202keyboard using core protocol requests, XKB examines the map to determine likely 203default values for the components that cannot be specified using the core 204protocol. 205</para> 206 207 208<para> 209Some aspects of this automatic mapping are configurable, and make it fairly 210easy to take advantage of many XKB features using existing tools like <emphasis> 211xmodmap</emphasis> 212, but much of the process of mapping a core keyboard description into an XKB 213description is designed to preserve compatible behavior for pre-XKB clients and 214cannot be redefined by the user. Clients or users that want behavior that 215cannot be described using this mapping should use XKB functions directly. 216</para> 217 218 219<sect2 id='Explicit_Keyboard_Mapping_Components'> 220<title>Explicit Keyboard Mapping Components</title> 221 222<para> 223This automatic remapping might accidentally replace definitions that were 224explicitly requested by an application, so the XKB keyboard description defines 225a set of <emphasis> 226explicit components</emphasis> 227 for each key; any components that are listed in the explicit components for a 228key are not changed by the automatic keyboard mapping. The explicit components 229field for a key can contain any combination of the following values: 230</para> 231 232<informaltable frame='topbot'> 233<?dbfo keep-together="always" ?> 234<tgroup cols='2' align='left' colsep='0' rowsep='0'> 235<colspec colname='c1' colwidth='1.0*'/> 236<colspec colname='c2' colwidth='3.0*'/> 237<thead> 238 <row rowsep='1'> 239 <entry>Bit in Explicit Mask</entry> 240 <entry>Protects Against</entry> 241 </row> 242</thead> 243<tbody> 244 <row> 245 <entry>ExplicitKeyType1</entry> 246 <entry>Automatic determination of the key type associated with <emphasis> 247Group1</emphasis> 248 (see <link linkend='Assigning_Types_To_Groups_of_Symbols_for_a_Key'>Assigning Types To Groups of 249Symbols for a Key</link>)</entry> 250 </row> 251 <row> 252 <entry>ExplicitKeyType2</entry> 253 <entry>Automatic determination of the key type associated with <emphasis> 254Group2 </emphasis> 255(see <link linkend='Assigning_Types_To_Groups_of_Symbols_for_a_Key'>Assigning Types To Groups of 256Symbols for a Key</link>)</entry> 257 </row> 258 <row> 259 <entry>ExplicitKeyType3</entry> 260 <entry>Automatic determination of the key type associated with <emphasis> 261Group3 </emphasis> 262(see <link linkend='Assigning_Types_To_Groups_of_Symbols_for_a_Key'>Assigning Types To Groups of 263Symbols for a Key</link>).</entry> 264 </row> 265 <row> 266 <entry>ExplicitKeyType4</entry> 267 <entry>Automatic determination of the key type associated with <emphasis> 268Group4 </emphasis> 269(see <link linkend='Assigning_Types_To_Groups_of_Symbols_for_a_Key'>Assigning Types To Groups of 270Symbols for a Key</link>).</entry> 271 </row> 272 <row> 273 <entry>ExplicitInterpret</entry> 274 <entry>Application of any of the fields of a symbol interpretation to the 275key in question (see <link linkend='Assigning_Actions_To_Keys'>Assigning 276Actions To Keys</link>).</entry> 277 </row> 278 <row> 279 <entry>ExplicitAutoRepeat</entry> 280 <entry>Automatic determination of autorepeat status for the key, as 281specified in a symbol interpretation (see <link linkend='Assigning_Actions_To_Keys'>Assigning Actions To 282Keys</link>).</entry> 283 </row> 284 <row> 285 <entry>ExplicitBehavior</entry> 286 <entry>Automatic assignment of the <emphasis> 287KB_Lock</emphasis> 288 behavior to the key, if the <emphasis> 289LockingKey</emphasis> 290 flag is set in a symbol interpretation (see <link linkend='Assigning_Actions_To_Keys'>Assigning Actions To 291Keys</link>).</entry> 292 </row> 293 <row> 294 <entry>ExplicitVModMap</entry> 295 <entry>Automatic determination of the virtual modifier map for the key 296based on the actions assigned to the key and the symbol interpretations which 297match the key (see <link linkend='Assigning_Actions_To_Keys'>Assigning 298Actions To Keys</link>).</entry> 299 </row> 300</tbody> 301</tgroup> 302</informaltable> 303 304</sect2> 305<sect2 id='Assigning_Symbols_To_Groups'> 306<title>Assigning Symbols To Groups</title> 307 308<para> 309The first step in applying the changes specified by a core protocol <emphasis> 310ChangeKeyboardMapping</emphasis> 311 request to the XKB description of a keyboard is to determine the number of 312groups that are defined for the key and the width of each group. The XKB 313extension does not change key types in response to core protocol <emphasis> 314SetModifierMapping</emphasis> 315 requests, but it does choose key actions as described in <link linkend='Assigning_Actions_To_Keys'>Assigning Actions To Keys</link>. 316</para> 317 318 319<para> 320Determining the number of symbols required for each group is straightforward. 321If the key type for some group is not protected by the corresponding <emphasis> 322ExplicitKeyType</emphasis> 323 component, that group has two symbols. If any of the explicit components for 324the key include <emphasis> 325ExplicitKeyType3</emphasis> 326 or <emphasis> 327ExplicitKeyType4</emphasis> 328, the width of the key type currently assigned to that group determines the 329number of symbols required for the group in the core protocol keyboard 330description. The explicit type components for <emphasis> 331Group1</emphasis> 332 and <emphasis> 333Group2</emphasis> 334 behave similarly, but for compatibility reasons the first two groups must have 335at least two symbols in the core protocol symbol mapping. Even if an explicit 336type assigned to either of the first two keyboard groups has fewer than two 337symbols, XKB requires two symbols for it in the core keyboard description. 338</para> 339 340 341<para> 342If the core protocol request contains fewer symbols than XKB needs, XKB adds 343trailing <emphasis> 344NoSymbol</emphasis> 345 keysyms to the request to pad it to the required length. If the core protocol 346request includes more symbols than it needs, XKB truncates the list of keysyms 347to the appropriate length. 348</para> 349 350 351<para> 352Finally, XKB divides the symbols from the (possibly padded or truncated) list 353of symbols specified by the core protocol request among the four keyboard 354groups. In most cases, the symbols for each group are taken from the core 355protocol definition in sequence (i.e. the first pair of symbols is assigned to 356<emphasis> 357Group1</emphasis> 358, the second pair of symbols is assigned to <emphasis> 359Group2</emphasis> 360, and so forth). If either <emphasis> 361Group1</emphasis> 362 or <emphasis> 363Group2</emphasis> 364 has an explicitly defined key type with a width other than two, it gets a 365little more complicated. 366</para> 367 368 369<sect3 id='Assigning_Symbols_to_Groups_One_and_Two_with_Explicitly_Defined_Key_Types'> 370<title>Assigning Symbols to Groups One and Two with Explicitly Defined Key Types</title> 371 372<para> 373The server assigns the first four symbols from the expanded or truncated map to 374the symbol positions <emphasis>G1L1</emphasis> , <emphasis>G1L2</emphasis>, 375<emphasis>G2L1</emphasis> and <emphasis>G2L2</emphasis>, respectively. If the key 376type assigned to <emphasis>Group1</emphasis> reports more than two shift levels, 377the fifth and following symbols contain 378the extra keysyms for <emphasis> 379Group2</emphasis> 380. If the key type assigned to <emphasis> 381Group2</emphasis> 382 reports more than two shift levels, the extra symbols follow the symbols (if 383any) for <emphasis> 384Group1</emphasis> 385 in the core protocol list of symbols. Symbols for <emphasis> 386Group3</emphasis> 387 and <emphasis> 388Group4</emphasis> 389 are contiguous and follow the extra symbols, if any, for <emphasis> 390Group1</emphasis> 391 and <emphasis> 392Group2</emphasis> 393. 394</para> 395 396 397<para> 398For example, consider a key with a key type that returns three shift levels 399bound to each group. The symbols bound to the core protocol are assigned in 400sequence to the symbol positions: 401</para> 402 403<literallayout class='monospaced'> 404<emphasis>G1L1</emphasis>, <emphasis>G1L2</emphasis>, <emphasis>G2L1</emphasis>, <emphasis>G2L2</emphasis>, <emphasis>G1L3</emphasis>, <emphasis>G2L3</emphasis>, <emphasis>G3L1</emphasis>, <emphasis>G3L2</emphasis>, <emphasis>G3L3</emphasis>, <emphasis>G4L1</emphasis>, <emphasis>G4L2</emphasis>, and <emphasis>G4L3</emphasis> 405</literallayout> 406 407<para> 408For a key with a width one key type on group one, a width two key type on group 409two and a width three key type on group three, the symbols bound to the key by 410the core protocol are assigned to the following key positions: 411</para> 412 413<literallayout class='monospaced'> 414<emphasis>G1L1</emphasis>, (<emphasis>G1L2</emphasis>), <emphasis>G2L1</emphasis>, <emphasis>G2L2</emphasis>, <emphasis>G3L1</emphasis>, <emphasis>G3L2</emphasis>, <emphasis>G3L3</emphasis> 415</literallayout> 416 417<para> 418Note that the second and fourth symbols (positions <emphasis> 419G1L2 and G2L2</emphasis> 420) can never be generated if the key type associated with the group yields only 421one symbol. XKB accepts and ignores them in order to maintain compatibility 422with the core protocol. 423</para> 424 425 426</sect3> 427</sect2> 428<sect2 id='Assigning_Types_To_Groups_of_Symbols_for_a_Key'> 429<title>Assigning Types To Groups of Symbols for a Key</title> 430 431<para> 432Once the symbols specified by <emphasis> 433ChangeKeyboardMapping</emphasis> 434 have been assigned to the four keyboard groups for a key, the X server assigns 435a key type to each group on the key from a canonical list of key types. The 436first four key types in any keyboard map are reserved for these standard key 437types: 438</para> 439 440<informaltable frame='topbot'> 441<?dbfo keep-together="always" ?> 442<tgroup cols='2' align='left' colsep='0' rowsep='0'> 443<colspec colname='c1' colwidth='1.0*'/> 444<colspec colname='c2' colwidth='3.0*'/> 445<thead> 446 <row rowsep='1'> 447 <entry>Key Type Name</entry> 448 <entry>Standard Definition</entry> 449 </row> 450</thead> 451<tbody> 452 <row> 453 <entry><emphasis> 454ONE_LEVEL</emphasis> 455</entry> 456 <entry>Describes keys that have exactly one symbol per group. Most special 457or function keys (such as <emphasis> 458Return</emphasis> 459) are <emphasis> 460ONE_LEVEL</emphasis> 461 keys. Any combination of modifiers yields level <emphasis> 4620</emphasis> 463. Index <emphasis> 4640</emphasis> 465 in any key symbol map specifies key type <emphasis> 466ONE_LEVEL</emphasis> 467.</entry> 468 </row> 469 <row> 470 <entry><emphasis> 471TWO_LEVEL</emphasis> 472</entry> 473 <entry>Describes non-keypad and non-alphabetic keys that have exactly two 474symbols per group. By default, the <emphasis> 475TWO_LEVEL</emphasis> 476 type yields column <emphasis> 4771</emphasis> 478 if the Shift modifier is set, column <emphasis> 4790</emphasis> 480 otherwise. Index <emphasis> 4811</emphasis> 482 in any key symbol map specifies key type <emphasis> 483TWO_LEVEL</emphasis> 484.</entry> 485 </row> 486 <row> 487 <entry><emphasis> 488ALPHABETIC</emphasis> 489</entry> 490 <entry>Describes alphabetic keys that have exactly two symbols per group. 491The default definition of the <emphasis> 492ALPHABETIC</emphasis> 493 type provides shift-cancels-caps behavior as described in <link linkend='Key_Types'>Key Types</link>. Index <emphasis> 4942</emphasis> 495 in any key symbol map specifies key type <emphasis> 496ALPHABETIC</emphasis> 497.</entry> 498 </row> 499 <row> 500 <entry><emphasis> 501KEYPAD</emphasis> 502</entry> 503 <entry>Describes numeric keypad keys with two symbols per group. Yields 504column <emphasis> 5051</emphasis> 506 if either of the <emphasis> 507Shift</emphasis> 508 modifier or the real modifier bound to the virtual modifier named <emphasis> 509NumLock</emphasis> 510 are set. Yields column <emphasis> 5110</emphasis> 512 if neither or both modifiers are set. Index <emphasis> 5133</emphasis> 514 in any key symbol map specifies key type <emphasis> 515KEYPAD</emphasis> 516.</entry> 517 </row> 518</tbody> 519</tgroup> 520</informaltable> 521 522<para> 523Users or applications may change these key types to get different default 524behavior (to make shift cancel caps lock, for example) but they must always 525have the specified number of symbols per group. 526</para> 527 528 529<para> 530Before assigning key types to groups, the X server expands any alphanumeric 531symbol definitions as follows: 532</para> 533 534 535<para> 536If the second symbol of either group is <emphasis> 537NoSymbol</emphasis> 538 and the first symbol of that group is an alphabetic keysym for which both 539lowercase and uppercase forms are defined, the X server treats the key as if 540the first element of the group were the lowercase form of the symbol and the 541second element were the uppercase form of the symbol. For the purposes of this 542expansion, XKB ignores the locale and uses the capitalization rules defined in 543<link linkend="default_symbol_transformations">Default Symbol Transformations</link>. 544</para> 545 546 547<para> 548For each keyboard group that does not have an explicit type definition, XKB 549chooses a key type from the canonical key types. If the second symbol assigned 550to a group is <emphasis> 551NoSymbol</emphasis> 552 (after alphabetic expansion), the server assigns key type <emphasis> 553ONE_LEVEL</emphasis> 554. If the group contains the lowercase and uppercase forms of a single glyph 555(after alphanumeric expansion), the server assigns key type <emphasis> 556ALPHABETIC</emphasis> 557. If either of the symbols in a group is a numeric keypad keysym (<emphasis> 558KP_*</emphasis> 559), the server assigns key type <emphasis> 560KEYPAD</emphasis> 561. Otherwise, it assigns key type <emphasis> 562TWO_LEVEL</emphasis> 563. 564</para> 565 566 567<para> 568Finally, XKB determines the number of groups of symbols that are actually 569defined for the key. Trailing empty groups (i.e. groups that have <emphasis> 570NoSymbol</emphasis> 571 in all symbol positions) are ignored. 572</para> 573 574 575<para> 576There are two last special cases for compatibility with the core protocol: If, 577after trailing empty groups are excluded, all of the groups of symbols bound to 578the key have identical type and symbol bindings, XKB assigns only one group to 579the key. If <emphasis> 580Group2</emphasis> 581 is empty and either of <emphasis> 582Group3</emphasis> 583 or <emphasis> 584Group4</emphasis> 585 are not, and if neither <emphasis> 586Group1</emphasis> 587 nor <emphasis> 588Group2</emphasis> 589 have explicit key types, XKB copies the symbols and key type from <emphasis> 590Group1</emphasis> 591 into <emphasis> 592Group2</emphasis> 593. 594</para> 595 596 597</sect2> 598<sect2 id='Assigning_Actions_To_Keys'> 599<title>Assigning Actions To Keys</title> 600 601<para> 602Once symbols have been divided into groups and key types chosen for the keys 603affected by a <emphasis> 604ChangeKeyboardMapping</emphasis> 605 request, XKB examines the symbols and modifier mapping for each changed key 606and assigns server actions where appropriate. XKB also automatically assigns 607server actions to changed keys if the client issues a core protocol <emphasis> 608SetModifierMapping</emphasis> 609 request, and does so optionally in response to <emphasis> 610XkbSetMap</emphasis> 611 and <emphasis> 612XkbSetCompatMap</emphasis> 613 requests. 614</para> 615 616 617<para> 618The compatibility map includes a list of <emphasis> 619symbol interpretations</emphasis> 620, which XKB compares to each symbol associated with any changed keys in turn, 621unless the <emphasis> 622ExplicitInterp</emphasis> 623 component is set for a key. Setting the <emphasis> 624ExplicitInterp</emphasis> 625 component prevents the application of symbol interpretations to that key. 626</para> 627 628 629<para> 630If the modifiers and keysym specified in a symbol interpretation match the 631modifier mapping and a symbol bound to a changed key that is not protected by 632<emphasis> 633ExplicitInterp</emphasis> 634, the server applies the symbol interpretation to the symbol position. The 635server considers all symbol interpretations which specify an explicit keysym 636before considering any that do not. The server uses the first interpretation 637which matches the given combination of keysym and modifier mapping; other 638matching interpretations are ignored. 639</para> 640 641 642<para> 643XKB uses four of the fields of a symbol interpretation to decide if it matches 644one of the symbols bound to some changed key: 645</para> 646 647<itemizedlist> 648<listitem> 649 <para>The <emphasis> 650symbol</emphasis> 651 field is a keysym which matches if it has the value <emphasis> 652NoSymbol</emphasis> 653 or is identical to the symbol in question. 654 </para> 655</listitem> 656<listitem> 657 <para>The modifiers specified in the <emphasis> 658mods</emphasis> 659 field are compared to the modifiers affected by the key in question as 660indicated by <emphasis> 661match</emphasis> 662. 663 </para> 664</listitem> 665<listitem> 666 <para>The <emphasis> 667match</emphasis> 668 field can specify any of the comparisons: <emphasis> 669NoneOf</emphasis> 670, <emphasis> 671AnyOfOrNone</emphasis> 672, <emphasis> 673AnyOf</emphasis> 674, <emphasis> 675AllOf</emphasis> 676 or <emphasis> 677Exactly</emphasis> 678. 679 </para> 680</listitem> 681<listitem> 682 <para>The <emphasis> 683levelOneOnly</emphasis> 684 setting, indicates that the interpretation in question should only use the 685modifiers bound to this key by the modifier mapping if the symbol that matches 686in level one of its group. Otherwise, if the symbol being considered is not in 687shift level one of its group, the server behaves as if the modifier map for the 688key were empty. Note that it is still possible for such an interpretation to 689apply to a symbol in a shift level other than one if it matches a key without 690modifiers; the <emphasis> 691levelOneOnly</emphasis> 692 flag only controls the way that matches are determined and that the key 693modifiers are applied when an interpretation does match. 694 </para> 695</listitem> 696</itemizedlist> 697 698<para> 699Applying a symbol interpretation can affect several aspects of the XKB 700definition of the key symbol mapping to which it is applied: 701</para> 702 703<itemizedlist> 704<listitem> 705 <para>The <emphasis> 706action</emphasis> 707 specified in the symbol interpretation is bound to the symbol position; any 708key event which yields that symbol will also activate the new action. 709 </para> 710</listitem> 711<listitem> 712 <para>If the matching symbol is in position G1L1, the autorepeat behavior of 713the key is set from the <emphasis> 714autorepeat</emphasis> 715 field of the symbol interpretation. The <emphasis> 716ExplicitAutoRepeat</emphasis> 717 component protects the autorepeat status of a key from symbol interpretation 718initiated changes. 719 </para> 720</listitem> 721<listitem> 722 <para>If the symbol interpretation specifies an associated virtual modifier, 723that virtual modifier is added to the virtual modifier map for the key. The 724<emphasis> 725ExplicitVModMap</emphasis> 726 component guards the virtual modifier map for a key from automatic changes. If 727the <emphasis> 728levelOneOnly</emphasis> 729 flag is set for the interpretation, and the symbol in question is not in 730position G1L1, the virtual modifier map is not updated. 731 </para> 732</listitem> 733<listitem> 734 <para>If the matching symbol is in position G1L1, and the <emphasis> 735locking key</emphasis> 736 field is set in the symbol interpretation, the behavior of the key is changed 737to <emphasis> 738KB_Lock</emphasis> 739 (see <link linkend='Key_Behavior'>Key Behavior</link>). The 740<emphasis> 741ExplicitBehavior</emphasis> 742 component prevents this change. 743 </para> 744</listitem> 745</itemizedlist> 746 747<para> 748If no interpretations match a given symbol or key, the server uses: <emphasis> 749SA_NoAction</emphasis> 750, autorepeat enabled, non-locking key. with no virtual modifiers. 751</para> 752 753 754<para> 755If all of the actions computed for a key are <emphasis> 756SA_NoAction</emphasis> 757, the server assigns an length zero list of actions to the key. 758</para> 759 760 761<para> 762If the core protocol modifier mapping is changed, the server regenerates 763actions for the affected keys. The <emphasis> 764XkbSetMap</emphasis> 765 and <emphasis> 766XkbSetCompatMap</emphasis> 767 requests can also cause actions for some or all keyboard keys to be recomputed. 768</para> 769 770 771</sect2> 772<sect2 id='Updating_Everything_Else'> 773<title>Updating Everything Else</title> 774 775<para> 776Changes to the symbols or modifier mapping can affect the bindings of virtual 777modifiers. If any virtual modifiers change, XKB updates all of its data 778structures to reflect the change. Applying virtual modifier changes to the 779keyboard mapping night result in changes to types, the group compatibility map, 780indicator maps, internal modifiers or ignore locks modifiers. 781</para> 782 783 784</sect2> 785</sect1> 786<sect1 id='Effects_of_XKB_on_Core_Protocol_Events'> 787<title>Effects of XKB on Core Protocol Events</title> 788 789<para> 790After applying server actions which modify the base, latched or locked modifier 791or group state of the keyboard, the X server recomputes the effective group and 792state. Several components of the keyboard state are reported to XKB-aware 793clients depending on context (see <link linkend='Keyboard_State'> 794Keyboard State</link> for a detailed description of each of the keyboard state 795components): 796</para> 797 798<itemizedlist> 799<listitem> 800 <para>The effective modifier state is reported in <emphasis> 801XkbStateNotify</emphasis> 802 events and in response to <emphasis> 803XkbGetState</emphasis> 804 requests. 805 </para> 806</listitem> 807<listitem> 808 <para>The symbol lookup state is reported to XKB-aware clients in the state 809field of core protocol and input extension key press and release events that do 810not activate passive grabs. Unless the <emphasis> 811LookupStateWhenGrabbed</emphasis> 812 per-client flag is set, the lookup state is only reported in these events when 813no grabs are active. 814 </para> 815</listitem> 816<listitem> 817 <para>The grab state is reported to XKB-aware clients in the state field of 818all core protocol events that report keyboard state, except <emphasis> 819KeyPress</emphasis> 820 and <emphasis> 821KeyRelease</emphasis> 822 events that do not activate passive grabs. 823 </para> 824</listitem> 825<listitem> 826 <para>The effective group is the sum of the base, latched and locked keyboard 827groups. An out of range effective group is wrapped or truncated into range 828according to the setting of the <emphasis> 829groupsWrap</emphasis> 830 flag for the keyboard. 831 </para> 832</listitem> 833</itemizedlist> 834 835<para> 836The server reports compatibility states to any clients that have not issued a 837successful <emphasis> 838XkbUseExtension</emphasis> 839 request. The server computes the compatibility symbol lookup state and the 840compatibility effective grab state by applying the compatibility modifier map 841to the corresponding computed XKB states. 842</para> 843 844 845<para> 846The compatibility symbol lookup state is reported to non-XKB clients whenever 847an XKB-aware client would receive the XKB lookup state. The compatibility grab 848state is reported to XKB-unaware clients whenever an XKB client would receive 849the XKB grab state. 850</para> 851 852 853<para> 854If the <emphasis> 855GrabsUseXKBState</emphasis> 856 per-client option is not set, even XKB-aware clients receive the compatibility 857grab state in events that trigger or terminate passive grabs. If this flag is 858not set, XKB clients also receive the compatibility grab or lookup state 859whenever any keyboard grab is active. 860</para> 861 862 863<para> 864If the <emphasis> 865LookupStateWhenGrabbed</emphasis> 866 per-client option is set, clients receive either the XKB or compatibility 867lookup state when the keyboard is grabbed, otherwise they receive either the 868XKB or compatibility grab state. All non-XKB clients receive the compatibility 869form of the appropriate state component; the form that is sent to an XKB-aware 870client depends on the setting of the <emphasis> 871GrabsUseXKBState</emphasis> 872 option for that client. 873</para> 874 875 876</sect1> 877<sect1 id='Effect_of_XKB_on_Core_Protocol_Requests'> 878<title>Effect of XKB on Core Protocol Requests</title> 879 880<para> 881Whenever a client updates the keyboard mapping using a core protocol request, 882the server saves the requested core protocol keyboard mapping and reports it to 883any clients that issue <emphasis> 884GetKeyboardMapping</emphasis> 885 or <emphasis> 886GetModifierMapping</emphasis> 887 requests. Whenever a client updates the keyboard mapping using XKB requests, 888the server discards the affected portion of the stored core keyboard 889description and regenerates it based on the XKB description of the keyboard. 890</para> 891 892 893<para> 894The symbols associated with the XKB keyboard description appear in the order: 895</para> 896 897<literallayout class='monospaced'> 898G1L1 G1L2 G2L1 G2L2 G1L3-n G2L3-n G3L* G4L* 899</literallayout> 900 901<para> 902If the type associated with <emphasis> 903Group1</emphasis> 904 is width one, the second symbol is <emphasis> 905NoSymbol</emphasis> 906; if the type associated with <emphasis> 907Group2</emphasis> 908 is width one, the fourth symbol is <emphasis> 909NoSymbol</emphasis> 910. 911</para> 912 913 914<para> 915If a key has only one group but the keyboard has several, the symbols for 916<emphasis> 917Group1</emphasis> 918 are repeated for each group. For example, given a keyboard with three groups 919and a key with one group that contains the symbols { <emphasis> 920a A</emphasis> 921 }, the core protocol description would contain the six symbols: { <emphasis> 922a</emphasis> 923 <emphasis> 924A</emphasis> 925 <emphasis> 926a</emphasis> 927 <emphasis> 928A</emphasis> 929 <emphasis> 930a</emphasis> 931 <emphasis> 932A</emphasis> 933 }. As a slightly more complicated example, an XKB key which had a single width 934three group with the symbols { <emphasis> 935a</emphasis> 936 <emphasis> 937b</emphasis> 938 <emphasis> 939c</emphasis> 940 } would show up in the generated core protocol keyboard description with the 941symbols { <emphasis> 942a</emphasis> 943 <emphasis> 944b</emphasis> 945 <emphasis> 946a</emphasis> 947 <emphasis> 948b</emphasis> 949 <emphasis> 950c</emphasis> 951 <emphasis> 952c</emphasis> 953 <emphasis> 954a</emphasis> 955 <emphasis> 956b</emphasis> 957 <emphasis> 958c</emphasis> 959 } for a keyboard with three groups. 960</para> 961 962 963<para> 964The generated modifier mapping for a key contains all of the modifiers affected 965by all of the actions associated with the key plus all of the modifiers 966associated with any virtual modifiers bound to the key by the virtual modifier 967mapping. If any of the actions associated with a key affect any component of 968the keyboard group, any modifiers specified in any entry of the group 969compatibility map (see <link linkend='Group_Compatibility_Map'>Group 970Compatibility Map</link>) are reported in the modifier mask. The <emphasis> 971SA_ISOLock</emphasis> 972 action can theoretically affect any modifier, but the modifier map of an 973<emphasis> 974SA_ISOLock</emphasis> 975 key contains only the modifiers or group state that it sets by default. 976</para> 977 978 979<para> 980The server notifies interested clients of keyboard map changes in one of two 981ways. It sends <emphasis> 982XkbMapNotify</emphasis> 983 to clients that have explicitly selected them and core protocol <emphasis> 984MappingNotify</emphasis> 985 events to clients that have not. Once a client requests <emphasis> 986XkbMapNotify</emphasis> 987 events, the server stops sending it <emphasis> 988MappingNotify</emphasis> 989 events to inform it of keyboard changes. 990</para> 991 992 993</sect1> 994<sect1 id='Sending_Events_to_Clients'> 995<title>Sending Events to Clients</title> 996 997<para> 998XKB normally assumes that events sent to clients using the core protocol 999<emphasis> 1000SendEvent</emphasis> 1001 request contain a core protocol state, if applicable. If the client which will 1002receive the event is not XKB-capable, XKB attempts to convert the core state to 1003an XKB state as follows: if any of the modifiers bound to <emphasis> 1004Group2</emphasis> 1005 in the group compatibility map are set in the event state, XKB clears them in 1006the resulting event but sets the effective group in the event state to 1007<emphasis> 1008Group2</emphasis> 1009. 1010</para> 1011 1012 1013<para> 1014If the <emphasis> 1015PCF_SendEventUsesXKBState</emphasis> 1016 per-client flag is set at the time of the SendEvent request, XKB instead 1017assumes that the event reported in the event is an XKB state. If the receiving 1018client is not XKB-aware, the extension converts the XKB state (which contains 1019the effective state in bits 13-14) to a core state by applying the group 1020compatibility map just as it would for actual key events. 1021</para> 1022 1023</sect1> 1024</chapter> 1025