|
|
@ -6,6 +6,7 @@ typedef struct nciqueue {
|
|
|
|
struct nciqueue *next;
|
|
|
|
struct nciqueue *next;
|
|
|
|
} nciqueue;
|
|
|
|
} nciqueue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static bool spawned;
|
|
|
|
static pthread_t tid;
|
|
|
|
static pthread_t tid;
|
|
|
|
static nciqueue* queue;
|
|
|
|
static nciqueue* queue;
|
|
|
|
static nciqueue** enqueue = &queue;
|
|
|
|
static nciqueue** enqueue = &queue;
|
|
|
@ -35,15 +36,17 @@ char32_t demo_getc(const struct timespec* ts, ncinput* ni){
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pthread_cond_timedwait(&cond, &lock, &abstime);
|
|
|
|
pthread_cond_timedwait(&cond, &lock, &abstime);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
char32_t id = queue->ni.id;
|
|
|
|
nciqueue* q = queue;
|
|
|
|
if(ni){
|
|
|
|
|
|
|
|
memcpy(ni, &queue->ni, sizeof(*ni));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
queue = queue->next;
|
|
|
|
queue = queue->next;
|
|
|
|
if(queue == NULL){
|
|
|
|
if(queue == NULL){
|
|
|
|
enqueue = &queue;
|
|
|
|
enqueue = &queue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pthread_mutex_unlock(&lock);
|
|
|
|
pthread_mutex_unlock(&lock);
|
|
|
|
|
|
|
|
char32_t id = q->ni.id;
|
|
|
|
|
|
|
|
if(ni){
|
|
|
|
|
|
|
|
memcpy(ni, &q->ni, sizeof(*ni));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
free(q);
|
|
|
|
return id;
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -100,7 +103,9 @@ ultramegaok_demo(void* vnc){
|
|
|
|
// listens for events, handling mouse events directly and making other ones
|
|
|
|
// listens for events, handling mouse events directly and making other ones
|
|
|
|
// available to demos
|
|
|
|
// available to demos
|
|
|
|
int input_dispatcher(struct notcurses* nc){
|
|
|
|
int input_dispatcher(struct notcurses* nc){
|
|
|
|
|
|
|
|
spawned = true;
|
|
|
|
if(pthread_create(&tid, NULL, ultramegaok_demo, nc)){
|
|
|
|
if(pthread_create(&tid, NULL, ultramegaok_demo, nc)){
|
|
|
|
|
|
|
|
spawned = false;
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
@ -108,7 +113,10 @@ int input_dispatcher(struct notcurses* nc){
|
|
|
|
|
|
|
|
|
|
|
|
int stop_input(void){
|
|
|
|
int stop_input(void){
|
|
|
|
int ret = 0;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
if(spawned){
|
|
|
|
ret |= pthread_cancel(tid);
|
|
|
|
ret |= pthread_cancel(tid);
|
|
|
|
ret |= pthread_join(tid, NULL);
|
|
|
|
ret |= pthread_join(tid, NULL);
|
|
|
|
|
|
|
|
spawned = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|