mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-12-23 02:19:49 +01:00
input/pointer: try harder to not send duplicate motion events
wl_fixed_t is a 32-bit data type, but our doubles are 64-bit. This meant that two doubles that would map to the same wl_fixed_t could compare unequal, and send a duplicate motion event. Refs swaywm/sway#4632.
This commit is contained in:
parent
c27263c105
commit
033c9cab74
1 changed files with 13 additions and 10 deletions
|
@ -230,18 +230,21 @@ void wlr_seat_pointer_send_motion(struct wlr_seat *wlr_seat, uint32_t time,
|
|||
return;
|
||||
}
|
||||
|
||||
if (wlr_seat->pointer_state.sx == sx && wlr_seat->pointer_state.sy == sy) {
|
||||
return;
|
||||
}
|
||||
// Ensure we don't send duplicate motion events. Instead of comparing with an
|
||||
// epsilon, chop off some precision by converting to a `wl_fixed_t` first,
|
||||
// since that is what a client receives.
|
||||
wl_fixed_t sx_fixed = wl_fixed_from_double(sx);
|
||||
wl_fixed_t sy_fixed = wl_fixed_from_double(sy);
|
||||
if (wl_fixed_from_double(wlr_seat->pointer_state.sx) != sx_fixed ||
|
||||
wl_fixed_from_double(wlr_seat->pointer_state.sy) != sy_fixed) {
|
||||
struct wl_resource *resource;
|
||||
wl_resource_for_each(resource, &client->pointers) {
|
||||
if (wlr_seat_client_from_pointer_resource(resource) == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
struct wl_resource *resource;
|
||||
wl_resource_for_each(resource, &client->pointers) {
|
||||
if (wlr_seat_client_from_pointer_resource(resource) == NULL) {
|
||||
continue;
|
||||
wl_pointer_send_motion(resource, time, sx_fixed, sy_fixed);
|
||||
}
|
||||
|
||||
wl_pointer_send_motion(resource, time, wl_fixed_from_double(sx),
|
||||
wl_fixed_from_double(sy));
|
||||
}
|
||||
|
||||
wlr_seat_pointer_warp(wlr_seat, sx, sy);
|
||||
|
|
Loading…
Reference in a new issue