aboutsummaryrefslogtreecommitdiff
path: root/libX11/specs/XKB/ch18.xml
blob: 0f283ecfc0acfa1e76bd5bfbaa57bd9c1cf8c15d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
	  "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd">
<chapter id='Symbolic_Names'>
<title>Symbolic Names</title>

<para>
The core protocol does not provide any information to clients other than that
actually used to interpret events. This makes it difficult to write an
application that presents the keyboard to a user in an easy-to-understand way.
Such applications have to examine the vendor string and keycodes to determine
the type of keyboard connected to the server and then examine keysyms and
modifier mappings to determine the effects of most modifiers (the
<symbol>Shift</symbol>,
<symbol>Lock</symbol>
and
<symbol>Control</symbol>
modifiers are defined by the core protocol but no semantics are implied for
any other modifiers).
</para>


<para>
To make it easier for applications to present a keyboard to the user, Xkb
supports symbolic names for most components of the keyboard extension. Most of
these symbolic names are grouped into the
<structfield>names</structfield>
component of the keyboard description.
</para>

<sect1 id='The_XkbNamesRec_Structure'>
<title>The XkbNamesRec Structure</title>
<indexterm significance="preferred" zone="The_XkbNamesRec_Structure">
<primary><structname>XkbKeyNameRec</structname></primary></indexterm>
<indexterm significance="preferred" zone="The_XkbNamesRec_Structure">
<primary><structname>XkbKeyAliasRec</structname></primary></indexterm>
<indexterm significance="preferred" zone="The_XkbNamesRec_Structure">
<primary><structname>XkbNamesRec</structname></primary></indexterm>

<para>
The names component of the keyboard description is defined as follows:

<programlisting>
#define      XkbKeyNameLength      4
#define      XkbKeyNumVirtualMods  16
#define      XkbKeyNumIndicators   32
#define      XkbKeyNumKbdGroups    4
#define      XkbMaxRadioGroups     32

typedef struct {
    char      name[XkbKeyNameLength];      /* symbolic key names */
} <structname>XkbKeyNameRec</structname>, *XkbKeyNamePtr;

typedef struct {
    char      real[XkbKeyNameLength];
              /* this key name must be in the keys array */
    char      alias[XkbKeyNameLength];
              /* symbolic key name as alias for the key */
} <structname>XkbKeyAliasRec</structname>, *XkbKeyAliasPtr;

typedef struct _XkbNamesRec {
    Atom            keycodes;        /* identifies range and meaning
                                        of keycodes */
    Atom            geometry;        /* identifies physical location,
                                        size, and shape of keys */
    Atom            symbols;         /* identifies the symbols logically
                                        bound to the keys */
    Atom            types;           /* identifies the set of key types */
    Atom            compat;          /* identifies actions for keys using
                                        core protocol */
    Atom            vmods[XkbNumVirtualMods]; /* symbolic names for
                                                 virtual modifiers */
    Atom            indicators[XkbNumIndicators]; /* symbolic names
                                                     for indicators */
    Atom            groups[XkbNumKbdGroups];  /* symbolic names for
                                                 keyboard groups */
    XkbKeyNamePtr   keys;            /* symbolic key name array */
    XkbKeyAliasPtr  key_aliases;     /* real/alias symbolic name pairs array */
    Atom *          radio_groups;    /* radio group name array */
    Atom            phys_symbols;    /* identifies the symbols engraved
                                        on the keyboard */
    unsigned char   num_keys;        /* number of keys in the <structfield>keys</structfield> array */
    unsigned char   num_key_aliases; /* number of keys in the
                                        <structfield>key_aliases</structfield> array */
    unsigned short  num_rg;          /* number of radio groups */
} <structname>XkbNamesRec</structname>, *XkbNamesPtr;
</programlisting></para>

<para>
The
<structfield>keycodes</structfield>
name identifies the range and meaning of the keycodes returned by the keyboard
in question. The
<structfield>geometry</structfield>
name, on the other hand, identifies the physical location, size and shape of
the various keys on the keyboard. As an example to distinguish between these
two names, consider function keys on PC-compatible keyboards. Function keys are
sometimes above the main keyboard and sometimes to the left of the main
keyboard, but the same keycode is used for the key that is logically F1
regardless of physical position. Thus, all PC-compatible keyboards share a
similar keycodes name but may have different geometry names.
</para>

<note><para>The keycodes name is intended to be a very general description of
the keycodes returned by a keyboard; a single keycodes name might cover
keyboards with differing numbers of keys provided all keys have the same
semantics when present. For example, 101 and 102 key PC keyboards might use the
same name. In these cases, applications can use the keyboard
<structfield>geometry</structfield>
name to determine which subset of the named keycodes is in use.</para></note>

<para>
The
<structfield>symbols</structfield>
name identifies the symbols logically bound to the keys. The symbols name is a
human or application-readable description of the intended locale or usage of
the keyboard with these symbols. The
<structfield>phys_symbols</structfield>
name, on the other hand, identifies the symbols actually engraved on the
keyboard. Given this, the
<structfield>symbols</structfield>
name and
<structfield>phys_symbols</structfield>
names might be different. For example, the description for a keyboard that has
English US engravings, but that is using Swiss German symbols might have a
<structfield>phys_symbols</structfield>
name of "en_US" and a
<structfield>symbols</structfield>
name of "de_CH."
</para>


<para>
The
<structfield>types</structfield>
name provides some information about the set of key types (see <link linkend="Key_Types">section 15.2</link>)
that can be associated with the keyboard. In addition, each key type can have a
name, and each shift level of a type can have a name. Although these names are
stored in the map description with each of the types, they are accessed using
the same methods as the other symbolic names.
</para>


<para>
The
<structfield>compat</structfield>
name provides some information about the rules used to bind actions to keys
that are changed using core protocol requests.
</para>


<para>
Xkb provides symbolic names for each of the 4 keyboard groups, 16 virtual
modifiers, 32 keyboard indicators, and 4 keyboard groups. These names are held
in the
<structfield>vmods</structfield>,
<structfield>indicators</structfield>,
and
<structfield>groups</structfield>
fixed-length arrays.
</para>


<para>
Each key has a four-byte symbolic name. All of the symbolic key names are held
in the
<structfield>keys</structfield>
array, and
<structfield>num_keys</structfield>
reports the number of entries that are in the keys array. For each key, the
key name links keys with similar functions or in similar positions on keyboards
that report different keycodes. For example, the
<keycap>F1</keycap>
key may emit keycode 23 on one keyboard and keycode 86 on another. By naming
this key "FK01" on both keyboards, the keyboard layout designer can reuse parts
of keyboard descriptions for different keyboards.
</para>


<para>
Key aliases allow the keyboard layout designer to assign multiple key names to
a single key. This allows the keyboard layout designer to refer to keys using
either their position or their <quote>function</quote>.
For example, a keyboard layout
designer may wish to refer to the left arrow key on a PC keyboard using the
ISO9995-5 positional specification of A31 or using the functional specification
of LEFT. The
<structfield>key_aliases</structfield>
field holds a variable-length array of real and alias key name pairs, and the
total number of entries in the
<structfield>key_aliases</structfield>
array is held in
<structfield>num_key_aliases</structfield>.
For each real and alias key name pair, the
<structfield>real</structfield>
field refers to the a name in the keys array, and the
<structfield>alias</structfield>
field refers to the alias for that key. Using the previous example, the
keyboard designer may use the name A31 in the keys array, but also define the
name LEFT as an alias for A31 in the
<structfield>key_aliases</structfield>
array.
</para>

<note><para>Key aliases defined in the geometry component of a keyboard mapping
(see <xref linkend="Keyboard_Geometry" />) override those defined in the keycodes component of the server
database, which are stored in the
<structname>XkbNamesRec</structname>

(<structfield>xkb-&gt;names</structfield>).
Therefore, consider the key aliases defined by the geometry before
considering key aliases supplied by the
<structname>XkbNamesRec</structname>.
</para></note>

<para>
A radio group is a set of keys whose behavior simulates a set of radio buttons.
Once a key in a radio group is pressed, it stays logically depressed until
another key in the group is pressed, at which point the previously depressed
key is logically released. Consequently, at most one key in a radio group can
be logically depressed at one time.
</para>


<para>
Each radio group in the keyboard description can have a name. These names are
held in the variable-length array
<structfield>radio_groups</structfield>,
and
<structfield>num_rg</structfield>
tells how many elements are in the
<structfield>radio_groups</structfield>
array.
</para>


</sect1>
<sect1 id='Symbolic_Names_Masks'>
<title>Symbolic Names Masks</title>

<para>
Xkb provides several functions that work with symbolic names. Each of these
functions uses a mask to specify individual fields of the structures described
above. These masks and their relationships to the fields in a keyboard
description are shown in <link linkend="table18.1">Table 18.1</link>.
</para>

<table id='table18.1' frame='topbot'>
<title>Symbolic Names Masks</title>
<?dbfo keep-together="always" ?>
<tgroup cols='4' align='left' colsep='0' rowsep='0'>
<colspec colname='c1' colwidth='3.0*'/>
<colspec colname='c2' colwidth='1.0*'/>
<colspec colname='c3' colwidth='1.5*'/>
<colspec colname='c4' colwidth='2.0*'/>
<thead>
<row rowsep='1'>
  <entry>Mask Bit</entry>
  <entry>Value</entry>
  <entry>Keyboard Component</entry>
  <entry>Field</entry>
</row>
</thead>
<tbody>
<row>
    <entry><symbol>XkbKeycodesNameMask</symbol></entry>
    <entry>(1&lt;&lt;0)</entry>
    <entry>Xkb-&gt;names</entry>
    <entry>keycodes</entry>
</row>
<row>
    <entry><symbol>XkbGeometryNameMask</symbol></entry>
    <entry>(1&lt;&lt;1)</entry>
    <entry>Xkb-&gt;names</entry>
    <entry>geometry</entry>
</row>
<row>
    <entry><symbol>XkbSymbolsNameMask</symbol></entry>
    <entry>(1&lt;&lt;2)</entry>
    <entry>Xkb-&gt;names</entry>
    <entry>symbols</entry>
</row>
<row>
    <entry><symbol>XkbPhysSymbolsNameMask</symbol></entry>
    <entry>(1&lt;&lt;3)</entry>
    <entry>Xkb-&gt;names</entry>
    <entry>phys_symbols</entry>
</row>
<row>
    <entry><symbol>XkbTypesNameMask</symbol></entry>
    <entry>(1&lt;&lt;4)</entry>
    <entry>Xkb-&gt;names</entry>
    <entry>type</entry>
</row>
<row>
    <entry><symbol>XkbCompatNameMask</symbol></entry>
    <entry>(1&lt;&lt;5)</entry>
    <entry>Xkb-&gt;names</entry>
    <entry>compat</entry>
</row>
<row>
    <entry><symbol>XkbKeyTypeNamesMask</symbol></entry>
    <entry>(1&lt;&lt;6)</entry>
    <entry>Xkb-&gt;map</entry>
    <entry>type[*].name</entry>
</row>
<row>
    <entry><symbol>XkbKTLevelNamesMask</symbol></entry>
    <entry>(1&lt;&lt;7)</entry>
    <entry>Xkb-&gt;map</entry>
    <entry>type[*].lvl_names[*]</entry>
</row>
<row>
    <entry><symbol>XkbIndicatorNamesMask</symbol></entry>
    <entry>(1&lt;&lt;8)</entry>
    <entry>Xkb-&gt;names</entry>
    <entry>indicators[*]</entry>
</row>
<row>
    <entry><symbol>XkbKeyNamesMask</symbol></entry>
    <entry>(1&lt;&lt;9)</entry>
    <entry>Xkb-&gt;names</entry>
    <entry>keys[*], num_keys</entry>
</row>
<row>
    <entry><symbol>XkbKeyAliasesMask</symbol></entry>
    <entry>(1&lt;&lt;10)</entry>
    <entry>Xkb-&gt;names</entry>
    <entry>key_aliases[*], num_key_aliases</entry>
</row>
<row>
    <entry><symbol>XkbVirtualModNamesMask</symbol></entry>
    <entry>(1&lt;&lt;11)</entry>
    <entry>Xkb-&gt;names</entry>
    <entry>vmods[*]</entry>
</row>
<row>
    <entry><symbol>XkbGroupNamesMask</symbol></entry>
    <entry>(1&lt;&lt;12)</entry>
    <entry>Xkb-&gt;names</entry>
    <entry>groups[*]</entry>
</row>
<row>
    <entry><symbol>XkbRGNamesMask</symbol></entry>
    <entry>(1&lt;&lt;13)</entry>
    <entry>Xkb-&gt;names</entry>
    <entry>radio_groups[*], num_rg</entry>
</row>
<row>
    <entry><symbol>XkbComponentNamesMask</symbol></entry>
    <entry>(0x3f)</entry>
    <entry>Xkb-&gt;names</entry>
    <entry>
<para>keycodes,</para>
<para>geometry,</para>
<para>symbols,</para>
<para>physical symbols,</para>
<para>types, and</para>
<para>compatibility map</para>
    </entry>
</row>
<row>
    <entry><symbol>XkbAllNamesMask</symbol></entry>
    <entry>(0x3fff)</entry>
    <entry>Xkb-&gt;names</entry>
    <entry>all name components</entry>
  </row>
</tbody>
</tgroup>
</table>

</sect1>
<sect1 id='Getting_Symbolic_Names_From_the_Server'>
<title>Getting Symbolic Names From the Server</title>

<para>
To obtain symbolic names from the server, use
<function>XkbGetNames</function>.
</para>

<indexterm significance="preferred" zone="XkbGetNames"><primary><function>XkbGetNames</function></primary></indexterm>
<funcsynopsis id="XkbGetNames">
  <funcprototype>
    <funcdef>Status <function>XkbGetNames</function></funcdef>
<!-- (
<parameter>dpy, which, Xkb</parameter>
) -->

    <paramdef>Display *<parameter>dpy</parameter></paramdef>
    <paramdef>unsigned int <parameter>which</parameter></paramdef>
    <paramdef>XkbDescPtr <parameter>xkb</parameter></paramdef>
  </funcprototype>
</funcsynopsis>
<variablelist>
  <varlistentry>
    <term>
      <parameter>dpy</parameter>
    </term>
    <listitem>
      <para>
        connection to the X server
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <parameter>which</parameter>
    </term>
    <listitem>
      <para>
        mask of names or map components to be updated
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <parameter>xkb</parameter>
    </term>
    <listitem>
      <para>
        keyboard description to be updated
      </para>
    </listitem>
  </varlistentry>
</variablelist>

<para>
<function>XkbGetNames</function>
retrieves symbolic names for the components of the keyboard extension from the
X server. The
<parameter>which</parameter>
parameter specifies the name components to be updated in the
<parameter>xkb</parameter>
parameter, and is the bitwise inclusive OR of the valid names mask bits
defined in <link linkend="table18.1">Table 18.1</link>.
</para>


<para>
If the
<structfield>names</structfield>
field of the keyboard description
<parameter>xkb</parameter>
is
<symbol>NULL</symbol>,
<function>XkbGetNames</function>
allocates and initializes the
<structfield>names</structfield>
component of the keyboard description before obtaining the values specified by
<parameter>which</parameter>.
If the
<structfield>names</structfield>
field of
<parameter>xkb</parameter>
is not
<symbol>NULL</symbol>,
<function>XkbGetNames</function>
obtains the values specified by
<parameter>which</parameter>
and copies them into the keyboard description
<parameter>xkb</parameter>.
</para>


<para>
If the
<structfield>map</structfield>
component of the
<parameter>xkb</parameter>
parameter is
<symbol>NULL</symbol>,
<function>XkbGetNames</function>
does not retrieve type or shift level names, even if
<symbol>XkbKeyTypeNamesMask</symbol>
or
<symbol>XkbKTLevelNamesMask</symbol>
are set in
<parameter>which</parameter>.
</para>


<para>
<function>XkbGetNames</function>
can return
<symbol>Success</symbol>,
or
<errorname>BadAlloc</errorname>,
<errorname>BadLength</errorname>,
<errorname>BadMatch</errorname>,
and
<errorname>BadImplementation</errorname>
errors.
</para>


<para>
To free symbolic names, use
<function>XkbFreeNames</function>
(see <link linkend="Allocating_and_Freeing_Symbolic_Names">section 18.6</link>)
</para>


</sect1>
<sect1 id='Changing_Symbolic_Names_on_the_Server'>
<title>Changing Symbolic Names on the Server</title>

<para>
To change the symbolic names in the server, first modify a local copy of the
keyboard description and then use either
<function>XkbSetNames</function>,
or, to save network traffic, use a
<structname>XkbNameChangesRec</structname>
structure and call
<function>XkbChangeNames</function>
to download the changes to the server.
<function>XkbSetNames</function>
and
<function>XkbChangeNames</function>
can generate
<errorname>BadAlloc</errorname>,
<errorname>BadAtom</errorname>,
<errorname>BadLength</errorname>,
<errorname>BadMatch</errorname>,
and
<errorname>BadImplementation</errorname>
errors.
</para>

<indexterm significance="preferred" zone="XkbSetNames"><primary><function>XkbSetNames</function></primary></indexterm>
<funcsynopsis id="XkbSetNames">
  <funcprototype>
    <funcdef>Bool <function>XkbSetNames</function></funcdef>
<!-- (
<parameter>dpy, which, first_type, num_types, xkb</parameter>
) -->

    <paramdef>Display *<parameter>dpy</parameter></paramdef>
    <paramdef>unsigned int <parameter>which</parameter></paramdef>
    <paramdef>unsigned int <parameter>first_type</parameter></paramdef>
    <paramdef>unsigned int <parameter>num_types</parameter></paramdef>
    <paramdef>XkbDescPtr <parameter>xkb</parameter></paramdef>
  </funcprototype>
</funcsynopsis>
<variablelist>
  <varlistentry>
    <term>
      <parameter>dpy</parameter>
    </term>
    <listitem>
      <para>
        connection to the X server
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <parameter>which</parameter>
    </term>
    <listitem>
      <para>
        mask of names or map components to be changed
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <parameter>first_type</parameter>
    </term>
    <listitem>
      <para>
        first type whose name is to be changed
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <parameter>num_types</parameter>
    </term>
    <listitem>
      <para>
        number of types for which names are to be changed
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <parameter>xkb</parameter>
    </term>
    <listitem>
      <para>
        keyboard description from which names are to be taken
      </para>
    </listitem>
  </varlistentry>
</variablelist>

<para>
Use
<function>XkbSetNames</function>
to change many names at the same time. For each bit set in
<parameter>which</parameter>,
<function>XkbSetNames</function>
takes the corresponding value (or values in the case of arrays) from the
keyboard description
<parameter>xkb</parameter>
and sends it to the server.
</para>


<para>
The
<parameter>first_type</parameter>
and
<parameter>num_types</parameter>
arguments are used only if
<symbol>XkbKeyTypeNamesMask</symbol>
or
<symbol>XkbKTLevelNamesMask</symbol>
is set in
<parameter>which</parameter>
and specify a subset of the types for which the corresponding names are to be
changed. If either or both of these mask bits are set but the specified types
are illegal,
<function>XkbSetNames</function>
returns
<symbol>False</symbol>
and does not update any of the names specified in
<parameter>which</parameter>.
The specified types are illegal if
<parameter>xkb</parameter>
does not include a map component or if
<parameter>first_type</parameter>
and
<parameter>num_types</parameter>
specify types that are not defined in the keyboard description.
</para>


<sect2>
<title/>

<sect3 id='The_XkbNameChangesRec_Structure'>
<title>The XkbNameChangesRec Structure</title>
<indexterm significance="preferred" zone="The_XkbNameChangesRec_Structure">
<primary><structname>XkbNameChangesRec</structname></primary></indexterm>

<para>
The
<structname>XkbNameChangesRec</structname>
allows applications to identify small modifications to the symbolic names and
effectively reduces the amount of traffic sent to the server:

<programlisting>
typedef struct _XkbNameChanges {
    unsigned int       changed;           /* name components that have
                                             changed */
    unsigned char      first_type;        /* first key type with a new name */
    unsigned char      num_types;         /* number of types with new names */
    unsigned char      first_lvl;         /* first key type with new level
                                             names */
    unsigned char      num_lvls;          /* number of key types with new
                                             level names */
    unsigned char      num_aliases;       /* if key aliases changed,
                                             total number of key aliases */
    unsigned char      num_rg;            /* if radio groups changed, total
                                             number of radio groups */
    unsigned char      first_key;         /* first key with a new name */
    unsigned char      num_keys;          /* number of keys with new names */
    unsigned short     changed_vmods;     /* mask of virtual modifiers
                                             for which names have changed */
    unsigned long      changed_indicators;  /* mask of indicators
                                               for which names were changed */
    unsigned char      changed_groups;    /* mask of groups for
                                             which names were changed */
} <structname>XkbNameChangesRec</structname>, *XkbNameChangesPtr;
</programlisting></para>

<para>
The
<structfield>changed</structfield>
field specifies the name components that have changed and is the bitwise
inclusive OR of the valid names mask bits defined in
<link linkend="table18.1">Table 18.1</link>. The rest of
the fields in the structure specify the ranges that have changed for the
various kinds of symbolic names, as shown in
<link linkend="table18.2">Table 18.2</link>.
</para>

<table id='table18.2' frame='topbot'>
<title>XkbNameChanges Fields</title>
<?dbfo keep-together="always" ?>
<tgroup cols='4' align='left' colsep='0' rowsep='0'>
<colspec colname='c1' colwidth='2.0*'/>
<colspec colname='c2' colwidth='1.0*'/>
<colspec colname='c3' colwidth='1.0*'/>
<colspec colname='c4' colwidth='2.0*'/>
<thead>
<row rowsep='1'>
  <entry>Mask</entry>
  <entry>Fields</entry>
  <entry>Component</entry>
  <entry>Field</entry>
</row>
</thead>
<tbody>
<row>
    <entry><symbol>XkbKeyTypeNamesMask</symbol></entry>
    <entry>
<para>first_type,</para>
<para>num_types</para>
    </entry>
    <entry>Xkb-&gt;map</entry>
    <entry>type[*].name</entry>
</row>
<row>
    <entry><symbol>XkbKTLevelNamesMask</symbol></entry>
    <entry>
<para>first_lvl,</para>
<para>num_lvls</para>
    </entry>
    <entry>Xkb-&gt;map</entry>
    <entry>type[*].lvl_names[*]</entry>
</row>
<row>
    <entry><symbol>XkbKeyAliasesMask</symbol></entry>
    <entry>num_aliases</entry>
    <entry>Xkb-&gt;names</entry>
    <entry>key_aliases[*]</entry>
</row>
<row>
    <entry><symbol>XkbRGNamesMask</symbol></entry>
    <entry>num_rg</entry>
    <entry>Xkb-&gt;names</entry>
    <entry>radio_groups[*]</entry>
</row>
<row>
    <entry><symbol>XkbKeyNamesMask</symbol></entry>
    <entry>
<para>first_key,</para>
<para>num_keys</para>
    </entry>
    <entry>Xkb-&gt;names</entry>
    <entry>keys[*]</entry>
</row>
<row>
    <entry><symbol>XkbVirtualModNamesMask</symbol></entry>
    <entry>changed_vmods</entry>
    <entry>Xkb-&gt;names</entry>
    <entry>vmods[*]</entry>
</row>
<row>
    <entry><symbol>XkbIndicatorNamesMask</symbol></entry>
    <entry>changed_indicators</entry>
    <entry>Xkb-&gt;names</entry>
    <entry>indicators[*]</entry>
</row>
<row>
    <entry><symbol>XkbGroupNamesMask</symbol></entry>
    <entry>changed_groups</entry>
    <entry>Xkb-&gt;names</entry>
    <entry>groups[*]</entry>
  </row>
</tbody>
</tgroup>
</table>

<para>
<function>XkbChangeNames</function>
provides a more flexible method for changing symbolic names than
<function>XkbSetNames</function>
and requires the use of an
<structname>XkbNameChangesRec</structname>
structure.
</para>

<indexterm significance="preferred" zone="XkbChangeNames"><primary><function>XkbChangeNames</function></primary></indexterm>
<funcsynopsis id="XkbChangeNames">
  <funcprototype>
    <funcdef>Bool <function>XkbChangeNames</function></funcdef>
<!-- (
<parameter>dpy, xkb, changes</parameter>
) -->

    <paramdef>Display *<parameter>dpy</parameter></paramdef>
    <paramdef>XkbDescPtr <parameter>xkb</parameter></paramdef>
    <paramdef>XkbNameChangesPtr <parameter>changes</parameter></paramdef>
  </funcprototype>
</funcsynopsis>
<variablelist>
  <varlistentry>
    <term>
      <parameter>dpy</parameter>
    </term>
    <listitem>
      <para>
        connection to the X server
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <parameter>xkb</parameter>
    </term>
    <listitem>
      <para>
        keyboard description from which names are to be taken
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <parameter>changes</parameter>
    </term>
    <listitem>
      <para>
        names map components to be updated on the server
      </para>
    </listitem>
  </varlistentry>
</variablelist>

<para>
<function>XkbChangeNames</function>
copies any names specified by
<parameter>changes</parameter>
from the keyboard description,
<parameter>xkb</parameter>,
to the X server specified by
<parameter>dpy</parameter>.
<function>XkbChangeNames</function>
aborts and returns
<symbol>False</symbol>
if any illegal type names or type shift level names are specified by
<parameter>changes</parameter>.
</para>

</sect3>
</sect2>
</sect1>
<sect1 id='Tracking_Name_Changes'>
<title>Tracking Name Changes</title>
<indexterm significance="preferred" zone="Tracking_Name_Changes">
<primary>events</primary><secondary><symbol>XkbNamesNotify</symbol></secondary></indexterm>
<indexterm significance="preferred" zone="Tracking_Name_Changes">
<primary><structname>XkbNamesNotifyEvent</structname></primary></indexterm>

<para>
Whenever a symbolic name changes in the server’s keyboard description, the
server sends a
<symbol>XkbNamesNotify</symbol>
event to all interested clients. To receive name notify events, use
<function>XkbSelectEvents</function>
(see <link linkend="Selecting_Xkb_Events">section 4.3</link>) with
<symbol>XkbNamesNotifyMask</symbol>
in both the
<parameter>bits_to_change</parameter>
and
<parameter>values_for_bits</parameter>
parameters.
</para>


<para>
To receive events for only specific names, use
<function>XkbSelectEventDetails</function>.
Set the
<structfield>event_type</structfield>
parameter to
<symbol>XkbNamesNotify</symbol>,
and set both the
<parameter>bits_to_change</parameter>
and
<parameter>values_for_bits</parameter>
detail parameter to a mask composed of a bitwise OR of masks in
<link linkend="table18.1">Table 18.1</link>.
</para>


<para>
The structure for the
<symbol>XkbNamesNotify</symbol>
event is defined as follows:

<programlisting>
typedef struct {
    int             type;           /* Xkb extension base event code */
    unsigned long   serial;         /* X server serial number for event */
    Bool            send_event;     /* <symbol>True</symbol> &rArr; synthetically generated */
    Display *       display;        /* server connection where event generated */
    Time            time;           /* server time when event generated */
    int             xkb_type;       /* <symbol>XkbNamesNotify</symbol> */
    int             device;         /* Xkb device ID, will not be
                                       <symbol>XkbUseCoreKbd</symbol> */
    unsigned int    changed;        /* mask of name components
                                       that have changed */
    int             first_type;     /* first key type with a new name */
    int             num_types;      /* number of types with new names */
    int             first_lvl;      /* first key type with new level names */
    int             num_lvls;       /* number of key types with new level names */
    int             num_aliases;    /* if key aliases changed, total number
                                       of key aliases */
    int             num_radio_groups;  /* if radio groups changed,
                                         total number of radio groups */
    unsigned int    changed_vmods;  /* mask of virtual modifiers for
                                       which names have changed */
    unsigned int    changed_groups; /* mask of groups for
                                       which names were changed */
    unsigned int    changed_indicators;  /* mask of indicators for which
                                              names were changed */
    int             first_key;      /* first key with a new name */
    int             num_keys;       /* number of keys with new names */
} <structname>XkbNamesNotifyEvent</structname>;
</programlisting></para>

<para>
The
<structfield>changed</structfield>
field specifies the name components that have changed and is the bitwise
inclusive OR of the valid names mask bits defined in
<link linkend="table18.1">Table 18.1</link>. The other
fields in this event are interpreted as the like-named fields in an
<structname>XkbNameChangesRec</structname> , as previously defined.
</para>


<para>
When your application receives a
<symbol>XkbNamesNotify</symbol>
event, you can note the changed names in a changes structure using
<function>XkbNoteNameChanges</function>.
</para>

<indexterm significance="preferred" zone="XkbNoteNameChanges"><primary><function>XkbNoteNameChanges</function></primary></indexterm>
<funcsynopsis id="XkbNoteNameChanges">
  <funcprototype>
    <funcdef>void <function>XkbNoteNameChanges</function></funcdef>
<!-- (
<parameter>old</parameter>,
<parameter>new</parameter>,
<parameter>wanted</parameter>
) -->

    <paramdef>XkbNameChangesPtr <parameter>old</parameter></paramdef>
    <paramdef>XkbNamesNotifyEvent *<parameter>new</parameter></paramdef>
    <paramdef>unsigned int <parameter>wanted</parameter></paramdef>
  </funcprototype>
</funcsynopsis>
<variablelist>
  <varlistentry>
    <term>
      <parameter>old</parameter>
    </term>
    <listitem>
      <para>
        <structname>XkbNameChangesRec</structname> structure to be updated
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <parameter>new</parameter>
    </term>
    <listitem>
      <para>
        event from which changes are to be copied
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <parameter>wanted</parameter>
    </term>
    <listitem>
      <para>
        types of names for which changes are to be noted
      </para>
    </listitem>
  </varlistentry>
</variablelist>

<para>
The
<parameter>wanted</parameter>
parameter is the bitwise inclusive OR of the valid names mask bits shown in
<link linkend="table18.1">Table 18.1</link>.
<function>XkbNoteNameChanges</function>
copies any changes that are reported in
<parameter>new</parameter>
and specified in
<parameter>wanted</parameter>
into the changes record specified by
<parameter>old</parameter>.
</para>


<para>
To update the local copy of the keyboard description with the actual values,
pass to
<function>XkbGetNameChanges</function>
the results of one or more calls to
<function>XkbNoteNameChanges</function>.
</para>


<indexterm significance="preferred" zone="XkbGetNameChanges"><primary><function>XkbGetNameChanges</function></primary></indexterm>
<funcsynopsis id="XkbGetNameChanges">
  <funcprototype>
    <funcdef>Status <function>XkbGetNameChanges</function></funcdef>
<!-- (
<parameter>dpy</parameter>,
<parameter>xkb</parameter>,
<parameter>changes</parameter>
) -->

    <paramdef>Display *<parameter>dpy</parameter></paramdef>
    <paramdef>XkbDescPtr <parameter>xkb</parameter></paramdef>
    <paramdef>XkbNameChangesPtr <parameter>changes</parameter></paramdef>
  </funcprototype>
</funcsynopsis>
<variablelist>
  <varlistentry>
    <term>
      <parameter>dpy</parameter>
    </term>
    <listitem>
      <para>
        connection to the X server
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <parameter>xkb</parameter>
    </term>
    <listitem>
      <para>
        keyboard description to which names are copied
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <parameter>changes</parameter>
    </term>
    <listitem>
      <para>
        names components to be obtained from the server
      </para>
    </listitem>
  </varlistentry>
</variablelist>

<para>
<function>XkbGetNameChanges</function>
examines the
<parameter>changes</parameter>
parameter, retrieves the necessary information from the server, and places the
results into the
<parameter>xkb</parameter>
keyboard description.
</para>


<para>
<function>XkbGetNameChanges</function>
can generate
<errorname>BadAlloc</errorname>,
<errorname>BadImplementation</errorname>,
and
<errorname>BadMatch</errorname>
errors.
</para>


</sect1>
<sect1 id='Allocating_and_Freeing_Symbolic_Names'>
<title>Allocating and Freeing Symbolic Names</title>

<para>
Most applications do not need to directly allocate symbolic names structures.
Do not allocate a names structure directly using
<function>malloc</function>
or
<function>Xmalloc</function>
if your application changes the number of key aliases or radio groups or
constructs a symbolic names structure without loading the necessary components
from the X server. Instead use
<function>XkbAllocNames</function>.
</para>

<indexterm significance="preferred" zone="XkbAllocNames"><primary><function>XkbAllocNames</function></primary></indexterm>
<funcsynopsis id="XkbAllocNames">
  <funcprototype>
    <funcdef>Status <function>XkbAllocNames</function></funcdef>
<!-- (
<parameter>xkb, which, num_rg, num_key_aliases)</parameter> -->

    <paramdef>XkbDescPtr <parameter>xkb</parameter></paramdef>
    <paramdef>unsigned int <parameter>which</parameter></paramdef>
    <paramdef>int <parameter>num_rg</parameter></paramdef>
    <paramdef>int <parameter>num_key_aliases</parameter></paramdef>
  </funcprototype>
</funcsynopsis>
<variablelist>
  <varlistentry>
    <term>
      <parameter>xkb</parameter>
    </term>
    <listitem>
      <para>
        keyboard description for which names are to be allocated
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <parameter>which</parameter>
    </term>
    <listitem>
      <para>
        mask of names to be allocated
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <parameter>num_rg</parameter>
    </term>
    <listitem>
      <para>
        total number of radio group names needed
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <parameter>num_key_aliases</parameter>
    </term>
    <listitem>
      <para>
        total number of key aliases needed
      </para>
    </listitem>
  </varlistentry>
</variablelist>

<para>
<function>XkbAllocNames</function>
can return
<errorname>BadAlloc</errorname>,
<errorname>BadMatch</errorname>,
and
<errorname>BadValue</errorname>
errors.
The
<parameter>which</parameter>
parameter is the bitwise inclusive OR of the valid names mask bits defined in
<link linkend="table18.1">Table 18.1</link>.
</para>


<para>
Do not free symbolic names structures directly using
<function>free</function>
or
<function>XFree</function>.
Use
<function>XkbFreeNames</function>
instead.
</para>


<indexterm significance="preferred" zone="XkbFreeNames"><primary><function>XkbFreeNames</function></primary></indexterm>
<funcsynopsis id="XkbFreeNames">
  <funcprototype>
    <funcdef>void <function>XkbFreeNames</function></funcdef>
<!-- (
<parameter>xkb, which, free_map)</parameter> -->

    <paramdef>XkbDescPtr <parameter>xkb</parameter></paramdef>
    <paramdef>unsigned int <parameter>which</parameter></paramdef>
    <paramdef>Bool <parameter>free_map</parameter></paramdef>
  </funcprototype>
</funcsynopsis>
<variablelist>
  <varlistentry>
    <term>
      <parameter>xkb</parameter>
    </term>
    <listitem>
      <para>
        keyboard description for which names are to be freed
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <parameter>which</parameter>
    </term>
    <listitem>
      <para>
        mask of names components to be freed
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <parameter>free_map</parameter>
    </term>
    <listitem>
      <para>
        <symbol>True</symbol>
         &rArr; XkbNamesRec structure itself should be freed
      </para>
    </listitem>
  </varlistentry>
</variablelist>

<para>
The
<parameter>which</parameter>
parameter is the bitwise inclusive OR of the valid names mask bits defined in
<link linkend="table18.1">Table 18.1</link>.
</para>
</sect1>
</chapter>