+#ifndef DONT_USE_X11
+static void *x11_event_loop_thread(void *unused) {
+ Display *display;
+ XEvent event;
+
+ (void)unused;
+
+ pthread_detach(pthread_self());
+
+ display = XOpenDisplay(NULL);
+ if (!display) {
+ fprintf(stderr, "failed to connect to X server\n");
+ exit(EXIT_FAILURE);
+ }
+
+ /* Do nothing. We just want to die if the X11 session is closed. */
+ while (1) {
+ XNextEvent(display, &event);
+ }
+}
+#endif