~ubuntu-branches/ubuntu/natty/libx11/natty

« back to all changes in this revision

Viewing changes to specs/XKB/ch18.xml

  • Committer: Bazaar Package Importer
  • Author(s): Timo Aaltonen
  • Date: 2011-02-24 12:02:14 UTC
  • mfrom: (1.1.12 upstream) (2.1.12 sid)
  • Revision ID: james.westby@ubuntu.com-20110224120214-a86d0lv48wk8itl6
Tags: 2:1.4.1-5ubuntu1
* Merge from debian unstable.  Remaining changes:
  - Add Latin locale.
  - Add Klingon locale.
  - Add 102_double_arrows_Compose.patch: compose keys for double arrows
    (LP: 680143)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<chapter id='symbolic_names'>
 
2
<title>Symbolic Names</title>
 
3
 
 
4
<para>
 
5
The core protocol does not provide any information to clients other than that
 
6
actually used to interpret events. This makes it difficult to write an
 
7
application that presents the keyboard to a user in an easy-to-understand way.
 
8
Such applications have to examine the vendor string and keycodes to determine
 
9
the type of keyboard connected to the server and then examine keysyms and
 
10
modifier mappings to determine the effects of most modifiers (the <emphasis>
 
11
Shift</emphasis>
 
12
, <emphasis>
 
13
Lock</emphasis>
 
14
 and <emphasis>
 
15
Control</emphasis>
 
16
 modifiers are defined by the core protocol but no semantics are implied for
 
17
any other modifiers).
 
18
</para>
 
19
 
 
20
 
 
21
<para>
 
22
To make it easier for applications to present a keyboard to the user, Xkb
 
23
supports symbolic names for most components of the keyboard extension. Most of
 
24
these symbolic names are grouped into the <emphasis>
 
25
names</emphasis>
 
26
 component of the keyboard description.
 
27
</para>
 
28
 
 
29
<sect1 id='the_xkbnamesrec_structure'>
 
30
<title>The XkbNamesRec Structure</title>
 
31
 
 
32
<para>
 
33
The names component of the keyboard description is defined as follows:
 
34
</para>
 
35
 
 
36
<para><programlisting>
 
37
#define      XkbKeyNameLength      4
 
38
#define      XkbKeyNumVirtualMods  16
 
39
#define      XkbKeyNumIndicators   32
 
40
#define      XkbKeyNumKbdGroups    4
 
41
#define      XkbMaxRadioGroups     32
 
42
</programlisting></para>
 
43
 
 
44
<para><programlisting>
 
45
typedef struct {
 
46
      char      name[XkbKeyNameLength];      /* symbolic key names */
 
47
} <emphasis>XkbKeyNameRec</emphasis>,*XkbKeyNamePtr;
 
48
</programlisting></para>
 
49
 
 
50
<para><programlisting>
 
51
typedef struct {
 
52
      char      real[XkbKeyNameLength];
 
53
                /* this key name must be in the keys array */
 
54
      char      alias[XkbKeyNameLength];
 
55
                /* symbolic key name as alias for the key */
 
56
} <emphasis>XkbKeyAliasRec</emphasis>,*XkbKeyAliasPtr;
 
57
</programlisting></para>
 
58
 
 
59
<para><programlisting>
 
60
typedef struct _XkbNamesRec {
 
61
      Atom      keycodes;      /* identifies range and meaning of keycodes */
 
62
      Atom      geometry;      /* identifies physical location, size, and shape of keys */
 
63
      Atom      symbols;       /* identifies the symbols logically bound to the keys */
 
64
      Atom      types;         /* identifies the set of key types */
 
65
      Atom      compat;        /* identifies actions for keys using core protocol */
 
66
      Atom      vmods[XkbNumVirtualMods]; /* symbolic names for virtual modifiers */
 
67
      Atom      indicators[XkbNumIndicators];   /* symbolic names for indicators */
 
68
      Atom      groups[XkbNumKbdGroups]; /* symbolic names for keyboard groups */
 
69
      XkbKeyNamePtr      keys;         /* symbolic key name array */
 
70
      XkbKeyAliasPtr     key_aliases;  /* real/alias symbolic name pairs array */
 
71
      Atom *    radio_groups;      /* radio group name array */
 
72
      Atom      phys_symbols;      /* identifies the symbols engraved on the keyboard */
 
73
      unsigned char      num_keys; /* number of keys in the <emphasis> keys</emphasis> array */
 
74
      unsigned char      num_key_aliases;  /* number of keys in the
 
75
                                              <emphasis> key_aliases</emphasis> array */
 
76
      unsigned short     num_rg;      /* number of radio groups */
 
77
} <emphasis>XkbNamesRec</emphasis>,*XkbNamesPtr;      /*
 
78
</programlisting></para>
 
79
 
 
80
<para>
 
81
The <emphasis>
 
82
keycodes</emphasis>
 
83
 name identifies the range and meaning of the keycodes returned by the keyboard
 
84
in question. The <emphasis>
 
85
geometry</emphasis>
 
86
 name, on the other hand, identifies the physical location, size and shape of
 
87
the various keys on the keyboard. As an example to distinguish between these
 
88
two names, consider function keys on PC-compatible keyboards. Function keys are
 
89
sometimes above the main keyboard and sometimes to the left of the main
 
90
keyboard, but the same keycode is used for the key that is logically F1
 
91
regardless of physical position. Thus, all PC-compatible keyboards share a
 
92
similar keycodes name but may have different geometry names.
 
93
</para>
 
94
 
 
95
<note><para>The keycodes name is intended to be a very general description of
 
96
the keycodes returned by a keyboard; a single keycodes name might cover
 
97
keyboards with differing numbers of keys provided all keys have the same
 
98
semantics when present. For example, 101 and 102 key PC keyboards might use the
 
99
same name. In these cases, applications can use the keyboard <emphasis>
 
100
geometry</emphasis>
 
101
 name to determine which subset of the named keycodes is in use.</para></note>
 
102
 
 
103
<para>
 
104
The <emphasis>
 
105
symbols</emphasis>
 
106
 name identifies the symbols logically bound to the keys. The symbols name is a
 
107
human or application-readable description of the intended locale or usage of
 
108
the keyboard with these symbols. The <emphasis>
 
109
phys_symbols</emphasis>
 
110
 name, on the other hand, identifies the symbols actually engraved on the
 
111
keyboard. Given this, the <emphasis>
 
112
symbols</emphasis>
 
113
 name and <emphasis>
 
114
phys_symbols</emphasis>
 
115
 names might be different. For example, the description for a keyboard that has
 
116
English US engravings, but that is using Swiss German symbols might have a
 
117
<emphasis>
 
118
phys_symbols</emphasis>
 
119
 name of "en_US" and a <emphasis>
 
120
symbols</emphasis>
 
121
 name of "de_CH."
 
122
</para>
 
123
 
 
124
 
 
125
<para>
 
126
The <emphasis>
 
127
types</emphasis>
 
128
 name provides some information about the set of key types (see section 15.2)
 
129
that can be associated with the keyboard. In addition, each key type can have a
 
130
name, and each shift level of a type can have a name. Although these names are
 
131
stored in the map description with each of the types, they are accessed using
 
132
the same methods as the other symbolic names.
 
133
</para>
 
134
 
 
135
 
 
136
<para>
 
137
The <emphasis>
 
138
compat</emphasis>
 
139
 name provides some information about the rules used to bind actions to keys
 
140
that are changed using core protocol requests.
 
141
</para>
 
142
 
 
143
 
 
144
<para>
 
145
Xkb provides symbolic names for each of the 4 keyboard groups, 16 virtual
 
146
modifiers, 32 keyboard indicators, and 4 keyboard groups. These names are held
 
147
in the <emphasis>
 
148
vmods</emphasis>
 
149
, <emphasis>
 
150
indicators</emphasis>
 
151
, and <emphasis>
 
152
groups</emphasis>
 
153
 fixed-length arrays.
 
154
</para>
 
155
 
 
156
 
 
157
<para>
 
158
Each key has a four-byte symbolic name. All of the symbolic key names are held
 
159
in the <emphasis>
 
160
keys</emphasis>
 
161
 array, and <emphasis>
 
162
num_keys</emphasis>
 
163
 reports the number of entries that are in the keys array. For each key, the
 
164
key name links keys with similar functions or in similar positions on keyboards
 
165
that report different keycodes. For example, the <emphasis>
 
166
F1</emphasis>
 
167
 key may emit keycode 23 on one keyboard and keycode 86 on another. By naming
 
168
this key "FK01" on both keyboards, the keyboard layout designer can reuse parts
 
169
of keyboard descriptions for different keyboards.
 
170
</para>
 
171
 
 
172
 
 
173
<para>
 
174
Key aliases allow the keyboard layout designer to assign multiple key names to
 
175
a single key. This allows the keyboard layout designer to refer to keys using
 
176
either their position or their "function." For example, a keyboard layout
 
177
designer may wish to refer to the left arrow key on a PC keyboard using the
 
178
ISO9995-5 positional specification of A31 or using the functional specification
 
179
of LEFT. The <emphasis>
 
180
key_aliases</emphasis>
 
181
 field holds a variable-length array of real and alias key name pairs, and the
 
182
total number of entries in the <emphasis>
 
183
key_aliases</emphasis>
 
184
 array is held in <emphasis>
 
185
num_key_aliases</emphasis>
 
186
. For each real and alias key name pair, the <emphasis>
 
187
real</emphasis>
 
188
 field refers to the a name in the keys array, and the <emphasis>
 
189
alias</emphasis>
 
190
 field refers to the alias for that key. Using the previous example, the
 
191
keyboard designer may use the name A31 in the keys array, but also define the
 
192
name LEFT as an alias for A31 in the <emphasis>
 
193
key_aliases</emphasis>
 
194
 array.
 
195
</para>
 
196
 
 
197
<note><para>Key aliases defined in the geometry component of a keyboard mapping
 
198
(see Chapter 13) override those defined in the keycodes component of the server
 
199
database, which are stored in the <emphasis>
 
200
XkbNamesRec</emphasis>
 
201
 (<emphasis>
 
202
xkb-&gt;names</emphasis>
 
203
). Therefore, consider the key aliases defined by the geometry before
 
204
considering key aliases supplied by the <emphasis>
 
205
XkbNamesRec</emphasis>
 
206
.</para></note>
 
207
 
 
208
<para>
 
209
A radio group is a set of keys whose behavior simulates a set of radio buttons.
 
210
Once a key in a radio group is pressed, it stays logically depressed until
 
211
another key in the group is pressed, at which point the previously depressed
 
212
key is logically released. Consequently, at most one key in a radio group can
 
213
be logically depressed at one time.
 
214
</para>
 
215
 
 
216
 
 
217
<para>
 
218
Each radio group in the keyboard description can have a name. These names are
 
219
held in the variable-length array <emphasis>
 
220
radio_groups</emphasis>
 
221
, and <emphasis>
 
222
num_rg</emphasis>
 
223
 tells how many elements are in the <emphasis>
 
224
radio_groups</emphasis>
 
225
 array.
 
226
</para>
 
227
 
 
228
 
 
229
</sect1>
 
230
<sect1 id='symbolic_names_masks'>
 
231
<title>Symbolic Names Masks</title>
 
232
 
 
233
<para>
 
234
Xkb provides several functions that work with symbolic names. Each of these
 
235
functions uses a mask to specify individual fields of the structures described
 
236
above. These masks and their relationships to the fields in a keyboard
 
237
description are shown in Table 18.1.
 
238
</para>
 
239
 
 
240
<table frame='none'>
 
241
<title>Symbolic Names Masks</title>
 
242
<tgroup cols='4'>
 
243
<colspec colsep='0'/>
 
244
<colspec colsep='0'/>
 
245
<colspec colsep='0'/>
 
246
<colspec colsep='0'/>
 
247
<thead>
 
248
<row rowsep='0'>
 
249
  <entry>Mask Bit</entry>
 
250
  <entry>Value</entry>
 
251
  <entry>Keyboard Component</entry>
 
252
  <entry>Field</entry>
 
253
</row>
 
254
</thead>
 
255
<tbody>
 
256
<row rowsep='0'>
 
257
    <entry>XkbKeycodesNameMask</entry>
 
258
    <entry>(1&lt;&lt;0)</entry>
 
259
    <entry>Xkb-&gt;names</entry>
 
260
    <entry>keycodes</entry>
 
261
</row>
 
262
<row rowsep='0'>
 
263
    <entry>XkbGeometryNameMask</entry>
 
264
    <entry>(1&lt;&lt;1)</entry>
 
265
    <entry>Xkb-&gt;names</entry>
 
266
    <entry>geometry</entry>
 
267
</row>
 
268
<row rowsep='0'>
 
269
    <entry>XkbSymbolsNameMask</entry>
 
270
    <entry>(1&lt;&lt;2)</entry>
 
271
    <entry>Xkb-&gt;names</entry>
 
272
    <entry>symbols</entry>
 
273
</row>
 
274
<row rowsep='0'>
 
275
    <entry>XkbPhysSymbolsNameMask</entry>
 
276
    <entry>(1&lt;&lt;3)</entry>
 
277
    <entry>Xkb-&gt;names</entry>
 
278
    <entry>phys_symbols</entry>
 
279
</row>
 
280
<row rowsep='0'>
 
281
    <entry>XkbTypesNameMask</entry>
 
282
    <entry>(1&lt;&lt;4)</entry>
 
283
    <entry>Xkb-&gt;names</entry>
 
284
    <entry>type</entry>
 
285
</row>
 
286
<row rowsep='0'>
 
287
    <entry>XkbCompatNameMask</entry>
 
288
    <entry>(1&lt;&lt;5)</entry>
 
289
    <entry>Xkb-&gt;names</entry>
 
290
    <entry>compat</entry>
 
291
</row>
 
292
<row rowsep='0'>
 
293
    <entry>XkbKeyTypeNamesMask</entry>
 
294
    <entry>(1&lt;&lt;6)</entry>
 
295
    <entry>Xkb-&gt;map</entry>
 
296
    <entry>type[*].name</entry>
 
297
</row>
 
298
<row rowsep='0'>
 
299
    <entry>XkbKTLevelNamesMask</entry>
 
300
    <entry>(1&lt;&lt;7)</entry>
 
301
    <entry>Xkb-&gt;map</entry>
 
302
    <entry>type[*].lvl_names[*]</entry>
 
303
</row>
 
304
<row rowsep='0'>
 
305
    <entry>XkbIndicatorNamesMask</entry>
 
306
    <entry>(1&lt;&lt;8)</entry>
 
307
    <entry>Xkb-&gt;names</entry>
 
308
    <entry>indicators[*]</entry>
 
309
</row>
 
310
<row rowsep='0'>
 
311
    <entry>XkbKeyNamesMask</entry>
 
312
    <entry>(1&lt;&lt;9)</entry>
 
313
    <entry>Xkb-&gt;names</entry>
 
314
    <entry>keys[*], num_keys</entry>
 
315
</row>
 
316
<row rowsep='0'>
 
317
    <entry>XkbKeyAliasesMask</entry>
 
318
    <entry>(1&lt;&lt;10)</entry>
 
319
    <entry>Xkb-&gt;names</entry>
 
320
    <entry>key_aliases[*], num_key_aliases</entry>
 
321
</row>
 
322
<row rowsep='0'>
 
323
    <entry>XkbVirtualModNamesMask</entry>
 
324
    <entry>(1&lt;&lt;11)</entry>
 
325
    <entry>Xkb-&gt;names</entry>
 
326
    <entry>vmods[*]</entry>
 
327
</row>
 
328
<row rowsep='0'>
 
329
    <entry>XkbGroupNamesMask</entry>
 
330
    <entry>(1&lt;&lt;12)</entry>
 
331
    <entry>Xkb-&gt;names</entry>
 
332
    <entry>groups[*]</entry>
 
333
</row>
 
334
<row rowsep='0'>
 
335
    <entry>XkbRGNamesMask</entry>
 
336
    <entry>(1&lt;&lt;13)</entry>
 
337
    <entry>Xkb-&gt;names</entry>
 
338
    <entry>radio_groups[*], num_rg</entry>
 
339
</row>
 
340
<row rowsep='0'>
 
341
    <entry>XkbComponentNamesMask</entry>
 
342
    <entry>(0x3f)</entry>
 
343
    <entry>Xkb-&gt;names</entry>
 
344
    <entry>
 
345
<para>keycodes,</para>
 
346
<para>geometry,</para>
 
347
<para>symbols,</para>
 
348
<para>physical symbols,</para>
 
349
<para>types, and</para>
 
350
<para>compatibility map</para>
 
351
    </entry>
 
352
</row>
 
353
<row rowsep='0'>
 
354
    <entry>XkbAllNamesMask</entry>
 
355
    <entry>(0x3fff)</entry>
 
356
    <entry>Xkb-&gt;names</entry>
 
357
    <entry>all name components</entry>
 
358
  </row>
 
359
</tbody>
 
360
</tgroup>
 
361
</table>
 
362
 
 
363
</sect1>
 
364
<sect1 id='getting_symbolic_names_from_the_server'>
 
365
<title>Getting Symbolic Names From the Server</title>
 
366
 
 
367
<para>
 
368
To obtain symbolic names from the server, use <emphasis>
 
369
XkbGetNames</emphasis>
 
370
.
 
371
</para>
 
372
 
 
373
<informaltable frame='none'>
 
374
<tgroup cols='1'>
 
375
<colspec colsep='0'/>
 
376
<tbody>
 
377
  <row rowsep='0'>
 
378
    <entry role='functiondecl'>
 
379
Status <emphasis>
 
380
XkbGetNames</emphasis>
 
381
(<emphasis>
 
382
dpy, which, Xkb</emphasis>
 
383
)
 
384
    </entry>
 
385
  </row>
 
386
  <row rowsep='0'>
 
387
    <entry role='functionargdecl'>
 
388
Display *      <emphasis>
 
389
dpy</emphasis>
 
390
;      /* connection to the X server */
 
391
    </entry>
 
392
  </row>
 
393
  <row rowsep='0'>
 
394
    <entry role='functionargdecl'>
 
395
unsigned int      <emphasis>
 
396
which</emphasis>
 
397
;      /* mask of names or map components to be updated */
 
398
    </entry>
 
399
  </row>
 
400
  <row rowsep='0'>
 
401
    <entry role='functionargdecl'>
 
402
XkbDescPtr      <emphasis>
 
403
xkb</emphasis>
 
404
      /* keyboard description to be updated */
 
405
    </entry>
 
406
</row>
 
407
</tbody>
 
408
</tgroup>
 
409
</informaltable>
 
410
 
 
411
<para>
 
412
<emphasis>
 
413
XkbGetNames</emphasis>
 
414
 retrieves symbolic names for the components of the keyboard extension from the
 
415
X server. The <emphasis>
 
416
which</emphasis>
 
417
 parameter specifies the name components to be updated in the <emphasis>
 
418
xkb</emphasis>
 
419
 parameter, and is the bitwise inclusive OR of the valid names mask bits
 
420
defined in Table 18.1.
 
421
</para>
 
422
 
 
423
 
 
424
<para>
 
425
If the <emphasis>
 
426
names</emphasis>
 
427
 field of the keyboard description <emphasis>
 
428
xkb</emphasis>
 
429
 is <emphasis>
 
430
NULL</emphasis>
 
431
, <emphasis>
 
432
XkbGetNames</emphasis>
 
433
 allocates and initializes the <emphasis>
 
434
names</emphasis>
 
435
 component of the keyboard description before obtaining the values specified by
 
436
<emphasis>
 
437
which</emphasis>
 
438
. If the <emphasis>
 
439
names</emphasis>
 
440
 field of <emphasis>
 
441
xkb</emphasis>
 
442
 is not <emphasis>
 
443
NULL</emphasis>
 
444
, <emphasis>
 
445
XkbGetNames</emphasis>
 
446
 obtains the values specified by <emphasis>
 
447
which</emphasis>
 
448
 and copies them into the keyboard description <emphasis>
 
449
Xkb</emphasis>
 
450
.
 
451
</para>
 
452
 
 
453
 
 
454
<para>
 
455
If the <emphasis>
 
456
map</emphasis>
 
457
 component of the <emphasis>
 
458
xkb</emphasis>
 
459
 parameter is <emphasis>
 
460
NULL</emphasis>
 
461
, <emphasis>
 
462
XkbGetNames</emphasis>
 
463
 does not retrieve type or shift level names, even if <emphasis>
 
464
XkbKeyTypeNamesMask</emphasis>
 
465
 or <emphasis>
 
466
XkbKTLevelNamesMask</emphasis>
 
467
 are set in <emphasis>
 
468
which</emphasis>
 
469
.
 
470
</para>
 
471
 
 
472
 
 
473
<para>
 
474
<emphasis>
 
475
XkbGetNames</emphasis>
 
476
 can return <emphasis>
 
477
Success</emphasis>
 
478
, or <emphasis>
 
479
BadAlloc</emphasis>
 
480
, <emphasis>
 
481
BadLength</emphasis>
 
482
, <emphasis>
 
483
BadMatch</emphasis>
 
484
, and <emphasis>
 
485
BadImplementation</emphasis>
 
486
 errors.
 
487
</para>
 
488
 
 
489
 
 
490
<para>
 
491
To free symbolic names, use <emphasis>
 
492
XkbFreeNames</emphasis>
 
493
 (see section 18.6)
 
494
</para>
 
495
 
 
496
 
 
497
</sect1>
 
498
<sect1 id='changing_symbolic_names_on_the_server'>
 
499
<title>Changing Symbolic Names on the Server</title>
 
500
 
 
501
<para>
 
502
To change the symbolic names in the server, first modify a local copy of the
 
503
keyboard description and then use either <emphasis>
 
504
XkbSetNames,</emphasis>
 
505
 or, to save network traffic, use a <emphasis>
 
506
XkbNameChangesRec</emphasis>
 
507
structure and call <emphasis>
 
508
XkbChangeNames</emphasis>
 
509
 to download the changes to the server. <emphasis>
 
510
XkbSetNames</emphasis>
 
511
 and <emphasis>
 
512
XkbChangeNames</emphasis>
 
513
 can generate <emphasis>
 
514
BadAlloc</emphasis>
 
515
, <emphasis>
 
516
BadAtom</emphasis>
 
517
, <emphasis>
 
518
BadLength</emphasis>
 
519
, <emphasis>
 
520
BadMatch,</emphasis>
 
521
 and <emphasis>
 
522
BadImplementation</emphasis>
 
523
 errors.
 
524
</para>
 
525
 
 
526
<informaltable frame='none'>
 
527
<tgroup cols='1'>
 
528
<colspec colsep='0'/>
 
529
<tbody>
 
530
  <row rowsep='0'>
 
531
    <entry role='functiondecl'>
 
532
Bool <emphasis>
 
533
XkbSetNames</emphasis>
 
534
(<emphasis>
 
535
dpy, which, first_type, num_types, xkb</emphasis>
 
536
)
 
537
    </entry>
 
538
  </row>
 
539
  <row rowsep='0'>
 
540
    <entry role='functionargdecl'>
 
541
Display *      <emphasis>
 
542
dpy</emphasis>
 
543
;            /* connection to the X server */
 
544
    </entry>
 
545
  </row>
 
546
  <row rowsep='0'>
 
547
    <entry role='functionargdecl'>
 
548
unsigned int      <emphasis>
 
549
which</emphasis>
 
550
;            /* mask of names or map components to be changed */
 
551
    </entry>
 
552
  </row>
 
553
  <row rowsep='0'>
 
554
    <entry role='functionargdecl'>
 
555
unsigned int      <emphasis>
 
556
first_type</emphasis>
 
557
      ;      /* first type whose name is to be changed */
 
558
    </entry>
 
559
  </row>
 
560
  <row rowsep='0'>
 
561
    <entry role='functionargdecl'>
 
562
unsigned int      <emphasis>
 
563
num_types</emphasis>
 
564
;            /* number of types for which names are to be changed */
 
565
    </entry>
 
566
  </row>
 
567
  <row rowsep='0'>
 
568
    <entry role='functionargdecl'>
 
569
XkbDescPtr      <emphasis>
 
570
xkb</emphasis>
 
571
;            /* keyboard description from which names are to be taken */
 
572
    </entry>
 
573
</row>
 
574
</tbody>
 
575
</tgroup>
 
576
</informaltable>
 
577
 
 
578
<para>
 
579
Use<emphasis>
 
580
 XkbSetNames</emphasis>
 
581
 to change many names at the same time. For each bit set in <emphasis>
 
582
which</emphasis>
 
583
, <emphasis>
 
584
XkbSetNames</emphasis>
 
585
 takes the corresponding value (or values in the case of arrays) from the
 
586
keyboard description <emphasis>
 
587
xkb</emphasis>
 
588
 and sends it to the server.
 
589
</para>
 
590
 
 
591
 
 
592
<para>
 
593
The <emphasis>
 
594
first_type</emphasis>
 
595
 and <emphasis>
 
596
num_types</emphasis>
 
597
 arguments are used only if <emphasis>
 
598
XkbKeyTypeNamesMask</emphasis>
 
599
 or <emphasis>
 
600
XkbKTLevelNamesMask</emphasis>
 
601
 is set in <emphasis>
 
602
which</emphasis>
 
603
 and specify a subset of the types for which the corresponding names are to be
 
604
changed. If either or both of these mask bits are set but the specified types
 
605
are illegal, <emphasis>
 
606
XkbSetNames</emphasis>
 
607
 returns <emphasis>
 
608
False</emphasis>
 
609
 and does not update any of the names specified in <emphasis>
 
610
which</emphasis>
 
611
. The specified types are illegal if <emphasis>
 
612
xkb</emphasis>
 
613
 does not include a map component or if <emphasis>
 
614
first_type</emphasis>
 
615
 and <emphasis>
 
616
num_types</emphasis>
 
617
 specify types that are not defined in the keyboard description.
 
618
</para>
 
619
 
 
620
 
 
621
<sect2>
 
622
<title/>
 
623
 
 
624
<sect3 id='the_xkbnamechangesrec_structure'>
 
625
<title>The XkbNameChangesRec Structure</title>
 
626
 
 
627
<para>
 
628
The <emphasis>
 
629
XkbNameChangesRec</emphasis>
 
630
 allows applications to identify small modifications to the symbolic names and
 
631
effectively reduces the amount of traffic sent to the server:
 
632
</para>
 
633
 
 
634
<para><programlisting>
 
635
typedef struct _XkbNameChanges {
 
636
      unsigned int      changed;            /* name components that have
 
637
                                               changed */
 
638
      unsigned char      first_type;        /* first key type with a new
 
639
                                               name */
 
640
      unsigned char      num_types;         /* number of types with new
 
641
                                               names */
 
642
      unsigned char      first_lvl;         /* first key type with new level
 
643
                                               names */
 
644
      unsigned char      num_lvls;          /* number of key types with new
 
645
                                               level names */
 
646
      unsigned char      num_aliases;       /* if key aliases changed,
 
647
                                               total number of key aliases */
 
648
      unsigned char      num_rg;            /* if radio groups changed, total
 
649
                                               number of radio groups */
 
650
      unsigned char      first_key;         /* first key with a new name */
 
651
      unsigned char      num_keys;          /* number of keys with new names
 
652
                                               */
 
653
      unsigned short      changed_vmods;    /* mask of virtual
 
654
                                               modifiers for which names have changed */
 
655
      unsigned long      changed_indicators;  /* mask of indicators
 
656
                                                 for which names were changed */
 
657
      unsigned char       changed_groups;   /* mask of groups for
 
658
                                               which names were changed */
 
659
} <emphasis>XkbNameChangesRec</emphasis>, *XkbNameChangesPtr
 
660
</programlisting></para>
 
661
 
 
662
<para>
 
663
The <emphasis>
 
664
changed</emphasis>
 
665
 field specifies the name components that have changed and is the bitwise
 
666
inclusive OR of the valid names mask bits defined in Table 18.1. The rest of
 
667
the fields in the structure specify the ranges that have changed for the
 
668
various kinds of symbolic names, as shown in Table 18.2.
 
669
</para>
 
670
 
 
671
<table frame='none'>
 
672
<title>XkbNameChanges Fields</title>
 
673
<tgroup cols='4'>
 
674
<colspec colsep='0'/>
 
675
<colspec colsep='0'/>
 
676
<colspec colsep='0'/>
 
677
<colspec colsep='0'/>
 
678
<thead>
 
679
<row rowsep='0'>
 
680
  <entry>Mask</entry>
 
681
  <entry>Fields</entry>
 
682
  <entry>Component</entry>
 
683
  <entry>Field</entry>
 
684
</row>
 
685
</thead>
 
686
<tbody>
 
687
<row rowsep='0'>
 
688
    <entry>XkbKeyTypeNamesMask</entry>
 
689
    <entry>
 
690
<para>first_type,</para>
 
691
<para>num_types</para>
 
692
    </entry>
 
693
    <entry>Xkb-&gt;map</entry>
 
694
    <entry>type[*].name</entry>
 
695
</row>
 
696
<row rowsep='0'>
 
697
    <entry>XkbKTLevelNamesMask</entry>
 
698
    <entry>
 
699
<para>first_lvl,</para>
 
700
<para>num_lvls</para>
 
701
    </entry>
 
702
    <entry>Xkb-&gt;map</entry>
 
703
    <entry>type[*].lvl_names[*]</entry>
 
704
</row>
 
705
<row rowsep='0'>
 
706
    <entry>XkbKeyAliasesMask</entry>
 
707
    <entry>num_aliases</entry>
 
708
    <entry>Xkb-&gt;names</entry>
 
709
    <entry>key_aliases[*]</entry>
 
710
</row>
 
711
<row rowsep='0'>
 
712
    <entry>XkbRGNamesMask</entry>
 
713
    <entry>num_rg</entry>
 
714
    <entry>Xkb-&gt;names</entry>
 
715
    <entry>radio_groups[*]</entry>
 
716
</row>
 
717
<row rowsep='0'>
 
718
    <entry>XkbKeyNamesMask</entry>
 
719
    <entry>
 
720
<para>first_key,</para>
 
721
<para>num_keys</para>
 
722
    </entry>
 
723
    <entry>Xkb-&gt;names</entry>
 
724
    <entry>keys[*]</entry>
 
725
</row>
 
726
<row rowsep='0'>
 
727
    <entry>XkbVirtualModNamesMask</entry>
 
728
    <entry>changed_vmods</entry>
 
729
    <entry>Xkb-&gt;names</entry>
 
730
    <entry>vmods[*]</entry>
 
731
</row>
 
732
<row rowsep='0'>
 
733
    <entry>XkbIndicatorNamesMask</entry>
 
734
    <entry>changed_indicators</entry>
 
735
    <entry>Xkb-&gt;names</entry>
 
736
    <entry>indicators[*]</entry>
 
737
</row>
 
738
<row rowsep='0'>
 
739
    <entry>XkbGroupNamesMask</entry>
 
740
    <entry>changed_groups</entry>
 
741
    <entry>Xkb-&gt;names</entry>
 
742
    <entry>groups[*]</entry>
 
743
  </row>
 
744
</tbody>
 
745
</tgroup>
 
746
</table>
 
747
 
 
748
<para>
 
749
<emphasis>
 
750
XkbChangeNames</emphasis>
 
751
 provides a more flexible method for changing symbolic names than <emphasis>
 
752
XkbSetNames</emphasis>
 
753
 and requires the use of an <emphasis>
 
754
XkbNameChangesRec</emphasis>
 
755
 structure.
 
756
</para>
 
757
 
 
758
<informaltable frame='none'>
 
759
<tgroup cols='1'>
 
760
<colspec colsep='0'/>
 
761
<tbody>
 
762
  <row rowsep='0'>
 
763
    <entry role='functiondecl'>
 
764
Bool <emphasis>
 
765
XkbChangeNames</emphasis>
 
766
(<emphasis>
 
767
dpy, xkb, changes</emphasis>
 
768
)
 
769
    </entry>
 
770
  </row>
 
771
  <row rowsep='0'>
 
772
    <entry role='functionargdecl'>
 
773
Display *            <emphasis>
 
774
dpy</emphasis>
 
775
;            /* connection to the X server */
 
776
    </entry>
 
777
  </row>
 
778
  <row rowsep='0'>
 
779
    <entry role='functionargdecl'>
 
780
XkbDescPtr      <emphasis>
 
781
      xkb</emphasis>
 
782
;            /* keyboard description from which names are to be taken */
 
783
    </entry>
 
784
  </row>
 
785
  <row rowsep='0'>
 
786
    <entry role='functionargdecl'>
 
787
XkbNameChangesPtr      <emphasis>
 
788
      changes</emphasis>
 
789
;            /* names map components to be updated on the server */
 
790
    </entry>
 
791
</row>
 
792
</tbody>
 
793
</tgroup>
 
794
</informaltable>
 
795
 
 
796
<para>
 
797
<emphasis>
 
798
XkbChangeNames</emphasis>
 
799
 copies any names specified by <emphasis>
 
800
changes</emphasis>
 
801
 from the keyboard description, <emphasis>
 
802
xkb</emphasis>
 
803
, to the X server specified by <emphasis>
 
804
dpy</emphasis>
 
805
.<emphasis>
 
806
 XkbChangeNames</emphasis>
 
807
 aborts and returns <emphasis>
 
808
False</emphasis>
 
809
 if any illegal type names or type shift level names are specified by <emphasis>
 
810
changes</emphasis>
 
811
.
 
812
</para>
 
813
 
 
814
</sect3>
 
815
</sect2>
 
816
</sect1>
 
817
<sect1 id='tracking_name_changes'>
 
818
<title>Tracking Name Changes</title>
 
819
 
 
820
<para>
 
821
Whenever a symbolic name changes in the server’s keyboard description, the
 
822
server sends a <emphasis>
 
823
XkbNamesNotify</emphasis>
 
824
 event to all interested clients. To receive name notify events, use <emphasis>
 
825
XkbSelectEvents</emphasis>
 
826
 (see section 4.3) with <emphasis>
 
827
XkbNamesNotifyMask</emphasis>
 
828
 in both the <emphasis>
 
829
bits_to_change</emphasis>
 
830
 and <emphasis>
 
831
values_for_bits</emphasis>
 
832
 parameters.
 
833
</para>
 
834
 
 
835
 
 
836
<para>
 
837
To receive events for only specific names, use <emphasis>
 
838
XkbSelectEventDetails</emphasis>
 
839
. Set the <emphasis>
 
840
event_type</emphasis>
 
841
 parameter to <emphasis>
 
842
XkbNamesNotify</emphasis>
 
843
, and set both the <emphasis>
 
844
bits_to_change </emphasis>
 
845
and<emphasis>
 
846
 values_for_bits</emphasis>
 
847
 detail parameter to a mask composed of a bitwise OR of masks in Table 18.1.
 
848
</para>
 
849
 
 
850
 
 
851
<para>
 
852
The structure for the <emphasis>
 
853
XkbNamesNotify</emphasis>
 
854
 event is defined as follows:
 
855
</para>
 
856
 
 
857
<para><programlisting>
 
858
typedef struct {
 
859
      int      type;                  /* Xkb extension base event code */
 
860
      unsigned long      serial;      /* X server serial number for
 
861
                                         event */
 
862
      Bool      send_event;           /* <emphasis>True</emphasis>
 
863
                                         =&gt; synthetically generated */
 
864
      Display *      display;         /* server connection where event
 
865
                                         generated */
 
866
      Time      time;                 /* server time when event generated */
 
867
      int      xkb_type;              /* <emphasis>XkbNamesNotify</emphasis> */
 
868
      int      device;                /* Xkb device ID, will not be
 
869
                                         <emphasis>XkbUseCoreKbd</emphasis> */
 
870
      unsigned int      changed;      /* mask of name components
 
871
that have changed */
 
872
      int      first_type;            /* first key type with a new name */
 
873
      int      num_types;             /* number of types with new names */
 
874
      int      first_lvl;             /* first key type with new level names */
 
875
      int      num_lvls;              /* number of key types with new level names */
 
876
      int      num_aliases;           /* if key aliases changed, total number
 
877
                                         of key aliases */
 
878
      int      num_radio_groups;      /* if radio groups changed,
 
879
                                         total number of radio groups */
 
880
      unsigned int      changed_vmods;  /* mask of virtual modifiers for
 
881
                                           which names have changed */
 
882
      unsigned int      changed_groups; /* mask of groups for
 
883
                                           which names were changed */
 
884
      unsigned int      changed_indicators;  /* mask of indicators for which
 
885
                                                names were changed */
 
886
      int      first_key;             /* first key with a new name */
 
887
      int      num_keys;              /* number of keys with new names */
 
888
} <emphasis>XkbNamesNotifyEvent</emphasis>;
 
889
</programlisting></para>
 
890
 
 
891
<para>
 
892
The <emphasis>
 
893
changed</emphasis>
 
894
 field specifies the name components that have changed and is the bitwise
 
895
inclusive OR of the valid names mask bits defined in Table 18.1. The other
 
896
fields in this event are interpreted as the like-named fields in an <emphasis>
 
897
XkbNameChangesRec</emphasis> , as previously defined.
 
898
</para>
 
899
 
 
900
 
 
901
<para>
 
902
When your application receives a X<emphasis>
 
903
kbNamesNotify</emphasis>
 
904
 event, you can note the changed names in a changes structure using <emphasis>
 
905
XkbNoteNameChanges</emphasis>
 
906
.
 
907
</para>
 
908
 
 
909
<informaltable frame='none'>
 
910
<tgroup cols='1'>
 
911
<colspec colsep='0'/>
 
912
<tbody>
 
913
  <row rowsep='0'>
 
914
    <entry role='functiondecl'>
 
915
void <emphasis>
 
916
XkbNoteNameChanges</emphasis>
 
917
(<emphasis>
 
918
old</emphasis>
 
919
,<emphasis>
 
920
 new</emphasis>
 
921
,<emphasis>
 
922
 wanted</emphasis>
 
923
)
 
924
    </entry>
 
925
  </row>
 
926
  <row rowsep='0'>
 
927
    <entry role='functionargdecl'>
 
928
XkbNameChangesPtr            <emphasis>
 
929
old</emphasis>
 
930
;            /* <emphasis>
 
931
XkbNameChanges</emphasis>
 
932
 structure to be updated */
 
933
    </entry>
 
934
  </row>
 
935
  <row rowsep='0'>
 
936
    <entry role='functionargdecl'>
 
937
XkbNamesNotifyEvent *            <emphasis>
 
938
new</emphasis>
 
939
;            /* event from which changes are to be copied */
 
940
    </entry>
 
941
  </row>
 
942
  <row rowsep='0'>
 
943
    <entry role='functionargdecl'>
 
944
unsigned int            <emphasis>
 
945
wanted</emphasis>
 
946
;            /* types of names for which changes are to be noted */
 
947
    </entry>
 
948
</row>
 
949
</tbody>
 
950
</tgroup>
 
951
</informaltable>
 
952
 
 
953
<para>
 
954
The <emphasis>
 
955
wanted</emphasis>
 
956
 parameter is the bitwise inclusive OR of the valid names mask bits shown in
 
957
Table 18.1. <emphasis>
 
958
XkbNoteNameChanges</emphasis>
 
959
 copies any changes that are reported in <emphasis>
 
960
new</emphasis>
 
961
 and specified in <emphasis>
 
962
wanted</emphasis>
 
963
 into the changes record specified by <emphasis>
 
964
old</emphasis>
 
965
.
 
966
</para>
 
967
 
 
968
 
 
969
<para>
 
970
To update the local copy of the keyboard description with the actual values,
 
971
pass to <emphasis>
 
972
XkbGetNameChanges</emphasis>
 
973
 the results of one or more calls to <emphasis>
 
974
XkbNoteNameChanges</emphasis>
 
975
.
 
976
</para>
 
977
 
 
978
 
 
979
<informaltable frame='none'>
 
980
<tgroup cols='1'>
 
981
<colspec colsep='0'/>
 
982
<tbody>
 
983
  <row rowsep='0'>
 
984
    <entry role='functiondecl'>
 
985
Status <emphasis>
 
986
XkbGetNameChanges</emphasis>
 
987
(<emphasis>
 
988
dpy</emphasis>
 
989
,<emphasis>
 
990
 xkb</emphasis>
 
991
,<emphasis>
 
992
 changes</emphasis>
 
993
)
 
994
    </entry>
 
995
  </row>
 
996
  <row rowsep='0'>
 
997
    <entry role='functionargdecl'>
 
998
Display *            <emphasis>
 
999
dpy</emphasis>
 
1000
;            /* connection to the X server */
 
1001
    </entry>
 
1002
  </row>
 
1003
  <row rowsep='0'>
 
1004
    <entry role='functionargdecl'>
 
1005
XkbDescPtr            <emphasis>
 
1006
xkb</emphasis>
 
1007
;            /* keyboard description to which names are copied */
 
1008
    </entry>
 
1009
  </row>
 
1010
  <row rowsep='0'>
 
1011
    <entry role='functionargdecl'>
 
1012
XkbNameChangesPtr            <emphasis>
 
1013
changes</emphasis>
 
1014
;            /* names components to be obtained from the server */
 
1015
    </entry>
 
1016
</row>
 
1017
</tbody>
 
1018
</tgroup>
 
1019
</informaltable>
 
1020
 
 
1021
<para>
 
1022
<emphasis>
 
1023
XkbGetNameChanges</emphasis>
 
1024
 examines the <emphasis>
 
1025
changes</emphasis>
 
1026
 parameter, retrieves the necessary information from the server, and places the
 
1027
results into the <emphasis>
 
1028
xkb</emphasis>
 
1029
 keyboard description.
 
1030
</para>
 
1031
 
 
1032
 
 
1033
<para>
 
1034
<emphasis>
 
1035
XkbGetNamesChanges</emphasis>
 
1036
 can generate <emphasis>
 
1037
BadAlloc</emphasis>
 
1038
, <emphasis>
 
1039
BadImplementation,</emphasis>
 
1040
 and <emphasis>
 
1041
BadMatch</emphasis>
 
1042
 errors.
 
1043
</para>
 
1044
 
 
1045
 
 
1046
</sect1>
 
1047
<sect1 id='allocating_and_freeing_symbolic_names'>
 
1048
<title>Allocating and Freeing Symbolic Names</title>
 
1049
 
 
1050
<para>
 
1051
Most applications do not need to directly allocate symbolic names structures.
 
1052
Do not allocate a names structure directly using <emphasis>
 
1053
malloc</emphasis>
 
1054
 or <emphasis>
 
1055
Xmalloc</emphasis>
 
1056
 if your application changes the number of key aliases or radio groups or
 
1057
constructs a symbolic names structure without loading the necessary components
 
1058
from the X server. Instead use <emphasis>
 
1059
XkbAllocNames</emphasis>
 
1060
.
 
1061
</para>
 
1062
 
 
1063
<informaltable frame='none'>
 
1064
<tgroup cols='1'>
 
1065
<colspec colsep='0'/>
 
1066
<tbody>
 
1067
  <row rowsep='0'>
 
1068
    <entry role='functiondecl'>
 
1069
Status <emphasis>
 
1070
XkbAllocNames</emphasis>
 
1071
(<emphasis>
 
1072
xkb, which, num_rg, num_key_aliases)</emphasis>
 
1073
    </entry>
 
1074
  </row>
 
1075
  <row rowsep='0'>
 
1076
    <entry role='functionargdecl'>
 
1077
XkbDescPtr      <emphasis>
 
1078
xkb;</emphasis>
 
1079
      /* keyboard description for which names are to be allocated */
 
1080
    </entry>
 
1081
  </row>
 
1082
  <row rowsep='0'>
 
1083
    <entry role='functionargdecl'>
 
1084
unsigned int      <emphasis>
 
1085
which;</emphasis>
 
1086
      /* mask of names to be allocated */
 
1087
    </entry>
 
1088
  </row>
 
1089
  <row rowsep='0'>
 
1090
    <entry role='functionargdecl'>
 
1091
int      <emphasis>
 
1092
num_rg;</emphasis>
 
1093
      /* total number of radio group names needed */
 
1094
    </entry>
 
1095
  </row>
 
1096
  <row rowsep='0'>
 
1097
    <entry role='functionargdecl'>
 
1098
int      <emphasis>
 
1099
num_key_aliases;</emphasis>
 
1100
      /* total number of key aliases needed */
 
1101
    </entry>
 
1102
</row>
 
1103
</tbody>
 
1104
</tgroup>
 
1105
</informaltable>
 
1106
 
 
1107
<para>
 
1108
<emphasis>
 
1109
XkbAllocNames</emphasis>
 
1110
 can return <emphasis>
 
1111
BadAlloc</emphasis>
 
1112
, <emphasis>
 
1113
BadMatch,</emphasis>
 
1114
 and <emphasis>
 
1115
BadValue</emphasis>
 
1116
 errors.<emphasis>
 
1117
 </emphasis>
 
1118
The <emphasis>
 
1119
which</emphasis>
 
1120
 parameter is the bitwise inclusive OR of the valid names mask bits defined in
 
1121
Table 18.1.
 
1122
</para>
 
1123
 
 
1124
 
 
1125
<para>
 
1126
Do not free symbolic names structures directly using <emphasis>
 
1127
free</emphasis>
 
1128
 or <emphasis>
 
1129
XFree</emphasis>
 
1130
. Use <emphasis>
 
1131
XkbFreeNames</emphasis>
 
1132
 instead.
 
1133
</para>
 
1134
 
 
1135
 
 
1136
<informaltable frame='none'>
 
1137
<tgroup cols='1'>
 
1138
<colspec colsep='0'/>
 
1139
<tbody>
 
1140
  <row rowsep='0'>
 
1141
    <entry role='functiondecl'>
 
1142
void <emphasis>
 
1143
XkbFreeNames</emphasis>
 
1144
(<emphasis>
 
1145
xkb, which, free_map)</emphasis>
 
1146
    </entry>
 
1147
  </row>
 
1148
  <row rowsep='0'>
 
1149
    <entry role='functionargdecl'>
 
1150
XkbDescPtr      <emphasis>
 
1151
xkb</emphasis>
 
1152
;      /* keyboard description for which names are to be freed */
 
1153
    </entry>
 
1154
  </row>
 
1155
  <row rowsep='0'>
 
1156
    <entry role='functionargdecl'>
 
1157
unsigned int      <emphasis>
 
1158
which</emphasis>
 
1159
;      /* mask of names components to be freed */
 
1160
    </entry>
 
1161
  </row>
 
1162
  <row rowsep='0'>
 
1163
    <entry role='functionargdecl'>
 
1164
Bool      <emphasis>
 
1165
free_map</emphasis>
 
1166
;      /* <emphasis>
 
1167
True</emphasis>
 
1168
 =&gt; XkbNamesRec structure itself should be freed */
 
1169
    </entry>
 
1170
</row>
 
1171
</tbody>
 
1172
</tgroup>
 
1173
</informaltable>
 
1174
 
 
1175
<para>
 
1176
The <emphasis>
 
1177
which</emphasis>
 
1178
 parameter is the bitwise inclusive OR of the valid names mask bits defined in
 
1179
Table 18.1.
 
1180
</para>
 
1181
</sect1>
 
1182
</chapter>