static struct termios g_kbd_termios_saved;
static int g_kbdfd;
+static pthread_cond_t g_start_cond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t g_start_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+static void signal_main_thread(void)
+{
+ pthread_mutex_lock(&g_start_mutex);
+ pthread_cond_signal(&g_start_cond);
+ pthread_mutex_unlock(&g_start_mutex);
+}
static Cursor transparent_cursor(Display *display, Window win)
{
{
fprintf(stderr, PFX "(not hiding X): Can't open display: %s\n",
XDisplayName(NULL));
+ signal_main_thread();
return NULL;
}
XSelectInput(display, win, ExposureMask);
XMapWindow(display, win);
XGrabKeyboard(display, win, False, GrabModeAsync, GrabModeAsync, CurrentTime);
+ XSync(display, False);
while (1)
{
XNextEvent(display, &report);
- if (report.type == Expose)
+ if (report.type == Expose) {
+ signal_main_thread();
while (XCheckTypedEvent(display, Expose, &report))
;
+ }
}
return NULL;
pthread_t tid;
int ret;
+ pthread_mutex_lock(&g_start_mutex);
+
ret = pthread_create(&tid, NULL, x11_handler, NULL);
if (ret != 0) {
fprintf(stderr, PFX "pthread_create: %d\n", ret);
}
pthread_detach(tid);
+ pthread_cond_wait(&g_start_cond, &g_start_mutex);
+ pthread_mutex_unlock(&g_start_mutex);
+
hidecon_start();
do_exec(argv + 1);