ch12.xml revision 0f8248bf
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='Interpreting_Key_Events'> 5<title>Interpreting Key Events</title> 6 7<para> 8Xkb provides functions to help developers interpret key events without having 9to directly interpret Xkb data structures. Xkb also modifies the behavior of 10several core X library functions. 11</para> 12 13<sect1 id='Effects_of_Xkb_on_the_Core_X_Library'> 14<title>Effects of Xkb on the Core X Library</title> 15 16<para> 17When support for Xkb is built into the X library, the 18<function>XOpenDisplay</function> 19function looks for a compatible version of Xkb on the server. If it finds a 20compatible version, it initializes the extension and enables 21<firstterm>implicit support</firstterm> 22for Xkb in a number of X library functions. This makes it possible for clients 23to take advantage of nearly all Xkb features without having to be rewritten or 24even recompiled, if they are built with shared libraries. This implicit support 25is invisible to most clients, but it can have side effects, so the extension 26includes ways to control or disable it. 27</para> 28 29 30<sect2 id='Effects_of_Xkb_on_Event_State'> 31<title>Effects of Xkb on Event State</title> 32 33<para> 34Because 35<function>XOpenDisplay</function> 36initializes Xkb, some events contain an Xkb description of the keyboard state 37instead of that normally used by the core protocol. See <link linkend="Xkb_State_to_Core_Protocol_State_Transformation">section 17.1.1</link> for more 38information about the differences between Xkb keyboard state and that reported 39by the core protocol. 40</para> 41 42 43</sect2> 44<sect2 id='Effects_of_Xkb_on_MappingNotify_Events'> 45<title>Effects of Xkb on MappingNotify Events</title> 46 47<indexterm zone="Effects_of_Xkb_on_MappingNotify_Events"> 48<primary>events</primary><secondary><symbol>MappingNotify</symbol></secondary></indexterm> 49 50<para> 51When Xkb is missing or disabled, the X library tracks changes to the keyboard 52mapping using 53<symbol>MappingNotify</symbol> 54events. Whenever the keyboard mapping is changed, the server sends all clients 55a 56<symbol>MappingNotify</symbol> 57event to report the change. When a client receives a 58<symbol>MappingNotify</symbol> 59event, it is supposed to call 60<function>XRefreshKeyboardMapping</function> 61to update the keyboard description used internally by the X library. 62</para> 63 64 65<para> 66The X Keyboard Extension uses 67<symbol>XkbMapNotify</symbol> 68and 69<symbol>XkbNewKeyboardNotify</symbol> 70events to track changes to the keyboard mapping. When an Xkb-aware client 71receives either event, it should call 72<function>XkbRefreshKeyboardMapping</function> 73to update the keyboard description used internally by the X library. To avoid 74duplicate events, the X server does not send core protocol 75<symbol>MappingNotify</symbol> 76events to a client that has selected for 77<symbol>XkbMapNotify</symbol> 78events. 79</para> 80 81 82<para> 83The implicit support for Xkb selects for 84<symbol>XkbMapNotify</symbol> 85events. This means that clients that do not explicitly use Xkb but that are 86using a version of the X library that has implicit support for Xkb do not 87receive 88<symbol>MappingNotify</symbol> 89events over the wire. Clients that were not written with Xkb in mind do not 90recognize or properly handle the new Xkb events, so the implicit support 91converts them to 92<symbol>MappingNotify</symbol> 93events that report approximately the same information, unless the client has 94explicitly selected for the Xkb version of the event. 95</para> 96 97 98<para> 99An Xkb-capable X server does not send events from keys that fall outside the 100legal range of keycodes expected by that client. Once the server sends a client 101an 102<symbol>XkbNewKeyboardNotify</symbol> 103event, it reports events from all keys because it assumes that any client that 104has received an 105<symbol>XkbNewKeyboardNotify</symbol> 106event expects key events from the new range of keycodes. The implicit support 107for Xkb asks for 108<symbol>XkbNewKeyboardNotify</symbol> 109events, so the range of keycodes reported to the client might vary without the 110client’s knowledge. Most clients don’t really care about the range of legal 111keycodes, but some clients maintain information about each key and might have 112problems with events that come from unexpected keys. Such clients can set the 113<symbol>XkbLC_IgnoreNewKeyboards</symbol> 114library control (see <link linkend="IgnoreNewKeyboards">section 11.3.1</link>) to prevent the implicit support from 115requesting notification of changes to the legal range of keycodes. 116</para> 117 118 119</sect2> 120<sect2 id='X_Library_Functions_Affected_by_Xkb'> 121<title>X Library Functions Affected by Xkb</title> 122 123<para> 124The following X library functions are modified by Xkb: 125 126 <simplelist type='vert' columns='1'> 127 <member><function>XKeycodeToKeysym</function></member> 128 <member><function>XKeysymToKeycode</function></member> 129 <member><function>XLookupKeysym</function></member> 130 <member><function>XLookupString</function></member> 131 <member><function>XRefreshKeyboardMapping</function></member> 132 <member><function>XRebindKeysym</function></member> 133 </simplelist> 134</para> 135 136<para> 137The implicit support for Xkb replaces a number of X library functions with 138versions that understand and use the X Keyboard Extension. In most cases, the 139semantics of the new versions are identical to those of the old, but there are 140occasional visible differences. This section lists all of the functions that 141are affected and the differences in behavior, if any, that are visible to 142clients. 143</para> 144 145 146<para id='XKeycodeToKeysym'> 147The 148<olink targetdoc='libX11' targetptr='XKeycodeToKeysym'><function>XKeycodeToKeysym</function></olink> 149<indexterm significance="preferred" zone="XKeycodeToKeysym"><primary><function>XKeycodeToKeysym</function></primary></indexterm> 150function reports the keysym associated with a particular index for a single 151key. The index specifies a column of symbols in the core keyboard mapping (that 152is, as reported by the core protocol 153<systemitem>GetKeyboardMapping</systemitem> 154request). The order of the symbols in the core mapping does not necessarily 155correspond to the order of the symbols used by Xkb; <link linkend="Xkb_Keyboard_Mapping_to_Core_Keyboard_Mapping_Transformations">section 17.1.3</link> describes 156the differences. 157</para> 158 159 160<para id='XKeysymToKeycode'> 161The 162<olink targetdoc='libX11' targetptr='XKeysymToKeycode'><function>XKeysymToKeycode</function></olink> 163<indexterm significance="preferred" zone="XKeysymToKeycode"><primary><function>XKeysymToKeycode</function></primary></indexterm> 164function reports a keycode to which a particular keysym is bound. When Xkb is 165missing or disabled, this function looks in each column of the core keyboard 166mapping in turn and returns the lowest numbered key that matches in the lowest 167numbered group. When Xkb is present, this function uses the Xkb ordering for 168symbols instead. 169</para> 170 171 172<para id='XLookupKeysym'> 173The 174<olink targetdoc='libX11' targetptr='XLookupKeysym'><function>XLookupKeysym</function></olink> 175<indexterm significance="preferred" zone="XLookupKeysym"><primary><function>XLookupKeysym</function></primary></indexterm> 176function reports the symbol in a specific column of the key associated with an 177event. Whether or not Xkb is present, the column specifies an index into the 178core symbol mapping. 179</para> 180 181 182<para id='XLookupString'> 183The 184<olink targetdoc='libX11' targetptr='XLookupString'><function>XLookupString</function></olink> 185<indexterm significance="preferred" zone="XLookupString"><primary><function>XLookupString</function></primary></indexterm> 186function reports the symbol and string associated with a key event, taking 187into account the keycode and keyboard state as reported in the event. When Xkb 188is disabled or missing, 189<function>XLookupString</function> 190uses the rules specified by the core protocol and reports only ISO Latin-1 191characters. When Xkb is present, 192<function>XLookupString</function> 193uses the explicit keyboard group, key types, and rules specified by Xkb. When 194Xkb is present, 195<function>XLookupString</function> 196is allowed, but not required, to return strings in character sets other than 197ISO Latin-1, depending on the current locale. If any key bindings are defined, 198<function>XLookupString</function> 199does not use any consumed modifiers (see <link linkend="ConsumeLookupMods">section 11.1.2</link> and <link linkend="Key_Types">section 15.2</link>) to 200determine matching bindings. 201</para> 202 203 204<para id='XRefreshKeyboardMapping'> 205The 206<olink targetdoc='libX11' targetptr='XRefreshKeyboardMapping'><function>XRefreshKeyboardMapping</function></olink> 207<indexterm significance="preferred" zone="XRefreshKeyboardMapping"><primary><function>XRefreshKeyboardMapping</function></primary></indexterm> 208function updates the X library’s internal representation of the keyboard to 209reflect changes reported via 210<symbol>MappingNotify</symbol> 211events. When Xkb is missing or disabled, this function reloads the entire 212modifier map or keyboard mapping. When Xkb is present, the implicit Xkb support 213keeps track of the changed components reported by each 214<symbol>XkbMapNotify</symbol> 215event and updates only those pieces of the keyboard description that have 216changed. If the implicit support has not noted any keyboard mapping changes, 217<function>XRefreshKeyboardMapping</function> 218updates the entire keyboard description. 219</para> 220 221 222<para id='XRebindKeysym'> 223The 224<olink targetdoc='libX11' targetptr='XRebindKeysym'><function>XRebindKeysym</function></olink> 225<indexterm significance="preferred" zone="XRebindKeysym"><primary><function>XRebindKeysym</function></primary></indexterm> 226function associates a string with a keysym and a set of modifiers. Xkb does 227not directly change this function, but it does affect the way that the state 228reported in the event is compared to the state specified to 229<function>XRebindKeysym</function>. 230When Xkb is missing or disabled, 231<function>XLookupString</function> 232returns the specified string if the modifiers in the event exactly match the 233modifiers from this call. When Xkb is present, any modifiers used to determine 234the keysym are consumed and are not used to look up the string. 235</para> 236 237 238</sect2> 239</sect1> 240<sect1 id='Xkb_Event_and_Keymap_Functions'> 241<title>Xkb Event and Keymap Functions</title> 242 243<para> 244To find the keysym bound to a particular key at a specified group and shift 245level, use <function>XkbKeycodeToKeysym</function>. 246</para> 247 248<indexterm significance="preferred" zone="XkbKeycodeToKeysym"><primary><function>XkbKeycodeToKeysym</function></primary></indexterm> 249<funcsynopsis id="XkbKeycodeToKeysym"> 250 <funcprototype> 251 <funcdef>KeySym <function>XkbKeycodeToKeysym</function></funcdef> 252<!-- ( 253<parameter>dpy, kc, group, level</parameter> 254) --> 255 256 <paramdef>Display *<parameter>dpy</parameter></paramdef> 257 <paramdef>KeyCode <parameter>kc</parameter></paramdef> 258 <paramdef>unsigned int <parameter>group</parameter></paramdef> 259 <paramdef>unsigned int <parameter>level</parameter></paramdef> 260 </funcprototype> 261</funcsynopsis> 262<variablelist> 263 <varlistentry> 264 <term> 265 <parameter>dpy</parameter> 266 </term> 267 <listitem> 268 <para> 269 connection to X server 270 </para> 271 </listitem> 272 </varlistentry> 273 <varlistentry> 274 <term> 275 <parameter>kc</parameter> 276 </term> 277 <listitem> 278 <para> 279 key of interest 280 </para> 281 </listitem> 282 </varlistentry> 283 <varlistentry> 284 <term> 285 <parameter>group</parameter> 286 </term> 287 <listitem> 288 <para> 289 group of interest 290 </para> 291 </listitem> 292 </varlistentry> 293 <varlistentry> 294 <term> 295 <parameter>level</parameter> 296 </term> 297 <listitem> 298 <para> 299 shift level of interest 300 </para> 301 </listitem> 302 </varlistentry> 303</variablelist> 304 305<para> 306<function>XkbKeycodeToKeysym</function> 307returns the keysym bound to a particular group and shift level for a 308particular key on the core keyboard. If 309<parameter>kc</parameter> 310is not a legal keycode for the core keyboard, or if 311<parameter>group</parameter> 312or 313<parameter>level</parameter> 314are out of range for the specified key, 315<function>XkbKeycodeToKeysym</function> 316returns 317<symbol>NoSymbol</symbol>. 318</para> 319 320 321<para> 322To find the set of modifiers bound to a particular keysym on the core keyboard, 323use 324<function>XkbKeysymToModifiers</function>. 325</para> 326 327 328<indexterm significance="preferred" zone="XkbKeysymToModifiers"><primary><function>XkbKeysymToModifiers</function></primary></indexterm> 329<funcsynopsis id="XkbKeysymToModifiers"> 330 <funcprototype> 331 <funcdef>unsigned int <function>XkbKeysymToModifiers</function></funcdef> 332<!-- ( 333<parameter>dpy</parameter>, 334<parameter>ks</parameter> 335) --> 336 337 <paramdef>Display *<parameter>dpy</parameter></paramdef> 338 <paramdef>KeySym <parameter>ks</parameter></paramdef> 339 </funcprototype> 340</funcsynopsis> 341<variablelist> 342 <varlistentry> 343 <term> 344 <parameter>dpy</parameter> 345 </term> 346 <listitem> 347 <para> 348 connection to X server 349 </para> 350 </listitem> 351 </varlistentry> 352 <varlistentry> 353 <term> 354 <parameter>ks</parameter> 355 </term> 356 <listitem> 357 <para> 358 keysym of interest 359 </para> 360 </listitem> 361 </varlistentry> 362</variablelist> 363 364<para> 365<function>XkbKeysymToModifiers</function> 366finds the set of modifiers currently bound to the keysym 367<parameter>ks</parameter> 368on the core keyboard. The value returned is the mask of modifiers bound to the 369keysym 370<parameter>ks</parameter>. 371If no modifiers are bound to the keysym, 372<function>XkbKeysymToModifiers</function> 373returns zero; otherwise, it returns the inclusive OR of zero or more of the 374following: 375<symbol>ShiftMask</symbol>, 376<symbol>ControlMask</symbol>, 377<symbol>LockMask</symbol>, 378<symbol>Mod1Mask</symbol>, 379<symbol>Mod2Mask</symbol>, 380<symbol>Mod3Mask</symbol>, 381<symbol>Mod4Mask</symbol>, 382and 383<symbol>Mod5Mask</symbol>. 384</para> 385 386 387<para> 388Use 389<function>XkbLookupKeySym</function> 390to find the symbol associated with a key for a particular state. 391</para> 392 393 394<indexterm significance="preferred" zone="XkbLookupKeySym"><primary><function>XkbLookupKeySym</function></primary></indexterm> 395<funcsynopsis id="XkbLookupKeySym"> 396 <funcprototype> 397 <funcdef>Bool <function>XkbLookupKeySym</function></funcdef> 398<!-- ( 399<parameter>dpy</parameter>, 400<parameter>key</parameter>, 401<parameter>state</parameter>, 402<parameter>mods_rtrn</parameter>, 403<parameter>sym_rtrn</parameter> 404) --> 405 406 <paramdef>Display *<parameter>dpy</parameter></paramdef> 407 <paramdef>KeyCode <parameter>key</parameter></paramdef> 408 <paramdef>unsigned int <parameter>state</parameter></paramdef> 409 <paramdef>unsigned int *<parameter>mods_rtrn</parameter></paramdef> 410 <paramdef>KeySym *<parameter>sym_rtrn</parameter></paramdef> 411 </funcprototype> 412</funcsynopsis> 413<variablelist> 414 <varlistentry> 415 <term> 416 <parameter>dpy</parameter> 417 </term> 418 <listitem> 419 <para> 420 connection to X server 421 </para> 422 </listitem> 423 </varlistentry> 424 <varlistentry> 425 <term> 426 <parameter>key</parameter> 427 </term> 428 <listitem> 429 <para> 430 key for which symbols are to be found 431 </para> 432 </listitem> 433 </varlistentry> 434 <varlistentry> 435 <term> 436 <parameter>state</parameter> 437 </term> 438 <listitem> 439 <para> 440 state for which symbol should be found 441 </para> 442 </listitem> 443 </varlistentry> 444 <varlistentry> 445 <term> 446 <parameter>mods_rtrn</parameter> 447 </term> 448 <listitem> 449 <para> 450 backfilled with consumed modifiers 451 </para> 452 </listitem> 453 </varlistentry> 454 <varlistentry> 455 <term> 456 <parameter>sym_rtrn</parameter> 457 </term> 458 <listitem> 459 <para> 460 backfilled with symbol associated with key + state 461 </para> 462 </listitem> 463 </varlistentry> 464</variablelist> 465 466<para> 467<function>XkbLookupKeySym</function> 468is the equivalent of the core 469<symbol>XLookupKeySym</symbol> 470function. For the core keyboard, given a keycode 471<parameter>key</parameter> 472and an Xkb state 473<parameter>state</parameter>, 474<function>XkbLookupKeySym</function> 475returns the symbol associated with the key in 476<parameter>sym_rtrn</parameter> 477and the list of modifiers that should still be applied in 478<parameter>mods_rtrn</parameter>. 479The 480<parameter>state</parameter> 481parameter is the state from a 482<symbol>KeyPress</symbol> 483or 484<symbol>KeyRelease</symbol> 485event. 486<function>XkbLookupKeySym</function> 487returns 488<symbol>True</symbol> 489if it succeeds. 490</para> 491 492 493<para> 494Use 495<function>XkbLookupKeyBinding</function> 496to find the string bound to a key by 497<function>XRebindKeysym</function>. 498<function>XkbLookupKeyBinding</function> 499is the equivalent of the core 500<function>XLookupString</function> 501function. 502</para> 503 504 505<indexterm significance="preferred" zone="XkbLookupKeyBinding"><primary><function>XkbLookupKeyBinding</function></primary></indexterm> 506<funcsynopsis id="XkbLookupKeyBinding"> 507 <funcprototype> 508 <funcdef>int <function>XkbLookupKeyBinding</function></funcdef> 509<!-- ( 510<parameter>dpy</parameter>, 511<parameter>sym</parameter>, 512<parameter>state</parameter>, 513<parameter>buf</parameter>, 514<parameter>nbytes</parameter>, 515<parameter>extra_rtrn</parameter> 516) --> 517 518 <paramdef>Display *<parameter>dpy</parameter></paramdef> 519 <paramdef>KeySym <parameter>sym</parameter></paramdef> 520 <paramdef>unsigned int <parameter>state</parameter></paramdef> 521 <paramdef>char *<parameter>buf</parameter></paramdef> 522 <paramdef>int <parameter>nbytes</parameter></paramdef> 523 <paramdef>int *<parameter>extra_rtrn</parameter></paramdef> 524 </funcprototype> 525</funcsynopsis> 526<variablelist> 527 <varlistentry> 528 <term> 529 <parameter>dpy</parameter> 530 </term> 531 <listitem> 532 <para> 533 connection to server 534 </para> 535 </listitem> 536 </varlistentry> 537 <varlistentry> 538 <term> 539 <parameter>sym</parameter> 540 </term> 541 <listitem> 542 <para> 543 symbol to be looked up 544 </para> 545 </listitem> 546 </varlistentry> 547 <varlistentry> 548 <term> 549 <parameter>state</parameter> 550 </term> 551 <listitem> 552 <para> 553 state for which string is to be looked up 554 </para> 555 </listitem> 556 </varlistentry> 557 <varlistentry> 558 <term> 559 <parameter>buf</parameter> 560 </term> 561 <listitem> 562 <para> 563 buffer into which returned string is written 564 </para> 565 </listitem> 566 </varlistentry> 567 <varlistentry> 568 <term> 569 <parameter>nbytes</parameter> 570 </term> 571 <listitem> 572 <para> 573 size of buffer in bytes 574 </para> 575 </listitem> 576 </varlistentry> 577 <varlistentry> 578 <term> 579 <parameter>extra_rtrn</parameter> 580 </term> 581 <listitem> 582 <para> 583 backfilled with number bytes overflow 584 </para> 585 </listitem> 586 </varlistentry> 587</variablelist> 588 589<para> 590<function>XRebindKeysym</function> 591binds an ASCII string to a specified keysym, so that the string and keysym are 592returned when the key is pressed and a specified list of modifiers are also 593being held down. 594<function>XkbLookupKeyBinding</function> 595returns in 596<parameter>buf</parameter> 597the string associated with the keysym 598<parameter>sym</parameter> 599and modifier state 600<parameter>state</parameter>. 601<parameter>buf</parameter> 602is 603<symbol>NULL</symbol> 604terminated unless there’s an overflow. If the string returned is larger than 605<parameter>nbytes</parameter>, 606a count of bytes that does not fit into the buffer is returned in extra_rtrn. 607<function>XkbTranslateKeySym</function> 608returns the number of bytes that it placed into 609<parameter>buf</parameter>. 610</para> 611 612 613<para> 614To find the string and symbol associated with a keysym for a given keyboard 615state, use 616<function>XkbTranslateKeySym</function>. 617</para> 618 619 620<indexterm significance="preferred" zone="XkbTranslateKeySym"><primary><function>XkbTranslateKeySym</function></primary></indexterm> 621<funcsynopsis id="XkbTranslateKeySym"> 622 <funcprototype> 623 <funcdef>int <function>XkbTranslateKeySym</function></funcdef> 624<!-- ( 625<parameter>dpy</parameter>, 626<parameter>sym_inout</parameter>, 627<parameter>mods</parameter>, 628<parameter>buf</parameter>, 629<parameter>nbytes</parameter>, 630<parameter>extra_rtrn</parameter> 631) --> 632 633 <paramdef>Display *<parameter>dpy</parameter></paramdef> 634 <paramdef>KeySym *<parameter>sym_inout</parameter></paramdef> 635 <paramdef>unsigned int <parameter>mods</parameter></paramdef> 636 <paramdef>char *<parameter>buf</parameter></paramdef> 637 <paramdef>int <parameter>nbytes</parameter></paramdef> 638 <paramdef>int *<parameter>extra_rtrn</parameter></paramdef> 639 </funcprototype> 640</funcsynopsis> 641<variablelist> 642 <varlistentry> 643 <term> 644 <parameter>dpy</parameter> 645 </term> 646 <listitem> 647 <para> 648 connection to X server 649 </para> 650 </listitem> 651 </varlistentry> 652 <varlistentry> 653 <term> 654 <parameter>sym_inout</parameter> 655 </term> 656 <listitem> 657 <para> 658 symbol to be translated; result of translation 659 </para> 660 </listitem> 661 </varlistentry> 662 <varlistentry> 663 <term> 664 <parameter>mods</parameter> 665 </term> 666 <listitem> 667 <para> 668 modifiers to apply to <parameter>sym_inout</parameter> 669 </para> 670 </listitem> 671 </varlistentry> 672 <varlistentry> 673 <term> 674 <parameter>buf</parameter> 675 </term> 676 <listitem> 677 <para> 678 buffer into which returned string is written 679 </para> 680 </listitem> 681 </varlistentry> 682 <varlistentry> 683 <term> 684 <parameter>nbytes</parameter> 685 </term> 686 <listitem> 687 <para> 688 size of buffer in bytes 689 </para> 690 </listitem> 691 </varlistentry> 692 <varlistentry> 693 <term> 694 <parameter>extra_rtrn</parameter> 695 </term> 696 <listitem> 697 <para> 698 number of bytes overflow 699 </para> 700 </listitem> 701 </varlistentry> 702</variablelist> 703 704<para> 705<function>XkbTranslateKeySym</function> 706applies the transformations specified in 707<parameter>mods</parameter> 708to the symbol specified by 709<parameter>sym_inout</parameter>. 710It returns in 711<parameter>buf</parameter> 712the string, if any, associated with the keysym for the current locale. If the 713transformations in 714<parameter>mods</parameter> 715changes the keysym, 716<parameter>sym_inout</parameter> 717is updated accordingly. If the string returned is larger than 718<parameter>nbytes</parameter>, 719a count of bytes that does not fit into the buffer is returned in extra_rtrn. 720<function>XkbTranslateKeySym</function> 721returns the number of bytes it placed into 722<parameter>buf</parameter>. 723</para> 724 725 726<para> 727To update the keyboard description that is internal to the X library, use 728<function>XkbRefreshKeyboardMapping</function>. 729</para> 730 731 732<indexterm significance="preferred" zone="XkbRefreshKeyboardMapping"><primary><function>XkbRefreshKeyboardMapping</function></primary></indexterm> 733<funcsynopsis id="XkbRefreshKeyboardMapping"> 734 <funcprototype> 735 <funcdef>Status <function>XkbRefreshKeyboardMapping</function></funcdef> 736<!-- ( 737<parameter>event)</parameter> --> 738 739 <paramdef>XkbMapNotifyEvent *<parameter>event</parameter></paramdef> 740 </funcprototype> 741</funcsynopsis> 742<variablelist> 743 <varlistentry> 744 <term> 745 <parameter>event</parameter> 746 </term> 747 <listitem> 748 <para> 749 event initiating remapping 750 </para> 751 </listitem> 752 </varlistentry> 753</variablelist> 754 755<para> 756<function>XkbRefreshKeyboardMapping</function> 757is the Xkb equivalent of the core 758<function>XRefreshKeyboardMapping</function> 759function. It requests that the X server send the current key mapping 760information to this client. A client usually invokes 761<function>XkbRefreshKeyboardMapping</function> 762after receiving an 763<symbol>XkbMapNotify</symbol> 764event. 765<function>XkbRefreshKeyboardMapping</function> 766returns 767<symbol>Success</symbol> 768if it succeeds and 769<errorname>BadMatch</errorname> 770if the event is not an Xkb event. 771</para> 772 773 774<para> 775The 776<symbol>XkbMapNotify</symbol> 777event can be generated when some client calls 778<function>XkbSetMap</function>, 779<function>XkbChangeMap</function>, 780<function>XkbGetKeyboardByName</function>, 781or any of the standard X library functions that change the keyboard mapping 782or modifier mapping. 783</para> 784 785 786<para> 787To translate a keycode to a key symbol and modifiers, use 788<function>XkbTranslateKeyCode</function>. 789</para> 790 791 792<indexterm significance="preferred" zone="XkbTranslateKeyCode"><primary><function>XkbTranslateKeyCode</function></primary></indexterm> 793<funcsynopsis id="XkbTranslateKeyCode"> 794 <funcprototype> 795 <funcdef>Bool <function>XkbTranslateKeyCode</function></funcdef> 796<!-- ( 797<parameter>xkb, key, mods, mods_rtrn, keysym_rtrn)</parameter> --> 798 799 <paramdef>XkbDescPtr <parameter>xkb</parameter></paramdef> 800 <paramdef>KeyCode <parameter>key</parameter></paramdef> 801 <paramdef>unsigned int <parameter>mods</parameter></paramdef> 802 <paramdef>unsigned int *<parameter>mods_rtrn</parameter></paramdef> 803 <paramdef>KeySym *<parameter>keysym_rtrn</parameter></paramdef> 804 </funcprototype> 805</funcsynopsis> 806<variablelist> 807 <varlistentry> 808 <term> 809 <parameter>xkb</parameter> 810 </term> 811 <listitem> 812 <para> 813 keyboard description to use for translation 814 </para> 815 </listitem> 816 </varlistentry> 817 <varlistentry> 818 <term> 819 <parameter>key</parameter> 820 </term> 821 <listitem> 822 <para> 823 keycode to translate 824 </para> 825 </listitem> 826 </varlistentry> 827 <varlistentry> 828 <term> 829 <parameter>mods</parameter> 830 </term> 831 <listitem> 832 <para> 833 modifiers to apply when translating <parameter>key</parameter> 834 </para> 835 </listitem> 836 </varlistentry> 837 <varlistentry> 838 <term> 839 <parameter>mods_rtrn</parameter> 840 </term> 841 <listitem> 842 <para> 843 backfilled with consumed modifiers 844 </para> 845 </listitem> 846 </varlistentry> 847 <varlistentry> 848 <term> 849 <parameter>keysym_rtrn</parameter> 850 </term> 851 <listitem> 852 <para> 853 keysym resulting from translation 854 </para> 855 </listitem> 856 </varlistentry> 857</variablelist> 858 859<para> 860<parameter>mods_rtrn</parameter> 861is backfilled with the modifiers consumed by the translation process. 862<parameter>mods</parameter> 863is a bitwise inclusive OR of the legal modifier masks: 864<symbol>ShiftMask</symbol>, 865<symbol>LockMask</symbol>, 866<symbol>ControlMask</symbol>, 867<symbol>Mod1Mask</symbol>, 868<symbol>Mod2Mask</symbol>, 869<symbol>Mod3Mask</symbol>, 870<symbol>Mod4Mask</symbol>, 871<symbol>Mod5Mask</symbol>. 872The 873<emphasis>AlwaysConsumeShiftAndLock</emphasis> 874library control (see <link linkend="AlwaysConsumeShiftAndLock">section 11.1.3</link>), if enabled, causes 875<function>XkbTranslateKeyCode</function> 876to consume shift and lock. 877<function>XkbTranslateKeyCode</function> 878returns 879<symbol>True</symbol> 880if the translation resulted in a keysym, and 881<symbol>False</symbol> 882if it resulted in 883<symbol>NoSymbol</symbol>. 884</para> 885</sect1> 886</chapter> 887