~ubuntu-branches/ubuntu/wily/libx11/wily-proposed

« back to all changes in this revision

Viewing changes to specs/XKB/ch19.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='replacing_a_keyboard_on_the_fly'>
 
2
<title>Replacing a Keyboard "On the Fly"</title>
 
3
 
 
4
<para>
 
5
Some operating system and X server implementations allow "hot plugging" of
 
6
input devices. When using these implementations, input devices can be unplugged
 
7
and new ones plugged in without restarting the software that is using those
 
8
devices. There is no provision in the standard X server for notification of
 
9
client programs if input devices are unplugged and/or new ones plugged in. In
 
10
the case of the X keyboard, this could result in the X server having a keymap
 
11
that does not match the new keyboard.
 
12
</para>
 
13
 
 
14
 
 
15
<para>
 
16
If the X server implementation supports the X input device extension, a client
 
17
program may also change the X keyboard programmatically. The
 
18
XChangeKeyboardDevice input extension request allows a client to designate an
 
19
input extension keyboard device as the X keyboard, in which case the old X
 
20
keyboard device becomes inaccessible except via the input device extension. In
 
21
this case, core protocol <emphasis>
 
22
XMappingNotify</emphasis>
 
23
 and input extension <emphasis>
 
24
XChangeDeviceNotify</emphasis>
 
25
 events are generated to notify all clients that a new keyboard with a new
 
26
keymap has been designated.
 
27
</para>
 
28
 
 
29
 
 
30
<para>
 
31
When a client opens a connection to the X server, the server reports the
 
32
minimum and maximum keycodes. The server keeps track of the minimum and maximum
 
33
keycodes last reported to each client. When delivering events to a particular
 
34
client, the server filters out any events that fall outside of the valid range
 
35
for the client.
 
36
</para>
 
37
 
 
38
 
 
39
<para>
 
40
Xkb provides an <emphasis>
 
41
XkbNewKeyboardNotify</emphasis>
 
42
 event that reports a change in keyboard geometry and/or the range of supported
 
43
keycodes. The server can generate an <emphasis>
 
44
XkbNewKeyboardNotify</emphasis>
 
45
 event when it detects a new keyboard or in response to an <emphasis>
 
46
XkbGetKeyboardByName</emphasis>
 
47
 request that loads a new keyboard description. Selecting for <emphasis>
 
48
XkbNewKeyboardNotify</emphasis>
 
49
 events allows Xkb-aware clients to be notified whenever a keyboard change
 
50
occurs that may affect the keymap.
 
51
</para>
 
52
 
 
53
 
 
54
<para>
 
55
When a client requests <emphasis>
 
56
XkbNewKeyboardNotify</emphasis>
 
57
 events, the server compares the range of keycodes for the current keyboard to
 
58
the range of keycodes that are valid for the client. If they are not the same,
 
59
the server immediately sends the client an <emphasis>
 
60
XkbNewKeyboardNotify</emphasis>
 
61
 event. Even if the "new" keyboard is not new to the server, it is new to this
 
62
particular client.
 
63
</para>
 
64
 
 
65
 
 
66
<para>
 
67
When the server sends an <emphasis>
 
68
XkbNewKeyboardNotify</emphasis>
 
69
 event to a client to inform it of a new keycode range, it resets the stored
 
70
range of legal keycodes for the client to the keycode range reported in the
 
71
event; it does not reset this range for the client if it does not sent an
 
72
<emphasis>
 
73
XkbNewKeyboardNotify</emphasis>
 
74
 event to a client. Because Xkb-unaware clients and Xkb-aware clients that do
 
75
not request <emphasis>
 
76
XkbNewKeyboardNotify</emphasis>
 
77
 events are never sent these events, the server’s notion of the legal keycode
 
78
range never changes, and these clients never receive events from keys that fall
 
79
outside of their notion of the legal keycode range.
 
80
</para>
 
81
 
 
82
 
 
83
<para>
 
84
Clients that have not selected to receive <emphasis>
 
85
XkbNewKeyboardNotify</emphasis>
 
86
 events do, however, receive the <emphasis>
 
87
XkbNewKeyboardNotify</emphasis>
 
88
 event when a keyboard change occurs. Clients that have not selected to receive
 
89
this event also receive numerous other events detailing the individual changes
 
90
that occur when a keyboard change occurs.
 
91
</para>
 
92
 
 
93
 
 
94
<para>
 
95
Clients wishing to track changes in <emphasis>
 
96
min_key_code</emphasis>
 
97
 and <emphasis>
 
98
max_key_code</emphasis>
 
99
 must watch for both <emphasis>
 
100
XkbNewKeyboardNotify</emphasis>
 
101
 and <emphasis>
 
102
XkbMapNotify</emphasis>
 
103
 events, because a simple mapping change causes an <emphasis>
 
104
XkbMapNotify</emphasis>
 
105
 event and may change the range of valid keycodes, but does not cause an
 
106
<emphasis>
 
107
XkbNewKeyboardNotify</emphasis>
 
108
 event. If a client does not select for <emphasis>
 
109
XkbNewKeyboardNotify</emphasis>
 
110
 events, the server restricts the range of keycodes reported to the client.
 
111
</para>
 
112
 
 
113
 
 
114
<para>
 
115
In addition to filtering out-of-range key events, Xkb:
 
116
</para>
 
117
 
 
118
<itemizedlist>
 
119
<listitem>
 
120
  <para>
 
121
Adjusts core protocol <emphasis>
 
122
MappingNotify</emphasis>
 
123
 events to refer only to keys that match the stored legal range.
 
124
  </para>
 
125
</listitem>
 
126
<listitem>
 
127
  <para>
 
128
Reports keyboard mappings for keys that match the stored legal range to clients
 
129
that issue a core protocol <emphasis>
 
130
GetKeyboardMapping</emphasis>
 
131
 request.
 
132
  </para>
 
133
</listitem>
 
134
<listitem>
 
135
  <para>
 
136
Reports modifier mappings only for keys that match the stored legal range to
 
137
clients that issue a core protocol <emphasis>
 
138
GetModifierMapping</emphasis>
 
139
 request.
 
140
  </para>
 
141
</listitem>
 
142
<listitem>
 
143
  <para>
 
144
Restricts the core protocol <emphasis>
 
145
ChangeKeyboardMapping</emphasis>
 
146
 and <emphasis>
 
147
SetModifierMapping</emphasis>
 
148
 requests to keys that fall inside the stored legal range.
 
149
  </para>
 
150
</listitem>
 
151
</itemizedlist>
 
152
 
 
153
<para>
 
154
In short, Xkb does everything possible to hide from Xkb-unaware clients the
 
155
fact that the range of legal keycodes has changed, because such clients cannot
 
156
be expected to deal with them. Xkb events and requests are not modified in this
 
157
manner; all Xkb events report the full range of legal keycodes. No requested
 
158
Xkb events are discarded, and no Xkb requests have their keycode range clamped.
 
159
</para>
 
160
 
 
161
 
 
162
<para>
 
163
The structure for the <emphasis>
 
164
XkbNewKeyboardNotify</emphasis>
 
165
 event is defined as follows:
 
166
</para>
 
167
 
 
168
<para><programlisting>
 
169
typedef struct _XkbNewKeyboardNotify {
 
170
      int            type;         /* Xkb extension base event code */
 
171
      unsigned long  serial;       /* X server serial number for event*/
 
172
      Bool           send_event;   /* <emphasis>True</emphasis>
 
173
                                      =&gt; synthetically generated */
 
174
      Display *      display;      /* server connection where event generated */
 
175
      Time           time;         /* server time when event generated */
 
176
      int            xkb_type;  /* <emphasis>XkbNewKeyboardNotify</emphasis> */
 
177
      int            device;       /* device ID of new keyboard */
 
178
      int            old_device;   /* device ID of old keyboard */
 
179
      int            min_key_code; /* min keycode of new keyboard */
 
180
      int            max_key_code; /* max keycode of new keyboard */
 
181
      int            old_min_key_code; /* min keycode of old keyboard */
 
182
      int            old_max_key_code; /* max keycode of old keyboard */
 
183
      unsigned int            changed; /* changed aspects - see masks below */
 
184
      char            req_major;   /* major request that caused change */
 
185
      char            req_minor;   /* minor request that caused change */
 
186
} <emphasis>XkbNewKeyboardNotifyEvent</emphasis>;
 
187
</programlisting></para>
 
188
 
 
189
<para>
 
190
To receive name notify events, use <emphasis>
 
191
XkbSelectEvents</emphasis>
 
192
 (see section 4.3) with <emphasis>
 
193
XkbNewKeyboardNotifyMask</emphasis>
 
194
 in both the <emphasis>
 
195
bits_to_change</emphasis>
 
196
 and <emphasis>
 
197
values_for_bits</emphasis>
 
198
 parameters. To receive events for only specific names, use <emphasis>
 
199
XkbSelectEventDetails</emphasis>
 
200
. Set the <emphasis>
 
201
event_type</emphasis>
 
202
 parameter to <emphasis>
 
203
XkbNewKeyboardNotify</emphasis>
 
204
, and set both the <emphasis>
 
205
bits_to_change </emphasis>
 
206
and<emphasis>
 
207
 values_for_bits</emphasis>
 
208
 detail parameter to a mask composed of a bitwise OR of masks in Table 19.1.
 
209
</para>
 
210
 
 
211
<table frame='none'>
 
212
<title>XkbNewKeyboardNotifyEvent Details</title>
 
213
<tgroup cols='3'>
 
214
<colspec colsep='0'/>
 
215
<colspec colsep='0'/>
 
216
<colspec colsep='0'/>
 
217
<thead>
 
218
<row rowsep='1'>
 
219
  <entry>XkbNewKeyboardNotify Event Details</entry>
 
220
  <entry>Value</entry>
 
221
  <entry>Circumstances</entry>
 
222
  </row>
 
223
</thead>
 
224
<tbody>
 
225
  <row rowsep='1'>
 
226
    <entry><emphasis>XkbNKN_KeycodesMask</emphasis></entry>
 
227
    <entry>(1L&lt;&lt;0)</entry>
 
228
    <entry>Notification of keycode range changes wanted</entry>
 
229
  </row>
 
230
  <row rowsep='0'>
 
231
    <entry><emphasis>XkbNKN_GeometryMask</emphasis></entry>
 
232
    <entry>(1L&lt;&lt;1)</entry>
 
233
    <entry>Notification of geometry changes wanted</entry>
 
234
  </row>
 
235
  <row rowsep='0'>
 
236
    <entry>XkbNKN_DeviceIDMask</entry>
 
237
    <entry>(1L&lt;&lt;2)</entry>
 
238
    <entry>Notification of device ID changes wanted</entry>
 
239
  </row>
 
240
  <row rowsep='0'>
 
241
    <entry><emphasis>XkbNKN_AllChangesMask</emphasis></entry>
 
242
    <entry>(0x7)</entry>
 
243
    <entry>Includes all of the above masks</entry>
 
244
  </row>
 
245
</tbody>
 
246
</tgroup>
 
247
</table>
 
248
 
 
249
<para>
 
250
The <emphasis>
 
251
req_major</emphasis>
 
252
 and <emphasis>
 
253
req_minor</emphasis>
 
254
 fields indicate what type of keyboard change has occurred.
 
255
</para>
 
256
 
 
257
 
 
258
<para>
 
259
If <emphasis>
 
260
req_major</emphasis>
 
261
 and <emphasis>
 
262
req_minor</emphasis>
 
263
 are zero, the device change was not caused by a software request to the server
 
264
— a spontaneous change has occurred, such as hot-plugging a new device. In
 
265
this case, <emphasis>
 
266
device</emphasis>
 
267
 is the device identifier for the new, current X keyboard device, but no
 
268
implementation-independent guarantee can be made about <emphasis>
 
269
old_device</emphasis>
 
270
. <emphasis>
 
271
old_device</emphasis>
 
272
 may be identical to <emphasis>
 
273
device</emphasis>
 
274
 (an implementor is permitted to reuse the device specifier when the device
 
275
changes); or it may be different. Note that <emphasis>
 
276
req_major</emphasis>
 
277
 and <emphasis>
 
278
req_minor</emphasis>
 
279
 being zero do not necessarily mean that the physical keyboard device has
 
280
changed; rather, they only imply a spontaneous change outside of software
 
281
control (some systems have keyboards that can change personality at the press
 
282
of a key).
 
283
</para>
 
284
 
 
285
 
 
286
<para>
 
287
If the keyboard change is the result of an X Input Extension <emphasis>
 
288
ChangeKeyboardDevice</emphasis>
 
289
 request, <emphasis>
 
290
req_major</emphasis>
 
291
 contains the input extension major opcode, and <emphasis>
 
292
req_minor</emphasis>
 
293
 contains the input extension request number for <emphasis>
 
294
X_ChangeKeyboardDevice</emphasis>
 
295
. In this case, <emphasis>
 
296
device</emphasis>
 
297
 and <emphasis>
 
298
old_device</emphasis>
 
299
 are different, with <emphasis>
 
300
device</emphasis>
 
301
 being the identifier for the new, current X keyboard device, and <emphasis>
 
302
old_device</emphasis>
 
303
 being the identifier for the former device.
 
304
</para>
 
305
 
 
306
 
 
307
<para>
 
308
If the keyboard change is the result of an <emphasis>
 
309
XkbGetKeyboardByName</emphasis>
 
310
 function call, which generates an <emphasis>
 
311
X_kbGetKbdByName</emphasis>
 
312
 request, <emphasis>
 
313
req_major</emphasis>
 
314
 contains the Xkb extension base event code (see section 2.4), and <emphasis>
 
315
req_minor</emphasis>
 
316
 contains the event code for the Xkb extension request <emphasis>
 
317
X_kbGetKbdByName</emphasis>
 
318
. <emphasis>
 
319
device</emphasis>
 
320
 contains the device identifier for the new device, but nothing definitive can
 
321
be said for <emphasis>
 
322
old_device</emphasis>
 
323
; it may be identical to <emphasis>
 
324
device</emphasis>
 
325
, or it may be different, depending on the implementation.
 
326
</para>
 
327
 
 
328
</chapter>