|
|
|
@ -1,11 +1,12 @@
|
|
|
|
|
#include "demo.h"
|
|
|
|
|
#include <pthread.h>
|
|
|
|
|
|
|
|
|
|
// we provide a heads-up display throughout the demo, detailing the demos we're
|
|
|
|
|
// about to run, running, and just runned. the user can move this HUD with
|
|
|
|
|
// their mouse. it should always be on the top of the z-stack.
|
|
|
|
|
struct ncplane* hud = NULL;
|
|
|
|
|
|
|
|
|
|
pthread_mutex_t demo_render_lock = PTHREAD_MUTEX_INITIALIZER;
|
|
|
|
|
static pthread_mutex_t demo_render_lock = PTHREAD_MUTEX_INITIALIZER;
|
|
|
|
|
|
|
|
|
|
// while the HUD is grabbed by the mouse, these are set to the position where
|
|
|
|
|
// the grab started. they are reset once the HUD is released.
|
|
|
|
@ -340,6 +341,10 @@ int hud_completion_notify(const demoresult* result){
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void unlock_mutex(void* vm){
|
|
|
|
|
pthread_mutex_unlock(vm);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// inform the HUD of an upcoming demo
|
|
|
|
|
int hud_schedule(const char* demoname){
|
|
|
|
|
elem* cure;
|
|
|
|
@ -440,9 +445,20 @@ int demo_render(struct notcurses* nc){
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
int ret = 0;
|
|
|
|
|
pthread_cleanup_push(unlock_mutex, &demo_render_lock);
|
|
|
|
|
// lock against a possible notcurses_refresh() on Ctrl+L
|
|
|
|
|
pthread_mutex_lock(&demo_render_lock);
|
|
|
|
|
int ret = notcurses_render(nc);
|
|
|
|
|
ret = notcurses_render(nc);
|
|
|
|
|
pthread_mutex_unlock(&demo_render_lock);
|
|
|
|
|
pthread_cleanup_pop(1);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void lock_demo_render(void){
|
|
|
|
|
pthread_mutex_lock(&demo_render_lock);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void unlock_demo_render(void){
|
|
|
|
|
pthread_mutex_unlock(&demo_render_lock);
|
|
|
|
|
}
|
|
|
|
|