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='Symbolic_Names'> 5<title>Symbolic Names</title> 6 7<para> 8The core protocol does not provide any information to clients other than that 9actually used to interpret events. This makes it difficult to write an 10application that presents the keyboard to a user in an easy-to-understand way. 11Such applications have to examine the vendor string and keycodes to determine 12the type of keyboard connected to the server and then examine keysyms and 13modifier mappings to determine the effects of most modifiers (the 14<symbol>Shift</symbol>, 15<symbol>Lock</symbol> 16and 17<symbol>Control</symbol> 18modifiers are defined by the core protocol but no semantics are implied for 19any other modifiers). 20</para> 21 22 23<para> 24To make it easier for applications to present a keyboard to the user, Xkb 25supports symbolic names for most components of the keyboard extension. Most of 26these symbolic names are grouped into the 27<structfield>names</structfield> 28component of the keyboard description. 29</para> 30 31<sect1 id='The_XkbNamesRec_Structure'> 32<title>The XkbNamesRec Structure</title> 33<indexterm significance="preferred" zone="The_XkbNamesRec_Structure"> 34<primary><structname>XkbKeyNameRec</structname></primary></indexterm> 35<indexterm significance="preferred" zone="The_XkbNamesRec_Structure"> 36<primary><structname>XkbKeyAliasRec</structname></primary></indexterm> 37<indexterm significance="preferred" zone="The_XkbNamesRec_Structure"> 38<primary><structname>XkbNamesRec</structname></primary></indexterm> 39 40<para> 41The names component of the keyboard description is defined as follows: 42 43<programlisting> 44#define XkbKeyNameLength 4 45#define XkbKeyNumVirtualMods 16 46#define XkbKeyNumIndicators 32 47#define XkbKeyNumKbdGroups 4 48#define XkbMaxRadioGroups 32 49 50typedef struct { 51 char name[XkbKeyNameLength]; /* symbolic key names */ 52} <structname>XkbKeyNameRec</structname>, *XkbKeyNamePtr; 53 54typedef struct { 55 char real[XkbKeyNameLength]; 56 /* this key name must be in the keys array */ 57 char alias[XkbKeyNameLength]; 58 /* symbolic key name as alias for the key */ 59} <structname>XkbKeyAliasRec</structname>, *XkbKeyAliasPtr; 60 61typedef struct _XkbNamesRec { 62 Atom keycodes; /* identifies range and meaning 63 of keycodes */ 64 Atom geometry; /* identifies physical location, 65 size, and shape of keys */ 66 Atom symbols; /* identifies the symbols logically 67 bound to the keys */ 68 Atom types; /* identifies the set of key types */ 69 Atom compat; /* identifies actions for keys using 70 core protocol */ 71 Atom vmods[XkbNumVirtualMods]; /* symbolic names for 72 virtual modifiers */ 73 Atom indicators[XkbNumIndicators]; /* symbolic names 74 for indicators */ 75 Atom groups[XkbNumKbdGroups]; /* symbolic names for 76 keyboard groups */ 77 XkbKeyNamePtr keys; /* symbolic key name array */ 78 XkbKeyAliasPtr key_aliases; /* real/alias symbolic name pairs array */ 79 Atom * radio_groups; /* radio group name array */ 80 Atom phys_symbols; /* identifies the symbols engraved 81 on the keyboard */ 82 unsigned char num_keys; /* number of keys in the <structfield>keys</structfield> array */ 83 unsigned char num_key_aliases; /* number of keys in the 84 <structfield>key_aliases</structfield> array */ 85 unsigned short num_rg; /* number of radio groups */ 86} <structname>XkbNamesRec</structname>, *XkbNamesPtr; 87</programlisting></para> 88 89<para> 90The 91<structfield>keycodes</structfield> 92name identifies the range and meaning of the keycodes returned by the keyboard 93in question. The 94<structfield>geometry</structfield> 95name, on the other hand, identifies the physical location, size and shape of 96the various keys on the keyboard. As an example to distinguish between these 97two names, consider function keys on PC-compatible keyboards. Function keys are 98sometimes above the main keyboard and sometimes to the left of the main 99keyboard, but the same keycode is used for the key that is logically F1 100regardless of physical position. Thus, all PC-compatible keyboards share a 101similar keycodes name but may have different geometry names. 102</para> 103 104<note><para>The keycodes name is intended to be a very general description of 105the keycodes returned by a keyboard; a single keycodes name might cover 106keyboards with differing numbers of keys provided all keys have the same 107semantics when present. For example, 101 and 102 key PC keyboards might use the 108same name. In these cases, applications can use the keyboard 109<structfield>geometry</structfield> 110name to determine which subset of the named keycodes is in use.</para></note> 111 112<para> 113The 114<structfield>symbols</structfield> 115name identifies the symbols logically bound to the keys. The symbols name is a 116human or application-readable description of the intended locale or usage of 117the keyboard with these symbols. The 118<structfield>phys_symbols</structfield> 119name, on the other hand, identifies the symbols actually engraved on the 120keyboard. Given this, the 121<structfield>symbols</structfield> 122name and 123<structfield>phys_symbols</structfield> 124names might be different. For example, the description for a keyboard that has 125English US engravings, but that is using Swiss German symbols might have a 126<structfield>phys_symbols</structfield> 127name of "en_US" and a 128<structfield>symbols</structfield> 129name of "de_CH." 130</para> 131 132 133<para> 134The 135<structfield>types</structfield> 136name provides some information about the set of key types (see <link linkend="Key_Types">section 15.2</link>) 137that can be associated with the keyboard. In addition, each key type can have a 138name, and each shift level of a type can have a name. Although these names are 139stored in the map description with each of the types, they are accessed using 140the same methods as the other symbolic names. 141</para> 142 143 144<para> 145The 146<structfield>compat</structfield> 147name provides some information about the rules used to bind actions to keys 148that are changed using core protocol requests. 149</para> 150 151 152<para> 153Xkb provides symbolic names for each of the 4 keyboard groups, 16 virtual 154modifiers, 32 keyboard indicators, and 4 keyboard groups. These names are held 155in the 156<structfield>vmods</structfield>, 157<structfield>indicators</structfield>, 158and 159<structfield>groups</structfield> 160fixed-length arrays. 161</para> 162 163 164<para> 165Each key has a four-byte symbolic name. All of the symbolic key names are held 166in the 167<structfield>keys</structfield> 168array, and 169<structfield>num_keys</structfield> 170reports the number of entries that are in the keys array. For each key, the 171key name links keys with similar functions or in similar positions on keyboards 172that report different keycodes. For example, the 173<keycap>F1</keycap> 174key may emit keycode 23 on one keyboard and keycode 86 on another. By naming 175this key "FK01" on both keyboards, the keyboard layout designer can reuse parts 176of keyboard descriptions for different keyboards. 177</para> 178 179 180<para> 181Key aliases allow the keyboard layout designer to assign multiple key names to 182a single key. This allows the keyboard layout designer to refer to keys using 183either their position or their <quote>function</quote>. 184For example, a keyboard layout 185designer may wish to refer to the left arrow key on a PC keyboard using the 186ISO9995-5 positional specification of A31 or using the functional specification 187of LEFT. The 188<structfield>key_aliases</structfield> 189field holds a variable-length array of real and alias key name pairs, and the 190total number of entries in the 191<structfield>key_aliases</structfield> 192array is held in 193<structfield>num_key_aliases</structfield>. 194For each real and alias key name pair, the 195<structfield>real</structfield> 196field refers to the a name in the keys array, and the 197<structfield>alias</structfield> 198field refers to the alias for that key. Using the previous example, the 199keyboard designer may use the name A31 in the keys array, but also define the 200name LEFT as an alias for A31 in the 201<structfield>key_aliases</structfield> 202array. 203</para> 204 205<note><para>Key aliases defined in the geometry component of a keyboard mapping 206(see <xref linkend="Keyboard_Geometry" />) override those defined in the keycodes component of the server 207database, which are stored in the 208<structname>XkbNamesRec</structname> 209 210(<structfield>xkb->names</structfield>). 211Therefore, consider the key aliases defined by the geometry before 212considering key aliases supplied by the 213<structname>XkbNamesRec</structname>. 214</para></note> 215 216<para> 217A radio group is a set of keys whose behavior simulates a set of radio buttons. 218Once a key in a radio group is pressed, it stays logically depressed until 219another key in the group is pressed, at which point the previously depressed 220key is logically released. Consequently, at most one key in a radio group can 221be logically depressed at one time. 222</para> 223 224 225<para> 226Each radio group in the keyboard description can have a name. These names are 227held in the variable-length array 228<structfield>radio_groups</structfield>, 229and 230<structfield>num_rg</structfield> 231tells how many elements are in the 232<structfield>radio_groups</structfield> 233array. 234</para> 235 236 237</sect1> 238<sect1 id='Symbolic_Names_Masks'> 239<title>Symbolic Names Masks</title> 240 241<para> 242Xkb provides several functions that work with symbolic names. Each of these 243functions uses a mask to specify individual fields of the structures described 244above. These masks and their relationships to the fields in a keyboard 245description are shown in <link linkend="table18.1">Table 18.1</link>. 246</para> 247 248<table id='table18.1' frame='topbot'> 249<title>Symbolic Names Masks</title> 250<?dbfo keep-together="always" ?> 251<tgroup cols='4' align='left' colsep='0' rowsep='0'> 252<colspec colname='c1' colwidth='3.0*'/> 253<colspec colname='c2' colwidth='1.0*'/> 254<colspec colname='c3' colwidth='1.5*'/> 255<colspec colname='c4' colwidth='2.0*'/> 256<thead> 257<row rowsep='1'> 258 <entry>Mask Bit</entry> 259 <entry>Value</entry> 260 <entry>Keyboard Component</entry> 261 <entry>Field</entry> 262</row> 263</thead> 264<tbody> 265<row> 266 <entry><symbol>XkbKeycodesNameMask</symbol></entry> 267 <entry>(1<<0)</entry> 268 <entry>Xkb->names</entry> 269 <entry>keycodes</entry> 270</row> 271<row> 272 <entry><symbol>XkbGeometryNameMask</symbol></entry> 273 <entry>(1<<1)</entry> 274 <entry>Xkb->names</entry> 275 <entry>geometry</entry> 276</row> 277<row> 278 <entry><symbol>XkbSymbolsNameMask</symbol></entry> 279 <entry>(1<<2)</entry> 280 <entry>Xkb->names</entry> 281 <entry>symbols</entry> 282</row> 283<row> 284 <entry><symbol>XkbPhysSymbolsNameMask</symbol></entry> 285 <entry>(1<<3)</entry> 286 <entry>Xkb->names</entry> 287 <entry>phys_symbols</entry> 288</row> 289<row> 290 <entry><symbol>XkbTypesNameMask</symbol></entry> 291 <entry>(1<<4)</entry> 292 <entry>Xkb->names</entry> 293 <entry>type</entry> 294</row> 295<row> 296 <entry><symbol>XkbCompatNameMask</symbol></entry> 297 <entry>(1<<5)</entry> 298 <entry>Xkb->names</entry> 299 <entry>compat</entry> 300</row> 301<row> 302 <entry><symbol>XkbKeyTypeNamesMask</symbol></entry> 303 <entry>(1<<6)</entry> 304 <entry>Xkb->map</entry> 305 <entry>type[*].name</entry> 306</row> 307<row> 308 <entry><symbol>XkbKTLevelNamesMask</symbol></entry> 309 <entry>(1<<7)</entry> 310 <entry>Xkb->map</entry> 311 <entry>type[*].lvl_names[*]</entry> 312</row> 313<row> 314 <entry><symbol>XkbIndicatorNamesMask</symbol></entry> 315 <entry>(1<<8)</entry> 316 <entry>Xkb->names</entry> 317 <entry>indicators[*]</entry> 318</row> 319<row> 320 <entry><symbol>XkbKeyNamesMask</symbol></entry> 321 <entry>(1<<9)</entry> 322 <entry>Xkb->names</entry> 323 <entry>keys[*], num_keys</entry> 324</row> 325<row> 326 <entry><symbol>XkbKeyAliasesMask</symbol></entry> 327 <entry>(1<<10)</entry> 328 <entry>Xkb->names</entry> 329 <entry>key_aliases[*], num_key_aliases</entry> 330</row> 331<row> 332 <entry><symbol>XkbVirtualModNamesMask</symbol></entry> 333 <entry>(1<<11)</entry> 334 <entry>Xkb->names</entry> 335 <entry>vmods[*]</entry> 336</row> 337<row> 338 <entry><symbol>XkbGroupNamesMask</symbol></entry> 339 <entry>(1<<12)</entry> 340 <entry>Xkb->names</entry> 341 <entry>groups[*]</entry> 342</row> 343<row> 344 <entry><symbol>XkbRGNamesMask</symbol></entry> 345 <entry>(1<<13)</entry> 346 <entry>Xkb->names</entry> 347 <entry>radio_groups[*], num_rg</entry> 348</row> 349<row> 350 <entry><symbol>XkbComponentNamesMask</symbol></entry> 351 <entry>(0x3f)</entry> 352 <entry>Xkb->names</entry> 353 <entry> 354<para>keycodes,</para> 355<para>geometry,</para> 356<para>symbols,</para> 357<para>physical symbols,</para> 358<para>types, and</para> 359<para>compatibility map</para> 360 </entry> 361</row> 362<row> 363 <entry><symbol>XkbAllNamesMask</symbol></entry> 364 <entry>(0x3fff)</entry> 365 <entry>Xkb->names</entry> 366 <entry>all name components</entry> 367 </row> 368</tbody> 369</tgroup> 370</table> 371 372</sect1> 373<sect1 id='Getting_Symbolic_Names_From_the_Server'> 374<title>Getting Symbolic Names From the Server</title> 375 376<para> 377To obtain symbolic names from the server, use 378<function>XkbGetNames</function>. 379</para> 380 381<indexterm significance="preferred" zone="XkbGetNames"><primary><function>XkbGetNames</function></primary></indexterm> 382<funcsynopsis id="XkbGetNames"> 383 <funcprototype> 384 <funcdef>Status <function>XkbGetNames</function></funcdef> 385<!-- ( 386<parameter>dpy, which, Xkb</parameter> 387) --> 388 389 <paramdef>Display *<parameter>dpy</parameter></paramdef> 390 <paramdef>unsigned int <parameter>which</parameter></paramdef> 391 <paramdef>XkbDescPtr <parameter>xkb</parameter></paramdef> 392 </funcprototype> 393</funcsynopsis> 394<variablelist> 395 <varlistentry> 396 <term> 397 <parameter>dpy</parameter> 398 </term> 399 <listitem> 400 <para> 401 connection to the X server 402 </para> 403 </listitem> 404 </varlistentry> 405 <varlistentry> 406 <term> 407 <parameter>which</parameter> 408 </term> 409 <listitem> 410 <para> 411 mask of names or map components to be updated 412 </para> 413 </listitem> 414 </varlistentry> 415 <varlistentry> 416 <term> 417 <parameter>xkb</parameter> 418 </term> 419 <listitem> 420 <para> 421 keyboard description to be updated 422 </para> 423 </listitem> 424 </varlistentry> 425</variablelist> 426 427<para> 428<function>XkbGetNames</function> 429retrieves symbolic names for the components of the keyboard extension from the 430X server. The 431<parameter>which</parameter> 432parameter specifies the name components to be updated in the 433<parameter>xkb</parameter> 434parameter, and is the bitwise inclusive OR of the valid names mask bits 435defined in <link linkend="table18.1">Table 18.1</link>. 436</para> 437 438 439<para> 440If the 441<structfield>names</structfield> 442field of the keyboard description 443<parameter>xkb</parameter> 444is 445<symbol>NULL</symbol>, 446<function>XkbGetNames</function> 447allocates and initializes the 448<structfield>names</structfield> 449component of the keyboard description before obtaining the values specified by 450<parameter>which</parameter>. 451If the 452<structfield>names</structfield> 453field of 454<parameter>xkb</parameter> 455is not 456<symbol>NULL</symbol>, 457<function>XkbGetNames</function> 458obtains the values specified by 459<parameter>which</parameter> 460and copies them into the keyboard description 461<parameter>xkb</parameter>. 462</para> 463 464 465<para> 466If the 467<structfield>map</structfield> 468component of the 469<parameter>xkb</parameter> 470parameter is 471<symbol>NULL</symbol>, 472<function>XkbGetNames</function> 473does not retrieve type or shift level names, even if 474<symbol>XkbKeyTypeNamesMask</symbol> 475or 476<symbol>XkbKTLevelNamesMask</symbol> 477are set in 478<parameter>which</parameter>. 479</para> 480 481 482<para> 483<function>XkbGetNames</function> 484can return 485<symbol>Success</symbol>, 486or 487<errorname>BadAlloc</errorname>, 488<errorname>BadLength</errorname>, 489<errorname>BadMatch</errorname>, 490and 491<errorname>BadImplementation</errorname> 492errors. 493</para> 494 495 496<para> 497To free symbolic names, use 498<function>XkbFreeNames</function> 499(see <link linkend="Allocating_and_Freeing_Symbolic_Names">section 18.6</link>) 500</para> 501 502 503</sect1> 504<sect1 id='Changing_Symbolic_Names_on_the_Server'> 505<title>Changing Symbolic Names on the Server</title> 506 507<para> 508To change the symbolic names in the server, first modify a local copy of the 509keyboard description and then use either 510<function>XkbSetNames</function>, 511or, to save network traffic, use a 512<structname>XkbNameChangesRec</structname> 513structure and call 514<function>XkbChangeNames</function> 515to download the changes to the server. 516<function>XkbSetNames</function> 517and 518<function>XkbChangeNames</function> 519can generate 520<errorname>BadAlloc</errorname>, 521<errorname>BadAtom</errorname>, 522<errorname>BadLength</errorname>, 523<errorname>BadMatch</errorname>, 524and 525<errorname>BadImplementation</errorname> 526errors. 527</para> 528 529<indexterm significance="preferred" zone="XkbSetNames"><primary><function>XkbSetNames</function></primary></indexterm> 530<funcsynopsis id="XkbSetNames"> 531 <funcprototype> 532 <funcdef>Bool <function>XkbSetNames</function></funcdef> 533<!-- ( 534<parameter>dpy, which, first_type, num_types, xkb</parameter> 535) --> 536 537 <paramdef>Display *<parameter>dpy</parameter></paramdef> 538 <paramdef>unsigned int <parameter>which</parameter></paramdef> 539 <paramdef>unsigned int <parameter>first_type</parameter></paramdef> 540 <paramdef>unsigned int <parameter>num_types</parameter></paramdef> 541 <paramdef>XkbDescPtr <parameter>xkb</parameter></paramdef> 542 </funcprototype> 543</funcsynopsis> 544<variablelist> 545 <varlistentry> 546 <term> 547 <parameter>dpy</parameter> 548 </term> 549 <listitem> 550 <para> 551 connection to the X server 552 </para> 553 </listitem> 554 </varlistentry> 555 <varlistentry> 556 <term> 557 <parameter>which</parameter> 558 </term> 559 <listitem> 560 <para> 561 mask of names or map components to be changed 562 </para> 563 </listitem> 564 </varlistentry> 565 <varlistentry> 566 <term> 567 <parameter>first_type</parameter> 568 </term> 569 <listitem> 570 <para> 571 first type whose name is to be changed 572 </para> 573 </listitem> 574 </varlistentry> 575 <varlistentry> 576 <term> 577 <parameter>num_types</parameter> 578 </term> 579 <listitem> 580 <para> 581 number of types for which names are to be changed 582 </para> 583 </listitem> 584 </varlistentry> 585 <varlistentry> 586 <term> 587 <parameter>xkb</parameter> 588 </term> 589 <listitem> 590 <para> 591 keyboard description from which names are to be taken 592 </para> 593 </listitem> 594 </varlistentry> 595</variablelist> 596 597<para> 598Use 599<function>XkbSetNames</function> 600to change many names at the same time. For each bit set in 601<parameter>which</parameter>, 602<function>XkbSetNames</function> 603takes the corresponding value (or values in the case of arrays) from the 604keyboard description 605<parameter>xkb</parameter> 606and sends it to the server. 607</para> 608 609 610<para> 611The 612<parameter>first_type</parameter> 613and 614<parameter>num_types</parameter> 615arguments are used only if 616<symbol>XkbKeyTypeNamesMask</symbol> 617or 618<symbol>XkbKTLevelNamesMask</symbol> 619is set in 620<parameter>which</parameter> 621and specify a subset of the types for which the corresponding names are to be 622changed. If either or both of these mask bits are set but the specified types 623are illegal, 624<function>XkbSetNames</function> 625returns 626<symbol>False</symbol> 627and does not update any of the names specified in 628<parameter>which</parameter>. 629The specified types are illegal if 630<parameter>xkb</parameter> 631does not include a map component or if 632<parameter>first_type</parameter> 633and 634<parameter>num_types</parameter> 635specify types that are not defined in the keyboard description. 636</para> 637 638 639<sect2> 640<title/> 641 642<sect3 id='The_XkbNameChangesRec_Structure'> 643<title>The XkbNameChangesRec Structure</title> 644<indexterm significance="preferred" zone="The_XkbNameChangesRec_Structure"> 645<primary><structname>XkbNameChangesRec</structname></primary></indexterm> 646 647<para> 648The 649<structname>XkbNameChangesRec</structname> 650allows applications to identify small modifications to the symbolic names and 651effectively reduces the amount of traffic sent to the server: 652 653<programlisting> 654typedef struct _XkbNameChanges { 655 unsigned int changed; /* name components that have 656 changed */ 657 unsigned char first_type; /* first key type with a new name */ 658 unsigned char num_types; /* number of types with new names */ 659 unsigned char first_lvl; /* first key type with new level 660 names */ 661 unsigned char num_lvls; /* number of key types with new 662 level names */ 663 unsigned char num_aliases; /* if key aliases changed, 664 total number of key aliases */ 665 unsigned char num_rg; /* if radio groups changed, total 666 number of radio groups */ 667 unsigned char first_key; /* first key with a new name */ 668 unsigned char num_keys; /* number of keys with new names */ 669 unsigned short changed_vmods; /* mask of virtual modifiers 670 for which names have changed */ 671 unsigned long changed_indicators; /* mask of indicators 672 for which names were changed */ 673 unsigned char changed_groups; /* mask of groups for 674 which names were changed */ 675} <structname>XkbNameChangesRec</structname>, *XkbNameChangesPtr; 676</programlisting></para> 677 678<para> 679The 680<structfield>changed</structfield> 681field specifies the name components that have changed and is the bitwise 682inclusive OR of the valid names mask bits defined in 683<link linkend="table18.1">Table 18.1</link>. The rest of 684the fields in the structure specify the ranges that have changed for the 685various kinds of symbolic names, as shown in 686<link linkend="table18.2">Table 18.2</link>. 687</para> 688 689<table id='table18.2' frame='topbot'> 690<title>XkbNameChanges Fields</title> 691<?dbfo keep-together="always" ?> 692<tgroup cols='4' align='left' colsep='0' rowsep='0'> 693<colspec colname='c1' colwidth='2.0*'/> 694<colspec colname='c2' colwidth='1.0*'/> 695<colspec colname='c3' colwidth='1.0*'/> 696<colspec colname='c4' colwidth='2.0*'/> 697<thead> 698<row rowsep='1'> 699 <entry>Mask</entry> 700 <entry>Fields</entry> 701 <entry>Component</entry> 702 <entry>Field</entry> 703</row> 704</thead> 705<tbody> 706<row> 707 <entry><symbol>XkbKeyTypeNamesMask</symbol></entry> 708 <entry> 709<para>first_type,</para> 710<para>num_types</para> 711 </entry> 712 <entry>Xkb->map</entry> 713 <entry>type[*].name</entry> 714</row> 715<row> 716 <entry><symbol>XkbKTLevelNamesMask</symbol></entry> 717 <entry> 718<para>first_lvl,</para> 719<para>num_lvls</para> 720 </entry> 721 <entry>Xkb->map</entry> 722 <entry>type[*].lvl_names[*]</entry> 723</row> 724<row> 725 <entry><symbol>XkbKeyAliasesMask</symbol></entry> 726 <entry>num_aliases</entry> 727 <entry>Xkb->names</entry> 728 <entry>key_aliases[*]</entry> 729</row> 730<row> 731 <entry><symbol>XkbRGNamesMask</symbol></entry> 732 <entry>num_rg</entry> 733 <entry>Xkb->names</entry> 734 <entry>radio_groups[*]</entry> 735</row> 736<row> 737 <entry><symbol>XkbKeyNamesMask</symbol></entry> 738 <entry> 739<para>first_key,</para> 740<para>num_keys</para> 741 </entry> 742 <entry>Xkb->names</entry> 743 <entry>keys[*]</entry> 744</row> 745<row> 746 <entry><symbol>XkbVirtualModNamesMask</symbol></entry> 747 <entry>changed_vmods</entry> 748 <entry>Xkb->names</entry> 749 <entry>vmods[*]</entry> 750</row> 751<row> 752 <entry><symbol>XkbIndicatorNamesMask</symbol></entry> 753 <entry>changed_indicators</entry> 754 <entry>Xkb->names</entry> 755 <entry>indicators[*]</entry> 756</row> 757<row> 758 <entry><symbol>XkbGroupNamesMask</symbol></entry> 759 <entry>changed_groups</entry> 760 <entry>Xkb->names</entry> 761 <entry>groups[*]</entry> 762 </row> 763</tbody> 764</tgroup> 765</table> 766 767<para> 768<function>XkbChangeNames</function> 769provides a more flexible method for changing symbolic names than 770<function>XkbSetNames</function> 771and requires the use of an 772<structname>XkbNameChangesRec</structname> 773structure. 774</para> 775 776<indexterm significance="preferred" zone="XkbChangeNames"><primary><function>XkbChangeNames</function></primary></indexterm> 777<funcsynopsis id="XkbChangeNames"> 778 <funcprototype> 779 <funcdef>Bool <function>XkbChangeNames</function></funcdef> 780<!-- ( 781<parameter>dpy, xkb, changes</parameter> 782) --> 783 784 <paramdef>Display *<parameter>dpy</parameter></paramdef> 785 <paramdef>XkbDescPtr <parameter>xkb</parameter></paramdef> 786 <paramdef>XkbNameChangesPtr <parameter>changes</parameter></paramdef> 787 </funcprototype> 788</funcsynopsis> 789<variablelist> 790 <varlistentry> 791 <term> 792 <parameter>dpy</parameter> 793 </term> 794 <listitem> 795 <para> 796 connection to the X server 797 </para> 798 </listitem> 799 </varlistentry> 800 <varlistentry> 801 <term> 802 <parameter>xkb</parameter> 803 </term> 804 <listitem> 805 <para> 806 keyboard description from which names are to be taken 807 </para> 808 </listitem> 809 </varlistentry> 810 <varlistentry> 811 <term> 812 <parameter>changes</parameter> 813 </term> 814 <listitem> 815 <para> 816 names map components to be updated on the server 817 </para> 818 </listitem> 819 </varlistentry> 820</variablelist> 821 822<para> 823<function>XkbChangeNames</function> 824copies any names specified by 825<parameter>changes</parameter> 826from the keyboard description, 827<parameter>xkb</parameter>, 828to the X server specified by 829<parameter>dpy</parameter>. 830<function>XkbChangeNames</function> 831aborts and returns 832<symbol>False</symbol> 833if any illegal type names or type shift level names are specified by 834<parameter>changes</parameter>. 835</para> 836 837</sect3> 838</sect2> 839</sect1> 840<sect1 id='Tracking_Name_Changes'> 841<title>Tracking Name Changes</title> 842<indexterm significance="preferred" zone="Tracking_Name_Changes"> 843<primary>events</primary><secondary><symbol>XkbNamesNotify</symbol></secondary></indexterm> 844<indexterm significance="preferred" zone="Tracking_Name_Changes"> 845<primary><structname>XkbNamesNotifyEvent</structname></primary></indexterm> 846 847<para> 848Whenever a symbolic name changes in the server’s keyboard description, the 849server sends a 850<symbol>XkbNamesNotify</symbol> 851event to all interested clients. To receive name notify events, use 852<function>XkbSelectEvents</function> 853(see <link linkend="Selecting_Xkb_Events">section 4.3</link>) with 854<symbol>XkbNamesNotifyMask</symbol> 855in both the 856<parameter>bits_to_change</parameter> 857and 858<parameter>values_for_bits</parameter> 859parameters. 860</para> 861 862 863<para> 864To receive events for only specific names, use 865<function>XkbSelectEventDetails</function>. 866Set the 867<structfield>event_type</structfield> 868parameter to 869<symbol>XkbNamesNotify</symbol>, 870and set both the 871<parameter>bits_to_change</parameter> 872and 873<parameter>values_for_bits</parameter> 874detail parameter to a mask composed of a bitwise OR of masks in 875<link linkend="table18.1">Table 18.1</link>. 876</para> 877 878 879<para> 880The structure for the 881<symbol>XkbNamesNotify</symbol> 882event is defined as follows: 883 884<programlisting> 885typedef struct { 886 int type; /* Xkb extension base event code */ 887 unsigned long serial; /* X server serial number for event */ 888 Bool send_event; /* <symbol>True</symbol> ⇒ synthetically generated */ 889 Display * display; /* server connection where event generated */ 890 Time time; /* server time when event generated */ 891 int xkb_type; /* <symbol>XkbNamesNotify</symbol> */ 892 int device; /* Xkb device ID, will not be 893 <symbol>XkbUseCoreKbd</symbol> */ 894 unsigned int changed; /* mask of name components 895 that have changed */ 896 int first_type; /* first key type with a new name */ 897 int num_types; /* number of types with new names */ 898 int first_lvl; /* first key type with new level names */ 899 int num_lvls; /* number of key types with new level names */ 900 int num_aliases; /* if key aliases changed, total number 901 of key aliases */ 902 int num_radio_groups; /* if radio groups changed, 903 total number of radio groups */ 904 unsigned int changed_vmods; /* mask of virtual modifiers for 905 which names have changed */ 906 unsigned int changed_groups; /* mask of groups for 907 which names were changed */ 908 unsigned int changed_indicators; /* mask of indicators for which 909 names were changed */ 910 int first_key; /* first key with a new name */ 911 int num_keys; /* number of keys with new names */ 912} <structname>XkbNamesNotifyEvent</structname>; 913</programlisting></para> 914 915<para> 916The 917<structfield>changed</structfield> 918field specifies the name components that have changed and is the bitwise 919inclusive OR of the valid names mask bits defined in 920<link linkend="table18.1">Table 18.1</link>. The other 921fields in this event are interpreted as the like-named fields in an 922<structname>XkbNameChangesRec</structname> , as previously defined. 923</para> 924 925 926<para> 927When your application receives a 928<symbol>XkbNamesNotify</symbol> 929event, you can note the changed names in a changes structure using 930<function>XkbNoteNameChanges</function>. 931</para> 932 933<indexterm significance="preferred" zone="XkbNoteNameChanges"><primary><function>XkbNoteNameChanges</function></primary></indexterm> 934<funcsynopsis id="XkbNoteNameChanges"> 935 <funcprototype> 936 <funcdef>void <function>XkbNoteNameChanges</function></funcdef> 937<!-- ( 938<parameter>old</parameter>, 939<parameter>new</parameter>, 940<parameter>wanted</parameter> 941) --> 942 943 <paramdef>XkbNameChangesPtr <parameter>old</parameter></paramdef> 944 <paramdef>XkbNamesNotifyEvent *<parameter>new</parameter></paramdef> 945 <paramdef>unsigned int <parameter>wanted</parameter></paramdef> 946 </funcprototype> 947</funcsynopsis> 948<variablelist> 949 <varlistentry> 950 <term> 951 <parameter>old</parameter> 952 </term> 953 <listitem> 954 <para> 955 <structname>XkbNameChangesRec</structname> structure to be updated 956 </para> 957 </listitem> 958 </varlistentry> 959 <varlistentry> 960 <term> 961 <parameter>new</parameter> 962 </term> 963 <listitem> 964 <para> 965 event from which changes are to be copied 966 </para> 967 </listitem> 968 </varlistentry> 969 <varlistentry> 970 <term> 971 <parameter>wanted</parameter> 972 </term> 973 <listitem> 974 <para> 975 types of names for which changes are to be noted 976 </para> 977 </listitem> 978 </varlistentry> 979</variablelist> 980 981<para> 982The 983<parameter>wanted</parameter> 984parameter is the bitwise inclusive OR of the valid names mask bits shown in 985<link linkend="table18.1">Table 18.1</link>. 986<function>XkbNoteNameChanges</function> 987copies any changes that are reported in 988<parameter>new</parameter> 989and specified in 990<parameter>wanted</parameter> 991into the changes record specified by 992<parameter>old</parameter>. 993</para> 994 995 996</sect1> 997<sect1 id='Allocating_and_Freeing_Symbolic_Names'> 998<title>Allocating and Freeing Symbolic Names</title> 999 1000<para> 1001Most applications do not need to directly allocate symbolic names structures. 1002Do not allocate a names structure directly using 1003<function>malloc</function> 1004or 1005<function>Xmalloc</function> 1006if your application changes the number of key aliases or radio groups or 1007constructs a symbolic names structure without loading the necessary components 1008from the X server. Instead use 1009<function>XkbAllocNames</function>. 1010</para> 1011 1012<indexterm significance="preferred" zone="XkbAllocNames"><primary><function>XkbAllocNames</function></primary></indexterm> 1013<funcsynopsis id="XkbAllocNames"> 1014 <funcprototype> 1015 <funcdef>Status <function>XkbAllocNames</function></funcdef> 1016<!-- ( 1017<parameter>xkb, which, num_rg, num_key_aliases)</parameter> --> 1018 1019 <paramdef>XkbDescPtr <parameter>xkb</parameter></paramdef> 1020 <paramdef>unsigned int <parameter>which</parameter></paramdef> 1021 <paramdef>int <parameter>num_rg</parameter></paramdef> 1022 <paramdef>int <parameter>num_key_aliases</parameter></paramdef> 1023 </funcprototype> 1024</funcsynopsis> 1025<variablelist> 1026 <varlistentry> 1027 <term> 1028 <parameter>xkb</parameter> 1029 </term> 1030 <listitem> 1031 <para> 1032 keyboard description for which names are to be allocated 1033 </para> 1034 </listitem> 1035 </varlistentry> 1036 <varlistentry> 1037 <term> 1038 <parameter>which</parameter> 1039 </term> 1040 <listitem> 1041 <para> 1042 mask of names to be allocated 1043 </para> 1044 </listitem> 1045 </varlistentry> 1046 <varlistentry> 1047 <term> 1048 <parameter>num_rg</parameter> 1049 </term> 1050 <listitem> 1051 <para> 1052 total number of radio group names needed 1053 </para> 1054 </listitem> 1055 </varlistentry> 1056 <varlistentry> 1057 <term> 1058 <parameter>num_key_aliases</parameter> 1059 </term> 1060 <listitem> 1061 <para> 1062 total number of key aliases needed 1063 </para> 1064 </listitem> 1065 </varlistentry> 1066</variablelist> 1067 1068<para> 1069<function>XkbAllocNames</function> 1070can return 1071<errorname>BadAlloc</errorname>, 1072<errorname>BadMatch</errorname>, 1073and 1074<errorname>BadValue</errorname> 1075errors. 1076The 1077<parameter>which</parameter> 1078parameter is the bitwise inclusive OR of the valid names mask bits defined in 1079<link linkend="table18.1">Table 18.1</link>. 1080</para> 1081 1082 1083<para> 1084Do not free symbolic names structures directly using 1085<function>free</function> 1086or 1087<function>XFree</function>. 1088Use 1089<function>XkbFreeNames</function> 1090instead. 1091</para> 1092 1093 1094<indexterm significance="preferred" zone="XkbFreeNames"><primary><function>XkbFreeNames</function></primary></indexterm> 1095<funcsynopsis id="XkbFreeNames"> 1096 <funcprototype> 1097 <funcdef>void <function>XkbFreeNames</function></funcdef> 1098<!-- ( 1099<parameter>xkb, which, free_map)</parameter> --> 1100 1101 <paramdef>XkbDescPtr <parameter>xkb</parameter></paramdef> 1102 <paramdef>unsigned int <parameter>which</parameter></paramdef> 1103 <paramdef>Bool <parameter>free_map</parameter></paramdef> 1104 </funcprototype> 1105</funcsynopsis> 1106<variablelist> 1107 <varlistentry> 1108 <term> 1109 <parameter>xkb</parameter> 1110 </term> 1111 <listitem> 1112 <para> 1113 keyboard description for which names are to be freed 1114 </para> 1115 </listitem> 1116 </varlistentry> 1117 <varlistentry> 1118 <term> 1119 <parameter>which</parameter> 1120 </term> 1121 <listitem> 1122 <para> 1123 mask of names components to be freed 1124 </para> 1125 </listitem> 1126 </varlistentry> 1127 <varlistentry> 1128 <term> 1129 <parameter>free_map</parameter> 1130 </term> 1131 <listitem> 1132 <para> 1133 <symbol>True</symbol> 1134 ⇒ XkbNamesRec structure itself should be freed 1135 </para> 1136 </listitem> 1137 </varlistentry> 1138</variablelist> 1139 1140<para> 1141The 1142<parameter>which</parameter> 1143parameter is the bitwise inclusive OR of the valid names mask bits defined in 1144<link linkend="table18.1">Table 18.1</link>. 1145</para> 1146</sect1> 1147</chapter> 1148