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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
diff --git a/src/window/Window.cpp b/src/window/Window.cpp
index 4d67e8d2..23e79df9 100644
--- a/src/window/Window.cpp
+++ b/src/window/Window.cpp
@@ -331,8 +331,9 @@ Window::Window() {
// Set up GLEW
glewExperimental = GL_TRUE;
err = glewInit();
- if (err != GLEW_OK) {
+ if (err != GLEW_OK && glfwGetPlatform() != GLFW_PLATFORM_WAYLAND) {
osdialog_message(OSDIALOG_ERROR, OSDIALOG_OK, "Could not initialize GLEW. Does your graphics card support OpenGL 2.0 or greater? If so, make sure you have the latest graphics drivers installed.");
+ WARN("glewInit failed: %s", glewGetErrorString(err));
throw Exception("Could not initialize GLEW");
}
@@ -682,24 +683,31 @@ int Window::getMods() {
int mods = 0;
#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
+ Display *display = NULL;
+ if (glfwGetPlatform() == GLFW_PLATFORM_X11) {
+ display = glfwGetX11Display();
+ }
+ 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;
@@ -709,7 +717,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;
}
|