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='The_Xkb_Compatibility_Map'> 5<title>The Xkb Compatibility Map</title> 6 7<para> 8As shown in <link linkend="figure17.1">Figure 17.1</link>, the X server is normally dealing with more than one 9client, each of which may be receiving events from the keyboard, and each of 10which may issue requests to modify the keyboard in some manner. Each client may 11be either Xkb-unaware, Xkb-capable, or Xkb-aware. The server itself may be 12either Xkb-aware or Xkb-unaware. If the server is Xkb-unaware, Xkb state and 13keyboard mappings are not involved in any manner, and Xkb-aware clients may not 14issue Xkb requests to the server. If the server is Xkb-aware, the server must 15be able to deliver events and accept requests in which the keyboard state and 16mapping are compatible with the mode in which the client is operating. 17Consequently, for some situations, conversions must be made between Xkb state / 18keyboard mappings and core protocol state / keyboard mappings, and vice versa. 19</para> 20 21<figure id='figure17.1'> 22 <title>Server Interaction with Types of Clients</title> 23 <mediaobject> 24 <imageobject> <imagedata format="SVG" fileref="XKBlib-18.svg"/> 25 </imageobject> 26 </mediaobject> 27</figure> 28 29 30 31<para> 32In addition to these situations involving a single server, there are cases 33where a client that deals with multiple servers may need to configure keyboards 34on different servers to be similar and the different servers may not all be 35Xkb-aware. Finally, a client may be dealing with descriptions of keyboards 36(files, and so on) that are based on core protocol and therefore may need to be 37able to map these descriptions to Xkb descriptions. 38</para> 39 40 41<para> 42An Xkb-aware server maintains keyboard state and mapping as an Xkb keyboard 43state and an Xkb keyboard mapping plus a compatibility map used to convert from 44Xkb components to core components and vice versa. In addition, the server also 45maintains a core keyboard mapping that approximates the Xkb keyboard mapping. 46The core keyboard mapping may be updated piecemeal, on a per-key basis. When 47the server receives a core protocol 48<systemitem>ChangeKeyboardMapping</systemitem> 49or 50<systemitem>SetModifierMapping</systemitem> 51request, it updates its core keyboard mapping, then uses the compatibility map 52to update its Xkb keyboard mapping. When the server receives an 53<function>XkbSetMap</function> 54request, it updates those portions of its Xkb keyboard mapping specified by 55the request, then uses its compatibility map to update the corresponding parts 56of its core keyboard map. Consequently, the server’s Xkb keyboard map and 57also its core keyboard map may contain components that were set directly and 58others that were computed. <link linkend="figure17.2">Figure 17.2</link> illustrates these relationships. 59</para> 60 61<note><para>The core keyboard map is contained only in the server, not in any 62client-side data structures.</para></note> 63 64<figure id='figure17.2'> 65 <title>Server Derivation of State and Keyboard Mapping Components</title> 66 <mediaobject> 67 <imageobject> <imagedata format="SVG" fileref="XKBlib-19.svg"/> 68 </imageobject> 69 </mediaobject> 70</figure> 71 72 73 74<para> 75There are three kinds of compatibility transformations made by the server: 76</para> 77 78<orderedlist> 79 <listitem> 80 <para><emphasis role='bold'>Xkb State to Core State</emphasis></para> 81 <para> 82Keyboard state information reported to a client in the state field of various 83core events may be translated from the Xkb keyboard state maintained by the 84server, which includes a group number, to core protocol state, which does 85not. 86 </para> 87 <para> 88In addition, whenever the Xkb state is retrieved, the 89<structfield>compat_state</structfield>, 90<structfield>compat_grab_mods</structfield>, 91and 92<structfield>compat_lookup_mods</structfield> 93fields of the 94<structname>XkbStateRec</structname> 95returned indicate the result of applying the compatibility map to the current 96Xkb state in the server. 97 </para> 98 </listitem> 99 <listitem> 100 <para><emphasis role='bold'>Core Keyboard Mapping to Xkb Keyboard Mapping</emphasis></para> 101 <para> 102After core protocol requests received by the server to change the keyboard 103mapping 104(<systemitem>ChangeKeyboardMapping</systemitem> 105and 106<systemitem>SetModifierMapping</systemitem>) 107have been applied to the server’s core keyboard map, the results must be 108transformed to achieve an equivalent change of the Xkb keyboard mapping 109maintained by the server. 110 </para> 111 </listitem> 112 <listitem> 113 <para><emphasis role='bold'>Xkb Keyboard Mapping to Core Keyboard Mapping</emphasis></para> 114 <para> 115After Xkb protocol requests received by the server to change the keyboard 116mapping 117(<function>XkbSetMap</function>) 118have been applied to the server’s Xkb keyboard map, the results are 119transformed to achieve an approximately equivalent change to the core keyboard 120mapping maintained by the server. 121 </para> 122 </listitem> 123</orderedlist> 124 125<para> 126This chapter discusses how a client may modify the compatibility map so that 127subsequent transformations have a particular result. 128</para> 129 130 131<sect1 id='The_XkbCompatMap_Structure'> 132<title>The XkbCompatMap Structure</title> 133<indexterm significance="preferred" zone="The_XkbCompatMap_Structure"> 134<primary><structname>XkbCompatMapRec</structname></primary></indexterm> 135 136<para> 137All configurable aspects of mapping Xkb state and configuration to and from 138core protocol state and configuration are defined by a compatibility map, 139contained in an 140<structname>XkbCompatMapRec</structname> 141structure; plus a set of explicit override controls used to prevent particular 142components of type 2 (core-to-Xkb keyboard mapping) transformations from 143automatically occurring. These explicit override controls are maintained in a 144separate data structure discussed in <link linkend="Explicit_ComponentsAvoiding_Automatic_Remapping_by_the_Server">section 16.3</link>. 145</para> 146 147 148<para> 149The 150<structfield>compat</structfield> 151member of an Xkb keyboard description 152(<structname>XkbDescRec</structname>) 153points to the 154<structname>XkbCompatMapRec</structname> 155structure: 156 157<programlisting> 158typedef struct _XkbCompatMapRec { 159 XkbSymInterpretPtr sym_interpret; /* symbol based key semantics */ 160 XkbModsRec groups[XkbNumKbdGroups]; /* group ⇒ modifier map */ 161 unsigned short num_si; /* # structures used in 162 <structfield>sym_interpret</structfield> */ 163 unsigned short size_si; /* # structures allocated in 164 <structfield>sym_interpret</structfield> */ 165} <structname>XkbCompatMapRec</structname>, *XkbCompatMapPtr; 166</programlisting></para> 167 168<figure id='figure17.3'> 169 <title>Xkb Compatibility Data Structures</title> 170 <mediaobject> 171 <imageobject> <imagedata format="SVG" fileref="XKBlib-20.svg"/> 172 </imageobject> 173 </mediaobject> 174</figure> 175 176 177<para> 178The subsections that follow discuss how the compatibility map and explicit 179override controls are used in each of the three cases where compatibility 180transformations are made. 181</para> 182 183<sect2 id='Xkb_State_to_Core_Protocol_State_Transformation'> 184<title>Xkb State to Core Protocol State Transformation</title> 185 186<para> 187As shown in <link linkend="figure17.3">Figure 17.3</link>, there are four 188<firstterm>group compatibility maps</firstterm> 189<indexterm significance="preferred" zone="Xkb_State_to_Core_Protocol_State_Transformation"> 190<primary>group compatibility map</primary></indexterm> 191<indexterm significance="preferred" zone="Xkb_State_to_Core_Protocol_State_Transformation"> 192<primary>map</primary><secondary>group compatibility</secondary></indexterm> 193(contained in 194<structfield>groups</structfield> 195[0..3]) in the 196<structname>XkbCompatMapRec</structname> 197structure, one per possible Xkb group. Each group compatibility map is a 198modifier definition (see <link linkend="Modifier_Definitions">section 7.2</link> for a description of modifier 199definitions). The 200<structfield>mask</structfield> 201component of the definition specifies which real modifiers should be set in 202the core protocol state field when the corresponding group is active. Because 203only one group is active at any one time, only one of the four possible 204transformations is ever applied at any one point in time. If the device 205described by the 206<structname>XkbDescRec</structname> 207does not support four groups, the extra groups fields are present, but 208undefined. 209</para> 210 211<para> 212Normally, the Xkb-aware server reports keyboard state in the 213<structfield>state</structfield> 214member of events such as a 215<symbol>KeyPress</symbol> 216event and 217<symbol>ButtonPress</symbol> 218event, encoded as follows: 219</para> 220 221<informaltable frame='topbot'> 222<?dbfo keep-together="always" ?> 223<tgroup cols='2' align='left' colsep='0' rowsep='0'> 224<colspec colname='c1' colwidth='1.0*'/> 225<colspec colname='c1' colwidth='2.0*'/> 226<thead> 227 <row rowsep='1'> 228 <entry>bits</entry> 229 <entry>meaning</entry> 230 </row> 231</thead> 232<tbody> 233 <row> 234 <entry>15</entry> 235 <entry>0</entry> 236 </row> 237 <row> 238 <entry>13–14</entry> 239 <entry>Group index</entry> 240 </row> 241 <row> 242 <entry>8–12</entry> 243 <entry>Pointer Buttons</entry> 244 </row> 245 <row> 246 <entry>0–7</entry> 247 <entry>Modifiers</entry> 248 </row> 249</tbody> 250</tgroup> 251</informaltable> 252 253<para> 254For Xkb-unaware clients, only core protocol keyboard information may be 255reported. Because core protocol does not define the group index, the group 256index is mapped to modifier bits as specified by the 257<structfield>groups</structfield> 258[group index] field of the compatibility map (the bits set in the compatibility 259map are ORed into bits 0–7 of the state), and bits 13–14 are reported in the 260event as zero. 261</para> 262 263</sect2> 264<sect2 id='Core_Keyboard_Mapping_to_Xkb_Keyboard_Mapping_Transformation'> 265<title>Core Keyboard Mapping to Xkb Keyboard Mapping Transformation</title> 266 267<para> 268When a core protocol keyboard mapping request is received by the server, the 269server’s core keyboard map is updated, and then the Xkb map maintained by the 270server is updated. Because a client may have explicitly configured some of the 271Xkb keyboard mapping in the server, this automatic regeneration of the Xkb 272keyboard mapping from the core protocol keyboard mapping should not modify any 273components of the Xkb keyboard mapping that were explicitly set by a client. 274The client must set explicit override controls to prevent this from happening 275(see <link linkend="Explicit_ComponentsAvoiding_Automatic_Remapping_by_the_Server">section 16.3</link>). The core-to-Xkb mapping is done as follows: 276</para> 277 278<orderedlist> 279 <listitem> 280 <para> 281Map the symbols from the keys in the core keyboard map to groups and symbols on 282keys in the Xkb keyboard map. The core keyboard mapping is of fixed width, so 283each key in the core mapping has the same number of symbols associated with it. 284The Xkb mapping allows a different number of symbols to be associated with each 285key; those symbols may be divided into a different number of groups (1-4) for 286each key. For each key, this process therefore involves partitioning the fixed 287number of symbols from the core mapping into a set of variable-length groups 288with a variable number of symbols in each group. For example, if the core 289protocol map is of width five, the partition for one key might result in one 290group with two symbols and another with three symbols. A different key might 291result in two groups with two symbols plus a third group with one symbol. The 292core protocol map requires at least two symbols in each of the first two 293groups. 294 </para> 295 <orderedlist> 296 <listitem> 297 <para> 298For each changed key, determine the number of groups represented in the new 299core keyboard map. This results in a tentative group count for each key in the 300Xkb map. 301 </para> 302 </listitem> 303 <listitem> 304 <para> 305For each changed key, determine the number of symbols in each of the groups 306found in step 1a. There is one explicit override control associated with each 307of the four possible groups for each Xkb key, 308<emphasis>ExplicitKeyType1</emphasis> 309through 310<emphasis>ExplicitKeyType4</emphasis>. 311If no explicit override control is set for a group, the number of symbols 312used for that group from the core map is two. If the explicit override control 313is set for a group on the key, the number of symbols used for that Xkb group 314from the core map is the width of the Xkb group with one exception: because of 315the core protocol requirement for at least two symbols in each of groups one 316and two, the number of symbols used for groups one and two is the maximum of 2 317or the width of the Xkb group. 318 </para> 319 </listitem> 320 <listitem> 321 <para> 322For each changed key, assign the symbols in the core map to the appropriate 323group on the key. If the total number of symbols required by the Xkb map for a 324particular key needs more symbols than the core protocol map contains, the 325additional symbols are taken to be 326<symbol>NoSymbol</symbol> 327keysyms appended to the end of the core set. If the core map contains more 328symbols than are needed by the Xkb map, trailing symbols in the core map are 329discarded. In the absence of an explicit override for group one or two, symbols 330are assigned in order by group; the first symbols in the core map are assigned 331to group one, in order, followed by group two, and so on. For example, if the 332core map contained eight symbols per key, and a particular Xkb map contained 2 333symbols for G1 and G2 and three for G3, the symbols would be assigned as (G is 334group, L is shift level): 335 </para> 336<literallayout> 337 G1L1 G1L2 G2L1 G2L2 G3L1 G3L2 G3L3 338</literallayout> 339 <para> 340If an explicit override control is set for group one or two, the symbols are 341taken from the core set in a somewhat different order. The first four symbols 342from the core set are assigned to G1L1, G1L2, G2L1, G2L2, respectively. If 343group one requires more symbols, they are taken next, and then any additional 344symbols needed by group two. Group three and four symbols are taken in complete 345sequence after group two. For example, a key with four groups and three symbols 346in each group would take symbols from the core set in the following order: 347 </para> 348<literallayout> 349G1L1 G1L2 G2L1 G2L2 G1L3 G2L3 G3L1 G3L2 G3L3 G4L1 G4L2 G4L3 350</literallayout> 351 <para> 352As previously noted, the core protocol map requires at lease two symbols in 353groups one and two. Because of this, if an explicit override control for an Xkb 354key is set and group one and / or group two is of width one, it is not possible 355to generate the symbols taken from the core protocol set and assigned to 356position G1L2 and / or G2L2. 357 </para> 358 </listitem> 359 <listitem> 360 <para> 361For each group on each changed key, assign a key type appropriate for the 362symbols in the group. 363 </para> 364 </listitem> 365 <listitem> 366 <para> 367For each changed key, remove any empty or redundant groups. 368 </para> 369 </listitem> 370 </orderedlist> 371 </listitem> 372 <listitem> 373 <para> 374At this point, the groups and their associated symbols have been assigned to 375the corresponding key definitions in the Xkb map. 376 </para> 377 </listitem> 378 <listitem> 379 <para> 380Apply symbol interpretations to modify key operation. This phase is completely 381skipped if the 382<emphasis>ExplicitInterpret</emphasis> 383override control bit is set in the explicit controls mask for the Xkb key (see 384<link linkend="Explicit_ComponentsAvoiding_Automatic_Remapping_by_the_Server">section 16.3</link>). 385 </para> 386 <orderedlist> 387 <listitem> 388 <para> 389For each symbol on each changed key, attempt to match the symbol and modifiers 390from the Xkb map to a symbol interpretation describing how to generate the 391symbol. 392 </para> 393 </listitem> 394 <listitem> 395 <para> 396When a match is found in step 2a, apply the symbol interpretation to change the 397semantics associated with the symbol in the Xkb key map. If no match is found, 398apply a default interpretation. 399 </para> 400 </listitem> 401 </orderedlist> 402 </listitem> 403</orderedlist> 404 405<para> 406The symbol interpretations used in step 2 are configurable and may be specified 407using 408<structname>XkbSymInterpretRec</structname> 409structures referenced by the 410<structfield>sym_interpret</structfield> 411field of an 412<structname>XkbCompatMapRec</structname> 413(see <link linkend="figure17.3">Figure 17.3</link>). 414</para> 415 416<sect3 id='Symbol_Interpretations__the_XkbSymInterpretRec_Structure'> 417<title>Symbol Interpretations — the XkbSymInterpretRec Structure</title> 418<indexterm significance="preferred" zone="Symbol_Interpretations__the_XkbSymInterpretRec_Structure"> 419<primary><structname>XkbSymInterpretRec</structname></primary></indexterm> 420 421<para> 422Symbol interpretations are used to guide the X server when it modifies the Xkb 423keymap in step 2. An initial set of symbol interpretations is loaded by the 424server when it starts. A client may add new ones using 425<function>XkbSetCompatMap</function> 426(see <link linkend="Changing_the_Servers_Compatibility_Map">section 17.4</link>). 427</para> 428 429 430<para> 431Symbol interpretations result in key semantics being set. When a symbol 432interpretation is applied, the following components of server key event 433processing may be modified for the particular key involved: 434 435 <simplelist type='vert' columns='1'> 436 <member>Virtual modifier map</member> 437 <member>Auto repeat</member> 438 <member>Key behavior (may be set to <symbol>XkbKB_Lock</symbol>)</member> 439 <member>Key action (see <link linkend="Key_Actions">section 16.1</link>)</member> 440 </simplelist> 441</para> 442 443<para> 444The <structname>XkbSymInterpretRec</structname> 445structure specifies a symbol interpretation: 446 447<programlisting> 448typedef struct { 449 KeySym sym; /* keysym of interest or <symbol>NULL</symbol> */ 450 unsigned char flags; /* <symbol>XkbSI_AutoRepeat</symbol>, <symbol>XkbSI_LockingKey</symbol> */ 451 unsigned char match; /* specifies how mods is interpreted */ 452 unsigned char mods; /* modifier bits, correspond to 453 eight real modifiers */ 454 unsigned char virtual_mod; /* 1 modifier to add to key virtual mod map */ 455 XkbAnyAction act; /* action to bind to symbol position on key */ 456} <structname>XkbSymInterpretRec</structname>,*XkbSymInterpretPtr; 457</programlisting></para> 458 459<para> 460If 461<structfield>sym</structfield> 462is not 463<symbol>NULL</symbol>, 464it limits the symbol interpretation to keys on which that particular keysym 465is selected by the modifiers matching the criteria specified by 466<structfield>mods</structfield> 467and 468<structfield>match</structfield>. 469If 470<structfield>sym</structfield> 471is 472<symbol>NULL</symbol>, 473the interpretation may be applied to any symbol selected on a key when the 474modifiers match the criteria specified by 475<structfield>mods</structfield> 476and 477<structfield>match</structfield>. 478</para> 479 480 481<para> 482<structfield>match</structfield> 483must be one of the values shown in 484<link linkend="table17.1">Table 17.1</link> and specifies how the real 485modifiers specified in <structfield>mods</structfield> 486are to be interpreted. 487</para> 488 489<table id='table17.1' frame='topbot'> 490<title>Symbol Interpretation Match Criteria</title> 491<?dbfo keep-together="always" ?> 492<tgroup cols='3' align='left' colsep='0' rowsep='0'> 493<colspec colname='c1' colwidth='2.0*'/> 494<colspec colname='c2' colwidth='1.0*'/> 495<colspec colname='c3' colwidth='3.0*'/> 496<thead> 497<row rowsep='1'> 498 <entry>Match Criteria</entry> 499 <entry>Value</entry> 500 <entry>Effect</entry> 501 </row> 502</thead> 503<tbody> 504 <row> 505 <entry><symbol>XkbSI_NoneOf</symbol></entry> 506 <entry>(0)</entry> 507 <entry> 508None of the bits that are on in <structfield>mods</structfield> 509can be set, but other bits can be. 510 </entry> 511 </row> 512 <row> 513 <entry><symbol>XkbSI_AnyOfOrNone</symbol></entry> 514 <entry>(1)</entry> 515 <entry> 516Zero or more of the bits that are on in 517<structfield>mods</structfield> 518can be set, as well as others. 519 </entry> 520 </row> 521 <row> 522 <entry><symbol>XkbSI_AnyOf</symbol></entry> 523 <entry>(2)</entry> 524 <entry> 525One or more of the bits that are on in 526<structfield>mods</structfield> 527can be set, as well as any others. 528 </entry> 529 </row> 530 <row> 531 <entry><symbol>XkbSI_AllOf</symbol></entry> 532 <entry>(3)</entry> 533 <entry> 534All of the bits that are on in 535<structfield>mods</structfield> 536must be set, but others may be set as well. 537 </entry> 538 </row> 539 <row> 540 <entry><symbol>XkbSI_Exactly</symbol></entry> 541 <entry>(4)</entry> 542 <entry> 543All of the bits that are on in 544<structfield>mods</structfield> 545must be set, and no other bits may be set. 546 </entry> 547 </row> 548</tbody> 549</tgroup> 550</table> 551 552<para> 553In addition to the above bits, 554<structfield>match</structfield> 555may contain the 556<symbol>XkbSI_LevelOneOnly</symbol> 557bit, in which case the modifier match criteria specified by 558<structfield>mods</structfield> 559and 560<structfield>match</structfield> 561applies only if 562<structfield>sym</structfield> 563is in level one of its group; otherwise, 564<structfield>mods</structfield> 565and 566<structfield>match</structfield> 567are ignored and the symbol matches a condition where no modifiers are set. 568</para> 569 570<para><programlisting> 571#define XkbSI_LevelOneOnly (0x80) 572/* use mods + match only if sym is level 1 */ 573</programlisting></para> 574 575<para> 576If no matching symbol interpretation is found, the server uses a default 577interpretation where: 578</para> 579 580<informaltable frame='none'> 581<?dbfo keep-together="always" ?> 582<tgroup cols='2' align='left' colsep='0' rowsep='0'> 583<colspec colname='c1' colwidth='1.0*'/> 584<colspec colname='c1' colwidth='3.0*'/> 585<tbody> 586 <row> 587 <entry><structfield>sym</structfield> =</entry> 588 <entry>0</entry> 589 </row> 590 <row> 591 <entry><structfield>flags</structfield> =</entry> 592 <entry><symbol>XkbSI_AutoRepeat</symbol></entry> 593 </row> 594 <row> 595 <entry><structfield>match</structfield> =</entry> 596 <entry><symbol>XkbSI_AnyOfOrNone</symbol></entry> 597 </row> 598 <row> 599 <entry><structfield>mods</structfield> =</entry> 600 <entry>0</entry> 601 </row> 602 <row> 603 <entry><structfield>virtual_mod</structfield> =</entry> 604 <entry><symbol>XkbNoModifier</symbol></entry> 605 </row> 606 <row> 607 608 <entry><structfield>act</structfield> =</entry> 609 <entry><emphasis>SA_NoAction</emphasis></entry> 610 </row> 611</tbody> 612</tgroup> 613</informaltable> 614 615<para> 616When a matching symbol interpretation is found in step 2a, the interpretation 617is applied to modify the Xkb map as follows. 618</para> 619 620<para> 621The 622<structfield>act</structfield> 623field specifies a single action to be bound to the symbol position; any key 624event that selects the symbol causes the action to be taken. Valid actions are 625defined in <link linkend="Key_Actions">section 16.1</link>. 626</para> 627 628 629<para> 630If the Xkb keyboard map for the key does not have its 631<emphasis>ExplicitVModMap</emphasis> 632control set, the 633<symbol>XkbSI_LevelOneOnly</symbol> 634bit and symbol position are examined. If the 635<symbol>XkbSI_LevelOneOnly</symbol> 636bit is not set in 637<structfield>match</structfield> 638or the symbol is in position G1L1, the 639<structfield>virtual_mod</structfield> 640field is examined. If 641<structfield>virtual_mod</structfield> 642is not 643<symbol>XkbNoModifier</symbol>, 644<structfield>virtual_mod</structfield> 645specifies a single virtual modifier to be added to the virtual modifier map 646for the key. 647<structfield>virtual_mod</structfield> 648is specified as an index in the range [0..15]. 649</para> 650 651 652<para> 653If the matching symbol is in position G1L1 of the key, two bits in the flags 654field potentially specify additional behavior modifications: 655 656<programlisting> 657#define XkbSI_AutoRepeat (1<<0) /* key repeats if sym 658 is in position G1L1 */ 659#define XkbSI_LockingKey (1<<1) /* set <emphasis>KB_Lock</emphasis> behavior 660 if sym is in psn G1L1 */ 661</programlisting></para> 662 663<para> 664If the Xkb keyboard map for the key does not have its 665<emphasis>ExplicitAutoRepeat</emphasis> 666control set, its auto repeat behavior is set based on the value of the 667<symbol>XkbSI_AutoRepeat</symbol> 668bit. If the 669<symbol>XkbSI_AutoRepeat</symbol> 670bit is set, the auto-repeat behavior of the key is turned on; otherwise, it is 671turned off. 672</para> 673 674 675<para> 676If the Xkb keyboard map for the key does not have its 677<emphasis>ExplicitBehavior</emphasis> 678control set, its locking behavior is set based on the value of the 679<symbol>XkbSI_LockingKey</symbol> 680bit. If 681<symbol>XkbSI_LockingKey</symbol> 682is set, the key behavior is set to 683<emphasis>KB_Lock</emphasis>; 684otherwise, it is turned off (see <link linkend="Explicit_ComponentsAvoiding_Automatic_Remapping_by_the_Server">section 16.3</link>). 685</para> 686 687 688</sect3> 689</sect2> 690<sect2 id='Xkb_Keyboard_Mapping_to_Core_Keyboard_Mapping_Transformations'> 691<title>Xkb Keyboard Mapping to Core Keyboard Mapping Transformations</title> 692 693<para> 694Whenever the server processes Xkb requests to change the keyboard mapping, it 695discards the affected portion of its core keyboard mapping and regenerates it 696based on the new Xkb mapping. 697</para> 698 699 700<para> 701When the Xkb mapping for a key is transformed to a core protocol mapping, the 702symbols for the core map are taken in the following order from the Xkb map: 703</para> 704 705 706<para> 707G1L1 G1L2 G2L1 G2L2 G1L3-n G2L3-n G3L1-n G4L1-n 708</para> 709 710 711<para> 712If group one is of width one in the Xkb map, G1L2 is taken to be NoSymbol; 713similarly, if group two is of width one in the Xkb map, G2L2 is taken to be 714NoSymbol. 715</para> 716 717 718<para> 719If the Xkb key map for a particular key has fewer groups than the core 720keyboard, the symbols for group one are repeated to fill in the missing core 721components. For example, an Xkb key with a single width-three group would be 722mapped to a core mapping counting three groups as: 723</para> 724 725 726<para> 727G1L1 G1L2 G1L1 G1L2 G1L3 G1L3 G1L1 G1L2 G1L3 728</para> 729 730 731<para> 732When a core keyboard map entry is generated from an Xkb keyboard map entry, a 733modifier mapping is generated as well. The modifier mapping contains all of the 734modifiers affected by any of the actions associated with the key combined with 735all of the real modifiers associated with any of the virtual modifiers bound to 736the key. In addition, if any of the actions associated with the key affect any 737component of the keyboard group, all of the modifiers in the 738<structfield>mask</structfield> 739field of all of the group compatibility maps are added to the modifier mapping 740as well. While an 741<symbol>XkbSA_ISOLock</symbol> 742action can theoretically affect any modifier, if the Xkb mapping for a key 743specifies an 744<symbol>XkbSA_ISOLock</symbol> 745action, only the modifiers or group that are set by default are added to the 746modifier mapping. 747</para> 748 749 750</sect2> 751</sect1> 752<sect1 id='Getting_Compatibility_Map_Components_From_the_Server'> 753<title>Getting Compatibility Map Components From the Server</title> 754 755<para> 756Use 757<function>XkbGetCompatMap</function> 758to fetch any combination of the current compatibility map components from the 759server. When another client modifies the compatibility map, you are notified if 760you have selected for 761<symbol>XkbCompatMapNotify</symbol> 762events (see <link linkend="Tracking_Changes_to_the_Compatibility_Map">section 17.5</link>). 763<function>XkbGetCompatMap</function> 764is particularly useful when you receive an event of this type, as it allows 765you to update your program’s version of the compatibility map to match the 766modified version now in the server. If your program is dealing with multiple 767servers and needs to configure them all in a similar manner, the updated 768compatibility map may be used to reconfigure other servers. 769</para> 770 771<note><para>To make a complete matching configuration you must also update the 772explicit override components of the server state.</para></note> 773 774<indexterm significance="preferred" zone="XkbGetCompatMap"><primary><function>XkbGetCompatMap</function></primary></indexterm> 775<funcsynopsis id="XkbGetCompatMap"> 776 <funcprototype> 777 <funcdef>Status <function>XkbGetCompatMap</function></funcdef> 778<!-- ( 779<parameter>display, which, xkb</parameter> 780) --> 781 782 <paramdef>Display *<parameter>display</parameter></paramdef> 783 <paramdef>unsigned int <parameter>which</parameter></paramdef> 784 <paramdef>XkbDescRec *<parameter>xkb</parameter></paramdef> 785 </funcprototype> 786</funcsynopsis> 787<variablelist> 788 <varlistentry> 789 <term> 790 <parameter>display</parameter> 791 </term> 792 <listitem> 793 <para> 794 connection to server 795 </para> 796 </listitem> 797 </varlistentry> 798 <varlistentry> 799 <term> 800 <parameter>which</parameter> 801 </term> 802 <listitem> 803 <para> 804 mask of compatibility map components to fetch 805 </para> 806 </listitem> 807 </varlistentry> 808 <varlistentry> 809 <term> 810 <parameter>xkb</parameter> 811 </term> 812 <listitem> 813 <para> 814 keyboard description where results placed 815 </para> 816 </listitem> 817 </varlistentry> 818</variablelist> 819 820<para> 821<function>XkbGetCompatMap</function> 822fetches the components of the compatibility map specified in 823<parameter>which</parameter> 824from the server specified by 825<parameter>display</parameter> 826and places them in the 827<structfield>compat</structfield> 828structure of the keyboard description 829<parameter>xkb</parameter>. 830Valid values for 831<parameter>which</parameter> 832are an inclusive OR of the values shown in 833<link linkend="table17.2">Table 17.2</link>. 834</para> 835 836<table id='table17.2' frame='topbot'> 837<title>Compatibility Map Component Masks</title> 838<?dbfo keep-together="always" ?> 839<tgroup cols='3' align='left' colsep='0' rowsep='0'> 840<colspec colname='c1' colwidth='1.5*'/> 841<colspec colname='c2' colwidth='1.0*'/> 842<colspec colname='c3' colwidth='2.0*'/> 843<thead> 844<row rowsep='1'> 845 <entry>Mask</entry> 846 <entry>Value</entry> 847 <entry>Affecting</entry> 848 </row> 849</thead> 850<tbody> 851 <row> 852 <entry><symbol>XkbSymInterpMask</symbol></entry> 853 <entry>(1<<0)</entry> 854 <entry>Symbol interpretations</entry> 855 </row> 856 <row> 857 <entry><symbol>XkbGroupCompatMask</symbol></entry> 858 <entry>(1<<1)</entry> 859 <entry>Group maps</entry> 860 </row> 861 <row> 862 <entry><symbol>XkbAllCompatMask</symbol></entry> 863 <entry>(0x3)</entry> 864 <entry>All compatibility map components</entry> 865 </row> 866</tbody> 867</tgroup> 868</table> 869 870<para> 871If no compatibility map structure is allocated in 872<parameter>xkb</parameter> 873upon entry, 874<function>XkbGetCompatMap</function> 875allocates one. If one already exists, its contents are overwritten with the 876returned results. 877</para> 878 879 880<para> 881<function>XkbGetCompatMap</function> 882fetches compatibility map information for the device specified by the 883<structfield>device_spec</structfield> 884field of 885<parameter>xkb</parameter>. 886Unless you have specifically modified this field, it is the default keyboard 887device. 888<function>XkbGetCompatMap</function> 889returns 890<symbol>Success</symbol> 891if successful, 892<errorname>BadAlloc</errorname> 893if it is unable to obtain necessary storage for either the return values or 894work space, 895<errorname>BadMatch</errorname> 896if the 897<structfield>dpy</structfield> 898field of the 899<parameter>xkb</parameter> 900argument is non- 901<symbol>NULL</symbol> 902and does not match the 903<parameter>display</parameter> 904argument, and 905<errorname>BadLength</errorname> 906under certain conditions caused by server or Xkb implementation errors. 907</para> 908 909 910</sect1> 911<sect1 id='Using_the_Compatibility_Map'> 912<title>Using the Compatibility Map</title> 913 914<para> 915Xkb provides several functions that make it easier to apply the compatibility 916map to configure a client-side Xkb keyboard mapping, given a core protocol 917representation of part or all of a keyboard mapping. Obtain a core protocol 918representation of a keyboard mapping from an actual server (by using 919<function>XGetKeyboardMapping</function>, 920for example), a data file, or some other source. 921</para> 922 923<para> 924To update a local Xkb keyboard map to reflect the mapping expressed by a core 925format mapping by calling the function 926<function>XkbUpdateMapFromCore</function>. 927</para> 928 929<indexterm significance="preferred" zone="XkbUpdateMapFromCore"><primary><function>XkbUpdateMapFromCore</function></primary></indexterm> 930<funcsynopsis id="XkbUpdateMapFromCore"> 931 <funcprototype> 932 <funcdef>Bool <function>XkbUpdateMapFromCore</function></funcdef> 933<!-- ( 934<parameter>xkb</parameter>, 935<parameter>first_key</parameter>, 936<parameter>num_keys</parameter>, 937<parameter>map_width</parameter>, 938<parameter>core_keysyms</parameter>, 939<parameter>changes</parameter> 940) --> 941 942 <paramdef>XkbDescPtr <parameter>xkb</parameter></paramdef> 943 <paramdef>KeyCode <parameter>first_key</parameter></paramdef> 944 <paramdef>int <parameter>num_keys</parameter></paramdef> 945 <paramdef>int <parameter>map_width</parameter></paramdef> 946 <paramdef>KeySym *<parameter>core_keysyms</parameter></paramdef> 947 <paramdef>XkbChangesPtr <parameter>changes</parameter></paramdef> 948 </funcprototype> 949</funcsynopsis> 950<variablelist> 951 <varlistentry> 952 <term> 953 <parameter>xkb</parameter> 954 </term> 955 <listitem> 956 <para> 957 keyboard description to update 958 </para> 959 </listitem> 960 </varlistentry> 961 <varlistentry> 962 <term> 963 <parameter>first_key</parameter> 964 </term> 965 <listitem> 966 <para> 967 keycode of first key description to update 968 </para> 969 </listitem> 970 </varlistentry> 971 <varlistentry> 972 <term> 973 <parameter>num_keys</parameter> 974 </term> 975 <listitem> 976 <para> 977 number of key descriptions to update 978 </para> 979 </listitem> 980 </varlistentry> 981 <varlistentry> 982 <term> 983 <parameter>map_width</parameter> 984 </term> 985 <listitem> 986 <para> 987 width of core protocol keymap 988 </para> 989 </listitem> 990 </varlistentry> 991 <varlistentry> 992 <term> 993 <parameter>core_keysyms</parameter> 994 </term> 995 <listitem> 996 <para> 997 symbols in core protocol keymap 998 </para> 999 </listitem> 1000 </varlistentry> 1001 <varlistentry> 1002 <term> 1003 <parameter>changes</parameter> 1004 </term> 1005 <listitem> 1006 <para> 1007 backfilled with changes made to Xkb 1008 </para> 1009 </listitem> 1010 </varlistentry> 1011</variablelist> 1012 1013<para> 1014<function>XkbUpdateMapFromCore</function> 1015interprets input argument information representing a keyboard map in core 1016format to update the Xkb keyboard description passed in 1017<parameter>xkb</parameter>. 1018Only a portion of the Xkb map is updated — the portion corresponding to 1019keys with keycodes in the range 1020<parameter>first_key</parameter> 1021through 1022<parameter>first_key</parameter> 1023+ 1024<parameter>num_keys</parameter> 1025- 1. If 1026<function>XkbUpdateMapFromCore</function> 1027is being called in response to a 1028<symbol>MappingNotify</symbol> 1029event, 1030<parameter>first_key</parameter> 1031and 1032<parameter>num_keys</parameter> 1033are reported in the 1034<symbol>MappingNotify</symbol> 1035event. 1036<parameter>core_keysyms</parameter> 1037contains the keysyms corresponding to the keycode range being updated, in core 1038keyboard description order. 1039<parameter>map_width</parameter> 1040is the number of keysyms per key in 1041<parameter>core_keysyms</parameter>. 1042Thus, the first 1043<parameter>map_width</parameter> 1044entries in 1045<parameter>core_keysyms</parameter> 1046are for the key with keycode 1047<parameter>first_key</parameter>, 1048the next 1049<parameter>map_width</parameter> 1050entries are for key 1051<parameter>first_key</parameter> 1052+ 1, and so on. 1053</para> 1054 1055 1056<para> 1057In addition to modifying the Xkb keyboard mapping in 1058<parameter>xkb</parameter>, 1059<function>XkbUpdateMapFromCore</function> 1060backfills the changes structure whose address is passed in 1061<parameter>changes</parameter> 1062to indicate the modifications that were made. You may then use 1063<parameter>changes</parameter> 1064in subsequent calls such as 1065<function>XkbSetMap</function>, 1066to propagate the local modifications to a server. 1067</para> 1068 1069 1070<para> 1071When dealing with core keyboard mappings or descriptions, it is sometimes 1072necessary to determine the Xkb key types appropriate for the symbols bound to a 1073key in a core keyboard mapping. Use 1074<function>XkbKeyTypesForCoreSymbols</function> 1075for this purpose: 1076</para> 1077 1078 1079<indexterm significance="preferred" zone="XkbKeyTypesForCoreSymbols"><primary><function>XkbKeyTypesForCoreSymbols</function></primary></indexterm> 1080<funcsynopsis id="XkbKeyTypesForCoreSymbols"> 1081 <funcprototype> 1082 <funcdef>int <function>XkbKeyTypesForCoreSymbols</function></funcdef> 1083<!-- ( 1084<parameter>map_width</parameter>, 1085<parameter>core_syms</parameter>, 1086<parameter>protected, types_inout, xkb_syms_rtrn</parameter> 1087) --> 1088 1089 <paramdef>XkbDescPtr <parameter>xkb</parameter></paramdef> 1090 <paramdef>int <parameter>map_width</parameter></paramdef> 1091 <paramdef>KeySym *<parameter>core_syms</parameter></paramdef> 1092 <paramdef>unsigned int <parameter>protected</parameter></paramdef> 1093 <paramdef>int *<parameter>types_inout</parameter></paramdef> 1094 <paramdef>KeySym *<parameter>xkb_syms_rtrn</parameter></paramdef> 1095 </funcprototype> 1096</funcsynopsis> 1097<variablelist> 1098 <varlistentry> 1099 <term> 1100 <parameter>xkb</parameter> 1101 </term> 1102 <listitem> 1103 <para> 1104 keyboard description in which to place symbols 1105 </para> 1106 </listitem> 1107 </varlistentry> 1108 <varlistentry> 1109 <term> 1110 <parameter>map_width</parameter> 1111 </term> 1112 <listitem> 1113 <para> 1114 width of core protocol keymap in <parameter>xkb_syms_rtrn</parameter> 1115 </para> 1116 </listitem> 1117 </varlistentry> 1118 <varlistentry> 1119 <term> 1120 <parameter>core_syms</parameter> 1121 </term> 1122 <listitem> 1123 <para> 1124 core protocol format array of KeySyms 1125 </para> 1126 </listitem> 1127 </varlistentry> 1128 <varlistentry> 1129 <term> 1130 <parameter>protected</parameter> 1131 </term> 1132 <listitem> 1133 <para> 1134 explicit key types 1135 </para> 1136 </listitem> 1137 </varlistentry> 1138 <varlistentry> 1139 <term> 1140 <parameter>types_inout</parameter> 1141 </term> 1142 <listitem> 1143 <para> 1144 backfilled with the canonical types bound to groups one and two 1145 for the key 1146 </para> 1147 </listitem> 1148 </varlistentry> 1149 <varlistentry> 1150 <term> 1151 <parameter>xkb_syms_rtrn</parameter> 1152 </term> 1153 <listitem> 1154 <para> 1155 backfilled with symbols bound to the key in the Xkb mapping 1156 </para> 1157 </listitem> 1158 </varlistentry> 1159</variablelist> 1160 1161<para> 1162<function>XkbKeyTypesForCoreSymbols</function> 1163expands the symbols in 1164<parameter>core_syms</parameter> 1165and types in 1166<parameter>types_inout</parameter> 1167according to the rules specified in section 12 of the core protocol, then 1168chooses canonical key types (canonical key types are defined in <link linkend="The_Canonical_Key_Types">section 15.2.1</link>) 1169for groups 1 and 2 using the rules specified by the Xkb protocol and places 1170them in 1171<parameter>xkb_syms_rtrn</parameter>, 1172which will be non- 1173<symbol>NULL</symbol>. 1174</para> 1175 1176 1177<para> 1178A core keymap is a two-dimensional array of keysyms. It has 1179<parameter>map_width</parameter> 1180columns and 1181<structfield>max_key_code</structfield> 1182rows. 1183<function>XkbKeyTypesForCoreSymbols</function> 1184takes a single row from a core keymap, determines the number of groups 1185associated with it, the type of each group, and the symbols bound to each 1186group. The return value is the number of groups, 1187<parameter>types_inout</parameter> 1188has the types for each group, and 1189<parameter>xkb_syms_rtrn</parameter> 1190has the symbols in Xkb order (that is, groups are contiguous, regardless of 1191size). 1192</para> 1193 1194 1195<para> 1196<parameter>protected</parameter> 1197contains the explicitly protected key types. There is one explicit override 1198control associated with each of the four possible groups for each Xkb key, 1199<emphasis>ExplicitKeyType1</emphasis> 1200through 1201<emphasis>ExplicitKeyType4</emphasis>; 1202<parameter>protected</parameter> 1203is an inclusive OR of these controls. 1204<parameter>map_width</parameter> 1205is the width of the core keymap and is not dependent on any Xkb definitions. 1206<parameter>types_inout</parameter> 1207is an array of four type indices. On input, 1208<parameter>types_inout</parameter> 1209contains the indices of any types already assigned to the key, in case they 1210are explicitly protected from change. 1211</para> 1212 1213 1214<para> 1215Upon return, 1216<parameter>types_inout</parameter> 1217contains any automatically selected (that is, canonical) types plus any 1218protected types. Canonical types are assigned to all four groups if there are 1219enough symbols to do so. The four entries in 1220<parameter>types_inout</parameter> 1221correspond to the four groups for the key in question. 1222</para> 1223 1224 1225<para> 1226If the groups mapping does not change, but the symbols assigned to an Xkb 1227keyboard compatibility map do change, the semantics of the key may be modified. 1228To apply the new compatibility mapping to an individual key to get its 1229semantics updated, use 1230<function>XkbApplyCompatMapToKey</function>. 1231</para> 1232 1233 1234<indexterm significance="preferred" zone="XkbApplyCompatMapToKey"><primary><function>XkbApplyCompatMapToKey</function></primary></indexterm> 1235<funcsynopsis id="XkbApplyCompatMapToKey"> 1236 <funcprototype> 1237 <funcdef>Bool <function>XkbApplyCompatMapToKey</function></funcdef> 1238<!-- ( 1239<parameter>xkb</parameter>, 1240<parameter>key</parameter>, 1241<parameter>changes</parameter> 1242) --> 1243 1244 <paramdef>XkbDescPtr <parameter>xkb</parameter></paramdef> 1245 <paramdef>KeyCode <parameter>key</parameter></paramdef> 1246 <paramdef>XkbChangesPtr <parameter>changes</parameter></paramdef> 1247 </funcprototype> 1248</funcsynopsis> 1249<variablelist> 1250 <varlistentry> 1251 <term> 1252 <parameter>xkb</parameter> 1253 </term> 1254 <listitem> 1255 <para> 1256 keyboard description to be updated 1257 </para> 1258 </listitem> 1259 </varlistentry> 1260 <varlistentry> 1261 <term> 1262 <parameter>key</parameter> 1263 </term> 1264 <listitem> 1265 <para> 1266 key to be updated 1267 </para> 1268 </listitem> 1269 </varlistentry> 1270 <varlistentry> 1271 <term> 1272 <parameter>changes</parameter> 1273 </term> 1274 <listitem> 1275 <para> 1276 notes changes to the Xkb keyboard description 1277 </para> 1278 </listitem> 1279 </varlistentry> 1280</variablelist> 1281 1282<para> 1283<function>XkbApplyCompatMapToKey</function> 1284essentially performs the operation described in <link linkend="Core_Keyboard_Mapping_to_Xkb_Keyboard_Mapping_Transformation">section 17.1.2</link> to a specific 1285key. This updates the behavior, actions, repeat status, and virtual modifier 1286bindings of the key. 1287</para> 1288 1289 1290</sect1> 1291<sect1 id='Changing_the_Servers_Compatibility_Map'> 1292<title>Changing the Server’s Compatibility Map</title> 1293 1294<para> 1295To modify the server’s compatibility map, first modify a local copy of the 1296Xkb compatibility map, then call 1297<function>XkbSetCompatMap</function>. 1298You may allocate a new compatibility map for this purpose using 1299<function>XkbAllocCompatMap</function> 1300(see <link linkend="Allocating_and_Freeing_the_Compatibility_Map">section 17.6</link>). You may also use a compatibility map from another server, 1301although you need to adjust the 1302<structfield>device_spec</structfield> 1303field in the 1304<structname>XkbDescRec</structname> 1305accordingly. Note that symbol interpretations in a compatibility map 1306( 1307<structfield>sym_interpret</structfield>, 1308the vector of 1309<structname>XkbSymInterpretRec</structname> 1310structures) are also allocated using this same function. 1311</para> 1312 1313<indexterm significance="preferred" zone="XkbSetCompatMap"><primary><function>XkbSetCompatMap</function></primary></indexterm> 1314<funcsynopsis id="XkbSetCompatMap"> 1315 <funcprototype> 1316 <funcdef>Bool <function>XkbSetCompatMap</function></funcdef> 1317<!-- ( 1318<parameter>display, which, xkb, update_actions</parameter> 1319) --> 1320 1321 <paramdef>Display *<parameter>display</parameter></paramdef> 1322 <paramdef>unsigned int <parameter>which</parameter></paramdef> 1323 <paramdef>XkbDescPtr <parameter>xkb</parameter></paramdef> 1324 <paramdef>Bool <parameter>update_actions</parameter></paramdef> 1325 </funcprototype> 1326</funcsynopsis> 1327<variablelist> 1328 <varlistentry> 1329 <term> 1330 <parameter>display</parameter> 1331 </term> 1332 <listitem> 1333 <para> 1334 connection to server 1335 </para> 1336 </listitem> 1337 </varlistentry> 1338 <varlistentry> 1339 <term> 1340 <parameter>which</parameter> 1341 </term> 1342 <listitem> 1343 <para> 1344 mask of compat map components to set 1345 </para> 1346 </listitem> 1347 </varlistentry> 1348 <varlistentry> 1349 <term> 1350 <parameter>xkb</parameter> 1351 </term> 1352 <listitem> 1353 <para> 1354 source for compat map components 1355 </para> 1356 </listitem> 1357 </varlistentry> 1358 <varlistentry> 1359 <term> 1360 <parameter>update_actions</parameter> 1361 </term> 1362 <listitem> 1363 <para> 1364 <symbol>True</symbol> ⇒ apply to server’s keyboard map 1365 </para> 1366 </listitem> 1367 </varlistentry> 1368</variablelist> 1369 1370<para> 1371<function>XkbSetCompatMap</function> 1372copies compatibility map information from the keyboard description in 1373<parameter>xkb</parameter> 1374to the server specified in 1375<parameter>display</parameter>’s 1376compatibility map for the device specified by the 1377<structfield>device_spec</structfield> 1378field of 1379<parameter>xkb</parameter>. 1380Unless you have specifically modified this field, it is the default keyboard 1381device. 1382<parameter>which</parameter> 1383specifies the compatibility map components to be set, and is an inclusive OR 1384of the bits shown in <link linkend="table17.2">Table 17.2</link>. 1385</para> 1386 1387 1388<para> 1389After updating its compatibility map for the specified device, if 1390<parameter>update_actions</parameter> 1391is 1392<symbol>True</symbol>, 1393the server applies the new compatibility map to its entire keyboard for the 1394device to generate a new set of key semantics, compatibility state, and a new 1395core keyboard map. If 1396<parameter>update_actions</parameter> 1397is 1398<symbol>False</symbol>, 1399the new compatibility map is not used to generate any modifications to the 1400current device semantics, state, or core keyboard map. One reason for not 1401applying the compatibility map immediately would be if one server was being 1402configured to match another on a piecemeal basis; the map should not be applied 1403until everything is updated. To force an update at a later time, use 1404<function>XkbSetCompatMap</function> 1405specifying 1406<parameter>which</parameter> 1407as zero and 1408<parameter>update_actions</parameter> 1409as 1410<symbol>True</symbol>. 1411</para> 1412 1413 1414<para> 1415<function>XkbSetCompatMap</function> 1416returns 1417<symbol>True</symbol> 1418if successful and 1419<symbol>False</symbol> 1420if unsuccessful. The server may report problems it encounters when processing 1421the request subsequently via protocol errors. 1422</para> 1423 1424 1425<para> 1426To add a symbol interpretation to the list of symbol interpretations in an 1427<structname>XkbCompatRec</structname>, 1428use 1429<function>XkbAddSymInterpret</function>. 1430</para> 1431 1432 1433<indexterm significance="preferred" zone="XkbAddSymInterpret"><primary><function>XkbAddSymInterpret</function></primary></indexterm> 1434<funcsynopsis id="XkbAddSymInterpret"> 1435 <funcprototype> 1436 <funcdef>XkbSymInterpretPtr <function>XkbAddSymInterpret</function></funcdef> 1437<!-- ( 1438<parameter>xkb, si, updateMap, changes</parameter> 1439) --> 1440 1441 <paramdef>XkbDescPtr <parameter>xkb</parameter></paramdef> 1442 <paramdef>XkbSymInterpretPtr <parameter>si</parameter></paramdef> 1443 <paramdef>Bool <parameter>updateMap</parameter></paramdef> 1444 <paramdef>XkbChangesPtr <parameter>changes</parameter></paramdef> 1445 </funcprototype> 1446</funcsynopsis> 1447<variablelist> 1448 <varlistentry> 1449 <term> 1450 <parameter>xkb</parameter> 1451 </term> 1452 <listitem> 1453 <para> 1454 keyboard description to be updated 1455 </para> 1456 </listitem> 1457 </varlistentry> 1458 <varlistentry> 1459 <term> 1460 <parameter>si</parameter> 1461 </term> 1462 <listitem> 1463 <para> 1464 symbol interpretation to be added 1465 </para> 1466 </listitem> 1467 </varlistentry> 1468 <varlistentry> 1469 <term> 1470 <parameter>updateMap</parameter> 1471 </term> 1472 <listitem> 1473 <para> 1474 <symbol>True</symbol>⇒apply compatibility map to keys 1475 </para> 1476 </listitem> 1477 </varlistentry> 1478 <varlistentry> 1479 <term> 1480 <parameter>changes</parameter> 1481 </term> 1482 <listitem> 1483 <para> 1484 changes are put here 1485 </para> 1486 </listitem> 1487 </varlistentry> 1488</variablelist> 1489 1490<para> 1491<function>XkbAddSymInterpret</function> 1492adds 1493<parameter>si</parameter> 1494to the list of symbol interpretations in 1495<parameter>xkb</parameter>. 1496If 1497<parameter>updateMap</parameter> 1498is 1499<symbol>True</symbol>, 1500it (re)applies the compatibility map to all of the keys on the keyboard. If 1501<parameter>changes</parameter> 1502is non- 1503<symbol>NULL</symbol>, 1504it reports the parts of the keyboard that were affected (unless 1505<parameter>updateMap</parameter> 1506is 1507<symbol>True</symbol>, 1508not much changes). 1509<function>XkbAddSymInterpret</function> 1510returns a pointer to the actual new symbol interpretation in the list or 1511<symbol>NULL</symbol> 1512if it failed. 1513</para> 1514 1515 1516</sect1> 1517<sect1 id='Tracking_Changes_to_the_Compatibility_Map'> 1518<title>Tracking Changes to the Compatibility Map</title> 1519<indexterm significance="preferred" zone="Tracking_Changes_to_the_Compatibility_Map"> 1520<primary>events</primary><secondary><symbol></symbol>XkbCompatMapNotify</secondary></indexterm> 1521<indexterm significance="preferred" zone="Tracking_Changes_to_the_Compatibility_Map"> 1522<primary><structname>XkbCompatMapNotifyEvent</structname></primary></indexterm> 1523 1524<para> 1525The server automatically generates 1526<symbol>MappingNotify</symbol> 1527events when the keyboard mapping changes. If you wish to be notified of 1528changes to the compatibility map, you should select for 1529<symbol>XkbCompatMapNotify</symbol> 1530events. If you select for 1531<symbol>XkbMapNotify</symbol> 1532events, you no longer receive the automatically generated 1533<symbol>MappingNotify</symbol> 1534events. If you subsequently deselect 1535<structname>XkbMapNotifyEvent</structname> 1536delivery, you again receive 1537<symbol>MappingNotify</symbol> 1538events. 1539</para> 1540 1541 1542<para> 1543To receive 1544<symbol>XkbCompatMapNotify</symbol> 1545events under all possible conditions, use 1546<function>XkbSelectEvents</function> 1547(see <link linkend="Selecting_Xkb_Events">section 4.3</link>) and pass 1548<symbol>XkbCompatMapNotifyMask</symbol> 1549in both 1550<parameter>bits_to_change</parameter> 1551and 1552<parameter>values_for_bits</parameter>. 1553</para> 1554 1555 1556<para> 1557To receive 1558<symbol>XkbCompatMapNotify</symbol> 1559events only under certain conditions, use 1560<function>XkbSelectEventDetails</function> 1561using 1562<symbol>XkbCompatMapNotify</symbol> 1563as the 1564<structfield>event_type</structfield> 1565and specifying the desired map changes in 1566<parameter>bits_to_change</parameter> 1567and 1568<parameter>values_for_bits</parameter> 1569using mask bits from <link linkend="table17.2">Table 17.2</link>. 1570</para> 1571 1572 1573<para> 1574Note that you are notified of changes you make yourself, as well as changes 1575made by other clients. 1576</para> 1577 1578 1579<para> 1580The structure for the 1581<structname>XkbCompatMapNotifyEvent</structname> 1582is: 1583 1584<programlisting> 1585typedef struct { 1586 int type; /* Xkb extension base event code */ 1587 unsigned long serial; /* X server serial number for event */ 1588 Bool send_event; /* <symbol>True</symbol> ⇒ 1589 synthetically generated */ 1590 Display * display; /* server connection where event generated */ 1591 Time time; /* server time when event generated */ 1592 int xkb_type; /* <symbol>XkbCompatMapNotify</symbol> */ 1593 int device; /* Xkb device ID, will not be 1594 <symbol>XkbUseCoreKbd</symbol> */ 1595 unsigned int changed_groups; /* number of group maps changed */ 1596 int first_si; /* index to 1st changed symbol 1597 interpretation */ 1598 int num_si; /* number of changed symbol 1599 interpretations */ 1600 int num_total_si; /* total number of valid symbol 1601 interpretations */ 1602} <structname>XkbCompatMapNotifyEvent</structname>; 1603</programlisting></para> 1604 1605<para> 1606<structfield>changed_groups</structfield> 1607is the number of group compatibility maps that have changed. If you are 1608maintaining a corresponding copy of the compatibility map, or get a fresh copy 1609from the server using 1610<function>XkbGetCompatMap</function>, 1611<structfield>changed_groups</structfield> 1612references 1613<structfield>groups</structfield> 1614[0.. 1615<structfield>changed_groups</structfield> 1616-1] in the 1617<structname>XkbCompatMapRec</structname> 1618structure. 1619</para> 1620 1621 1622<para> 1623<structfield>first_si</structfield> 1624is the index of the first changed symbol interpretation, 1625<structfield>num_si</structfield> 1626is the number of changed symbol interpretations, and 1627<structfield>num_total_si</structfield> 1628is the total number of valid symbol interpretations. If you are maintaining a 1629corresponding copy of the compatibility map, or get a fresh copy from the 1630server using 1631<function>XkbGetCompatMap</function>, 1632<structfield>first_si</structfield>, 1633<structfield>num_si</structfield>, 1634and 1635<structfield>num_total_si</structfield> 1636are appropriate for use with the 1637<structfield>compat.sym_interpret</structfield> 1638vector in this structure. 1639</para> 1640 1641 1642</sect1> 1643<sect1 id='Allocating_and_Freeing_the_Compatibility_Map'> 1644<title>Allocating and Freeing the Compatibility Map</title> 1645 1646<para> 1647If you are modifying the compatibility map, you need to allocate a new 1648compatibility map if you do not already have one available. To do so, use 1649<function>XkbAllocCompatMap</function>. 1650</para> 1651 1652<indexterm significance="preferred" zone="XkbAllocCompatMap"><primary><function>XkbAllocCompatMap</function></primary></indexterm> 1653<funcsynopsis id="XkbAllocCompatMap"> 1654 <funcprototype> 1655 <funcdef>Status <function>XkbAllocCompatMap</function></funcdef> 1656<!-- ( 1657<parameter>xkb, which, num_si</parameter> 1658) --> 1659 1660 <paramdef>XkbDescPtr <parameter>xkb</parameter></paramdef> 1661 <paramdef>unsigned int <parameter>which</parameter></paramdef> 1662 <paramdef>unsigned int <parameter>num_si</parameter></paramdef> 1663 </funcprototype> 1664</funcsynopsis> 1665<variablelist> 1666 <varlistentry> 1667 <term> 1668 <parameter>xkb</parameter> 1669 </term> 1670 <listitem> 1671 <para> 1672 keyboard description in which to allocate compat map 1673 </para> 1674 </listitem> 1675 </varlistentry> 1676 <varlistentry> 1677 <term> 1678 <parameter>which</parameter> 1679 </term> 1680 <listitem> 1681 <para> 1682 mask of compatibility map components to allocate 1683 </para> 1684 </listitem> 1685 </varlistentry> 1686 <varlistentry> 1687 <term> 1688 <parameter>num_si</parameter> 1689 </term> 1690 <listitem> 1691 <para> 1692 number of symbol interpretations to allocate 1693 </para> 1694 </listitem> 1695 </varlistentry> 1696</variablelist> 1697 1698<para> 1699<parameter>xkb</parameter> 1700specifies the keyboard description for which compatibility maps are to be 1701allocated. The compatibility map is the 1702<structfield>compat</structfield> 1703field in this structure. 1704</para> 1705 1706 1707<para> 1708<parameter>which</parameter> 1709specifies the compatibility map components to be allocated (see 1710<link linkend="XkbGetCompatMap"><function>XkbGetCompatMap</function></link>, 1711in <link linkend="Getting_Compatibility_Map_Components_From_the_Server">section 17.2</link>). 1712<parameter>which</parameter> 1713is an inclusive OR of the bits shown in 1714<link linkend="table17.2">Table 17.2</link>. 1715</para> 1716 1717 1718<para> 1719<parameter>num_si</parameter> 1720specifies the total number of entries to allocate in the symbol interpretation 1721vector 1722(<structfield>xkb.compat.sym_interpret</structfield>). 1723 1724</para> 1725 1726 1727<para> 1728Note that symbol interpretations in a compatibility map (the 1729<structfield>sym_interpret</structfield> 1730vector of 1731<structname>XkbSymInterpretRec</structname> 1732structures) are also allocated using this same function. To ensure that there 1733is sufficient space in the symbol interpretation vector for entries to be 1734added, use 1735<function>XkbAllocCompatMap</function> 1736specifying 1737<parameter>which</parameter> 1738as 1739<emphasis>XkbSymInterpretMask</emphasis> 1740and the number of free symbol interpretations needed in 1741<parameter>num_si</parameter>. 1742</para> 1743 1744 1745<para> 1746<function>XkbAllocCompatMap</function> 1747returns 1748<symbol>Success</symbol> 1749if successful, 1750<errorname>BadMatch</errorname> 1751if 1752<parameter>xkb</parameter> 1753is 1754<symbol>NULL</symbol>, 1755or 1756<errorname>BadAlloc</errorname> 1757if errors are encountered when attempting to allocate storage. 1758</para> 1759 1760 1761<para> 1762To free an entire compatibility map or selected portions of one, use 1763<function>XkbFreeCompatMap</function>. 1764</para> 1765 1766 1767<indexterm significance="preferred" zone="XkbFreeCompatMap"><primary><function>XkbFreeCompatMap</function></primary></indexterm> 1768<funcsynopsis id="XkbFreeCompatMap"> 1769 <funcprototype> 1770 <funcdef>void <function>XkbFreeCompatMap</function></funcdef> 1771<!-- ( 1772<parameter>xkb, which, free_map</parameter> 1773) --> 1774 1775 <paramdef>XkbDescPtr <parameter>xkb</parameter></paramdef> 1776 <paramdef>unsigned int <parameter>which</parameter></paramdef> 1777 <paramdef>Bool <parameter>free_map</parameter></paramdef> 1778 </funcprototype> 1779</funcsynopsis> 1780<variablelist> 1781 <varlistentry> 1782 <term> 1783 <parameter>xkb</parameter> 1784 </term> 1785 <listitem> 1786 <para> 1787 Xkb description in which to free compatibility map 1788 </para> 1789 </listitem> 1790 </varlistentry> 1791 <varlistentry> 1792 <term> 1793 <parameter>which</parameter> 1794 </term> 1795 <listitem> 1796 <para> 1797 mask of compatibility map components to free 1798 </para> 1799 </listitem> 1800 </varlistentry> 1801 <varlistentry> 1802 <term> 1803 <parameter>free_map</parameter> 1804 </term> 1805 <listitem> 1806 <para> 1807 <symbol>True</symbol> ⇒ free <structname>XkbCompatMapRec</structname> 1808 structure itself 1809 </para> 1810 </listitem> 1811 </varlistentry> 1812</variablelist> 1813 1814<para> 1815<parameter>which</parameter> 1816specifies the compatibility map components to be freed (see 1817<link linkend="XkbGetCompatMap"><function>XkbGetCompatMap</function></link>, 1818in <link linkend="Getting_Compatibility_Map_Components_From_the_Server">section 17.2</link>). 1819<parameter>which</parameter> 1820is an inclusive OR of the bits shown in 1821<link linkend="table17.2">Table 17.2</link> 1822</para> 1823 1824 1825<para> 1826<parameter>free_map</parameter> 1827indicates whether the 1828<structname>XkbCompatMapRec</structname> 1829structure itself should be freed. If 1830<parameter>free_map</parameter> 1831is 1832<symbol>True</symbol>, 1833<parameter>which</parameter> 1834is ignored, all non- 1835<symbol>NULL</symbol> 1836compatibility map components are freed, and the 1837<structfield>compat</structfield> 1838field in the 1839<structname>XkbDescRec</structname> 1840referenced by 1841<parameter>xkb</parameter> 1842is set to 1843<symbol>NULL</symbol>. 1844</para> 1845 1846</sect1> 1847</chapter> 1848