aboutsummaryrefslogtreecommitdiff
path: root/libX11/specs/XKB/ch18.xml
blob: 806b09a45716f72e7609f94d911e11979ffc6b9e (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
<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 <emphasis>
Shift</emphasis>
, <emphasis>
Lock</emphasis>
 and <emphasis>
Control</emphasis>
 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 <emphasis>
names</emphasis>
 component of the keyboard description.
</para>

<sect1 id='The_XkbNamesRec_Structure'>
<title>The XkbNamesRec Structure</title>

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

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

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

<para><programlisting>
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 */
} <emphasis>XkbKeyAliasRec</emphasis>,*XkbKeyAliasPtr;
</programlisting></para>

<para><programlisting>
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 <emphasis> keys</emphasis> array */
      unsigned char      num_key_aliases;  /* number of keys in the
                                              <emphasis> key_aliases</emphasis> array */
      unsigned short     num_rg;      /* number of radio groups */
} <emphasis>XkbNamesRec</emphasis>,*XkbNamesPtr;      /*
</programlisting></para>

<para>
The <emphasis>
keycodes</emphasis>
 name identifies the range and meaning of the keycodes returned by the keyboard
in question. The <emphasis>
geometry</emphasis>
 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 <emphasis>
geometry</emphasis>
 name to determine which subset of the named keycodes is in use.</para></note>

<para>
The <emphasis>
symbols</emphasis>
 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 <emphasis>
phys_symbols</emphasis>
 name, on the other hand, identifies the symbols actually engraved on the
keyboard. Given this, the <emphasis>
symbols</emphasis>
 name and <emphasis>
phys_symbols</emphasis>
 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
<emphasis>
phys_symbols</emphasis>
 name of "en_US" and a <emphasis>
symbols</emphasis>
 name of "de_CH."
</para>


<para>
The <emphasis>
types</emphasis>
 name provides some information about the set of key types (see section 15.2)
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 <emphasis>
compat</emphasis>
 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 <emphasis>
vmods</emphasis>
, <emphasis>
indicators</emphasis>
, and <emphasis>
groups</emphasis>
 fixed-length arrays.
</para>


<para>
Each key has a four-byte symbolic name. All of the symbolic key names are held
in the <emphasis>
keys</emphasis>
 array, and <emphasis>
num_keys</emphasis>
 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 <emphasis>
F1</emphasis>
 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 "function." 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 <emphasis>
key_aliases</emphasis>
 field holds a variable-length array of real and alias key name pairs, and the
total number of entries in the <emphasis>
key_aliases</emphasis>
 array is held in <emphasis>
num_key_aliases</emphasis>
. For each real and alias key name pair, the <emphasis>
real</emphasis>
 field refers to the a name in the keys array, and the <emphasis>
alias</emphasis>
 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 <emphasis>
key_aliases</emphasis>
 array.
</para>

<note><para>Key aliases defined in the geometry component of a keyboard mapping
(see Chapter 13) override those defined in the keycodes component of the server
database, which are stored in the <emphasis>
XkbNamesRec</emphasis>
 (<emphasis>
xkb-&gt;names</emphasis>
). Therefore, consider the key aliases defined by the geometry before
considering key aliases supplied by the <emphasis>
XkbNamesRec</emphasis>
.</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 <emphasis>
radio_groups</emphasis>
, and <emphasis>
num_rg</emphasis>
 tells how many elements are in the <emphasis>
radio_groups</emphasis>
 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 Table 18.1.
</para>

<table 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>XkbKeycodesNameMask</entry>
    <entry>(1&lt;&lt;0)</entry>
    <entry>Xkb-&gt;names</entry>
    <entry>keycodes</entry>
</row>
<row>
    <entry>XkbGeometryNameMask</entry>
    <entry>(1&lt;&lt;1)</entry>
    <entry>Xkb-&gt;names</entry>
    <entry>geometry</entry>
</row>
<row>
    <entry>XkbSymbolsNameMask</entry>
    <entry>(1&lt;&lt;2)</entry>
    <entry>Xkb-&gt;names</entry>
    <entry>symbols</entry>
</row>
<row>
    <entry>XkbPhysSymbolsNameMask</entry>
    <entry>(1&lt;&lt;3)</entry>
    <entry>Xkb-&gt;names</entry>
    <entry>phys_symbols</entry>
</row>
<row>
    <entry>XkbTypesNameMask</entry>
    <entry>(1&lt;&lt;4)</entry>
    <entry>Xkb-&gt;names</entry>
    <entry>type</entry>
</row>
<row>
    <entry>XkbCompatNameMask</entry>
    <entry>(1&lt;&lt;5)</entry>
    <entry>Xkb-&gt;names</entry>
    <entry>compat</entry>
</row>
<row>
    <entry>XkbKeyTypeNamesMask</entry>
    <entry>(1&lt;&lt;6)</entry>
    <entry>Xkb-&gt;map</entry>
    <entry>type[*].name</entry>
</row>
<row>
    <entry>XkbKTLevelNamesMask</entry>
    <entry>(1&lt;&lt;7)</entry>
    <entry>Xkb-&gt;map</entry>
    <entry>type[*].lvl_names[*]</entry>
</row>
<row>
    <entry>XkbIndicatorNamesMask</entry>
    <entry>(1&lt;&lt;8)</entry>
    <entry>Xkb-&gt;names</entry>
    <entry>indicators[*]</entry>
</row>
<row>
    <entry>XkbKeyNamesMask</entry>
    <entry>(1&lt;&lt;9)</entry>
    <entry>Xkb-&gt;names</entry>
    <entry>keys[*], num_keys</entry>
</row>
<row>
    <entry>XkbKeyAliasesMask</entry>
    <entry>(1&lt;&lt;10)</entry>
    <entry>Xkb-&gt;names</entry>
    <entry>key_aliases[*], num_key_aliases</entry>
</row>
<row>
    <entry>XkbVirtualModNamesMask</entry>
    <entry>(1&lt;&lt;11)</entry>
    <entry>Xkb-&gt;names</entry>
    <entry>vmods[*]</entry>
</row>
<row>
    <entry>XkbGroupNamesMask</entry>
    <entry>(1&lt;&lt;12)</entry>
    <entry>Xkb-&gt;names</entry>
    <entry>groups[*]</entry>
</row>
<row>
    <entry>XkbRGNamesMask</entry>
    <entry>(1&lt;&lt;13)</entry>
    <entry>Xkb-&gt;names</entry>
    <entry>radio_groups[*], num_rg</entry>
</row>
<row>
    <entry>XkbComponentNamesMask</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>XkbAllNamesMask</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 <emphasis>
XkbGetNames</emphasis>
.
</para>

<informaltable frame='none'>
<?dbfo keep-together="always" ?>
<tgroup cols='1' align='left' colsep='0' rowsep='0'>
<colspec colname='c1' colwidth='1.0*'/>
<tbody>
  <row>
    <entry role='functiondecl'>
Status <emphasis>
XkbGetNames</emphasis>
(<emphasis>
dpy, which, Xkb</emphasis>
)
    </entry>
  </row>
  <row>
    <entry role='functionargdecl'>
Display *      <emphasis>
dpy</emphasis>
;      /* connection to the X server */
    </entry>
  </row>
  <row>
    <entry role='functionargdecl'>
unsigned int      <emphasis>
which</emphasis>
;      /* mask of names or map components to be updated */
    </entry>
  </row>
  <row>
    <entry role='functionargdecl'>
XkbDescPtr      <emphasis>
xkb</emphasis>
      /* keyboard description to be updated */
    </entry>
</row>
</tbody>
</tgroup>
</informaltable>

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


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


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


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


<para>
To free symbolic names, use <emphasis>
XkbFreeNames</emphasis>
 (see section 18.6)
</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 <emphasis>
XkbSetNames,</emphasis>
 or, to save network traffic, use a <emphasis>
XkbNameChangesRec</emphasis>
structure and call <emphasis>
XkbChangeNames</emphasis>
 to download the changes to the server. <emphasis>
XkbSetNames</emphasis>
 and <emphasis>
XkbChangeNames</emphasis>
 can generate <emphasis>
BadAlloc</emphasis>
, <emphasis>
BadAtom</emphasis>
, <emphasis>
BadLength</emphasis>
, <emphasis>
BadMatch,</emphasis>
 and <emphasis>
BadImplementation</emphasis>
 errors.
</para>

<informaltable frame='none'>
<?dbfo keep-together="always" ?>
<tgroup cols='1' align='left' colsep='0' rowsep='0'>
<colspec colname='c1' colwidth='1.0*'/>
<tbody>
  <row>
    <entry role='functiondecl'>
Bool <emphasis>
XkbSetNames</emphasis>
(<emphasis>
dpy, which, first_type, num_types, xkb</emphasis>
)
    </entry>
  </row>
  <row>
    <entry role='functionargdecl'>
Display *      <emphasis>
dpy</emphasis>
;            /* connection to the X server */
    </entry>
  </row>
  <row>
    <entry role='functionargdecl'>
unsigned int      <emphasis>
which</emphasis>
;            /* mask of names or map components to be changed */
    </entry>
  </row>
  <row>
    <entry role='functionargdecl'>
unsigned int      <emphasis>
first_type</emphasis>
      ;      /* first type whose name is to be changed */
    </entry>
  </row>
  <row>
    <entry role='functionargdecl'>
unsigned int      <emphasis>
num_types</emphasis>
;            /* number of types for which names are to be changed */
    </entry>
  </row>
  <row>
    <entry role='functionargdecl'>
XkbDescPtr      <emphasis>
xkb</emphasis>
;            /* keyboard description from which names are to be taken */
    </entry>
</row>
</tbody>
</tgroup>
</informaltable>

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


<para>
The <emphasis>
first_type</emphasis>
 and <emphasis>
num_types</emphasis>
 arguments are used only if <emphasis>
XkbKeyTypeNamesMask</emphasis>
 or <emphasis>
XkbKTLevelNamesMask</emphasis>
 is set in <emphasis>
which</emphasis>
 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, <emphasis>
XkbSetNames</emphasis>
 returns <emphasis>
False</emphasis>
 and does not update any of the names specified in <emphasis>
which</emphasis>
. The specified types are illegal if <emphasis>
xkb</emphasis>
 does not include a map component or if <emphasis>
first_type</emphasis>
 and <emphasis>
num_types</emphasis>
 specify types that are not defined in the keyboard description.
</para>


<sect2>
<title/>

<sect3 id='The_XkbNameChangesRec_Structure'>
<title>The XkbNameChangesRec Structure</title>

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

<para><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 */
} <emphasis>XkbNameChangesRec</emphasis>, *XkbNameChangesPtr
</programlisting></para>

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

<table 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>XkbKeyTypeNamesMask</entry>
    <entry>
<para>first_type,</para>
<para>num_types</para>
    </entry>
    <entry>Xkb-&gt;map</entry>
    <entry>type[*].name</entry>
</row>
<row>
    <entry>XkbKTLevelNamesMask</entry>
    <entry>
<para>first_lvl,</para>
<para>num_lvls</para>
    </entry>
    <entry>Xkb-&gt;map</entry>
    <entry>type[*].lvl_names[*]</entry>
</row>
<row>
    <entry>XkbKeyAliasesMask</entry>
    <entry>num_aliases</entry>
    <entry>Xkb-&gt;names</entry>
    <entry>key_aliases[*]</entry>
</row>
<row>
    <entry>XkbRGNamesMask</entry>
    <entry>num_rg</entry>
    <entry>Xkb-&gt;names</entry>
    <entry>radio_groups[*]</entry>
</row>
<row>
    <entry>XkbKeyNamesMask</entry>
    <entry>
<para>first_key,</para>
<para>num_keys</para>
    </entry>
    <entry>Xkb-&gt;names</entry>
    <entry>keys[*]</entry>
</row>
<row>
    <entry>XkbVirtualModNamesMask</entry>
    <entry>changed_vmods</entry>
    <entry>Xkb-&gt;names</entry>
    <entry>vmods[*]</entry>
</row>
<row>
    <entry>XkbIndicatorNamesMask</entry>
    <entry>changed_indicators</entry>
    <entry>Xkb-&gt;names</entry>
    <entry>indicators[*]</entry>
</row>
<row>
    <entry>XkbGroupNamesMask</entry>
    <entry>changed_groups</entry>
    <entry>Xkb-&gt;names</entry>
    <entry>groups[*]</entry>
  </row>
</tbody>
</tgroup>
</table>

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

<informaltable frame='none'>
<?dbfo keep-together="always" ?>
<tgroup cols='1' align='left' colsep='0' rowsep='0'>
<colspec colname='c1' colwidth='1.0*'/>
<tbody>
  <row>
    <entry role='functiondecl'>
Bool <emphasis>
XkbChangeNames</emphasis>
(<emphasis>
dpy, xkb, changes</emphasis>
)
    </entry>
  </row>
  <row>
    <entry role='functionargdecl'>
Display *            <emphasis>
dpy</emphasis>
;            /* connection to the X server */
    </entry>
  </row>
  <row>
    <entry role='functionargdecl'>
XkbDescPtr      <emphasis>
      xkb</emphasis>
;            /* keyboard description from which names are to be taken */
    </entry>
  </row>
  <row>
    <entry role='functionargdecl'>
XkbNameChangesPtr      <emphasis>
      changes</emphasis>
;            /* names map components to be updated on the server */
    </entry>
</row>
</tbody>
</tgroup>
</informaltable>

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

</sect3>
</sect2>
</sect1>
<sect1 id='Tracking_Name_Changes'>
<title>Tracking Name Changes</title>

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


<para>
To receive events for only specific names, use <emphasis>
XkbSelectEventDetails</emphasis>
. Set the <emphasis>
event_type</emphasis>
 parameter to <emphasis>
XkbNamesNotify</emphasis>
, and set both the <emphasis>
bits_to_change </emphasis>
and<emphasis>
 values_for_bits</emphasis>
 detail parameter to a mask composed of a bitwise OR of masks in Table 18.1.
</para>


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

<para><programlisting>
typedef struct {
      int      type;                  /* Xkb extension base event code */
      unsigned long      serial;      /* X server serial number for
                                         event */
      Bool      send_event;           /* <emphasis>True</emphasis>
                                         =&gt; synthetically generated */
      Display *      display;         /* server connection where event
                                         generated */
      Time      time;                 /* server time when event generated */
      int      xkb_type;              /* <emphasis>XkbNamesNotify</emphasis> */
      int      device;                /* Xkb device ID, will not be
                                         <emphasis>XkbUseCoreKbd</emphasis> */
      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 */
} <emphasis>XkbNamesNotifyEvent</emphasis>;
</programlisting></para>

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


<para>
When your application receives a X<emphasis>
kbNamesNotify</emphasis>
 event, you can note the changed names in a changes structure using <emphasis>
XkbNoteNameChanges</emphasis>
.
</para>

<informaltable frame='none'>
<?dbfo keep-together="always" ?>
<tgroup cols='1' align='left' colsep='0' rowsep='0'>
<colspec colname='c1' colwidth='1.0*'/>
<tbody>
  <row>
    <entry role='functiondecl'>
void <emphasis>
XkbNoteNameChanges</emphasis>
(<emphasis>
old</emphasis>
,<emphasis>
 new</emphasis>
,<emphasis>
 wanted</emphasis>
)
    </entry>
  </row>
  <row>
    <entry role='functionargdecl'>
XkbNameChangesPtr            <emphasis>
old</emphasis>
;            /* <emphasis>
XkbNameChanges</emphasis>
 structure to be updated */
    </entry>
  </row>
  <row>
    <entry role='functionargdecl'>
XkbNamesNotifyEvent *            <emphasis>
new</emphasis>
;            /* event from which changes are to be copied */
    </entry>
  </row>
  <row>
    <entry role='functionargdecl'>
unsigned int            <emphasis>
wanted</emphasis>
;            /* types of names for which changes are to be noted */
    </entry>
</row>
</tbody>
</tgroup>
</informaltable>

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


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


<informaltable frame='none'>
<?dbfo keep-together="always" ?>
<tgroup cols='1' align='left' colsep='0' rowsep='0'>
<colspec colname='c1' colwidth='1.0*'/>
<tbody>
  <row>
    <entry role='functiondecl'>
Status <emphasis>
XkbGetNameChanges</emphasis>
(<emphasis>
dpy</emphasis>
,<emphasis>
 xkb</emphasis>
,<emphasis>
 changes</emphasis>
)
    </entry>
  </row>
  <row>
    <entry role='functionargdecl'>
Display *            <emphasis>
dpy</emphasis>
;            /* connection to the X server */
    </entry>
  </row>
  <row>
    <entry role='functionargdecl'>
XkbDescPtr            <emphasis>
xkb</emphasis>
;            /* keyboard description to which names are copied */
    </entry>
  </row>
  <row>
    <entry role='functionargdecl'>
XkbNameChangesPtr            <emphasis>
changes</emphasis>
;            /* names components to be obtained from the server */
    </entry>
</row>
</tbody>
</tgroup>
</informaltable>

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


<para>
<emphasis>
XkbGetNamesChanges</emphasis>
 can generate <emphasis>
BadAlloc</emphasis>
, <emphasis>
BadImplementation,</emphasis>
 and <emphasis>
BadMatch</emphasis>
 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 <emphasis>
malloc</emphasis>
 or <emphasis>
Xmalloc</emphasis>
 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 <emphasis>
XkbAllocNames</emphasis>
.
</para>

<informaltable frame='none'>
<?dbfo keep-together="always" ?>
<tgroup cols='1' align='left' colsep='0' rowsep='0'>
<colspec colname='c1' colwidth='1.0*'/>
<tbody>
  <row>
    <entry role='functiondecl'>
Status <emphasis>
XkbAllocNames</emphasis>
(<emphasis>
xkb, which, num_rg, num_key_aliases)</emphasis>
    </entry>
  </row>
  <row>
    <entry role='functionargdecl'>
XkbDescPtr      <emphasis>
xkb;</emphasis>
      /* keyboard description for which names are to be allocated */
    </entry>
  </row>
  <row>
    <entry role='functionargdecl'>
unsigned int      <emphasis>
which;</emphasis>
      /* mask of names to be allocated */
    </entry>
  </row>
  <row>
    <entry role='functionargdecl'>
int      <emphasis>
num_rg;</emphasis>
      /* total number of radio group names needed */
    </entry>
  </row>
  <row>
    <entry role='functionargdecl'>
int      <emphasis>
num_key_aliases;</emphasis>
      /* total number of key aliases needed */
    </entry>
</row>
</tbody>
</tgroup>
</informaltable>

<para>
<emphasis>
XkbAllocNames</emphasis>
 can return <emphasis>
BadAlloc</emphasis>
, <emphasis>
BadMatch,</emphasis>
 and <emphasis>
BadValue</emphasis>
 errors.<emphasis>
 </emphasis>
The <emphasis>
which</emphasis>
 parameter is the bitwise inclusive OR of the valid names mask bits defined in
Table 18.1.
</para>


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


<informaltable frame='none'>
<?dbfo keep-together="always" ?>
<tgroup cols='1' align='left' colsep='0' rowsep='0'>
<colspec colname='c1' colwidth='1.0*'/>
<tbody>
  <row>
    <entry role='functiondecl'>
void <emphasis>
XkbFreeNames</emphasis>
(<emphasis>
xkb, which, free_map)</emphasis>
    </entry>
  </row>
  <row>
    <entry role='functionargdecl'>
XkbDescPtr      <emphasis>
xkb</emphasis>
;      /* keyboard description for which names are to be freed */
    </entry>
  </row>
  <row>
    <entry role='functionargdecl'>
unsigned int      <emphasis>
which</emphasis>
;      /* mask of names components to be freed */
    </entry>
  </row>
  <row>
    <entry role='functionargdecl'>
Bool      <emphasis>
free_map</emphasis>
;      /* <emphasis>
True</emphasis>
 =&gt; XkbNamesRec structure itself should be freed */
    </entry>
</row>
</tbody>
</tgroup>
</informaltable>

<para>
The <emphasis>
which</emphasis>
 parameter is the bitwise inclusive OR of the valid names mask bits defined in
Table 18.1.
</para>
</sect1>
</chapter>