mirror of
https://github.com/glfw/glfw.git
synced 2025-10-03 13:20:58 +00:00
Merge 906a387d74
into a89a02ff85
This commit is contained in:
commit
bf035f7f85
@ -247,12 +247,16 @@ if (_GLFW_X11)
|
|||||||
list(APPEND glfw_LIBRARIES Xxf86vm)
|
list(APPEND glfw_LIBRARIES Xxf86vm)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Check for Xkb (X keyboard extension)
|
option(GLFW_USE_XKB "Use the X keyboard extension" ON)
|
||||||
if (NOT X11_Xkb_FOUND)
|
if(GLFW_USE_XKB)
|
||||||
message(FATAL_ERROR "The X keyboard extension headers were not found")
|
# Check for Xkb (X keyboard extension)
|
||||||
endif()
|
if (NOT X11_Xkb_FOUND)
|
||||||
|
message("The X keyboard extension headers were not found")
|
||||||
list(APPEND glfw_INCLUDE_DIR ${X11_Xkb_INCLUDE_PATH})
|
else()
|
||||||
|
list(APPEND glfw_INCLUDE_DIR ${X11_Xkb_INCLUDE_PATH})
|
||||||
|
set(_GLFW_USE_XKB 1)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
find_library(RT_LIBRARY rt)
|
find_library(RT_LIBRARY rt)
|
||||||
mark_as_advanced(RT_LIBRARY)
|
mark_as_advanced(RT_LIBRARY)
|
||||||
|
@ -68,6 +68,8 @@
|
|||||||
#cmakedefine _GLFW_HAS_GLXGETPROCADDRESSEXT
|
#cmakedefine _GLFW_HAS_GLXGETPROCADDRESSEXT
|
||||||
// Define this to 1 if dlopen is available
|
// Define this to 1 if dlopen is available
|
||||||
#cmakedefine _GLFW_HAS_DLOPEN
|
#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
|
// Define this to 1 if glfwInit should change the current directory
|
||||||
#cmakedefine _GLFW_USE_CHDIR
|
#cmakedefine _GLFW_USE_CHDIR
|
||||||
|
@ -84,6 +84,16 @@ static GLboolean chooseFBConfig(const _GLFWfbconfig* desired, GLXFBConfig* resul
|
|||||||
_glfw.x11.screen,
|
_glfw.x11.screen,
|
||||||
NULL,
|
NULL,
|
||||||
&nativeCount);
|
&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
|
else
|
||||||
{
|
{
|
||||||
|
@ -45,6 +45,7 @@ static int translateKey(int keyCode)
|
|||||||
if (keyCode < 8 || keyCode > 255)
|
if (keyCode < 8 || keyCode > 255)
|
||||||
return GLFW_KEY_UNKNOWN;
|
return GLFW_KEY_UNKNOWN;
|
||||||
|
|
||||||
|
#if defined(_GLFW_USE_XKB)
|
||||||
// Try secondary keysym, for numeric keypad keys
|
// Try secondary keysym, for numeric keypad keys
|
||||||
// Note: This way we always force "NumLock = ON", which is intentional
|
// Note: This way we always force "NumLock = ON", which is intentional
|
||||||
// since the returned key code should correspond to a physical
|
// 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
|
// should not be layout dependent (i.e. US layout and international
|
||||||
// layouts should give the same result).
|
// layouts should give the same result).
|
||||||
keySym = XkbKeycodeToKeysym(_glfw.x11.display, keyCode, 0, 0);
|
keySym = XkbKeycodeToKeysym(_glfw.x11.display, keyCode, 0, 0);
|
||||||
|
#else
|
||||||
|
keySym = XKeycodeToKeysym(_glfw.x11.display, keyCode, 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
switch (keySym)
|
switch (keySym)
|
||||||
{
|
{
|
||||||
case XK_Escape: return GLFW_KEY_ESCAPE;
|
case XK_Escape: return GLFW_KEY_ESCAPE;
|
||||||
@ -217,14 +222,18 @@ static int translateKey(int keyCode)
|
|||||||
//
|
//
|
||||||
static void updateKeyCodeLUT(void)
|
static void updateKeyCodeLUT(void)
|
||||||
{
|
{
|
||||||
int i, keyCode, keyCodeGLFW;
|
int keyCode, keyCodeGLFW;
|
||||||
|
#if defined(_GLFW_USE_XKB)
|
||||||
|
int i;
|
||||||
char name[XkbKeyNameLength + 1];
|
char name[XkbKeyNameLength + 1];
|
||||||
XkbDescPtr descr;
|
XkbDescPtr descr;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Clear the LUT
|
// Clear the LUT
|
||||||
for (keyCode = 0; keyCode < 256; keyCode++)
|
for (keyCode = 0; keyCode < 256; keyCode++)
|
||||||
_glfw.x11.keyCodeLUT[keyCode] = GLFW_KEY_UNKNOWN;
|
_glfw.x11.keyCodeLUT[keyCode] = GLFW_KEY_UNKNOWN;
|
||||||
|
|
||||||
|
#if defined(_GLFW_USE_XKB)
|
||||||
// Use XKB to determine physical key locations independently of the current
|
// Use XKB to determine physical key locations independently of the current
|
||||||
// keyboard layout
|
// keyboard layout
|
||||||
|
|
||||||
@ -303,6 +312,7 @@ static void updateKeyCodeLUT(void)
|
|||||||
|
|
||||||
// Free the keyboard description
|
// Free the keyboard description
|
||||||
XkbFreeKeyboard(descr, 0, True);
|
XkbFreeKeyboard(descr, 0, True);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Translate the un-translated key codes using traditional X11 KeySym
|
// Translate the un-translated key codes using traditional X11 KeySym
|
||||||
// lookups
|
// lookups
|
||||||
@ -487,6 +497,7 @@ static GLboolean initExtensions(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if Xkb is supported on this display
|
// Check if Xkb is supported on this display
|
||||||
|
#if defined(_GLFW_USE_XKB)
|
||||||
_glfw.x11.xkb.versionMajor = 1;
|
_glfw.x11.xkb.versionMajor = 1;
|
||||||
_glfw.x11.xkb.versionMinor = 0;
|
_glfw.x11.xkb.versionMinor = 0;
|
||||||
if (!XkbQueryExtension(_glfw.x11.display,
|
if (!XkbQueryExtension(_glfw.x11.display,
|
||||||
@ -514,6 +525,7 @@ static GLboolean initExtensions(void)
|
|||||||
"X11: Detectable key repeat is not supported");
|
"X11: Detectable key repeat is not supported");
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Update the key code LUT
|
// Update the key code LUT
|
||||||
// FIXME: We should listen to XkbMapNotify events to track changes to
|
// FIXME: We should listen to XkbMapNotify events to track changes to
|
||||||
|
@ -45,7 +45,9 @@
|
|||||||
#include <X11/extensions/XInput2.h>
|
#include <X11/extensions/XInput2.h>
|
||||||
|
|
||||||
// The Xkb extension provides improved keyboard support
|
// 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)
|
#if defined(_GLFW_GLX)
|
||||||
#define _GLFW_X11_CONTEXT_VISUAL window->glx.visual
|
#define _GLFW_X11_CONTEXT_VISUAL window->glx.visual
|
||||||
|
Loading…
Reference in New Issue
Block a user