1ea1d6981Smrg<chapter id='Replacing_the_Keyboard_On_the_Fly'> 2ea1d6981Smrg<title>Replacing the Keyboard "On-the-Fly"</title> 3ea1d6981Smrg 4ea1d6981Smrg<para> 5ea1d6981SmrgXKB supports the <emphasis> 6ea1d6981SmrgXkbNewKeyboardNotify</emphasis> 7ea1d6981Smrg event, which reports a change in keyboard geometry or the range of supported 8ea1d6981Smrgkeycodes. The server can generate an <emphasis> 9ea1d6981SmrgXkbNewKeyboardNotify</emphasis> 10ea1d6981Smrg event when it detects a new keyboard, or in response to an <emphasis> 11ea1d6981SmrgXkbGetKeyboardByName</emphasis> 12ea1d6981Smrg request (see <link linkend='Using_the_Servers_Database_of_Keyboard_Components'>Using the Server’s 13ea1d6981SmrgDatabase of Keyboard Components</link>) which loads a new keyboard description. 14ea1d6981Smrg</para> 15ea1d6981Smrg 16ea1d6981Smrg 17ea1d6981Smrg<para> 18ea1d6981SmrgWhen a client opens a connection to the X server, the server reports the 19ea1d6981Smrgminimum and maximum keycodes. If the range of supported keycodes is changed, 20ea1d6981SmrgXKB keeps track of the minimum and maximum keycodes that were reported to each 21ea1d6981Smrgclient and filters out any events that fall outside of that range. Note that 22ea1d6981Smrgthese events are simply ignored; they are not delivered to some other client. 23ea1d6981Smrg</para> 24ea1d6981Smrg 25ea1d6981Smrg 26ea1d6981Smrg<para> 27ea1d6981SmrgWhen the server sends an <emphasis> 28ea1d6981SmrgXkbNewKeyboardNotify</emphasis> 29ea1d6981Smrg event to a client to inform it of the new keycode range, XKB resets the stored 30ea1d6981Smrgrange of legal keycodes to the keycode range reported in the event. Non-XKB 31ea1d6981Smrgclients and XKB-aware clients that do not request <emphasis> 32ea1d6981SmrgXkbNewKeyboardNotify</emphasis> 33ea1d6981Smrg events never receive events from keys that fall outside of the legal range 34ea1d6981Smrgthat XKB maintains for that client. 35ea1d6981Smrg</para> 36ea1d6981Smrg 37ea1d6981Smrg 38ea1d6981Smrg<para> 39ea1d6981SmrgWhen a client requests <emphasis> 40ea1d6981SmrgXkbNewKeyboardNotify</emphasis> 41ea1d6981Smrg events, the server compares the range of keycodes for the current keyboard to 42ea1d6981Smrgthe range of keycodes that are valid for the client. If they are not the same, 43ea1d6981Smrgthe server immediately sends that client an <emphasis> 44ea1d6981SmrgXkbNewKeyboardNotify</emphasis> 45ea1d6981Smrg event. Even if the "new" keyboard is not new to the server, it is new to this 46ea1d6981Smrgparticular client. 47ea1d6981Smrg</para> 48ea1d6981Smrg 49ea1d6981Smrg 50ea1d6981Smrg<para> 51ea1d6981SmrgIn addition to filtering out-of-range key events, XKB: 52ea1d6981Smrg</para> 53ea1d6981Smrg 54ea1d6981Smrg<itemizedlist> 55ea1d6981Smrg<listitem> 56ea1d6981Smrg <para>Adjusts core protocol <emphasis> 57ea1d6981SmrgMappingNotify</emphasis> 58ea1d6981Smrg events to refer only to keys that match the stored legal range. 59ea1d6981Smrg </para> 60ea1d6981Smrg</listitem> 61ea1d6981Smrg<listitem> 62ea1d6981Smrg <para>Reports keyboard mappings for keys that match the stored legal range to 63ea1d6981Smrgclients that issue a core protocol <emphasis> 64ea1d6981SmrgGetKeyboardMapping</emphasis> 65ea1d6981Smrg request. 66ea1d6981Smrg </para> 67ea1d6981Smrg</listitem> 68ea1d6981Smrg<listitem> 69ea1d6981Smrg <para>Reports modifier mappings only for keys that match the stored legal 70ea1d6981Smrgrange to clients that issue a core protocol <emphasis> 71ea1d6981SmrgGetModifierMapping</emphasis> 72ea1d6981Smrg request. 73ea1d6981Smrg </para> 74ea1d6981Smrg</listitem> 75ea1d6981Smrg<listitem> 76ea1d6981Smrg <para>Restricts the core protocol <emphasis> 77ea1d6981SmrgChangeKeyboardMapping</emphasis> 78ea1d6981Smrg and <emphasis> 79ea1d6981SmrgSetModifierMapping</emphasis> 80ea1d6981Smrg requests to keys that fall inside the stored legal range. 81ea1d6981Smrg </para> 82ea1d6981Smrg</listitem> 83ea1d6981Smrg</itemizedlist> 84ea1d6981Smrg 85ea1d6981Smrg<para> 86ea1d6981SmrgIn short, XKB does everything possible to hide the fact that the range of legal 87ea1d6981Smrgkeycodes has changed from clients non-XKB clients, which cannot be expected to 88ea1d6981Smrgdeal with it. The corresponding XKB events and requests do <emphasis> 89ea1d6981Smrgnot</emphasis> 90ea1d6981Smrg pay attention to the legal keycode range in the same way because XKB makes it 91ea1d6981Smrgpossible for clients to track changes to the keycode range for a device and 92ea1d6981Smrgrespond to them. 93ea1d6981Smrg</para> 94ea1d6981Smrg</chapter> 95