diff --git a/INSTALL.md b/INSTALL.md index 15dcb50e9..60bc20230 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -65,6 +65,9 @@ using `USE_MULTIMEDIA`. Valid values are `ffmpeg`, `oiio` (for OpenImageIO), or `none`. Without a multimedia engine, Notcurses will be unable to decode images and videos. +To get mouse events in the Linux console, you'll need the GPM daemon running, +and you'll need run `cmake` with `-DUSE_GPM=on`. + Run unit tests with `make test` following a successful build. If you have unit test failures, *please* file a bug including the output of diff --git a/NEWS.md b/NEWS.md index 431bc4353..f64d48fd2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,10 @@ This document attempts to list user-visible changes and any major internal rearrangements of Notcurses. +* 2.3.19 (not yet released) + * Mouse events in the Linux console are now reported from GPM when built + with `-DUSE_GPM=on`. + * 2.3.18 (2021-08-31) * No user-visible changes. diff --git a/src/lib/gpm.c b/src/lib/gpm.c index 31ad91f35..dc0baa6b4 100644 --- a/src/lib/gpm.c +++ b/src/lib/gpm.c @@ -8,9 +8,13 @@ static Gpm_Connect gpmconn; // gpm server handle static void* gpmwatcher(void* vti){ + static char cmdbuf[20]; // max is '\x1b[= space){ + logwarn("input overflowed %hd %hd\n", gev.x, gev.y); + continue; + } + ncinput_shovel(&ti->input, cmdbuf, strlen(cmdbuf)); } return NULL; } diff --git a/src/lib/input.c b/src/lib/input.c index ef8bc3ffb..cc0f8a905 100644 --- a/src/lib/input.c +++ b/src/lib/input.c @@ -535,12 +535,15 @@ handle_queued_input(ncinputlayer* nc, ncinput* ni, return ret; } -int ncinput_shovel(ncinputlayer* ni, const unsigned char* buf, size_t len){ +int ncinput_shovel(ncinputlayer* ni, const char* buf, size_t len){ int ret = -1; pthread_mutex_lock(&ni->lock); size_t space = input_queue_space(ni); if(len < space){ size_t spaceback = sizeof(ni->inputbuf) / sizeof(*ni->inputbuf) - ni->inputbuf_write_at; + if(spaceback > len){ + spaceback = len; + } memcpy(ni->inputbuf + ni->inputbuf_write_at, buf, spaceback); len -= spaceback; ni->inputbuf_write_at += spaceback; diff --git a/src/lib/input.h b/src/lib/input.h index 420d5517a..24fbbd5f0 100644 --- a/src/lib/input.h +++ b/src/lib/input.h @@ -60,7 +60,7 @@ int cbreak_mode(struct tinfo* ti); // appropriate. we can be interrupted by a new user context. void ncinput_extract_clrs(struct tinfo* ti); -int ncinput_shovel(struct ncinputlayer* ni, const unsigned char* buf, size_t len); +int ncinput_shovel(struct ncinputlayer* ni, const char* buf, size_t len); #ifdef __cplusplus }