On 24/02/2019 20.27, Bill Allombert wrote:
>>  void
>> +report_pointer(int x, int y, enum current_button button)
>> +{
>> +  linux_selection(x, y, x, y, TIOCL_SELMOUSEREPORT + ((button+3) % 4) );
>> +}
>> +
> 
> Hello Daniel,
> 
> Thanks for your patch, it looks great! Could you explain me how this
> syscall work and where it is documented ?
> 
> All I have is console_ioctl(4):
> 
>        TIOCLINUX, subcode=7
> argp points to a char  which  is  set  to  the  value  of the  kernel
> variable report_mouse.  (Since Linux 1.1.33.)
> 

There is no documentation explicitly mentioning TIOCL_SELMOUSEREPORT in
sel_mode for TIOCLINUX, subcode=2 (TIOCL_SETSEL), but console_codes(4)
describes how it works in section "Mouse tracking" to some extent:
> The mouse tracking facility is intended to return xterm(1)-compatible
> mouse status reports.  Because the console driver has no way to know
> the device or type of the mouse, these reports are returned in
> the console input stream only when the virtual terminal driver
> receives a mouse update ioctl.  These ioctls must be generated by a
> mouse-aware user-mode application such as the gpm(8) daemon.
> ...

I've looked at the kernel code, and this seams to be the only way the
mouse position can be reported by the kernel. Another thing not
mentioned by the docs is, that the kernel only reports the mouse
position if report_mouse was enabled.

console_codes(4) also describes the possible values of report_mouse:
> ESC [ ? 9 h
>   X10 Mouse Reporting (default off): Set reporting mode to 1 (or reset
>   to 0)—see below.
> ESC [ ? 1000 h
>   X11 Mouse Reporting (default off): Set reporting mode to 2 (or reset
>   to 0)—see below.

I guess in X10 compatibility mode, sending the mouse releases isn't
completely correct, but it shouldn't really matter, if any application
still uses that, it'll probably just ignore it. I could add a check for
it if you want.

The reason I have set BUTTON_RELEASED=0 in my current_button enum and
not to 3 is mainly just a habit, I like to be able to initialize things
with all 0 and have them in some sort of neutral or default state.

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to