aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-03-31 19:29:54 +0200
committerdec05eba <dec05eba@protonmail.com>2020-03-31 19:29:54 +0200
commit07a8635c550303b44c0a751ef24ad1b1768df7f8 (patch)
treea3987f0a8d1b8fc35f5f5f445e0c30df0c4f3a39
parent9635df628785c03cd3441798a640c22349645535 (diff)
add debug handlers for x11
-rw-r--r--src/main.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp
index ff88a8e..4836189 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -63,6 +63,31 @@ static bool x11_supports_composite_named_window_pixmap(Display *dpy) {
(major_version > 0 || minor_version >= 2);
}
+static int x11_error_handler(Display *dpy, XErrorEvent *ev) {
+ char type_str[128];
+ XGetErrorText(dpy, ev->type, type_str, sizeof(type_str));
+
+ char major_opcode_str[128];
+ XGetErrorText(dpy, ev->type, major_opcode_str, sizeof(major_opcode_str));
+
+ char minor_opcode_str[128];
+ XGetErrorText(dpy, ev->type, minor_opcode_str, sizeof(minor_opcode_str));
+
+ fprintf(stderr,
+ "X Error of failed request: %s\n"
+ "Major opcode of failed request: %d (%s)\n"
+ "Minor opcode of failed request: %d (%s)\n"
+ "Serial number of failed request: %d\n",
+ type_str,
+ ev->request_code, major_opcode_str,
+ ev->minor_code, minor_opcode_str);
+ return 0;
+}
+
+static int x11_io_error_handler(Display *dpy) {
+ return 0;
+}
+
static void cleanup_window_pixmap(Display *dpy, WindowPixmap &pixmap) {
if (pixmap.target_texture_id) {
glDeleteTextures(1, &pixmap.target_texture_id);
@@ -468,6 +493,12 @@ int main(int argc, char **argv) {
glfwMakeContextCurrent(window);
glfwSwapInterval(0);
+#define DEBUG
+#if defined(DEBUG)
+ XSetErrorHandler(x11_error_handler);
+ XSetIOErrorHandler(x11_io_error_handler);
+#endif
+
glewExperimental = GL_TRUE;
GLenum nGlewError = glewInit();
if (nGlewError != GLEW_OK) {