Mouse wheel scrolling on the left edge of a terminal produces invalid SGR mouse coordinates
The grid coordinates for mouse scroll events are not confined to actual cells, like they are for all other mouse events.
When the mouse is on the very left edge of a window, the grid column index returned by Terminal::grid_coords_from_view_coords
is -1, which will map to an invalid SGR column of 0 if fed directly to the client (it should be a 1-based index). This can confuse programs that validate these events, like tmux (https://github.com/tmux/tmux/issues/3500). The other mouse event handlers (Terminal::maybe_send_mouse_button
and Terminal::maybe_send_mouse_drag
) call Terminal::confine_grid_coords
to constrain these coodinates to the visible area, but Terminal::widget_mouse_scroll
never does this.
Steps to reproduce
- Launch gnome-terminal or terminator
- Run
printf '\033[?1006h\033[?1000h'
to turn on SGR mouse reporting (edited: missing[
added -- egmont) - Run
cat -v
to show raw input - Move the mouse to the leftmost pixel of the terminal, and move the scroll wheel up or down
- The terminal will print something like
^[[<65;0;1M
or^[[<64;0;1M
, which has an invalid 0 for the column index.
Tested on Fedora 37 with VTE 0.70.3 and git master in GNOME Terminal 3.46.8 and Terminator 2.1.3.
Fix for current git master (7fa3e622): 0001-Fix-invalid-SGR-scroll-event-on-window-edge.patch