On Sun, Mar 10, 2019 at 10:26:23PM +0000, Daniel Abrecht wrote: > Hello Bill > > On 10/03/2019 16.41, Bill Allombert wrote: > > Do you know where in the GPM code this ioctl is used ? > > I'm not sure how gpm does it, but console application which use ncurses, > such as dialog for example, do detect mouse clicks from it. vttest > doesn't show them though, so it currently does it in another way. It has > a patch for it though: > https://sources.debian.org/src/gpm/1.20.4-6.2/patches/todo/xterm-mouse-for-console.patch/
Do you mean nobody used this ioctl before ? This might explain the problem. > > Do you have an example of program where this feature will be useful? > > I currently only know about dialog. Could you write a simple test program ? The problem with vttest is that it does not inhibit the normal copy paste mechanism. So while it correctly detects the button press, the result seems useless (try press- move-releas). This might explain why gpm use another solution. I attach a patch that try to silent the warning. Cheers, -- Bill. <ballo...@debian.org> Imagine a large red swirl here.
diff --git a/src/selection.c b/src/selection.c index aa0fedf..4f65863 100644 --- a/src/selection.c +++ b/src/selection.c @@ -22,6 +22,7 @@ #include <linux/tiocl.h> #include <stdint.h> #include <linux/kd.h> +#include <errno.h> #include "consolation.h" @@ -61,8 +62,16 @@ linux_selection(int xs, int ys, int xe, int ye, int sel_mode) s.sel.sel_mode = sel_mode; fd = open("/dev/tty0",O_RDONLY); if (check_mode(fd)) - if (ioctl(fd, TIOCLINUX, ((char*)&s)+1)<0) + { + int err = ioctl(fd, TIOCLINUX, ((char*)&s)+1); + if (err<0 && !(errno==EINVAL && (sel_mode&TIOCL_SELMOUSEREPORT))) + /* The kernel return EINVAL for TIOCL_SELMOUSEREPORT when + TIOCL_GETMOUSEREPORTING reports 0. Unfortunately this cannot be + checked without race conditions, so it is simpler to ignore the + error. + */ perror("selection: TIOCLINUX"); + } close(fd); }