gpm: add version to banner, launch thread #1405

pull/2137/head
nick black 3 years ago committed by nick black
parent 65e5b1d4bf
commit cd7b4c021d

@ -6,6 +6,22 @@
static Gpm_Connect gpmconn; // gpm server handle
static void*
gpmwatcher(void* vti){
tinfo* ti = vti;
(void)ti; // FIXME
Gpm_Event gev;
while(true){
if(Gpm_GetEvent(&gev)){
logerror("error reading from gpm daemon\n");
break;
}
loginfo("got gpm event\n");
// FIXME
}
return NULL;
}
int gpm_connect(tinfo* ti){
(void)ti;
gpm_zerobased = 1;
@ -15,7 +31,13 @@ int gpm_connect(tinfo* ti){
gpmconn.minMod = 0;
gpmconn.maxMod = 0; // allow shift+drag to be used for direct copy+paste
if(Gpm_Open(&gpmconn, 0) == -1){
logerror("couldn't connect to gpm");
logerror("couldn't connect to gpm\n");
return -1;
}
if(pthread_create(&ti->gpmthread, NULL, gpmwatcher, ti)){
logerror("couldn't spawn gpm thread\n");
Gpm_Close();
memset(&gpmconn, 0, sizeof(gpmconn));
return -1;
}
loginfo("connected to gpm on %d\n", gpm_fd);
@ -29,11 +51,21 @@ int gpm_read(tinfo* ti, ncinput* ni){
}
int gpm_close(tinfo* ti){
(void)ti;
if(pthread_cancel(ti->gpmthread)){
logerror("couldn't cancel gpm thread\n"); // daemon might have died
}
void* thrres;
if(pthread_join(ti->gpmthread, &thrres)){
logerror("error joining gpm thread\n");
}
Gpm_Close();
memset(&gpmconn, 0, sizeof(gpmconn));
return 0;
}
const char* gpm_version(void){
return Gpm_GetLibVersion(NULL);
}
#else
int gpm_connect(tinfo* ti){
(void)ti;
@ -50,4 +82,8 @@ int gpm_close(tinfo* ti){
(void)ti;
return -1;
}
const char* gpm_version(void){
return "n/a";
}
#endif

@ -23,6 +23,9 @@ int gpm_read(struct tinfo* ti, struct ncinput* ni);
int gpm_close(struct tinfo* ti);
// Returns a library-owned pointer to the libgpm client version.
const char* gpm_version(void);
#ifdef __cplusplus
}
#endif

@ -959,7 +959,7 @@ init_banner(const notcurses* nc, fbuf* f){
14 % nc->tcache.caps.colors : 0x2080e0);
fbuf_putc(f, '+');
}
fbuf_printf(f, "%u colors\n%s%s (%s)\nterminfo from %s zlib %s\n",
fbuf_printf(f, "%u colors\n%s%s (%s)\nterminfo from %s zlib %s GPM %s\n",
nc->tcache.caps.colors,
#ifdef __clang__
"", // name is contained in __VERSION__
@ -980,7 +980,7 @@ init_banner(const notcurses* nc, fbuf* f){
#else
#error "No __BYTE_ORDER__ definition"
#endif
curses_version(), zlibVersion());
curses_version(), zlibVersion(), gpm_version());
ncvisual_printbanner(f);
init_banner_warnings(nc, f);
const char* esc;

@ -199,6 +199,7 @@ typedef struct tinfo {
int default_cols; // COLUMNS environment var / cols terminfo / 80
int gpmfd; // connection to GPM daemon
pthread_t gpmthread; // thread handle for GPM watcher
#ifdef __linux__
int linux_fb_fd; // linux framebuffer device fd
char* linux_fb_dev; // device corresponding to linux_fb_dev

Loading…
Cancel
Save