input: Convert weston_pointer_motion_event to weston_coord

This struct has a lot of members that can be converted to weston_coord.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This commit is contained in:
Derek Foreman 2022-02-02 08:16:38 -06:00 committed by Pekka Paalanen
parent 8031b9d57f
commit 69908000e3
6 changed files with 31 additions and 34 deletions

View file

@ -592,12 +592,9 @@ enum weston_pointer_motion_mask {
struct weston_pointer_motion_event {
uint32_t mask;
struct timespec time;
double x;
double y;
double dx;
double dy;
double dx_unaccel;
double dy_unaccel;
struct weston_coord_global abs;
struct weston_coord rel;
struct weston_coord rel_unaccel;
};
struct weston_pointer_axis_event {

View file

@ -1447,10 +1447,8 @@ x11_backend_deliver_motion_event(struct x11_backend *b,
motion_event = (struct weston_pointer_motion_event) {
.mask = WESTON_POINTER_MOTION_REL,
.dx = pos.c.x - b->prev_x,
.dy = pos.c.y - b->prev_y
.rel = weston_coord_sub(pos.c, weston_coord(b->prev_x, b->prev_y)),
};
weston_compositor_get_time(&time);
notify_motion(&b->core_seat, &time, &motion_event);
notify_pointer_frame(&b->core_seat);

View file

@ -6776,9 +6776,7 @@ weston_output_set_transform(struct weston_output *output,
mid_y = output->y + output->height / 2;
ev.mask = WESTON_POINTER_MOTION_ABS;
ev.x = wl_fixed_to_double(wl_fixed_from_int(mid_x));
ev.y = wl_fixed_to_double(wl_fixed_from_int(mid_y));
ev.abs.c = weston_coord(mid_x, mid_y);
wl_list_for_each(seat, &output->compositor->seat_list, link) {
struct weston_pointer *pointer = weston_seat_get_pointer(seat);

View file

@ -316,11 +316,15 @@ weston_pointer_motion_to_abs(struct weston_pointer *pointer,
wl_fixed_t *x, wl_fixed_t *y)
{
if (event->mask & WESTON_POINTER_MOTION_ABS) {
*x = wl_fixed_from_double(event->x);
*y = wl_fixed_from_double(event->y);
*x = wl_fixed_from_double(event->abs.c.x);
*y = wl_fixed_from_double(event->abs.c.y);
} else if (event->mask & WESTON_POINTER_MOTION_REL) {
*x = pointer->x + wl_fixed_from_double(event->dx);
*y = pointer->y + wl_fixed_from_double(event->dy);
struct weston_coord pos;
pos = weston_coord_from_fixed(pointer->x, pointer->y);
pos = weston_coord_add(pos, event->rel);
*x = wl_fixed_from_double(pos.x);
*y = wl_fixed_from_double(pos.y);
} else {
assert(!"invalid motion event");
*x = *y = 0;
@ -335,18 +339,22 @@ weston_pointer_motion_to_rel(struct weston_pointer *pointer,
{
if (event->mask & WESTON_POINTER_MOTION_REL &&
event->mask & WESTON_POINTER_MOTION_REL_UNACCEL) {
*dx = event->dx;
*dy = event->dy;
*dx_unaccel = event->dx_unaccel;
*dy_unaccel = event->dy_unaccel;
*dx = event->rel.x;
*dy = event->rel.y;
*dx_unaccel = event->rel_unaccel.x;
*dy_unaccel = event->rel_unaccel.y;
return true;
} else if (event->mask & WESTON_POINTER_MOTION_REL) {
*dx_unaccel = *dx = event->dx;
*dy_unaccel = *dy = event->dy;
*dx = event->rel.x;
*dy = event->rel.y;
*dx_unaccel = event->rel.x;
*dy_unaccel = event->rel.y;
return true;
} else if (event->mask & WESTON_POINTER_MOTION_REL_UNACCEL) {
*dx_unaccel = *dx = event->dx_unaccel;
*dy_unaccel = *dy = event->dy_unaccel;
*dx = event->rel_unaccel.x;
*dy = event->rel_unaccel.y;
*dx_unaccel = event->rel_unaccel.x;
*dy_unaccel = event->rel_unaccel.y;
return true;
} else {
return false;
@ -1880,8 +1888,7 @@ notify_motion_absolute(struct weston_seat *seat, const struct timespec *time,
event = (struct weston_pointer_motion_event) {
.mask = WESTON_POINTER_MOTION_ABS,
.x = pos.c.x,
.y = pos.c.y,
.abs = pos,
};
pointer->grab->interface->motion(pointer->grab, time, &event);
}

View file

@ -123,12 +123,10 @@ handle_pointer_motion(struct libinput_device *libinput_device,
.mask = WESTON_POINTER_MOTION_REL |
WESTON_POINTER_MOTION_REL_UNACCEL,
.time = time,
.dx = libinput_event_pointer_get_dx(pointer_event),
.dy = libinput_event_pointer_get_dy(pointer_event),
.dx_unaccel = dx_unaccel,
.dy_unaccel = dy_unaccel,
};
event.rel = weston_coord(libinput_event_pointer_get_dx(pointer_event),
libinput_event_pointer_get_dy(pointer_event));
event.rel_unaccel = weston_coord(dx_unaccel, dy_unaccel);
notify_motion(device->seat, &time, &event);
return true;

View file

@ -289,10 +289,9 @@ move_pointer(struct wl_client *client, struct wl_resource *resource,
event = (struct weston_pointer_motion_event) {
.mask = WESTON_POINTER_MOTION_REL,
.dx = wl_fixed_to_double(wl_fixed_from_int(x) - pointer->x),
.dy = wl_fixed_to_double(wl_fixed_from_int(y) - pointer->y),
};
event.rel = weston_coord_from_fixed(wl_fixed_from_int(x) - pointer->x,
wl_fixed_from_int(y) - pointer->y);
timespec_from_proto(&time, tv_sec_hi, tv_sec_lo, tv_nsec);
notify_motion(seat, &time, &event);