aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md4
-rw-r--r--input.c4
-rw-r--r--input.h2
-rw-r--r--render.c8
4 files changed, 16 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bfff027d..0b7fd9db 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -143,6 +143,9 @@
available.
* Crash when a buggy compositor sends a `keyboard_enter()` event with
a `NULL` surface ([#2438][2438]).
+* Crash when clicking without moving the mouse after resizing the
+ window, and the clicked area is now outside the cell grid
+ ([#2435][2435]).
[2353]: https://codeberg.org/dnkl/foot/issues/2353
[2352]: https://codeberg.org/dnkl/foot/issues/2352
@@ -156,6 +159,7 @@
[2411]: https://codeberg.org/dnkl/foot/issues/2411
[2405]: https://codeberg.org/dnkl/foot/issues/2405
[2438]: https://codeberg.org/dnkl/foot/issues/2438
+[2435]: https://codeberg.org/dnkl/foot/issues/2435
### Security
diff --git a/input.c b/input.c
index 74cd320f..e11b86db 100644
--- a/input.c
+++ b/input.c
@@ -2417,12 +2417,12 @@ mouse_button_state_reset(struct seat *seat)
memset(&seat->mouse.last_time, 0, sizeof(seat->mouse.last_time));
}
-static void
+ void
mouse_coord_pixel_to_cell(struct seat *seat, const struct terminal *term,
int x, int y)
{
/*
- * Translate x,y pixel coordinate to a cell coordinate, or -1
+ * Translate x,y pixel coordinate to a cell coordinate, or clamp
* if the cursor is outside the grid. I.e. if it is inside the
* margins.
*/
diff --git a/input.h b/input.h
index 34342bbf..347466aa 100644
--- a/input.h
+++ b/input.h
@@ -38,3 +38,5 @@ void get_current_modifiers(const struct seat *seat,
uint32_t key, bool filter_locked);
enum cursor_shape xcursor_for_csd_border(struct terminal *term, int x, int y);
+void mouse_coord_pixel_to_cell(struct seat *seat, const struct terminal *term,
+ int x, int y);
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