Commit 4fccdee383493bb4fcd030087cf660075bdee61e

Ran Benita 2017-12-18T16:41:21

x11: check and document the correct range of device IDs The actual value is 127, not 255. https://bugs.freedesktop.org/show_bug.cgi?id=104321 Reported-by: Gatis Paeglis <gatis.paeglis@qt.io> Signed-off-by: Ran Benita <ran234@gmail.com>

diff --git a/src/x11/keymap.c b/src/x11/keymap.c
index 408d0eb..b469ef3 100644
--- a/src/x11/keymap.c
+++ b/src/x11/keymap.c
@@ -1155,7 +1155,7 @@ xkb_x11_keymap_new_from_device(struct xkb_context *ctx,
         return NULL;
     }
 
-    if (device_id < 0 || device_id > 255) {
+    if (device_id < 0 || device_id > 127) {
         log_err_func(ctx, "illegal device ID: %d\n", device_id);
         return NULL;
     }
diff --git a/xkbcommon/xkbcommon-x11.h b/xkbcommon/xkbcommon-x11.h
index 0158315..c3f5874 100644
--- a/xkbcommon/xkbcommon-x11.h
+++ b/xkbcommon/xkbcommon-x11.h
@@ -64,10 +64,9 @@ extern "C" {
  *
  * The XKB extension supports using separate keymaps and states for
  * different keyboard devices.  The devices are identified by an integer
- * device ID and are managed by another X11 extension, XInput (or its
- * successor, XInput2).  The original X11 protocol only had one keyboard
- * device, called the "core keyboard", which is still supported as a
- * "virtual device".
+ * device ID and are managed by another X11 extension, XInput. The
+ * original X11 protocol only had one keyboard device, called the "core
+ * keyboard", which is still supported as a "virtual device".
  *
  * 3. We will use the core keyboard as an example.  To get its device ID,
  *    use either the xcb_xkb_get_device_info() request directly, or the
@@ -197,8 +196,9 @@ xkb_x11_get_core_keyboard_device_id(xcb_connection_t *connection);
  * @param connection
  *     An XCB connection to the X server.
  * @param device_id
- *     An XInput 1 device ID (in the range 0-255) with input class KEY.
- *     Passing values outside of this range is an error.
+ *     An XInput device ID (in the range 0-127) with input class KEY.
+ *     Passing values outside of this range is an error (the XKB protocol
+ *     predates the XInput2 protocol, which first allowed IDs > 127).
  * @param flags
  *     Optional flags for the keymap, or 0.
  *