1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
diff --git a/src/window/Window.cpp b/src/window/Window.cpp
index cea09497..db1f03e7 100644
--- a/src/window/Window.cpp
+++ b/src/window/Window.cpp
@@ -674,23 +674,27 @@ int Window::getMods() {
#if defined ARCH_LIN
// On Linux X11, get mods directly from X11 display, to support X11 key remapping
Display* display = glfwGetX11Display();
- XkbStateRec state;
- XkbGetState(display, XkbUseCoreKbd, &state);
-
- // Derived from GLFW's translateState() from x11_window.c
- if (state.mods & ShiftMask)
- mods |= GLFW_MOD_SHIFT;
- if (state.mods & ControlMask)
- mods |= GLFW_MOD_CONTROL;
- if (state.mods & Mod1Mask)
- mods |= GLFW_MOD_ALT;
- if (state.mods & Mod4Mask)
- mods |= GLFW_MOD_SUPER;
- if (state.mods & LockMask)
- mods |= GLFW_MOD_CAPS_LOCK;
- if (state.mods & Mod2Mask)
- mods |= GLFW_MOD_NUM_LOCK;
-#else
+ if (display != NULL) {
+ XkbStateRec state;
+ XkbGetState(display, XkbUseCoreKbd, &state);
+
+ // Derived from GLFW's translateState() from x11_window.c
+ if (state.mods & ShiftMask)
+ mods |= GLFW_MOD_SHIFT;
+ if (state.mods & ControlMask)
+ mods |= GLFW_MOD_CONTROL;
+ if (state.mods & Mod1Mask)
+ mods |= GLFW_MOD_ALT;
+ if (state.mods & Mod4Mask)
+ mods |= GLFW_MOD_SUPER;
+ if (state.mods & LockMask)
+ mods |= GLFW_MOD_CAPS_LOCK;
+ if (state.mods & Mod2Mask)
+ mods |= GLFW_MOD_NUM_LOCK;
+
+ return mods;
+ }
+#endif
// Use GLFW key codes on other OS's
if (glfwGetKey(win, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS || glfwGetKey(win, GLFW_KEY_RIGHT_SHIFT) == GLFW_PRESS)
mods |= GLFW_MOD_SHIFT;
@@ -700,7 +704,6 @@ int Window::getMods() {
mods |= GLFW_MOD_ALT;
if (glfwGetKey(win, GLFW_KEY_LEFT_SUPER) == GLFW_PRESS || glfwGetKey(win, GLFW_KEY_RIGHT_SUPER) == GLFW_PRESS)
mods |= GLFW_MOD_SUPER;
-#endif
return mods;
}
|