This commit is contained in:
Andrew Corrigan 2014-03-06 14:45:45 +00:00
commit bf035f7f85
5 changed files with 38 additions and 8 deletions

View File

@ -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)

View File

@ -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

View File

@ -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
{

View File

@ -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

View File

@ -45,7 +45,9 @@
#include <X11/extensions/XInput2.h>
// The Xkb extension provides improved keyboard support
#include <X11/XKBlib.h>
#if defined(_GLFW_USE_XKB)
#include <X11/XKBlib.h>
#endif
#if defined(_GLFW_GLX)
#define _GLFW_X11_CONTEXT_VISUAL window->glx.visual