1 <chapter id='Xkb_Keyboard_Mapping'>
2 <title>Xkb Keyboard Mapping</title>
5 The Xkb keyboard mapping contains all the information the server and clients
6 need to interpret key events. This chapter provides an overview of the
7 terminology used to describe an Xkb keyboard mapping and introduces common
8 utilities for manipulating the keyboard mapping.
13 The mapping consists of two components, a server map and a client map. The
16 map is the collection of information a client needs to interpret key events
17 from the keyboard. It contains a global list of key types and an array of key
18 symbol maps, each of which describes the symbols bound to a key and the rules
19 to be used to interpret those symbols. The <emphasis>
21 map contains the information the server needs to interpret key events. This
22 includes actions and behaviors for each key, explicit components for a key, and
23 the virtual modifiers and the per-key virtual modifier mapping.
28 For detailed information on particular components of the keyboard map, refer to
29 Chapter 15, "Xkb Client Keyboard Mapping" and Chapter 16, "Xkb Server Keyboard
33 <sect1 id='Notation_and_Terminology'>
34 <title>Notation and Terminology</title>
37 The graphic characters or control functions that may be accessed by one key are
38 logically arranged in groups and levels, where <emphasis>
42 are defined as in the ISO9995 standard:
50 A logical state of a keyboard providing access to a collection of
51 graphic characters. Usually these graphic characters logically belong together
52 and may be arranged on several levels within a group.
60 One of several states (normally 2 or 3) governing which graphic
61 character is produced when a graphic key is actuated. In certain cases the
62 level may also affect function keys.
69 These definitions, taken from the ISO standard, refer to graphic keys and
70 characters. In the context of Xkb, Group and Level are not constrained to
71 graphic keys and characters; they may be used with any key to access any
72 character the key is capable of generating.
77 Level is often referred to as "Shift Level". Levels are numbered sequentially
81 <note><para>Shift level is derived from the modifier state, but not necessarily
82 in the same way for all keys. For example, the <emphasis>
84 modifier selects shift level 2 on most keys, but for keypad keys the modifier
87 (that is, the <emphasis>
89 virtual modifier) also selects shift level 2.</para></note>
92 For example, consider the following key (the gray characters indicate symbols
93 that are implied or expected but are not actually engraved on the key):
97 <imageobject> <imagedata format="SVG" fileref="XKBlib-14.svg"/>
99 <caption>Shift Levels and Groups</caption>
105 Shift Levels and Groups</H5>
109 This key has two groups, indicated by the columns, and each group has two shift
110 levels. For the first group (Group1), the symbol shift level one is <emphasis>
112 , and the symbol for shift level two is <emphasis>
114 . For the second group, the symbol for shift level one is <emphasis>
116 , and the symbol for shift level two is <emphasis>
121 <sect2 id='Core_Implementation'>
122 <title>Core Implementation</title>
125 The standard interpretation rules for the core X keymap only allow clients to
126 access keys such as the one shown in Figure 14.1. That is, clients using the
127 standard interpretation rules can only access one of four keysyms for any given
130 event — two different symbols in two different groups.
135 In general, the <emphasis>
137 modifier, the <emphasis>
139 modifier, and the modifier bound to the <emphasis>
141 key are used to change between shift level 1 and shift level 2. To switch
142 between groups, the core implementation uses the modifier bound to the
144 Mode_switch</emphasis>
145 key. When the <emphasis>
146 Mode_switch</emphasis>
147 modifier is set, the keyboard is logically in Group 2. When the <emphasis>
148 Mode_switch</emphasis>
149 modifier is not set, the keyboard is logically in Group 1.
154 The core implementation does not clearly specify the behavior of keys. For
155 example, the locking behavior of the <emphasis>
159 keys depends on the vendor.
164 <sect2 id='Xkb_Implementation'>
165 <title>Xkb Implementation</title>
168 Xkb extends the core implementation by providing access to up to four keyboard
169 groups with up to 63 shift levels per key
171 The core implementation restricts the number of symbols per key to 255.
172 With four groups, this allows for up to 63 symbols (or shift levels) per
173 group. Most keys will only have a few shift levels.
174 </para></footnote>. In
175 addition, Xkb provides precise specifications regarding the behavior of keys.
176 In Xkb, modifier state and the current group are independent (with the
177 exception of compatibility mapping, discussed in Chapter 17).
182 Xkb handles switching between groups via key actions, independent of any
183 modifier state information. Key actions are in the server map component and are
184 described in detail in section 16.1.4.
189 Xkb handles shift levels by associating a key type with each group on each key.
190 Each key type defines the shift levels available for the groups on keys of its
191 type and specifies the modifier combinations necessary to access each level.
196 For example, Xkb allows key types where the <emphasis>
198 modifier can be used to access the shift level two of a key. Key types are in
199 the client map component and are described in detail in section 15.2. <!-- xref -->
204 Xkb provides precise specification of the behavior of a key using key
205 behaviors. Key behaviors are in the server map component and are described in
206 detail in section 16.2. <!-- xref -->
212 <sect1 id='Getting_Map_Components_from_the_Server'>
213 <title>Getting Map Components from the Server</title>
216 Xkb provides two functions to obtain the keyboard mapping components from the
217 server. The first function, <emphasis>
219 , allocates an <emphasis>
220 XkbDescRec</emphasis>
221 structure, retrieves mapping components from the server, and stores them in
223 XkbDescRec</emphasis>
224 structure it just allocated. The second function, <emphasis>
225 XkbGetUpdatedMap</emphasis>
226 , retrieves mapping components from the server and stores them in an <emphasis>
227 XkbDescRec</emphasis>
228 structure that has previously been allocated.
233 To allocate an <emphasis>
234 XkbDescRec</emphasis>
235 structure and populate it with the server’s keyboard client map and server
237 XkbGetMap. XkbGetMap </emphasis>
238 is similar to <emphasis>
239 XkbGetKeyboard</emphasis>
240 (see section 6.2), but is used only for obtaining the address of an <emphasis>
241 XkbDescRec</emphasis>
242 structure that is populated with keyboard mapping components. It allows finer
243 control over which substructures of the keyboard mapping components are to be
244 populated. <emphasis>
245 XkbGetKeyboard</emphasis>
246 always returns fully populated components, while <emphasis>
248 can be instructed to return a partially populated component.
251 <informaltable frame='none'>
252 <?dbfo keep-together="always" ?>
253 <tgroup cols='1' align='left' colsep='0' rowsep='0'>
254 <colspec colname='c1' colwidth='1.0*'/>
257 <entry role='functiondecl'>
258 XkbDescPtr <emphasis>
261 display, which, device_spec</emphasis>
266 <entry role='functionargdecl'>
269 ; /* connection to X server */
273 <entry role='functionargdecl'>
274 unsigned int <emphasis>
276 ; /* mask selecting subcomponents to populate */
280 <entry role='functionargdecl'>
281 unsigned int <emphasis>
282 device_spec</emphasis>
283 ; /* device_id, or <emphasis>
284 XkbUseCoreKbd</emphasis>
295 mask is a bitwise inclusive OR of the masks defined in Table 14.1. Only those
296 portions of the keyboard server map and the keyboard client maps that are
297 specified in <emphasis>
299 are allocated and populated.
304 In addition to allocating and obtaining the server map and the client map,
307 also sets the <emphasis>
308 device_spec</emphasis>
310 min_key_code</emphasis>
314 max_key_code</emphasis>
315 fields of the keyboard description.
322 is synchronous; it queries the server for the desired information, waits for a
323 reply, and then returns. If successful<emphasis>
324 , XkbGetMap</emphasis>
325 returns a pointer to the <emphasis>
326 XkbDescRec</emphasis>
327 structure it allocated. If unsuccessful, <emphasis>
331 . When unsuccessful, one of the following protocol errors is also generated:
334 (unable to allocate the <emphasis>
335 XkbDescRec</emphasis>
336 structure), <emphasis>
338 (some mask bits in <emphasis>
340 are undefined)<emphasis>
343 BadImplementation</emphasis>
344 (a compatible version of the Xkb extension is not available in the server). To
345 free the returned data, use <emphasis>
346 XkbFreeClientMap</emphasis>
352 Xkb also provides convenience functions to get partial component definitions
353 from the server. These functions are specified in the "convenience functions"
354 column in Table 14.1. Refer to the sections listed in the table for more
355 information on these functions.
358 <table frame='topbot'>
359 <title>Xkb Mapping Component Masks and Convenience Functions</title>
360 <?dbfo keep-together="always" ?>
361 <tgroup cols='6' align='left' colsep='0' rowsep='0'>
362 <colspec colname='c1' colwidth='3.0*'/>
363 <colspec colname='c2' colwidth='0.9*'/>
364 <colspec colname='c3' colwidth='0.9*'/>
365 <colspec colname='c4' colwidth='1.6*'/>
366 <colspec colname='c5' colwidth='2.1*'/>
367 <colspec colname='c6' colwidth='0.9*'/>
373 <entry>Fields</entry>
374 <entry>Convenience Functions</entry>
375 <entry>Section</entry>
380 <entry><emphasis>XkbKeyTypesMask</emphasis></entry>
381 <entry>(1<<0)</entry>
382 <entry>client</entry>
384 <para><emphasis>types</emphasis></para>
385 <para><emphasis>size_types</emphasis></para>
386 <para><emphasis>num_types</emphasis></para>
389 <para><emphasis>XkbGetKeyTypes</emphasis></para>
390 <para><emphasis>XkbResizeKeyType</emphasis></para>
391 <para><emphasis>XkbCopyKeyType</emphasis></para>
392 <para><emphasis>XkbCopyKeyTypes</emphasis></para>
397 <entry><emphasis>XkbKeySymsMask</emphasis></entry>
398 <entry>(1<<1)</entry>
399 <entry>client</entry>
401 <para><emphasis>syms</emphasis></para>
402 <para><emphasis>size_syms</emphasis></para>
403 <para><emphasis>num_syms</emphasis></para>
404 <para><emphasis>key_sym_map</emphasis></para>
407 <para><emphasis>XkbGetKeySyms</emphasis></para>
408 <para><emphasis>XkbResizeKeySyms</emphasis></para>
409 <para><emphasis>XkbChangeTypes­OfKey</emphasis></para>
414 <entry><emphasis>XkbModifierMapMask</emphasis></entry>
415 <entry>(1<<2)</entry>
416 <entry>client</entry>
417 <entry><emphasis>modmap</emphasis></entry>
418 <entry><emphasis>XkbGetKeyModifier­Map</emphasis></entry>
422 <entry><emphasis>XkbExplicitComponentsMask</emphasis></entry>
423 <entry>(1<<3)</entry>
424 <entry>server</entry>
425 <entry><emphasis>explicit</emphasis></entry>
426 <entry><emphasis>XkbGetKeyExplicit­Components</emphasis></entry>
430 <entry><emphasis>XkbKeyActionsMask</emphasis></entry>
431 <entry>(1<<4)</entry>
432 <entry>server</entry>
434 <para><emphasis>key_acts</emphasis></para>
435 <para><emphasis>acts</emphasis></para>
436 <para><emphasis>num_acts</emphasis></para>
437 <para><emphasis>size_acts</emphasis></para>
440 <para><emphasis>XkbGetKeyActions</emphasis></para>
441 <para><emphasis>XkbResizeKey­Actions</emphasis></para>
446 <entry><emphasis>XkbKeyBehaviorsMask</emphasis></entry>
447 <entry>(1<<5)</entry>
448 <entry>server</entry>
449 <entry><emphasis>behaviors</emphasis></entry>
450 <entry><emphasis>XkbGetKey­Behaviors</emphasis></entry>
454 <entry><emphasis>XkbVirtualModsMask</emphasis></entry>
455 <entry>(1<<6)</entry>
456 <entry>server</entry>
457 <entry><emphasis>vmods</emphasis></entry>
458 <entry><emphasis>XkbGetVirtualMods</emphasis></entry>
462 <entry><emphasis>XkbVirtualModMapMask</emphasis></entry>
463 <entry>(1<<7)</entry>
464 <entry>server</entry>
465 <entry><emphasis>vmodmap</emphasis></entry>
466 <entry><emphasis>XkbGetVirtualMod­Map</emphasis></entry>
474 Xkb defines combinations of these masks for convenience:
477 <para><programlisting>
478 #define XkbResizableInfoMask (XkbKeyTypesMask)
479 #define XkbAllClientInfoMask (XkbKeyTypesMask | XkbKeySymsMask |
481 #define XkbAllServerInfoMask (XkbExplicitComponentsMask |
482 XkbKeyActionsMask| XkbKeyBehaviorsMask |
483 XkbVirtualModsMask | XkbVirtualModMapMask)
484 #define XkbAllMapComponentsMask (XkbAllClientInfoMask|XkbAllServerInfoMask)
485 </programlisting></para>
488 Key types, symbol maps, and actions are all interrelated: changes in one
489 require changes in the others. The convenience functions make it easier to edit
490 these components and handle the interdependencies.
495 To update the client or server map information in an existing keyboard
496 description, use <emphasis>XkbGetUpdatedMap</emphasis>.
500 <informaltable frame='none'>
501 <?dbfo keep-together="always" ?>
502 <tgroup cols='1' align='left' colsep='0' rowsep='0'>
503 <colspec colname='c1' colwidth='1.0*'/>
506 <entry role='functiondecl'>
508 XkbGetUpdatedMap</emphasis>
510 display, which, xkb</emphasis>
515 <entry role='functionargdecl'>
518 ; /* connection to X server */
522 <entry role='functionargdecl'>
523 unsigned int<emphasis>
525 ; /* mask selecting subcomponents to populate */
529 <entry role='functionargdecl'>
530 XkbDescPtr <emphasis>
532 ; /* keyboard description to be updated */
542 parameter is a bitwise inclusive OR of the masks in Table 14.1. If the needed
543 components of the <emphasis>
545 structure are not already allocated, <emphasis>
546 XkbGetUpdatedMap</emphasis>
547 allocates them. <emphasis>
548 XkbGetUpdatedMap</emphasis>
549 fetches the requested information for the device specified in the <emphasis>
550 XkbDescRec</emphasis>
551 passed in the <emphasis>
559 XkbGetUpdatedMap</emphasis>
560 is synchronous; it queries the server for the desired information, waits for a
561 reply, and then returns. If successful<emphasis>
562 , XkbGetUpdatedMap</emphasis>
565 . If unsuccessful, <emphasis>
566 XkbGetUpdatedMap</emphasis>
567 returns one of the following: <emphasis>
569 (unable to allocate a component in the <emphasis>
570 XkbDescRec</emphasis>
571 structure), <emphasis>
573 (some mask bits in <emphasis>
575 are undefined), <emphasis>
576 BadImplementation</emphasis>
577 (a compatible version of the Xkb extension is not available in the server or
578 the reply from the server was invalid).
582 <sect1 id='Changing_Map_Components_in_the_Server'>
583 <title>Changing Map Components in the Server</title>
586 There are two ways to make changes to map components: either change a local
587 copy of the keyboard map and call <emphasis>
589 to send the modified map to the server, or, to reduce network traffic, use
591 XkbMapChangesRec</emphasis>
592 structure and call <emphasis>XkbChangeMap</emphasis>.
595 <informaltable frame='none'>
596 <?dbfo keep-together="always" ?>
597 <tgroup cols='1' align='left' colsep='0' rowsep='0'>
598 <colspec colname='c1' colwidth='1.0*'/>
601 <entry role='functiondecl'>
614 <entry role='functionargdecl'>
617 ; /* connection to X server */
621 <entry role='functionargdecl'>
622 unsigned int<emphasis>
624 ; /* mask selecting subcomponents to update */
628 <entry role='functionargdecl'>
629 XkbDescPtr <emphasis>
631 ; /* description from which new values are taken */
641 to send a complete new set of values for entire components (for example, all
642 symbols, all actions, and so on) to the server. The <emphasis>
644 parameter specifies the components to be sent to the server, and is a bitwise
645 inclusive OR of the masks listed in Table 14.1. The <emphasis>
647 parameter is a pointer to an <emphasis>
648 XkbDescRec</emphasis>
649 structure and contains the information to be copied to the server. For each
650 bit set in the <emphasis>
652 parameter, <emphasis>
654 takes the corresponding structure values from the <emphasis>
656 parameter and sends it to the server specified by <emphasis>
661 If any components specified by <emphasis>
663 are not present in the <emphasis>
665 parameter, <emphasis>
669 . Otherwise, it sends the update request to the server and returns <emphasis>
673 can generate <emphasis>
684 Key types, symbol maps, and actions are all interrelated; changes in one
685 require changes in the others. Xkb provides functions to make it easier to edit
686 these components and handle the interdependencies. Table 14.1 lists these
687 helper functions and provides a pointer to where they are defined.
691 <sect2 id='The_XkbMapChangesRec_Structure'>
692 <title>The XkbMapChangesRec Structure</title>
696 XkbMapChangesRec</emphasis>
697 structure to identify and track partial modifications to the mapping
698 components and to reduce the amount of traffic between the server and clients.
701 <para><programlisting>
702 typedef struct _XkbMapChanges {
703 unsigned short changed; /* identifies valid components
705 KeyCode min_key_code; /* lowest numbered keycode for
707 KeyCode max_key_code; /* highest numbered keycode for
709 unsigned char first_type; /* index of first key <emphasis>type</emphasis>
711 unsigned char num_types; /* # types modified */
712 KeyCode first_key_sym; /* first key whose <emphasis>key_sym_map</emphasis>
714 unsigned char num_key_syms; /* # <emphasis>key_sym_map</emphasis>
716 KeyCode first_key_act; /* first key whose <emphasis>key_acts</emphasis>
718 unsigned char num_key_acts; /* # <emphasis>key_acts</emphasis>
720 KeyCode first_key_behavior; /* first key whose <emphasis>behaviors</emphasis>
722 unsigned char num_key_behaviors; /* # <emphasis>behaviors</emphasis>
724 KeyCode first_key_explicit; /* first key whose <emphasis>explicit</emphasis>
726 unsigned char num_key_explicit; /* # <emphasis> explicit</emphasis>
728 KeyCode first_modmap_key; /* first key whose <emphasis>modmap</emphasis>
730 unsigned char num_modmap_keys; /* # <emphasis>modmap</emphasis>
732 KeyCode first_vmodmap_key; /* first key whose <emphasis>vmodmap</emphasis>
734 unsigned char num_vmodmap_keys; /* # <emphasis> vmodmap</emphasis>
736 unsigned char pad1; /* reserved */
737 unsigned short vmods; /* mask indicating which <emphasis>vmods</emphasis>
739 } <emphasis>XkbMapChangesRec</emphasis>,*XkbMapChangesPtr;
740 </programlisting></para>
745 field identifies the map components that have changed in an <emphasis>
746 XkbDescRec</emphasis>
747 structure and may contain any of the bits in Table 14.1, which are also shown
748 in Table 14.2. Every 1 bit in <emphasis>
750 also identifies which other fields in the <emphasis>
751 XkbMapChangesRec</emphasis>
752 structure contain valid values, as indicated in Table 14.2. The <emphasis>
753 min_key_code</emphasis>
755 max_key_code</emphasis>
756 fields are for reference only; they are ignored on any requests sent to the
757 server and are always updated by the server whenever it returns the data for an
759 XkbMapChangesRec</emphasis>
763 <table frame='topbot'>
764 <title>XkbMapChangesRec Masks</title>
765 <?dbfo keep-together="always" ?>
766 <tgroup cols='3' align='left' colsep='0' rowsep='0'>
767 <colspec colname='c1' colwidth='1.0*'/>
768 <colspec colname='c2' colwidth='1.0*'/>
769 <colspec colname='c3' colwidth='1.0*'/>
773 <entry>Valid XkbMapChangesRec Fields</entry>
774 <entry>XkbDescRec Field Containing Changed Data</entry>
779 <entry><emphasis>XkbKeyTypesMask</emphasis></entry>
781 <para>first_type</para>,
782 <para>num_types</para>
785 <para>map->type[first_type] ..</para>
786 <para>map->type[first_type + num_types - 1]</para>
790 <entry><emphasis>XkbKeySymsMask</emphasis></entry>
792 <para>first_key_sym</para>,
793 <para>num_key_syms</para>
796 <para>map->key_sym_map[first_key_sym] ..</para>
797 <para>map->key_sym_map[first_key_sym + num_key_syms - 1]</para>
801 <entry><emphasis>XkbModifierMapMask</emphasis></entry>
803 <para>first_modmap_key</para>,
804 <para>num_modmap_keys</para>
807 <para>map->modmap[first_modmap_key] ..</para>
808 <para>map->modmap[first_modmap_key + num_modmap_keys-1]</para>
812 <entry><emphasis>XkbExplicitComponentsMask</emphasis></entry>
814 <para>first_key_explicit</para>,
815 <para>num_key_explicit</para>
818 <para>server->explicit[first_key_explicit] ..</para>
819 <para>server->explicit[first_key_explicit + num_key_explicit - 1]</para>
823 <entry><emphasis>XkbKeyActionsMask</emphasis></entry>
825 <para>first_key_act,</para>
826 <para>num_key_acts</para>
829 <para>server->key_acts[first_key_act] ..</para>
830 <para>server->key_acts[first_key_act + num_key_acts - 1]</para>
834 <entry><emphasis>XkbKeyBehaviorsMask</emphasis></entry>
836 <para>first_key_behavior,</para>
837 <para>num_key_behaviors</para>
840 <para>server->behaviors[first_key_behavior] ..</para>
841 <para>server->behaviors[first_key_behavior + num_key_behaviors - 1]</para>
845 <entry><emphasis>XkbVirtuawModsMask</emphasis></entry>
847 <entry>server->vmods[*]</entry>
850 <entry><emphasis>XkbVirtualModMapMask</emphasis></entry>
852 <para>first_vmodmap_key,</para>
853 <para>num_vmodmap_keys</para>
856 <para>server->vmodmap[first_vmodmap_key] ..</para>
857 <para>server->vmodmap[first_vmodmap_key + num_vmodmap_keys - 1]</para>
865 To update only partial components of a keyboard description, modify the
866 appropriate fields in the server and map components of a local copy of the
867 keyboard description, then call <emphasis>
868 XkbChangeMap</emphasis>
870 XkbMapChangesRec</emphasis>
871 structure indicating which components have changed.
874 <informaltable frame='none'>
875 <?dbfo keep-together="always" ?>
876 <tgroup cols='1' align='left' colsep='0' rowsep='0'>
877 <colspec colname='c1' colwidth='1.0*'/>
880 <entry role='functiondecl'>
882 XkbChangeMap</emphasis>
893 <entry role='functionargdecl'>
896 ; /* connection to X server */
900 <entry role='functionargdecl'>
901 XkbDescPtr <emphasis>
903 ; /* description from which new values are taken */
907 <entry role='functionargdecl'>
908 XkbMapChangesPtr <emphasis>
910 ; /*identifies component parts to update */
919 XkbChangeMap</emphasis>
920 copies any components specified by the <emphasis>
922 structure from the keyboard description, <emphasis>
924 , to the X server specified by <emphasis>
931 If any components specified by <emphasis>
933 are not present in the <emphasis>
935 parameter, <emphasis>
936 XkbChangeMap</emphasis>
939 . Otherwise, it sends a request to the server and returns <emphasis>
947 XkbChangeMap</emphasis>
948 can generate <emphasis>
960 <sect1 id='Tracking_Changes_to_Map_Components'>
961 <title>Tracking Changes to Map Components</title>
964 The Xkb extension reports <emphasis>
965 XkbMapNotify</emphasis>
966 events to clients wanting notification whenever a map component of the Xkb
967 description for a device changes. There are many different types of Xkb
968 keyboard map changes. Xkb uses an event detail mask to identify each type of
969 change. The event detail masks are identical to the masks listed in Table 14.1.
974 To receive <emphasis>
975 XkbMapNotify</emphasis>
976 events under all possible conditions, use <emphasis>
977 XkbSelectEvents</emphasis>
978 (see section 4.3) and pass <emphasis>
979 XkbMapNotifyMask</emphasis>
981 bits_to_change</emphasis>
983 values_for_bits</emphasis>
989 To receive <emphasis>
990 XkbMapNotify</emphasis>
991 events only under certain conditions, use <emphasis>
992 XkbSelectEventDetails</emphasis>
994 XkbMapNotify</emphasis>
996 event_type</emphasis>
997 and specifying the desired map changes in <emphasis>
998 bits_to_change</emphasis>
1000 values_for_bits</emphasis>
1001 using mask bits from Table 14.1.
1006 The structure for <emphasis>
1007 XkbMapNotify</emphasis>
1011 <para><programlisting>
1013 int type; /* Xkb extension base event code */
1014 unsigned long serial; /* X server serial number for event */
1015 Bool send_event; /* <emphasis>True</emphasis> => synthetically generated */
1016 Display * display; /* server connection where event generated */
1017 Time time; /* server time when event generated */
1018 int xkb_type; /* <emphasis> XkbMapNotify</emphasis> */
1019 int device; /* Xkb device ID, will not be <emphasis>XkbUseCoreKbd</emphasis> */
1020 unsigned int changed; /* identifies valid fields in rest of event */
1021 unsigned int resized; /* reserved */
1022 int first_type; /* index of first key <emphasis> type</emphasis> modified */
1023 int num_types /* # types modified */
1024 KeyCode min_key_code; /* minimum keycode for device */
1025 KeyCode max_key_code; /* maximum keycode for device */
1026 KeyCode first_key_sym; /* first key whose <emphasis>key_sym_map</emphasis> changed */
1027 KeyCode first_key_act; /* first key whose <emphasis> key_acts</emphasis> entry changed */
1028 KeyCode first_key_behavior; /* first key whose <emphasis> behaviors</emphasis> changed */
1029 KeyCode first_key_explicit; /* first key whose <emphasis> explicit </emphasis> entry changed */
1030 KeyCode first_modmap_key; /* first key whose <emphasis> modmap</emphasis> entry changed */
1031 KeyCode first_vmodmap_key; /* # <emphasis> modmap</emphasis> entries changed */
1032 int num_key_syms; /* # <emphasis>key_sym_map</emphasis> entries changed */
1033 int num_key_acts; /* # <emphasis> key_acts</emphasis> entries changed */
1034 int num_key_behaviors; /* # <emphasis> behaviors</emphasis> entries changed */
1035 int num_key_explicit; /* # <emphasis> explicit</emphasis> entries changed */
1036 int num_modmap_keys; /* # <emphasis> modmap</emphasis> entries changed */
1037 int num_vmodmap_keys; /* # <emphasis> vmodmap</emphasis> entries changed */
1038 unsigned in t vmods; /* mask indicating which <emphasis> vmods</emphasis> changed */
1039 } <emphasis>XkbMapNotifyEvent</emphasis>;
1040 </programlisting></para>
1045 field specifies the map components that have changed and is the bitwise
1046 inclusive OR of the mask bits defined in Table 14.1. The other fields in this
1047 event are interpreted as the like-named fields in an <emphasis>
1048 XkbMapChangesRec</emphasis>
1049 (see section 14.3.1). The <emphasis>
1050 XkbMapNotifyEvent</emphasis>
1051 structure also has an additional <emphasis>
1053 field that is reserved for future use.
1058 <sect1 id='Allocating_and_Freeing_Client_and_Server_Maps'>
1059 <title>Allocating and Freeing Client and Server Maps</title>
1063 XkbGetMap</emphasis>
1064 (see section 14.2) should be sufficient for most applications to get client
1065 and server maps. As a result, most applications do not need to directly
1066 allocate client and server maps.
1071 If you change the number of key types or construct map components without
1072 loading the necessary components from the X server, do not allocate any map
1073 components directly using <emphasis>
1077 . Instead, use the Xkb allocators, <emphasis>
1078 XkbAllocClientMap,</emphasis>
1080 XkbAllocServerMap</emphasis>
1086 Similarly, use the Xkb destructors, <emphasis>
1087 XkbFreeClientMap,</emphasis>
1089 XkbFreeServerMap</emphasis>
1090 instead of <emphasis>
1098 <sect2 id='Allocating_an_Empty_Client_Map'>
1099 <title>Allocating an Empty Client Map</title>
1102 To allocate and initialize an empty client map description record, use
1104 XkbAllocClientMap.</emphasis>
1107 <informaltable frame='none'>
1108 <?dbfo keep-together="always" ?>
1109 <tgroup cols='1' align='left' colsep='0' rowsep='0'>
1110 <colspec colname='c1' colwidth='1.0*'/>
1113 <entry role='functiondecl'>
1115 XkbAllocClientMap</emphasis>
1117 xkb, which, type_count</emphasis>
1122 <entry role='functionargdecl'>
1123 XkbDescPtr <emphasis>
1125 ; /* keyboard description in which to allocate client map */
1129 <entry role='functionargdecl'>
1130 unsigned int<emphasis>
1132 ; /* mask selecting map components to allocate */
1136 <entry role='functionargdecl'>
1137 unsigned int<emphasis>
1138 type_count</emphasis>
1139 ; /* value of <emphasis>
1140 num_types</emphasis>
1141 field in map to be allocated */
1150 XkbAllocClientMap</emphasis>
1151 allocates and initializes an empty client map in the <emphasis>
1153 field of the keyboard description specified by <emphasis>
1157 parameter specifies the particular components of the client map structure to
1158 allocate and is a mask composed by a bitwise inclusive OR of one or more of the
1159 masks shown in Table 14.3.
1162 <table frame='topbot'>
1163 <title>XkbAllocClientMap Masks</title>
1164 <?dbfo keep-together="always" ?>
1165 <tgroup cols='2' align='left' colsep='0' rowsep='0'>
1166 <colspec colname='c1' colwidth='1.0*'/>
1167 <colspec colname='c2' colwidth='2.0*'/>
1171 <entry>Effect</entry>
1176 <entry>XkbKeyTypesMask</entry>
1179 type_count </emphasis>
1180 field specifies the number of entries to preallocate for the <emphasis>
1182 field of the client map. If the <emphasis>
1183 type_count </emphasis>
1184 field is less than <emphasis>
1185 XkbNumRequiredTypes</emphasis>
1186 (see section 15.2.1), returns <emphasis>
1187 BadValue</emphasis>.
1191 <entry>XkbKeySymsMask</entry>
1194 min_key_code</emphasis>
1196 max_key_code</emphasis>
1197 fields of the <emphasis>
1199 parameter are used to allocate the <emphasis>
1202 key_sym_map</emphasis>
1203 fields of the client map. The fields are allocated to contain the maximum
1204 number of entries necessary for <emphasis>
1205 max_key_code</emphasis>
1207 min_key_code</emphasis>
1212 <entry>XkbModifierMapMask</entry>
1215 min_key_code</emphasis>
1217 max_key_code</emphasis>
1218 fields of the <emphasis>
1220 parameter are used to allocate the <emphasis>
1222 field of the client map. The field is allocated to contain the maximum number
1223 of entries necessary for <emphasis>
1224 max_key_code</emphasis>
1226 min_key_code</emphasis>
1234 <note><para>The <emphasis>
1235 min_key_code</emphasis>
1237 max_key_code</emphasis>
1238 fields of the <emphasis>
1240 parameter must be legal values if the <emphasis>
1241 XkbKeySymsMask</emphasis>
1243 XkbModifierMapMask</emphasis>
1244 masks are set in the <emphasis>
1246 parameter. If they are not valid, <emphasis>
1247 XkbAllocClientMap</emphasis>
1253 If the client map of the keyboard description is not <emphasis>
1255 , and any fields are already allocated in the client map, <emphasis>
1256 XkbAllocClientMap</emphasis>
1257 does not overwrite the existing values; it simply ignores that part of the
1258 request. The only exception is the <emphasis>
1260 array. If <emphasis>
1261 type_count</emphasis>
1262 is greater than the current <emphasis>
1263 num_types</emphasis>
1264 field of the client map, <emphasis>
1265 XkbAllocClientMap</emphasis>
1266 resizes the <emphasis>
1268 array and resets the <emphasis>
1269 num_types</emphasis>
1276 XkbAllocClientMap</emphasis>
1277 is successful, it returns <emphasis>
1279 . Otherwise, it can return either <emphasis>
1290 <sect2 id='Freeing_a_Client_Map'>
1291 <title>Freeing a Client Map</title>
1294 To free memory used by the client map member of an <emphasis>
1295 XkbDescRec</emphasis>
1296 structure, use <emphasis>
1297 XkbFreeClientMap.</emphasis>
1300 <informaltable frame='none'>
1301 <?dbfo keep-together="always" ?>
1302 <tgroup cols='1' align='left' colsep='0' rowsep='0'>
1303 <colspec colname='c1' colwidth='1.0*'/>
1306 <entry role='functiondecl'>
1308 XkbFreeClientMap</emphasis>
1310 xkb, which, free_all</emphasis>
1315 <entry role='functionargdecl'>
1316 XkbDescPtr <emphasis>
1318 ; /* keyboard description containing client map to free */
1322 <entry role='functionargdecl'>
1323 unsigned int<emphasis>
1325 ; /* mask identifying components of map to free */
1329 <entry role='functionargdecl'>
1334 => free all client components and map itself */
1343 XkbFreeClientMap</emphasis>
1344 frees the components of client map specified by <emphasis>
1347 XkbDescRec</emphasis>
1348 structure specified by the <emphasis>
1350 parameter and sets the corresponding structure component values to <emphasis>
1354 parameter specifies a combination of the client map masks shown in Table 14.3.
1365 is ignored; <emphasis>
1366 XkbFreeClientMap</emphasis>
1367 frees every non-<emphasis>
1369 structure component in the client map, frees the <emphasis>
1370 XkbClientMapRec</emphasis>
1371 structure referenced by the <emphasis>
1373 member of the <emphasis>
1375 parameter, and sets the <emphasis>
1377 member to <emphasis>
1383 <sect2 id='Allocating_an_Empty_Server_Map'>
1384 <title>Allocating an Empty Server Map</title>
1387 To allocate and initialize an empty server map description record, use
1389 XkbAllocServerMap.</emphasis>
1392 <informaltable frame='none'>
1393 <?dbfo keep-together="always" ?>
1394 <tgroup cols='1' align='left' colsep='0' rowsep='0'>
1395 <colspec colname='c1' colwidth='1.0*'/>
1398 <entry role='functiondecl'>
1400 XkbAllocServerMap</emphasis>
1402 xkb, which, count_acts</emphasis>
1407 <entry role='functionargdecl'>
1408 XkbDescPtr <emphasis>
1410 ; /* keyboard description in which to allocate server map */
1414 <entry role='functionargdecl'>
1415 unsigned int<emphasis>
1417 ; /* mask selecting map components to allocate */
1421 <entry role='functionargdecl'>
1422 unsigned int<emphasis>
1423 count_acts</emphasis>
1424 ; /* value of <emphasis>
1426 field in map to be allocated */
1435 XkbAllocServerMap</emphasis>
1436 allocates and initializes an empty server map in the <emphasis>
1438 field of the keyboard description specified by <emphasis>
1442 parameter specifies the particular components of the server map structure to
1443 allocate, as specified in Table 14.4.
1446 <table frame='topbot'>
1447 <title>XkbAllocServerMap Masks</title>
1448 <?dbfo keep-together="always" ?>
1449 <tgroup cols='2' align='left' colsep='0' rowsep='0'>
1450 <colspec colname='c1' colwidth='1.0*'/>
1451 <colspec colname='c2' colwidth='2.0*'/>
1455 <entry>Effect</entry>
1460 <entry>XkbExplicitComponentsMask</entry>
1463 min_key_code</emphasis>
1465 max_key_code</emphasis>
1466 fields of the <emphasis>
1468 parameter are used to allocate the <emphasis>
1469 explicit </emphasis>
1470 field of the server map.
1474 <entry>XkbKeyActionsMask</entry>
1477 min_key_code</emphasis>
1479 max_key_code</emphasis>
1480 fields of the <emphasis>
1482 parameter are used to allocate the <emphasis>
1483 key_acts </emphasis>
1484 field of the server map. The <emphasis>
1485 count_acts</emphasis>
1486 parameter is used to allocate the <emphasis>
1488 field of the server map.
1492 <entry>XkbKeyBehaviorsMask</entry>
1495 min_key_code</emphasis>
1497 max_key_code</emphasis>
1498 fields of the <emphasis>
1500 parameter are used to allocate the <emphasis>
1501 behaviors </emphasis>
1502 field of the server map.
1506 <entry>XkbVirtualModMapMask</entry>
1509 min_key_code</emphasis>
1511 max_key_code</emphasis>
1512 fields of the <emphasis>
1514 parameter are used to allocate the <emphasis>
1516 field of the server map.
1523 <note><para>The <emphasis>
1524 min_key_code</emphasis>
1526 max_key_code</emphasis>
1527 fields of the <emphasis>
1529 parameter must be legal values. If they are not valid, <emphasis>
1530 XkbAllocServerMap</emphasis>
1536 If the server map of the keyboard description is not <emphasis>
1538 and any fields are already allocated in the server map, <emphasis>
1539 XkbAllocServerMap</emphasis>
1540 does not overwrite the existing values. The only exception is with the
1543 array. If the <emphasis>
1544 count_acts </emphasis>
1545 parameter is greater than the current <emphasis>
1546 num_acts </emphasis>
1547 field of the server map, <emphasis>
1548 XkbAllocServerMap</emphasis>
1549 resizes the <emphasis>
1551 array and resets the <emphasis>
1552 num_acts </emphasis>
1559 XkbAllocServerMap</emphasis>
1560 is successful, it returns <emphasis>
1562 . Otherwise, it can return either <emphasis>
1571 <sect2 id='Freeing_a_Server_Map'>
1572 <title>Freeing a Server Map</title>
1575 To free memory used by the server member of an <emphasis>
1576 XkbDescRec</emphasis>
1577 structure, use <emphasis>
1578 XkbFreeServerMap.</emphasis>
1581 <informaltable frame='none'>
1582 <?dbfo keep-together="always" ?>
1583 <tgroup cols='1' align='left' colsep='0' rowsep='0'>
1584 <colspec colname='c1' colwidth='1.0*'/>
1587 <entry role='functiondecl'>
1589 XkbFreeServerMap</emphasis>
1591 xkb, which, free_all</emphasis>
1596 <entry role='functionargdecl'>
1597 XkbDescPtr <emphasis>
1599 ; /* keyboard description containing server map to free */
1603 <entry role='functionargdecl'>
1604 unsigned int<emphasis>
1606 ; /* mask identifying components of map to free */
1610 <entry role='functionargdecl'>
1615 => free all server map components and server itself */
1624 XkbFreeServerMap</emphasis>
1625 function frees the specified components of server map in the <emphasis>
1626 XkbDescRec</emphasis>
1627 structure specified by the <emphasis>
1629 parameter and sets the corresponding structure component values to <emphasis>
1633 parameter specifies a combination of the server map masks and is a bitwise
1634 inclusive OR of the masks listed in Table 14.4. If <emphasis>
1640 is ignored and <emphasis>
1641 XkbFreeServerMap</emphasis>
1642 frees every non-<emphasis>
1644 structure component in the server map, frees the <emphasis>
1645 XkbServerMapRec</emphasis>
1646 structure referenced by the <emphasis>
1648 member of the <emphasis>
1650 parameter, and sets the <emphasis>
1652 member to <emphasis>