From 2d39dff84af0f51e5c11c3e9b953cd2e2af166ef Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Fri, 14 Aug 2015 17:54:24 +0200 Subject: [PATCH] Replace XkbGetKeyboard with XkbGetMap Switch to XkbGetMap as XkbGetKeyboard returns NULL on XWayland. Fixes #389. --- README.md | 1 + src/x11_init.c | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index c9af1060..de03f8bd 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,7 @@ GLFW bundles a number of dependencies in the `deps/` directory. - [X11] Bugfix: The `GLFW_DECORATED` hint was not ignored for full screen - [X11] Bugfix: `glfwWaitEvents` did not handle `EINTR` for `select` - [X11] Bugfix: `glfwWaitEvents` could return when no events were available + - [X11] Bugfix: `XkbGetKeyboard` fails on XWayland - [WGL] Made all WGL functions dynamically loaded - [WGL] Removed `GLFW_USE_DWM_SWAP_INTERVAL` compile-time option - [WGL] Bugfix: Swap interval was ignored when DWM was enabled diff --git a/src/x11_init.c b/src/x11_init.c index 23a74e97..2fd06358 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -241,15 +241,14 @@ static void createKeyTables(void) // keyboard layout char name[XkbKeyNameLength + 1]; - XkbDescPtr descr = XkbGetKeyboard(_glfw.x11.display, - XkbAllComponentsMask, - XkbUseCoreKbd); + XkbDescPtr desc = XkbGetMap(_glfw.x11.display, 0, XkbUseCoreKbd); + XkbGetNames(_glfw.x11.display, XkbKeyNamesMask, desc); // Find the X11 key code -> GLFW key code mapping - for (scancode = descr->min_key_code; scancode <= descr->max_key_code; scancode++) + for (scancode = desc->min_key_code; scancode <= desc->max_key_code; scancode++) { - memcpy(name, descr->names->keys[scancode].name, XkbKeyNameLength); - name[XkbKeyNameLength] = 0; + memcpy(name, desc->names->keys[scancode].name, XkbKeyNameLength); + name[XkbKeyNameLength] = '\0'; // Map the key name to a GLFW key code. Note: We only map printable // keys here, and we use the US keyboard layout. The rest of the @@ -309,7 +308,8 @@ static void createKeyTables(void) _glfw.x11.publicKeys[scancode] = key; } - XkbFreeKeyboard(descr, 0, True); + XkbFreeNames(desc, XkbKeyNamesMask, True); + XkbFreeClientMap(desc, 0, True); } // Translate the un-translated key codes using traditional X11 KeySym