wlroots-hyprland/util
John Lindgren 3fc66d4525 util: fix non-linear behavior of wlr_box_closest_point()
Per comments in util/box.h, the width and height of a wlr_box are
exclusive; that is, for a 100x100 box at (0,0), the point (99,99) is
inside it while the point (100,100) is outside it.

Thus mathematically, there exists no single closest point to the
bottom-right corner of the box while remaining inside it. You can
construct an infinite series approaching the limit, such as {(99,99),
(99.9,99.9), (99.99,99.99)...}, but since the intervals are half-open,
there is no "last" point.

wlr_box_closest_point() must therefore define an arbitrary "closest"
point. For points below and to the right of the box, the current
implementation returns (box.x + width - 1, box.y + height - 1). Let's
continue to do this.

However, the current implementation is non-linear: with the example
100x100 box, it will return an input point of (99.9,99.9) unchanged, but
for an input point (100.1,100.1) the returned point will jump back to
(99.0,99.0).

In practice, this non-linearity results in strange behaviors when
driving the mouse cursor to a screen corner. On a 1920x1080 display for
example, driving the cursor quickly to the bottom-left corner results in
a position of exactly (0,1079). Continuing to slowly nudge the cursor
downward results in the position jumping between (0,1079) and other,
fractional coordinates such as (0,1079.88).

The fractional coordinates expose some client/toolkit-side bugs (which,
to be clear, should be fixed on the client side), but IMHO the wlroots
behavior is also inconsistent and wrong -- when I drive the mouse cursor
into the corner of the screen, it should come to a stop at a fixed
position, not jitter around.
2024-03-28 12:51:53 +00:00
..
addon.c util/addon: make wlr_addon_set_finish() safer 2023-10-08 11:06:09 +00:00
array.c util/array: unclutter 2022-08-29 13:48:42 +00:00
box.c util: fix non-linear behavior of wlr_box_closest_point() 2024-03-28 12:51:53 +00:00
env.c util/env: make env_parse_switch() return a size_t 2022-12-06 16:14:18 +01:00
global.c util/global: fix memory leak on display destroy in wlr_global_destroy_safe 2022-06-07 18:18:11 +02:00
log.c Define _POSIX_C_SOURCE globally 2024-02-15 15:41:12 +01:00
meson.build util/transform: move over wl_output_transform helpers 2023-11-23 11:03:57 +01:00
rect_union.c util: add struct to track union of rectangles 2023-10-05 11:45:32 +00:00
region.c util/region: forbid "shrinking" a region with wlr_region_expand() 2022-12-09 16:46:36 +00:00
set.c util/set: overhaul 2022-08-29 13:48:42 +00:00
shm.c Define _POSIX_C_SOURCE globally 2024-02-15 15:41:12 +01:00
time.c Define _POSIX_C_SOURCE globally 2024-02-15 15:41:12 +01:00
token.c Define _POSIX_C_SOURCE globally 2024-02-15 15:41:12 +01:00
transform.c util/transform: add wlr_output_transform_coords() 2023-11-23 11:07:34 +01:00
utf8.c xdg-toplevel: check that title provided actually is UTF-8 2023-11-22 22:03:00 +03:00