Only calculate offset points if needed

This commit is contained in:
Simon Long 2024-02-23 10:59:23 +00:00
parent eb19d10d6d
commit 5df63feea5

View file

@ -58,10 +58,10 @@ touch_motion(struct wl_listener *listener, void *data)
struct touch_point *touch_point;
wl_list_for_each(touch_point, &seat->touch_points, link) {
if (touch_point->touch_id == event->touch_id) {
double sx = lx - touch_point->x_offset;
double sy = ly - touch_point->y_offset;
if (touch_point->surface) {
double sx = lx - touch_point->x_offset;
double sy = ly - touch_point->y_offset;
wlr_seat_touch_notify_motion(seat->seat, event->time_msec,
event->touch_id, sx, sy);
} else {
@ -102,11 +102,11 @@ touch_down(struct wl_listener *listener, void *data)
wlr_cursor_absolute_to_layout_coords(seat->cursor, &event->touch->base,
event->x, event->y, &lx, &ly);
/* Apply offsets to get surface coords before reporting event */
double sx = lx - x_offset;
double sy = ly - y_offset;
if (touch_point->surface) {
/* Apply offsets to get surface coords before reporting event */
double sx = lx - x_offset;
double sy = ly - y_offset;
wlr_seat_touch_notify_down(seat->seat, touch_point->surface,
event->time_msec, event->touch_id, sx, sy);
} else {