diff options
author | John Lindgren <john@jlindgren.net> | 2022-09-21 13:41:48 -0400 |
---|---|---|
committer | John Lindgren <john@jlindgren.net> | 2022-09-21 14:25:09 -0400 |
commit | 5417a182e535da11348b87102cd5964d2fc476d0 (patch) | |
tree | 9d32898d69dd18736124cb58f611bf7bf0f2037b | |
parent | 8e8b9a72173727f125af227aaf671c38f7640db3 (diff) |
cursor: Add a more general check for infinite/NaN cursor position
It should be considered a bug if a compositor sets a non-finite
cursor position, so fail loudly (in debug builds) if that happens.
The existing check in wlr_cursor_warp_closest() is now redundant,
and would silently hide such bugs, so remove it.
-rw-r--r-- | types/wlr_cursor.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/types/wlr_cursor.c b/types/wlr_cursor.c index aafae248..4c8a801d 100644 --- a/types/wlr_cursor.c +++ b/types/wlr_cursor.c @@ -211,6 +211,10 @@ static struct wlr_cursor_device *get_cursor_device(struct wlr_cursor *cur, static void cursor_warp_unchecked(struct wlr_cursor *cur, double lx, double ly) { assert(cur->state->layout); + if (!isfinite(lx) || !isfinite(ly)) { + assert(false); + return; + } struct wlr_cursor_output_cursor *output_cursor; wl_list_for_each(output_cursor, &cur->state->output_cursors, link) { @@ -296,10 +300,6 @@ void wlr_cursor_warp_closest(struct wlr_cursor *cur, get_mapping(cur, dev, &mapping); if (!wlr_box_empty(&mapping)) { wlr_box_closest_point(&mapping, lx, ly, &lx, &ly); - if (isnan(lx) || isnan(ly)) { - lx = 0; - ly = 0; - } } else { wlr_output_layout_closest_point(cur->state->layout, NULL, lx, ly, &lx, &ly); |