summaryrefslogtreecommitdiff
path: root/specs/XKB/ch14.xml
blob: cc3ee002ada7b174191a6f1232d77f9ac3d90531 (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
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
<chapter id='xkb_keyboard_mapping'>
<title>Xkb Keyboard Mapping</title>

<para>
The Xkb keyboard mapping contains all the information the server and clients
need to interpret key events. This chapter provides an overview of the
terminology used to describe an Xkb keyboard mapping and introduces common
utilities for manipulating the keyboard mapping.
</para>


<para>
The mapping consists of two components, a server map and a client map. The
<emphasis>
client</emphasis>
 map is the collection of information a client needs to interpret key events
from the keyboard. It contains a global list of key types and an array of key
symbol maps, each of which describes the symbols bound to a key and the rules
to be used to interpret those symbols. The <emphasis>
server</emphasis>
 map contains the information the server needs to interpret key events. This
includes actions and behaviors for each key, explicit components for a key, and
the virtual modifiers and the per-key virtual modifier mapping.
</para>


<para>
For detailed information on particular components of the keyboard map, refer to
Chapter 15, "Xkb Client Keyboard Mapping" and Chapter 16, "Xkb Server Keyboard
Mapping."
</para>

<sect1 id='notation_and_terminology'>
<title>Notation and Terminology</title>

<para>
The graphic characters or control functions that may be accessed by one key are
logically arranged in groups and levels, where <emphasis>
group</emphasis>
 and <emphasis>
level</emphasis>
 are defined as in the ISO9995 standard:
</para>

<variablelist>
  <varlistentry>
    <term>Group:</term>
    <listitem>
      <para>
A logical state of a keyboard providing access to a collection of
graphic characters. Usually these graphic characters logically belong together
and may be arranged on several levels within a group.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>Level:</term>
    <listitem>
      <para>
One of several states (normally 2 or 3) governing which graphic
character is produced when a graphic key is actuated. In certain cases the
level may also affect function keys.
      </para>
    </listitem>
  </varlistentry>
</variablelist>

<para>
These definitions, taken from the ISO standard, refer to graphic keys and
characters. In the context of Xkb, Group and Level are not constrained to
graphic keys and characters; they may be used with any key to access any
character the key is capable of generating.
</para>


<para>
Level is often referred to as "Shift Level". Levels are numbered sequentially
starting at one.
</para>

<note><para>Shift level is derived from the modifier state, but not necessarily
in the same way for all keys. For example, the <emphasis>
Shift</emphasis>
 modifier selects shift level 2 on most keys, but for keypad keys the modifier
bound to <emphasis>
Num_Lock</emphasis>
 (that is, the <emphasis>
NumLock</emphasis>
 virtual modifier) also selects shift level 2.</para></note>

<para>
For example, consider the following key (the gray characters indicate symbols
that are implied or expected but are not actually engraved on the key):
</para>

<mediaobject>
 <imageobject> <imagedata fileref="XKBlib-14.gif"/>
 </imageobject>
<caption>Shift Levels and Groups</caption>
 </mediaobject>


<!--
<H5 CLASS="Figure">
Shift Levels and Groups</H5>
-->

<para>
This key has two groups, indicated by the columns, and each group has two shift
levels. For the first group (Group1), the symbol shift level one is <emphasis>
a</emphasis>
, and the symbol for shift level two is <emphasis>
A</emphasis>
. For the second group, the symbol for shift level one is <emphasis>
æ</emphasis>
, and the symbol for shift level two is <emphasis>
Æ</emphasis>
.
</para>

<sect2 id='core_implementation'>
<title>Core Implementation</title>

<para>
The standard interpretation rules for the core X keymap only allow clients to
access keys such as the one shown in Figure 14.1. That is, clients using the
standard interpretation rules can only access one of four keysyms for any given
<emphasis>
KeyPress</emphasis>
 event — two different symbols in two different groups.
</para>


<para>
In general, the <emphasis>
Shift</emphasis>
 modifier, the <emphasis>
Lock</emphasis>
 modifier, and the modifier bound to the <emphasis>
Num_Lock</emphasis>
 key are used to change between shift level 1 and shift level 2. To switch
between groups, the core implementation uses the modifier bound to the
<emphasis>
Mode_switch</emphasis>
 key. When the <emphasis>
Mode_switch</emphasis>
 modifier is set, the keyboard is logically in Group 2. When the <emphasis>
Mode_switch</emphasis>
 modifier is not set, the keyboard is logically in Group 1.
</para>


<para>
The core implementation does not clearly specify the behavior of keys. For
example, the locking behavior of the <emphasis>
CapsLock</emphasis>
 and <emphasis>
Num_Lock</emphasis>
 keys depends on the vendor.
</para>


</sect2>
<sect2 id='xkb_implementation'>
<title>Xkb Implementation</title>

<para>
Xkb extends the core implementation by providing access to up to four keyboard
groups with up to 63 shift levels per key
<footnote><para>
The core implementation restricts the number of symbols per key to 255.
With four groups, this allows for up to 63 symbols (or shift levels) per
group. Most keys will only have a few shift levels.
</para></footnote>. In
addition, Xkb provides precise specifications regarding the behavior of keys.
In Xkb, modifier state and the current group are independent (with the
exception of compatibility mapping, discussed in Chapter 17).
</para>


<para>
Xkb handles switching between groups via key actions, independent of any
modifier state information. Key actions are in the server map component and are
described in detail in section 16.1.4.
</para>


<para>
Xkb handles shift levels by associating a key type with each group on each key.
Each key type defines the shift levels available for the groups on keys of its
type and specifies the modifier combinations necessary to access each level.
</para>


<para>
For example, Xkb allows key types where the <emphasis>
Control</emphasis>
 modifier can be used to access the shift level two of a key. Key types are in
the client map component and are described in detail in section 15.2. <!-- xref -->
</para>


<para>
Xkb provides precise specification of the behavior of a key using key
behaviors. Key behaviors are in the server map component and are described in
detail in section 16.2. <!-- xref -->
</para>


</sect2>
</sect1>
<sect1 id='getting_map_components_from_the_server'>
<title>Getting Map Components from the Server</title>

<para>
Xkb provides two functions to obtain the keyboard mapping components from the
server. The first function, <emphasis>
XkbGetMap</emphasis>
, allocates an <emphasis>
XkbDescRec</emphasis>
 structure, retrieves mapping components from the server, and stores them in
the <emphasis>
XkbDescRec</emphasis>
 structure it just allocated. The second function, <emphasis>
XkbGetUpdatedMap</emphasis>
, retrieves mapping components from the server and stores them in an <emphasis>
XkbDescRec</emphasis>
 structure that has previously been allocated.
</para>


<para>
To allocate an <emphasis>
XkbDescRec</emphasis>
 structure and populate it with the server’s keyboard client map and server
map, use <emphasis>
XkbGetMap. XkbGetMap </emphasis>
is similar to <emphasis>
XkbGetKeyboard</emphasis>
 (see section 6.2), but is used only for obtaining the address of an <emphasis>
XkbDescRec</emphasis>
 structure that is populated with keyboard mapping components. It allows finer
control over which substructures of the keyboard mapping components are to be
populated. <emphasis>
XkbGetKeyboard</emphasis>
 always returns fully populated components, while <emphasis>
XkbGetMap</emphasis>
 can be instructed to return a partially populated component.
</para>

<informaltable frame='none'>
<tgroup cols='1'>
<colspec colsep='0'/>
<tbody>
  <row rowsep='0'>
    <entry role='functiondecl'>
XkbDescPtr <emphasis>
XkbGetMap</emphasis>
(<emphasis>
display, which, device_spec</emphasis>
)
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
Display *       <emphasis>
      display</emphasis>
;            /* connection to X server */
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
unsigned int      <emphasis>
      which</emphasis>
;            /* mask selecting subcomponents to populate */
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
unsigned int      <emphasis>
      device_spec</emphasis>
;            /* device_id, or <emphasis>
XkbUseCoreKbd</emphasis>
 */
    </entry>
</row>
</tbody>
</tgroup>
</informaltable>

<para>
The <emphasis>
which</emphasis>
 mask is a bitwise inclusive OR of the masks defined in Table 14.1. Only those
portions of the keyboard server map and the keyboard client maps that are
specified in <emphasis>
which</emphasis>
 are allocated and populated.
</para>


<para>
In addition to allocating and obtaining the server map and the client map,
<emphasis>
XkbGetMap</emphasis>
 also sets the <emphasis>
device_spec</emphasis>
, the <emphasis>
min_key_code</emphasis>
<emphasis>
, </emphasis>
and <emphasis>
max_key_code</emphasis>
 fields of the keyboard description.
</para>


<para>
<emphasis>
XkbGetMap</emphasis>
 is synchronous; it queries the server for the desired information, waits for a
reply, and then returns. If successful<emphasis>
, XkbGetMap</emphasis>
 returns a pointer to the <emphasis>
XkbDescRec</emphasis>
 structure it allocated. If unsuccessful, <emphasis>
XkbGetMap</emphasis>
 returns <emphasis>
NULL</emphasis>
. When unsuccessful, one of the following protocol errors is also generated:
<emphasis>
BadAlloc</emphasis>
 (unable to allocate the <emphasis>
XkbDescRec</emphasis>
 structure), <emphasis>
BadValue</emphasis>
 (some mask bits in <emphasis>
which</emphasis>
 are undefined)<emphasis>
,</emphasis>
 or <emphasis>
BadImplementation</emphasis>
 (a compatible version of the Xkb extension is not available in the server). To
free the returned data, use <emphasis>
XkbFreeClientMap</emphasis>
.
</para>


<para>
Xkb also provides convenience functions to get partial component definitions
from the server. These functions are specified in the "convenience functions"
column in Table 14.1. Refer to the sections listed in the table for more
information on these functions.
</para>

<table frame='none'>
<title>Xkb Mapping Component Masks and Convenience Functions</title>
<tgroup cols='6'>
<colspec colsep='0'/>
<thead>
<row rowsep='0'>
  <entry>Mask</entry>
  <entry>Value</entry>
  <entry>Map</entry>
  <entry>Fields</entry>
  <entry>Convenience Functions</entry>
  <entry>Section</entry>
</row>
</thead>
<tbody>
  <row rowsep='0'>
    <entry><emphasis>XkbKeyTypesMask</emphasis></entry>
    <entry>(1&lt;&lt;0)</entry>
    <entry>client</entry>
    <entry>
      <para><emphasis>types</emphasis></para>
      <para><emphasis>size_types</emphasis></para>
      <para><emphasis>num_types</emphasis></para>
    </entry>
    <entry>
      <para><emphasis>XkbGetKeyTypes</emphasis></para>
      <para><emphasis>XkbResizeKeyType</emphasis></para>
      <para><emphasis>XkbCopyKeyType</emphasis></para>
      <para><emphasis>XkbCopyKeyTypes</emphasis></para>
    </entry>
    <entry>15.2</entry>
  </row>
  <row rowsep='0'>
    <entry><emphasis>XkbKeySymsMask</emphasis></entry>
    <entry>(1&lt;&lt;1)</entry>
    <entry>client</entry>
    <entry>
      <para><emphasis>syms</emphasis></para>
      <para><emphasis>size_syms</emphasis></para>
      <para><emphasis>num_syms</emphasis></para>
      <para><emphasis>key_sym_map</emphasis></para>
    </entry>
    <entry>
      <para><emphasis>XkbGetKeySyms</emphasis></para>
      <para><emphasis>XkbResizeKeySyms</emphasis></para>
      <para><emphasis>XkbChangeTypesOfKey</emphasis></para>
    </entry>
    <entry>15.3</entry>
  </row>
  <row rowsep='0'>
    <entry><emphasis>XkbModifierMapMask</emphasis></entry>
    <entry>(1&lt;&lt;2)</entry>
    <entry>client</entry>
    <entry><emphasis>modmap</emphasis></entry>
    <entry><emphasis>XkbGetKeyModifierMap</emphasis></entry>
    <entry>15.4</entry>
  </row>
  <row rowsep='0'>
    <entry><emphasis>XkbExplicitComponentsMask</emphasis></entry>
    <entry>(1&lt;&lt;3)</entry>
    <entry>server</entry>
    <entry><emphasis>explicit</emphasis></entry>
    <entry><emphasis>XkbGetKeyExplicitComponents</emphasis></entry>
    <entry>16.3</entry>
  </row>
  <row rowsep='0'>
    <entry><emphasis>XkbKeyActionsMask</emphasis></entry>
    <entry>(1&lt;&lt;4)</entry>
    <entry>server</entry>
    <entry>
      <para><emphasis>key_acts</emphasis></para>
      <para><emphasis>acts</emphasis></para>
      <para><emphasis>num_acts</emphasis></para>
      <para><emphasis>size_acts</emphasis></para>
    </entry>
    <entry>
      <para><emphasis>XkbGetKeyActions</emphasis></para>
      <para><emphasis>XkbResizeKeyActions</emphasis></para>
    </entry>
    <entry>16.1</entry>
  </row>
  <row rowsep='0'>
    <entry><emphasis>XkbKeyBehaviorsMask</emphasis></entry>
    <entry>(1&lt;&lt;5)</entry>
    <entry>server</entry>
    <entry><emphasis>behaviors</emphasis></entry>
    <entry><emphasis>XkbGetKeyBehaviors</emphasis></entry>
    <entry>16.2</entry>
  </row>
  <row rowsep='0'>
    <entry><emphasis>XkbVirtualModsMask</emphasis></entry>
    <entry>(1&lt;&lt;6)</entry>
    <entry>server</entry>
    <entry><emphasis>vmods</emphasis></entry>
    <entry><emphasis>XkbGetVirtualMods</emphasis></entry>
    <entry>16.4</entry>
  </row>
  <row rowsep='0'>
    <entry><emphasis>XkbVirtualModMapMask</emphasis></entry>
    <entry>(1&lt;&lt;7)</entry>
    <entry>server</entry>
    <entry><emphasis>vmodmap</emphasis></entry>
    <entry><emphasis>XkbGetVirtualModMap</emphasis></entry>
    <entry>16.4</entry>
  </row>
</tbody>
</tgroup>
</table>

<para>
Xkb defines combinations of these masks for convenience:
</para>

<para><programlisting>
#define  XkbResizableInfoMask      (XkbKeyTypesMask)
#define  XkbAllClientInfoMask      (XkbKeyTypesMask | XkbKeySymsMask |
                                    XkbModifierMapMask)
#define  XkbAllServerInfoMask      (XkbExplicitComponentsMask |
                                    XkbKeyActionsMask| XkbKeyBehaviorsMask |
                                    XkbVirtualModsMask | XkbVirtualModMapMask)
#define  XkbAllMapComponentsMask   (XkbAllClientInfoMask|XkbAllServerInfoMask)
</programlisting></para>

<para>
Key types, symbol maps, and actions are all interrelated: changes in one
require changes in the others. The convenience functions make it easier to edit
these components and handle the interdependencies.
</para>


<para>
To update the client or server map information in an existing keyboard
description, use <emphasis>XkbGetUpdatedMap</emphasis>.
</para>


<informaltable frame='none'>
<tgroup cols='1'>
<colspec colsep='0'/>
<tbody>
  <row rowsep='0'>
    <entry role='functiondecl'>
Status <emphasis>
XkbGetUpdatedMap</emphasis>
(<emphasis>
display, which, xkb</emphasis>
)
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
Display * <emphasis>
            display</emphasis>
;            /* connection to X server */
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
unsigned int<emphasis>
            which</emphasis>
;            /* mask selecting subcomponents to populate */
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
XkbDescPtr            <emphasis>
xkb</emphasis>
;            /* keyboard description to be updated */
    </entry>
</row>
</tbody>
</tgroup>
</informaltable>

<para>
The <emphasis>
which</emphasis>
 parameter is a bitwise inclusive OR of the masks in Table 14.1. If the needed
components of the <emphasis>
xkb</emphasis>
 structure are not already allocated, <emphasis>
XkbGetUpdatedMap</emphasis>
 allocates them. <emphasis>
XkbGetUpdatedMap</emphasis>
 fetches the requested information for the device specified in the <emphasis>
XkbDescRec</emphasis>
 passed in the <emphasis>
xkb</emphasis>
 parameter.
</para>


<para>
<emphasis>
XkbGetUpdatedMap</emphasis>
 is synchronous; it queries the server for the desired information, waits for a
reply, and then returns. If successful<emphasis>
, XkbGetUpdatedMap</emphasis>
 returns <emphasis>
Success</emphasis>
. If unsuccessful, <emphasis>
XkbGetUpdatedMap</emphasis>
 returns one of the following: <emphasis>
BadAlloc</emphasis>
 (unable to allocate a component in the <emphasis>
XkbDescRec</emphasis>
 structure), <emphasis>
BadValue</emphasis>
 (some mask bits in <emphasis>
which</emphasis>
 are undefined), <emphasis>
BadImplementation</emphasis>
 (a compatible version of the Xkb extension is not available in the server or
the reply from the server was invalid).
</para>

</sect1>
<sect1 id='changing_map_components_in_the_server'>
<title>Changing Map Components in the Server</title>

<para>
There are two ways to make changes to map components: either change a local
copy of the keyboard map and call <emphasis>
XkbSetMap</emphasis>
 to send the modified map to the server, or, to reduce network traffic, use
an<emphasis>
 XkbMapChangesRec</emphasis>
 structure and call <emphasis>XkbChangeMap</emphasis>.
</para>

<informaltable frame='none'>
<tgroup cols='1'>
<colspec colsep='0'/>
<tbody>
  <row rowsep='0'>
    <entry role='functiondecl'>
Bool <emphasis>
XkbSetMap</emphasis>
(<emphasis>
dpy</emphasis>
,<emphasis>
 which</emphasis>
,<emphasis>
 xkb</emphasis>
)
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
Display *<emphasis>
            dpy</emphasis>
;            /* connection to X server */
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
unsigned int<emphasis>
            which</emphasis>
;            /* mask selecting subcomponents to update */
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
XkbDescPtr <emphasis>
            xkb</emphasis>
;            /* description from which new values are taken */
    </entry>
</row>
</tbody>
</tgroup>
</informaltable>

<para>
Use <emphasis>
XkbSetMap</emphasis>
 to send a complete new set of values for entire components (for example, all
symbols, all actions, and so on) to the server. The <emphasis>
which</emphasis>
 parameter specifies the components to be sent to the server, and is a bitwise
inclusive OR of the masks listed in Table 14.1. The <emphasis>
xkb</emphasis>
 parameter is a pointer to an <emphasis>
XkbDescRec</emphasis>
 structure and contains the information to be copied to the server. For each
bit set in the <emphasis>
which</emphasis>
 parameter, <emphasis>
XkbSetMap</emphasis>
 takes the corresponding structure values from the <emphasis>
xkb</emphasis>
 parameter and sends it to the server specified by <emphasis>
dpy</emphasis>.
</para>

<para>
If any components specified by <emphasis>
which</emphasis>
 are not present in the <emphasis>
xkb</emphasis>
 parameter, <emphasis>
XkbSetMap</emphasis>
 returns <emphasis>
False</emphasis>
. Otherwise, it sends the update request to the server and returns <emphasis>
True</emphasis>
. <emphasis>
XkbSetMap</emphasis>
 can generate <emphasis>
BadAlloc</emphasis>
, <emphasis>
BadLength</emphasis>
, and <emphasis>
BadValue</emphasis>
 protocol errors.
</para>


<para>
Key types, symbol maps, and actions are all interrelated; changes in one
require changes in the others. Xkb provides functions to make it easier to edit
these components and handle the interdependencies. Table 14.1 lists these
helper functions and provides a pointer to where they are defined.
</para>


<sect2 id='the_xkbmapchangesrec_structure'>
<title>The XkbMapChangesRec Structure</title>

<para>
Use the <emphasis>
XkbMapChangesRec</emphasis>
 structure to identify and track partial modifications to the mapping
components and to reduce the amount of traffic between the server and clients.
</para>

<para><programlisting>
typedef struct _XkbMapChanges {
      unsigned short    changed;              /* identifies valid components
                                                 in structure */
      KeyCode           min_key_code;         /* lowest numbered keycode for
                                                 device */
      KeyCode           max_key_code;         /* highest numbered keycode for
                                                 device */
      unsigned char     first_type;           /* index of first key <emphasis>type</emphasis>
                                                 modified */
      unsigned char     num_types;            /* # types modified */
      KeyCode           first_key_sym;        /* first key whose <emphasis>key_sym_map</emphasis>
                                                 changed */
      unsigned char     num_key_syms;         /* # <emphasis>key_sym_map</emphasis>
                                                 entries changed */
      KeyCode           first_key_act;        /* first key whose <emphasis>key_acts</emphasis>
                                                 entry changed */
      unsigned char     num_key_acts;         /* # <emphasis>key_acts</emphasis>
                                                 entries changed */
      KeyCode           first_key_behavior;   /* first key whose <emphasis>behaviors</emphasis>
                                                 changed */
      unsigned char     num_key_behaviors;    /* # <emphasis>behaviors</emphasis>
                                                 entries changed */
      KeyCode           first_key_explicit;   /* first key whose <emphasis>explicit</emphasis>
                                                 entry changed */
      unsigned char     num_key_explicit;     /* # <emphasis> explicit</emphasis>
                                                 entries changed */
      KeyCode           first_modmap_key;     /* first key whose <emphasis>modmap</emphasis>
                                                 entry changed */
      unsigned char     num_modmap_keys;      /* # <emphasis>modmap</emphasis>
                                                 entries changed */
      KeyCode           first_vmodmap_key;    /* first key whose <emphasis>vmodmap</emphasis>
                                                 changed */
      unsigned char     num_vmodmap_keys;     /* # <emphasis> vmodmap</emphasis>
                                                 entries changed */
      unsigned char     pad1;                 /* reserved */
      unsigned short    vmods;                /* mask indicating which <emphasis>vmods</emphasis>
                                                 changed */
} <emphasis>XkbMapChangesRec</emphasis>,*XkbMapChangesPtr;
</programlisting></para>

<para>
The <emphasis>
changed</emphasis>
 field identifies the map components that have changed in an <emphasis>
XkbDescRec</emphasis>
 structure and may contain any of the bits in Table 14.1, which are also shown
in Table 14.2. Every 1 bit in <emphasis>
changed</emphasis>
 also identifies which other fields in the <emphasis>
XkbMapChangesRec</emphasis>
 structure contain valid values, as indicated in Table 14.2. The <emphasis>
min_key_code</emphasis>
 and <emphasis>
max_key_code</emphasis>
 fields are for reference only; they are ignored on any requests sent to the
server and are always updated by the server whenever it returns the data for an
<emphasis>
XkbMapChangesRec</emphasis>
.
</para>

<table frame='none'>
<title>XkbMapChangesRec Masks</title>
<tgroup cols='3'>
<colspec colsep='0'/>
<thead>
<row rowsep='0'>
  <entry>Mask</entry>
  <entry>Valid XkbMapChangesRec Fields</entry>
  <entry>XkbDescRec Field Containing Changed Data</entry>
</row>
</thead>
<tbody>
  <row rowsep='0'>
    <entry><emphasis>XkbKeyTypesMask</emphasis></entry>
    <entry>
<para>first_type</para>,
<para>num_types</para>
    </entry>
    <entry>
<para>map-&gt;type[first_type] ..</para>
<para>map-&gt;type[first_type + num_types - 1]</para>
    </entry>
  </row>
  <row rowsep='0'>
    <entry><emphasis>XkbKeySymsMask</emphasis></entry>
    <entry>
<para>first_key_sym</para>,
<para>num_key_syms</para>
    </entry>
    <entry>
<para>map-&gt;key_sym_map[first_key_sym] ..</para>
<para>map-&gt;key_sym_map[first_key_sym + num_key_syms - 1]</para>
    </entry>
  </row>
  <row rowsep='0'>
    <entry><emphasis>XkbModifierMapMask</emphasis></entry>
    <entry>
<para>first_modmap_key</para>,
<para>num_modmap_keys</para>
    </entry>
    <entry>
<para>map-&gt;modmap[first_modmap_key] ..</para>
<para>map-&gt;modmap[first_modmap_key + num_modmap_keys-1]</para>
    </entry>
  </row>
  <row rowsep='0'>
    <entry><emphasis>XkbExplicitComponentsMask</emphasis></entry>
    <entry>
<para>first_key_explicit</para>,
<para>num_key_explicit</para>
    </entry>
    <entry>
<para>server-&gt;explicit[first_key_explicit] ..</para>
<para>server-&gt;explicit[first_key_explicit + num_key_explicit - 1]</para>
    </entry>
  </row>
  <row rowsep='0'>
    <entry><emphasis>XkbKeyActionsMask</emphasis></entry>
    <entry>
<para>first_key_act,</para>
<para>num_key_acts</para>
    </entry>
    <entry>
<para>server-&gt;key_acts[first_key_act] ..</para>
<para>server-&gt;key_acts[first_key_act + num_key_acts - 1]</para>
    </entry>
  </row>
  <row rowsep='0'>
    <entry><emphasis>XkbKeyBehaviorsMask</emphasis></entry>
    <entry>
<para>first_key_behavior,</para>
<para>num_key_behaviors</para>
    </entry>
    <entry>
<para>server-&gt;behaviors[first_key_behavior] ..</para>
<para>server-&gt;behaviors[first_key_behavior + num_key_behaviors - 1]</para>
    </entry>
  </row>
  <row rowsep='0'>
    <entry><emphasis>XkbVirtuawModsMask</emphasis></entry>
    <entry>vmods</entry>
    <entry>server-&gt;vmods[*]</entry>
  </row>
  <row rowsep='0'>
    <entry><emphasis>XkbVirtualModMapMask</emphasis></entry>
    <entry>
<para>first_vmodmap_key,</para>
<para>num_vmodmap_keys</para>
    </entry>
    <entry>
<para>server-&gt;vmodmap[first_vmodmap_key] ..</para>
<para>server-&gt;vmodmap[first_vmodmap_key + num_vmodmap_keys - 1]</para>
    </entry>
  </row>
</tbody>
</tgroup>
</table>

<para>
To update only partial components of a keyboard description, modify the
appropriate fields in the server and map components of a local copy of the
keyboard description, then call <emphasis>
XkbChangeMap</emphasis>
 with an <emphasis>
XkbMapChangesRec</emphasis>
 structure indicating which components have changed.
</para>

<informaltable frame='none'>
<tgroup cols='1'>
<colspec colsep='0'/>
<tbody>
  <row rowsep='0'>
    <entry role='functiondecl'>
Bool <emphasis>
XkbChangeMap</emphasis>
(<emphasis>
dpy</emphasis>
,<emphasis>
 xkb</emphasis>
,<emphasis>
 changes</emphasis>
)
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
Display *<emphasis>
            dpy</emphasis>
;            /* connection to X server */
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
XkbDescPtr <emphasis>
            xkb</emphasis>
;            /* description from which new values are taken */
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
XkbMapChangesPtr <emphasis>
            changes</emphasis>
;            /*identifies component parts to update */
    </entry>
</row>
</tbody>
</tgroup>
</informaltable>

<para>
<emphasis>
XkbChangeMap</emphasis>
 copies any components specified by the <emphasis>
changes</emphasis>
 structure from the keyboard description, <emphasis>
xkb</emphasis>
, to the X server specified by <emphasis>
dpy</emphasis>
.
</para>


<para>
If any components specified by <emphasis>
changes</emphasis>
 are not present in the <emphasis>
xkb</emphasis>
 parameter, <emphasis>
XkbChangeMap</emphasis>
 returns <emphasis>
False</emphasis>
. Otherwise, it sends a request to the server and returns <emphasis>
True</emphasis>
.
</para>


<para>
<emphasis>
XkbChangeMap</emphasis>
 can generate <emphasis>
BadAlloc</emphasis>
, <emphasis>
BadLength</emphasis>
, and <emphasis>
BadValue</emphasis>
 protocol errors.
</para>


</sect2>
</sect1>
<sect1 id='tracking_changes_to_map_components'>
<title>Tracking Changes to Map Components</title>

<para>
The Xkb extension reports <emphasis>
XkbMapNotify</emphasis>
 events to clients wanting notification whenever a map component of the Xkb
description for a device changes. There are many different types of Xkb
keyboard map changes. Xkb uses an event detail mask to identify each type of
change. The event detail masks are identical to the masks listed in Table 14.1.
</para>


<para>
To receive <emphasis>
XkbMapNotify</emphasis>
 events under all possible conditions, use <emphasis>
XkbSelectEvents</emphasis>
 (see section 4.3) and pass <emphasis>
XkbMapNotifyMask</emphasis>
 in both <emphasis>
bits_to_change</emphasis>
 and <emphasis>
values_for_bits</emphasis>
.
</para>


<para>
To receive <emphasis>
XkbMapNotify</emphasis>
 events only under certain conditions, use <emphasis>
XkbSelectEventDetails</emphasis>
 using <emphasis>
XkbMapNotify</emphasis>
 as the <emphasis>
event_type</emphasis>
 and specifying the desired map changes in <emphasis>
bits_to_change</emphasis>
 and <emphasis>
values_for_bits</emphasis>
 using mask bits from Table 14.1.
</para>


<para>
The structure for <emphasis>
XkbMapNotify</emphasis>
 events is:
</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> XkbMapNotify</emphasis> */
      int            device;       /* Xkb device ID, will not be <emphasis>XkbUseCoreKbd</emphasis> */
      unsigned int   changed;      /* identifies valid fields in rest of event */
      unsigned int   resized;      /* reserved */
      int            first_type;   /* index of first key <emphasis> type</emphasis> modified */
      int            num_types     /* # types modified */
      KeyCode        min_key_code; /* minimum keycode for device */
      KeyCode        max_key_code; /* maximum keycode for device */
      KeyCode        first_key_sym; /* first key whose <emphasis>key_sym_map</emphasis> changed */
      KeyCode        first_key_act; /* first key whose <emphasis> key_acts</emphasis> entry changed */
      KeyCode        first_key_behavior; /* first key whose <emphasis> behaviors</emphasis> changed */
      KeyCode        first_key_explicit; /* first key whose <emphasis> explicit </emphasis> entry changed */
      KeyCode        first_modmap_key;   /* first key whose <emphasis> modmap</emphasis> entry changed */
      KeyCode        first_vmodmap_key;  /* # <emphasis> modmap</emphasis> entries changed */
      int            num_key_syms;       /* # <emphasis>key_sym_map</emphasis> entries changed */
      int            num_key_acts;       /* # <emphasis> key_acts</emphasis> entries changed */
      int            num_key_behaviors;  /* # <emphasis> behaviors</emphasis> entries changed */
      int            num_key_explicit;   /* # <emphasis> explicit</emphasis> entries changed */
      int            num_modmap_keys;    /* # <emphasis> modmap</emphasis> entries changed */
      int            num_vmodmap_keys;   /* # <emphasis> vmodmap</emphasis> entries changed */
      unsigned in      t      vmods;     /* mask indicating which <emphasis> vmods</emphasis> changed */
} <emphasis>XkbMapNotifyEvent</emphasis>;
</programlisting></para>

<para>
The <emphasis>
changed</emphasis>
 field specifies the map components that have changed and is the bitwise
inclusive OR of the mask bits defined in Table 14.1. The other fields in this
event are interpreted as the like-named fields in an <emphasis>
XkbMapChangesRec</emphasis>
 (see section 14.3.1). The <emphasis>
XkbMapNotifyEvent</emphasis>
 structure also has an additional <emphasis>
resized</emphasis>
 field that is reserved for future use.
</para>


</sect1>
<sect1 id='allocating_and_freeing_client_and_server_maps'>
<title>Allocating and Freeing Client and Server Maps</title>

<para>
Calling <emphasis>
XkbGetMap</emphasis>
 (see section 14.2) should be sufficient for most applications to get client
and server maps. As a result, most applications do not need to directly
allocate client and server maps.
</para>


<para>
If you change the number of key types or construct map components without
loading the necessary components from the X server, do not allocate any map
components directly using <emphasis>
malloc</emphasis>
 or <emphasis>
Xmalloc</emphasis>
. Instead, use the Xkb allocators, <emphasis>
XkbAllocClientMap,</emphasis>
 and <emphasis>
XkbAllocServerMap</emphasis>
.
</para>


<para>
Similarly, use the Xkb destructors, <emphasis>
XkbFreeClientMap,</emphasis>
 and <emphasis>
XkbFreeServerMap</emphasis>
 instead of <emphasis>
free</emphasis>
 or <emphasis>
Xfree</emphasis>
.
</para>


<sect2 id='allocating_an_empty_client_map'>
<title>Allocating an Empty Client Map</title>

<para>
To allocate and initialize an empty client map description record, use
<emphasis>
XkbAllocClientMap.</emphasis>
</para>

<informaltable frame='none'>
<tgroup cols='1'>
<colspec colsep='0'/>
<tbody>
  <row rowsep='0'>
    <entry role='functiondecl'>
Status <emphasis>
XkbAllocClientMap</emphasis>
(<emphasis>
xkb, which, type_count</emphasis>
)
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
XkbDescPtr <emphasis>
            xkb</emphasis>
;            /* keyboard description in which to allocate client map */
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
unsigned int<emphasis>
            which</emphasis>
;            /* mask selecting map components to allocate */
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
unsigned int<emphasis>
            type_count</emphasis>
;            /* value of <emphasis>
num_types</emphasis>
 field in map to be allocated */
    </entry>
</row>
</tbody>
</tgroup>
</informaltable>

<para>
<emphasis>
XkbAllocClientMap</emphasis>
 allocates and initializes an empty client map in the <emphasis>
map</emphasis>
 field of the keyboard description specified by <emphasis>
xkb</emphasis>
. The <emphasis>
which</emphasis>
 parameter specifies the particular components of the client map structure to
allocate and is a mask composed by a bitwise inclusive OR of one or more of the
masks shown in Table 14.3.
</para>

<table frame='none'>
<title>XkbAllocClientMap Masks</title>
<tgroup cols='2'>
<colspec colsep='0'/>
<thead>
<row rowsep='0'>
  <entry>Mask</entry>
  <entry>Effect</entry>
  </row>
</thead>
<tbody>
  <row rowsep='0'>
    <entry>XkbKeyTypesMask</entry>
    <entry>
The <emphasis>
type_count </emphasis>
field specifies the number of entries to preallocate for the <emphasis>
types</emphasis>
 field of the client map. If the <emphasis>
type_count </emphasis>
field is less than <emphasis>
XkbNumRequiredTypes</emphasis>
 (see section 15.2.1), returns <emphasis>
BadValue</emphasis>.
</entry>
  </row>
  <row rowsep='0'>
    <entry>XkbKeySymsMask</entry>
<entry>
The <emphasis>
min_key_code</emphasis>
 and <emphasis>
max_key_code</emphasis>
 fields of the <emphasis>
xkb</emphasis>
 parameter are used to allocate the <emphasis>
syms</emphasis>
 and <emphasis>
key_sym_map</emphasis>
 fields of the client map. The fields are allocated to contain the maximum
number of entries necessary for <emphasis>
max_key_code</emphasis>
 - <emphasis>
min_key_code</emphasis>
 + 1 keys.
</entry>
  </row>
  <row rowsep='0'>
    <entry>XkbModifierMapMask</entry>
<entry>
The <emphasis>
min_key_code</emphasis>
 and <emphasis>
max_key_code</emphasis>
 fields of the <emphasis>
xkb</emphasis>
 parameter are used to allocate the <emphasis>
modmap</emphasis>
 field of the client map. The field is allocated to contain the maximum number
of entries necessary for <emphasis>
max_key_code</emphasis>
 - <emphasis>
min_key_code</emphasis>
 + 1 keys.
</entry>
  </row>
</tbody>
</tgroup>
</table>

<note><para>The <emphasis>
min_key_code</emphasis>
 and <emphasis>
max_key_code</emphasis>
 fields of the <emphasis>
xkb</emphasis>
 parameter must be legal values if the <emphasis>
XkbKeySymsMask</emphasis>
 or <emphasis>
XkbModifierMapMask</emphasis>
 masks are set in the <emphasis>
which</emphasis>
 parameter. If they are not valid, <emphasis>
XkbAllocClientMap</emphasis>
 returns <emphasis>
BadValue</emphasis>
. </para></note>

<para>
If the client map of the keyboard description is not <emphasis>
NULL</emphasis>
, and any fields are already allocated in the client map, <emphasis>
XkbAllocClientMap</emphasis>
 does not overwrite the existing values; it simply ignores that part of the
request. The only exception is the <emphasis>
types</emphasis>
 array. If <emphasis>
type_count</emphasis>
 is greater than the current <emphasis>
num_types</emphasis>
 field of the client map, <emphasis>
XkbAllocClientMap</emphasis>
 resizes the <emphasis>
types</emphasis>
 array and resets the <emphasis>
num_types</emphasis>
 field accordingly.
</para>


<para>
If <emphasis>
XkbAllocClientMap</emphasis>
 is successful, it returns <emphasis>
Success</emphasis>
. Otherwise, it can return either <emphasis>
BadMatch</emphasis>
, <emphasis>
BadAlloc</emphasis>
, or <emphasis>
BadValue</emphasis>
 errors.
</para>


</sect2>
<sect2 id='freeing_a_client_map'>
<title>Freeing a Client Map</title>

<para>
To free memory used by the client map member of an <emphasis>
XkbDescRec</emphasis>
 structure, use <emphasis>
XkbFreeClientMap.</emphasis>
</para>

<informaltable frame='none'>
<tgroup cols='1'>
<colspec colsep='0'/>
<tbody>
  <row rowsep='0'>
    <entry role='functiondecl'>
void <emphasis>
XkbFreeClientMap</emphasis>
(<emphasis>
xkb, which, free_all</emphasis>
)
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
XkbDescPtr <emphasis>
      xkb</emphasis>
;            /* keyboard description containing client map to free */
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
unsigned int<emphasis>
      which</emphasis>
;            /* mask identifying components of map to free */
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
Bool <emphasis>
      free_all</emphasis>
;            /* <emphasis>
True</emphasis>
 =&gt; free all client components and map itself */
    </entry>
</row>
</tbody>
</tgroup>
</informaltable>

<para>
<emphasis>
XkbFreeClientMap</emphasis>
 frees the components of client map specified by <emphasis>
which</emphasis>
 in the <emphasis>
XkbDescRec</emphasis>
 structure specified by the <emphasis>
xkb</emphasis>
 parameter and sets the corresponding structure component values to <emphasis>
NULL</emphasis>
. The <emphasis>
which</emphasis>
 parameter specifies a combination of the client map masks shown in Table 14.3.
</para>


<para>
If <emphasis>
free_all</emphasis>
 is <emphasis>
True</emphasis>
, <emphasis>
which</emphasis>
 is ignored; <emphasis>
XkbFreeClientMap</emphasis>
 frees every non-<emphasis>
NULL</emphasis>
 structure component in the client map, frees the <emphasis>
XkbClientMapRec</emphasis>
 structure referenced by the <emphasis>
map</emphasis>
 member of the <emphasis>
xkb</emphasis>
 parameter, and sets the <emphasis>
map</emphasis>
 member to <emphasis>
NULL.</emphasis>
</para>


</sect2>
<sect2 id='allocating_an_empty_server_map'>
<title>Allocating an Empty Server Map</title>

<para>
To allocate and initialize an empty server map description record, use
<emphasis>
XkbAllocServerMap.</emphasis>
</para>

<informaltable frame='none'>
<tgroup cols='1'>
<colspec colsep='0'/>
<tbody>
  <row rowsep='0'>
    <entry role='functiondecl'>
Status <emphasis>
XkbAllocServerMap</emphasis>
(<emphasis>
xkb, which, count_acts</emphasis>
)
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
XkbDescPtr <emphasis>
            xkb</emphasis>
;            /* keyboard description in which to allocate server map */
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
unsigned int<emphasis>
            which</emphasis>
;            /* mask selecting map components to allocate */
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
unsigned int<emphasis>
            count_acts</emphasis>
;            /* value of <emphasis>
num_acts</emphasis>
 field in map to be allocated */
    </entry>
</row>
</tbody>
</tgroup>
</informaltable>

<para>
<emphasis>
XkbAllocServerMap</emphasis>
 allocates and initializes an empty server map in the <emphasis>
server</emphasis>
 field of the keyboard description specified by <emphasis>
xkb</emphasis>
. The <emphasis>
which</emphasis>
 parameter specifies the particular components of the server map structure to
allocate, as specified in Table 14.4.
</para>

<table frame='none'>
<title>XkbAllocServerMap Masks</title>
<tgroup cols='2'>
<colspec colsep='0'/>
<thead>
<row rowsep='0'>
  <entry>Mask</entry>
  <entry>Effect</entry>
  </row>
</thead>
<tbody>
  <row rowsep='0'>
    <entry>XkbExplicitComponentsMask</entry>
    <entry>
The <emphasis>
min_key_code</emphasis>
 and <emphasis>
max_key_code</emphasis>
 fields of the <emphasis>
xkb</emphasis>
 parameter are used to allocate the <emphasis>
explicit </emphasis>
field of the server map.
    </entry>
  </row>
  <row rowsep='0'>
    <entry>XkbKeyActionsMask</entry>
    <entry>
The <emphasis>
min_key_code</emphasis>
 and <emphasis>
max_key_code</emphasis>
 fields of the <emphasis>
xkb</emphasis>
 parameter are used to allocate the <emphasis>
key_acts </emphasis>
field of the server map. The <emphasis>
count_acts</emphasis>
 parameter is used to allocate the <emphasis>
acts</emphasis>
 field of the server map.
    </entry>
  </row>
  <row rowsep='0'>
    <entry>XkbKeyBehaviorsMask</entry>
    <entry>
The <emphasis>
min_key_code</emphasis>
 and <emphasis>
max_key_code</emphasis>
 fields of the <emphasis>
xkb</emphasis>
 parameter are used to allocate the <emphasis>
behaviors </emphasis>
field of the server map.
    </entry>
  </row>
  <row rowsep='0'>
    <entry>XkbVirtualModMapMask</entry>
    <entry>
The <emphasis>
min_key_code</emphasis>
 and <emphasis>
max_key_code</emphasis>
 fields of the <emphasis>
xkb </emphasis>
parameter are used to allocate the <emphasis>
vmodmap </emphasis>
field of the server map.
    </entry>
  </row>
</tbody>
</tgroup>
</table>

<note><para>The <emphasis>
min_key_code</emphasis>
 and <emphasis>
max_key_code</emphasis>
 fields of the <emphasis>
xkb</emphasis>
 parameter must be legal values. If they are not valid, <emphasis>
XkbAllocServerMap</emphasis>
 returns <emphasis>
BadValue</emphasis>
. </para></note>

<para>
If the server map of the keyboard description is not <emphasis>
NULL</emphasis>
 and any fields are already allocated in the server map, <emphasis>
XkbAllocServerMap</emphasis>
 does not overwrite the existing values. The only exception is with the
<emphasis>
acts </emphasis>
array. If the <emphasis>
count_acts </emphasis>
parameter is greater than the current <emphasis>
num_acts </emphasis>
field of the server map, <emphasis>
XkbAllocServerMap</emphasis>
 resizes the <emphasis>
acts </emphasis>
array and resets the <emphasis>
num_acts </emphasis>
field accordingly.
</para>


<para>
If <emphasis>
XkbAllocServerMap</emphasis>
 is successful, it returns <emphasis>
Success</emphasis>
. Otherwise, it can return either <emphasis>
BadMatch</emphasis>
 or <emphasis>
BadAlloc</emphasis>
 errors.
</para>


</sect2>
<sect2 id='freeing_a_server_map'>
<title>Freeing a Server Map</title>

<para>
To free memory used by the server member of an <emphasis>
XkbDescRec</emphasis>
 structure, use <emphasis>
XkbFreeServerMap.</emphasis>
</para>

<informaltable frame='none'>
<tgroup cols='1'>
<colspec colsep='0'/>
<tbody>
  <row rowsep='0'>
    <entry role='functiondecl'>
void <emphasis>
XkbFreeServerMap</emphasis>
(<emphasis>
xkb, which, free_all</emphasis>
)
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
XkbDescPtr <emphasis>
      xkb</emphasis>
;            /* keyboard description containing server map to free */
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
unsigned int<emphasis>
      which</emphasis>
;            /* mask identifying components of map to free */
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
Bool <emphasis>
      free_all</emphasis>
;            /* <emphasis>
True</emphasis>
 =&gt; free all server map components and server itself */
    </entry>
</row>
</tbody>
</tgroup>
</informaltable>

<para>
The <emphasis>
XkbFreeServerMap</emphasis>
 function frees the specified components of server map in the <emphasis>
XkbDescRec</emphasis>
 structure specified by the <emphasis>
xkb</emphasis>
 parameter and sets the corresponding structure component values to <emphasis>
NULL</emphasis>
. The <emphasis>
which</emphasis>
 parameter specifies a combination of the server map masks and is a bitwise
inclusive OR of the masks listed in Table 14.4. If <emphasis>
free_all</emphasis>
 is <emphasis>
True</emphasis>
, <emphasis>
which</emphasis>
 is ignored and <emphasis>
XkbFreeServerMap</emphasis>
 frees every non-<emphasis>
NULL</emphasis>
 structure component in the server map, frees the <emphasis>
XkbServerMapRec</emphasis>
 structure referenced by the <emphasis>
server</emphasis>
 member of the <emphasis>
xkb</emphasis>
 parameter, and sets the <emphasis>
server</emphasis>
 member to <emphasis>
NULL.</emphasis>
</para>

</sect2>
</sect1>
</chapter>