feat(ui): support grid=0 in nvim_input_mouse #32535

Problem:
Multigrid UIs have to find out which window to send the input by using
the Nvim focus rules, which are not fully documented.

Furthermore,`getmousepos()` has several problems when multigrid is
enabled, with the main one being that screenrow and screencol are window
relative instead of screen relative, due to the fact that the UI don't
send any absolute coordinates.

Solution:
Allow passing 0 as grid to `nvim_input_mouse`, with absolute
coordinates, which lets nvim determine the actual window to send the
mouse input to. This works as long as nvim is in charge of the window
positioning. If the UI repositions or resizes the windows, it can still
pass the grid it determines like before.
This commit is contained in:
fredizzimo
2025-09-14 00:57:04 +03:00
committed by GitHub
parent c1648cf820
commit 8ae9a44d38
15 changed files with 2388 additions and 2162 deletions

View File

@@ -1606,7 +1606,8 @@ function vim.api.nvim_input(keys) end
--- The same specifiers are used as for a key press, except
--- that the "-" separator is optional, so "C-A-", "c-a"
--- and "CA" can all be used to specify Ctrl+Alt+click.
--- @param grid integer Grid number if the client uses `ui-multigrid`, else 0.
--- @param grid integer Grid number (used by `ui-multigrid` client), or 0 to let Nvim decide positioning of
--- windows. For more information, see [dev-ui-multigrid]
--- @param row integer Mouse row-position (zero-based, like redraw events)
--- @param col integer Mouse column-position (zero-based, like redraw events)
function vim.api.nvim_input_mouse(button, action, modifier, grid, row, col) end