diff --git a/CMakeLists.txt b/CMakeLists.txt index 22a3ef36b..b10a6b4b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -247,12 +247,16 @@ if (_GLFW_X11) list(APPEND glfw_LIBRARIES Xxf86vm) endif() - # Check for Xkb (X keyboard extension) - if (NOT X11_Xkb_FOUND) - message(FATAL_ERROR "The X keyboard extension headers were not found") - endif() - - list(APPEND glfw_INCLUDE_DIR ${X11_Xkb_INCLUDE_PATH}) + option(GLFW_USE_XKB "Use the X keyboard extension" ON) + if(GLFW_USE_XKB) + # Check for Xkb (X keyboard extension) + if (NOT X11_Xkb_FOUND) + message("The X keyboard extension headers were not found") + else() + list(APPEND glfw_INCLUDE_DIR ${X11_Xkb_INCLUDE_PATH}) + set(_GLFW_USE_XKB 1) + endif() + endif() find_library(RT_LIBRARY rt) mark_as_advanced(RT_LIBRARY) diff --git a/src/glfw_config.h.in b/src/glfw_config.h.in index 7234eb954..c4abb85d5 100644 --- a/src/glfw_config.h.in +++ b/src/glfw_config.h.in @@ -68,6 +68,8 @@ #cmakedefine _GLFW_HAS_GLXGETPROCADDRESSEXT // Define this to 1 if dlopen is available #cmakedefine _GLFW_HAS_DLOPEN +// Define this to 1 if Xkb is available +#cmakedefine _GLFW_USE_XKB // Define this to 1 if glfwInit should change the current directory #cmakedefine _GLFW_USE_CHDIR diff --git a/src/glx_context.c b/src/glx_context.c index 5c4cf1d79..04c6f6bd2 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -84,6 +84,16 @@ static GLboolean chooseFBConfig(const _GLFWfbconfig* desired, GLXFBConfig* resul _glfw.x11.screen, NULL, &nativeCount); + + // fallback, for when the above call fails running over TurboVNC + VirtualGL + if(!nativeCount) + { + nativeConfigs = glXGetFBConfigs(_glfw.x11.display, + _glfw.x11.screen, + &nativeCount); + + _glfw.glx.SGIX_fbconfig = GL_FALSE; + } } else { diff --git a/src/x11_init.c b/src/x11_init.c index 33ea7baf0..bd22cc7ea 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -45,6 +45,7 @@ static int translateKey(int keyCode) if (keyCode < 8 || keyCode > 255) return GLFW_KEY_UNKNOWN; +#if defined(_GLFW_USE_XKB) // Try secondary keysym, for numeric keypad keys // Note: This way we always force "NumLock = ON", which is intentional // since the returned key code should correspond to a physical @@ -73,6 +74,10 @@ static int translateKey(int keyCode) // should not be layout dependent (i.e. US layout and international // layouts should give the same result). keySym = XkbKeycodeToKeysym(_glfw.x11.display, keyCode, 0, 0); +#else + keySym = XKeycodeToKeysym(_glfw.x11.display, keyCode, 0); +#endif + switch (keySym) { case XK_Escape: return GLFW_KEY_ESCAPE; @@ -217,14 +222,18 @@ static int translateKey(int keyCode) // static void updateKeyCodeLUT(void) { - int i, keyCode, keyCodeGLFW; + int keyCode, keyCodeGLFW; +#if defined(_GLFW_USE_XKB) + int i; char name[XkbKeyNameLength + 1]; XkbDescPtr descr; +#endif // Clear the LUT for (keyCode = 0; keyCode < 256; keyCode++) _glfw.x11.keyCodeLUT[keyCode] = GLFW_KEY_UNKNOWN; +#if defined(_GLFW_USE_XKB) // Use XKB to determine physical key locations independently of the current // keyboard layout @@ -303,6 +312,7 @@ static void updateKeyCodeLUT(void) // Free the keyboard description XkbFreeKeyboard(descr, 0, True); +#endif // Translate the un-translated key codes using traditional X11 KeySym // lookups @@ -487,6 +497,7 @@ static GLboolean initExtensions(void) } // Check if Xkb is supported on this display +#if defined(_GLFW_USE_XKB) _glfw.x11.xkb.versionMajor = 1; _glfw.x11.xkb.versionMinor = 0; if (!XkbQueryExtension(_glfw.x11.display, @@ -514,6 +525,7 @@ static GLboolean initExtensions(void) "X11: Detectable key repeat is not supported"); return GL_FALSE; } +#endif // Update the key code LUT // FIXME: We should listen to XkbMapNotify events to track changes to diff --git a/src/x11_platform.h b/src/x11_platform.h index 235c0f3f8..d6cc1301b 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -45,7 +45,9 @@ #include // The Xkb extension provides improved keyboard support -#include +#if defined(_GLFW_USE_XKB) + #include +#endif #if defined(_GLFW_GLX) #define _GLFW_X11_CONTEXT_VISUAL window->glx.visual