libgpm: keep the fd around #1405

pull/2122/head
nick black 3 years ago
parent bab123913a
commit 919a549367
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -1145,7 +1145,12 @@ coerce_styles(fbuf* f, const tinfo* ti, uint16_t* curstyle,
static inline int
mouse_enable(tinfo* ti, FILE* out){
if(ti->qterm == TERMINAL_LINUX){
return gpm_connect(ti);
if(ti->gpmfd >= 0){
return 0;
}
if((ti->gpmfd = gpm_connect(ti)) >= 0){
return 0;
}
}
// Sets the shift-escape option, allowing shift+mouse to override the standard
// mouse protocol (mainly so copy-and-paste can still be performed).
@ -1159,6 +1164,10 @@ mouse_enable(tinfo* ti, FILE* out){
static inline int
mouse_disable(tinfo* ti, fbuf* f){
if(ti->qterm == TERMINAL_LINUX){
if(ti->gpmfd < 0){
return 0;
}
ti->gpmfd = -1;
return gpm_close(ti);
}
return fbuf_emit(f, "\x1b[?" SET_BTN_EVENT_MOUSE ";"

@ -673,10 +673,11 @@ int interrogate_terminfo(tinfo* ti, const char* termtype, FILE* out, unsigned ut
cursor_y = &foolcursor_y;
}
*cursor_x = *cursor_y = -1;
ti->qterm = TERMINAL_UNKNOWN;
memset(ti, 0, sizeof(*ti));
ti->qterm = TERMINAL_UNKNOWN;
// we don't need a controlling tty for everything we do; allow a failure here
ti->ttyfd = get_tty_fd(out);
ti->gpmfd = -1;
size_t tablelen = 0;
size_t tableused = 0;
const char* tname = NULL;

@ -195,6 +195,7 @@ typedef struct tinfo {
int default_rows; // LINES environment var / lines terminfo / 24
int default_cols; // COLUMNS environment var / cols terminfo / 80
int gpmfd; // connection to GPM daemon
#ifdef __linux__
int linux_fb_fd; // linux framebuffer device fd
char* linux_fb_dev; // device corresponding to linux_fb_dev

Loading…
Cancel
Save