From 765ca4070bb6f095fc58c030f2154ed03857701d Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sat, 29 Aug 2026 19:44:29 +0200 Subject: render: re-evaluate mouse col/row coordinates after a window resize Before this, the col/row coordinates for the mouse pointer was only updated when the mouse either entered our window, or was moved inside it. However, when a window is resized without using the mouse, and the user then clicks (again, without moving the mouse), we can get a button event outside the cell grid, that we still think is on top of the grid. Example: user moves mouse over the bottom row. The window is shrunk. Enough that the mouse is now outside the cell grid, but still inside our window. This means we get a button event outside the grid. But since we haven't updated the col/row coordinates, we think it's on a row, that no longer exists. Closes #2435 --- render.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'render.c') diff --git a/render.c b/render.c index fe2c29ba..b729ef40 100644 --- a/render.c +++ b/render.c @@ -35,6 +35,7 @@ #include "cursor-shape.h" #include "grid.h" #include "ime.h" +#include "input.h" #include "quirks.h" #include "search.h" #include "selection.h" @@ -4856,6 +4857,13 @@ render_resize(struct terminal *term, int width, int height, uint8_t opts) } } + /* Ensure mouse col/row coordinates are still valid */ + tll_foreach(term->wl->seats, it) { + struct seat *seat = &it->item; + if (seat->mouse_focus == term) + mouse_coord_pixel_to_cell(seat, term, seat->mouse.x, seat->mouse.y); + } + /* * TODO: if we remove the selection_finalize() call above (i.e. if * we start allowing selections to be ongoing across resizes), the -- cgit v1.3