On Sat, Oct 17, 2015 at 06:07:06PM +0300, Giulio Camuffo wrote: > Hi, > git send-email has decided that it doesn't want to send this patch but > likely format-patch is more reasonable so i've attached it. > > -- > Giulio
> From 060186308dde03279f7a0659e7edec706a0f5123 Mon Sep 17 00:00:00 2001 > From: Giulio Camuffo <giuliocamu...@gmail.com> > Date: Sat, 17 Oct 2015 17:36:08 +0300 > Subject: [PATCH] input: use doubles in the interfaces to notify of input > events > > This patch is a further step in the wl_fixed_t internal sanitization. > It changes the notify_* functions to take doubles instead of wl_fixed_t > but does not change how these are stored in the various input structs > yet. However this already allows to remove all wl_fixed_t usage in places > like the libinput or the x11 backend. lgtm, Reviewed-by: Peter Hutterer <peter.hutte...@who-t.net> Cheers, Peter > --- > src/compositor-rdp.c | 13 ++++--------- > src/compositor-wayland.c | 20 ++++++++++++++------ > src/compositor-x11.c | 18 +++++++++--------- > src/compositor.c | 12 ++++++------ > src/compositor.h | 14 +++++++------- > src/input.c | 24 ++++++++++++++++-------- > src/libinput-device.c | 33 +++++++++++++-------------------- > src/screen-share.c | 5 +++-- > tests/weston-test.c | 4 ++-- > 9 files changed, 74 insertions(+), 69 deletions(-) > > diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c > index 7272f41..8d186fa 100644 > --- a/src/compositor-rdp.c > +++ b/src/compositor-rdp.c > @@ -70,7 +70,7 @@ > #include "pixman-renderer.h" > > #define MAX_FREERDP_FDS 32 > -#define DEFAULT_AXIS_STEP_DISTANCE wl_fixed_from_int(10) > +#define DEFAULT_AXIS_STEP_DISTANCE 10 > #define RDP_MODE_FREQ 60 * 1000 > > struct rdp_backend_config { > @@ -943,7 +943,7 @@ static BOOL xf_peer_post_connect(freerdp_peer *client) > static FREERDP_CB_RET_TYPE > xf_mouseEvent(rdpInput *input, UINT16 flags, UINT16 x, UINT16 y) > { > - wl_fixed_t wl_x, wl_y, axis; > + double axis; > RdpPeerContext *peerContext = (RdpPeerContext *)input->context; > struct rdp_output *output; > uint32_t button = 0; > @@ -951,10 +951,8 @@ xf_mouseEvent(rdpInput *input, UINT16 flags, UINT16 x, > UINT16 y) > if (flags & PTR_FLAGS_MOVE) { > output = peerContext->rdpBackend->output; > if (x < output->base.width && y < output->base.height) { > - wl_x = wl_fixed_from_int((int)x); > - wl_y = wl_fixed_from_int((int)y); > notify_motion_absolute(&peerContext->item.seat, > weston_compositor_get_time(), > - wl_x, wl_y); > + x, y); > } > } > > @@ -993,16 +991,13 @@ xf_mouseEvent(rdpInput *input, UINT16 flags, UINT16 x, > UINT16 y) > static FREERDP_CB_RET_TYPE > xf_extendedMouseEvent(rdpInput *input, UINT16 flags, UINT16 x, UINT16 y) > { > - wl_fixed_t wl_x, wl_y; > RdpPeerContext *peerContext = (RdpPeerContext *)input->context; > struct rdp_output *output; > > output = peerContext->rdpBackend->output; > if (x < output->base.width && y < output->base.height) { > - wl_x = wl_fixed_from_int((int)x); > - wl_y = wl_fixed_from_int((int)y); > notify_motion_absolute(&peerContext->item.seat, > weston_compositor_get_time(), > - wl_x, wl_y); > + x, y); > } > > FREERDP_CB_RETURN(TRUE); > diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c > index 7b11ae4..8f039a9 100644 > --- a/src/compositor-wayland.c > +++ b/src/compositor-wayland.c > @@ -1273,6 +1273,7 @@ input_handle_pointer_enter(void *data, struct > wl_pointer *pointer, > struct wayland_input *input = data; > int32_t fx, fy; > enum theme_location location; > + double dx, dy; > > /* XXX: If we get a modifier event immediately before the focus, > * we should try to keep the same serial. */ > @@ -1293,11 +1294,14 @@ input_handle_pointer_enter(void *data, struct > wl_pointer *pointer, > location = THEME_LOCATION_CLIENT_AREA; > } > > - weston_output_transform_coordinate(&input->output->base, x, y, &x, &y); > + dx = wl_fixed_to_double(x); > + dy = wl_fixed_to_double(y); > + weston_output_transform_coordinate(&input->output->base, > + dx, dy, &dx, &dy); > > if (location == THEME_LOCATION_CLIENT_AREA) { > input->focus = 1; > - notify_pointer_focus(&input->base, &input->output->base, x, y); > + notify_pointer_focus(&input->base, &input->output->base, dx, > dy); > wl_pointer_set_cursor(input->parent.pointer, > input->enter_serial, NULL, 0, 0); > } else { > @@ -1335,6 +1339,7 @@ input_handle_motion(void *data, struct wl_pointer > *pointer, > struct wayland_input *input = data; > int32_t fx, fy; > enum theme_location location; > + double dx, dy; > > if (!input->output) > return; > @@ -1353,7 +1358,10 @@ input_handle_motion(void *data, struct wl_pointer > *pointer, > location = THEME_LOCATION_CLIENT_AREA; > } > > - weston_output_transform_coordinate(&input->output->base, x, y, &x, &y); > + dx = wl_fixed_to_double(x); > + dy = wl_fixed_to_double(y); > + weston_output_transform_coordinate(&input->output->base, > + dx, dy, &dx, &dy); > > if (input->focus && location != THEME_LOCATION_CLIENT_AREA) { > input_set_cursor(input); > @@ -1362,12 +1370,12 @@ input_handle_motion(void *data, struct wl_pointer > *pointer, > } else if (!input->focus && location == THEME_LOCATION_CLIENT_AREA) { > wl_pointer_set_cursor(input->parent.pointer, > input->enter_serial, NULL, 0, 0); > - notify_pointer_focus(&input->base, &input->output->base, x, y); > + notify_pointer_focus(&input->base, &input->output->base, dx, > dy); > input->focus = 1; > } > > if (location == THEME_LOCATION_CLIENT_AREA) > - notify_motion_absolute(&input->base, time, x, y); > + notify_motion_absolute(&input->base, time, dx, dy); > } > > static void > @@ -1426,7 +1434,7 @@ input_handle_axis(void *data, struct wl_pointer > *pointer, > { > struct wayland_input *input = data; > > - notify_axis(&input->base, time, axis, value); > + notify_axis(&input->base, time, axis, wl_fixed_to_double(value)); > } > > static const struct wl_pointer_listener pointer_listener = { > diff --git a/src/compositor-x11.c b/src/compositor-x11.c > index 9a23996..2b9c582 100644 > --- a/src/compositor-x11.c > +++ b/src/compositor-x11.c > @@ -58,7 +58,7 @@ > #include "presentation_timing-server-protocol.h" > #include "linux-dmabuf.h" > > -#define DEFAULT_AXIS_STEP_DISTANCE wl_fixed_from_int(10) > +#define DEFAULT_AXIS_STEP_DISTANCE 10 > > static int option_width; > static int option_height; > @@ -85,8 +85,8 @@ struct x11_backend { > /* We could map multi-pointer X to multiple wayland seats, but > * for now we only support core X input. */ > struct weston_seat core_seat; > - wl_fixed_t prev_x; > - wl_fixed_t prev_y; > + double prev_x; > + double prev_y; > > struct { > xcb_atom_t wm_protocols; > @@ -1125,7 +1125,7 @@ x11_backend_deliver_motion_event(struct x11_backend *b, > xcb_generic_event_t *event) > { > struct x11_output *output; > - wl_fixed_t x, y; > + double x, y; > xcb_motion_notify_event_t *motion_notify = > (xcb_motion_notify_event_t *) event; > > @@ -1136,8 +1136,8 @@ x11_backend_deliver_motion_event(struct x11_backend *b, > return; > > weston_output_transform_coordinate(&output->base, > - > wl_fixed_from_int(motion_notify->event_x), > - > wl_fixed_from_int(motion_notify->event_y), > + motion_notify->event_x, > + motion_notify->event_y, > &x, &y); > > notify_motion(&b->core_seat, weston_compositor_get_time(), > @@ -1152,7 +1152,7 @@ x11_backend_deliver_enter_event(struct x11_backend *b, > xcb_generic_event_t *event) > { > struct x11_output *output; > - wl_fixed_t x, y; > + double x, y; > > xcb_enter_notify_event_t *enter_notify = > (xcb_enter_notify_event_t *) event; > @@ -1165,8 +1165,8 @@ x11_backend_deliver_enter_event(struct x11_backend *b, > return; > > weston_output_transform_coordinate(&output->base, > - > wl_fixed_from_int(enter_notify->event_x), > - > wl_fixed_from_int(enter_notify->event_y), &x, &y); > + enter_notify->event_x, > + enter_notify->event_y, &x, &y); > > notify_pointer_focus(&b->core_seat, &output->base, x, y); > > diff --git a/src/compositor.c b/src/compositor.c > index f8437e8..9a1aa8b 100644 > --- a/src/compositor.c > +++ b/src/compositor.c > @@ -4107,19 +4107,19 @@ weston_compositor_add_output(struct weston_compositor > *compositor, > > WL_EXPORT void > weston_output_transform_coordinate(struct weston_output *output, > - wl_fixed_t device_x, wl_fixed_t device_y, > - wl_fixed_t *x, wl_fixed_t *y) > + double device_x, double device_y, > + double *x, double *y) > { > struct weston_vector p = { { > - wl_fixed_to_double(device_x), > - wl_fixed_to_double(device_y), > + device_x, > + device_y, > 0.0, > 1.0 } }; > > weston_matrix_transform(&output->inverse_matrix, &p); > > - *x = wl_fixed_from_double(p.f[0] / p.f[3]); > - *y = wl_fixed_from_double(p.f[1] / p.f[3]); > + *x = p.f[0] / p.f[3]; > + *y = p.f[1] / p.f[3]; > } > > static void > diff --git a/src/compositor.h b/src/compositor.h > index 2e2a185..d1f5cf3 100644 > --- a/src/compositor.h > +++ b/src/compositor.h > @@ -1065,16 +1065,16 @@ weston_surface_activate(struct weston_surface > *surface, > struct weston_seat *seat); > void > notify_motion(struct weston_seat *seat, uint32_t time, > - wl_fixed_t dx, wl_fixed_t dy); > + double dx, double dy); > void > notify_motion_absolute(struct weston_seat *seat, uint32_t time, > - wl_fixed_t x, wl_fixed_t y); > + double x, double y); > void > notify_button(struct weston_seat *seat, uint32_t time, int32_t button, > enum wl_pointer_button_state state); > void > notify_axis(struct weston_seat *seat, uint32_t time, uint32_t axis, > - wl_fixed_t value); > + double value); > void > notify_key(struct weston_seat *seat, uint32_t time, uint32_t key, > enum wl_keyboard_key_state state, > @@ -1084,7 +1084,7 @@ notify_modifiers(struct weston_seat *seat, uint32_t > serial); > > void > notify_pointer_focus(struct weston_seat *seat, struct weston_output *output, > - wl_fixed_t x, wl_fixed_t y); > + double x, double y); > > void > notify_keyboard_focus_in(struct weston_seat *seat, struct wl_array *keys, > @@ -1094,7 +1094,7 @@ notify_keyboard_focus_out(struct weston_seat *seat); > > void > notify_touch(struct weston_seat *seat, uint32_t time, int touch_id, > - wl_fixed_t x, wl_fixed_t y, int touch_type); > + double x, double y, int touch_type); > void > notify_touch_frame(struct weston_seat *seat); > > @@ -1397,8 +1397,8 @@ void > weston_output_destroy(struct weston_output *output); > void > weston_output_transform_coordinate(struct weston_output *output, > - wl_fixed_t device_x, wl_fixed_t device_y, > - wl_fixed_t *x, wl_fixed_t *y); > + double device_x, double device_y, > + double *x, double *y); > > void > weston_seat_init(struct weston_seat *seat, struct weston_compositor *ec, > diff --git a/src/input.c b/src/input.c > index 500c39a..7184731 100644 > --- a/src/input.c > +++ b/src/input.c > @@ -976,13 +976,15 @@ weston_pointer_handle_output_destroy(struct wl_listener > *listener, void *data) > > WL_EXPORT void > notify_motion(struct weston_seat *seat, > - uint32_t time, wl_fixed_t dx, wl_fixed_t dy) > + uint32_t time, double dx, double dy) > { > struct weston_compositor *ec = seat->compositor; > struct weston_pointer *pointer = weston_seat_get_pointer(seat); > > weston_compositor_wake(ec); > - pointer->grab->interface->motion(pointer->grab, time, pointer->x + dx, > pointer->y + dy); > + pointer->grab->interface->motion(pointer->grab, time, > + pointer->x + wl_fixed_from_double(dx), > + pointer->y + wl_fixed_from_double(dy)); > } > > static void > @@ -1023,13 +1025,15 @@ run_modifier_bindings(struct weston_seat *seat, > uint32_t old, uint32_t new) > > WL_EXPORT void > notify_motion_absolute(struct weston_seat *seat, > - uint32_t time, wl_fixed_t x, wl_fixed_t y) > + uint32_t time, double x, double y) > { > struct weston_compositor *ec = seat->compositor; > struct weston_pointer *pointer = weston_seat_get_pointer(seat); > > weston_compositor_wake(ec); > - pointer->grab->interface->motion(pointer->grab, time, x, y); > + pointer->grab->interface->motion(pointer->grab, time, > + wl_fixed_from_double(x), > + wl_fixed_from_double(y)); > } > > WL_EXPORT void > @@ -1080,12 +1084,13 @@ notify_button(struct weston_seat *seat, uint32_t > time, int32_t button, > > WL_EXPORT void > notify_axis(struct weston_seat *seat, uint32_t time, uint32_t axis, > - wl_fixed_t value) > + double dv) > { > struct weston_compositor *compositor = seat->compositor; > struct weston_pointer *pointer = weston_seat_get_pointer(seat); > struct wl_resource *resource; > struct wl_list *resource_list; > + wl_fixed_t value = wl_fixed_from_double(dv); > > weston_compositor_wake(compositor); > > @@ -1408,12 +1413,13 @@ notify_key(struct weston_seat *seat, uint32_t time, > uint32_t key, > > WL_EXPORT void > notify_pointer_focus(struct weston_seat *seat, struct weston_output *output, > - wl_fixed_t x, wl_fixed_t y) > + double x, double y) > { > struct weston_pointer *pointer = weston_seat_get_pointer(seat); > > if (output) { > - weston_pointer_move(pointer, x, y); > + weston_pointer_move(pointer, wl_fixed_from_double(x), > + wl_fixed_from_double(y)); > } else { > /* FIXME: We should call weston_pointer_set_focus(seat, > * NULL) here, but somehow that breaks re-entry... */ > @@ -1541,13 +1547,15 @@ weston_touch_set_focus(struct weston_touch *touch, > struct weston_view *view) > */ > WL_EXPORT void > notify_touch(struct weston_seat *seat, uint32_t time, int touch_id, > - wl_fixed_t x, wl_fixed_t y, int touch_type) > + double dx, double dy, int touch_type) > { > struct weston_compositor *ec = seat->compositor; > struct weston_touch *touch = weston_seat_get_touch(seat); > struct weston_touch_grab *grab = touch->grab; > struct weston_view *ev; > wl_fixed_t sx, sy; > + wl_fixed_t x = wl_fixed_from_double(dx); > + wl_fixed_t y = wl_fixed_from_double(dy); > > /* Update grab's global coordinates. */ > if (touch_id == touch->grab_touch_id && touch_type != WL_TOUCH_UP) { > diff --git a/src/libinput-device.c b/src/libinput-device.c > index 69dcbf8..13440df 100644 > --- a/src/libinput-device.c > +++ b/src/libinput-device.c > @@ -86,14 +86,11 @@ handle_pointer_motion(struct libinput_device > *libinput_device, > { > struct evdev_device *device = > libinput_device_get_user_data(libinput_device); > - wl_fixed_t dx, dy; > > - dx = wl_fixed_from_double(libinput_event_pointer_get_dx(pointer_event)); > - dy = wl_fixed_from_double(libinput_event_pointer_get_dy(pointer_event)); > notify_motion(device->seat, > libinput_event_pointer_get_time(pointer_event), > - dx, > - dy); > + libinput_event_pointer_get_dx(pointer_event), > + libinput_event_pointer_get_dy(pointer_event)); > } > > static void > @@ -105,7 +102,7 @@ handle_pointer_motion_absolute( > libinput_device_get_user_data(libinput_device); > struct weston_output *output = device->output; > uint32_t time; > - wl_fixed_t x, y; > + double x, y; > uint32_t width, height; > > if (!output) > @@ -115,12 +112,10 @@ handle_pointer_motion_absolute( > width = device->output->current_mode->width; > height = device->output->current_mode->height; > > - x = wl_fixed_from_double( > - libinput_event_pointer_get_absolute_x_transformed(pointer_event, > - width)); > - y = wl_fixed_from_double( > - libinput_event_pointer_get_absolute_y_transformed(pointer_event, > - height)); > + x = libinput_event_pointer_get_absolute_x_transformed(pointer_event, > + width); > + y = libinput_event_pointer_get_absolute_y_transformed(pointer_event, > + height); > > weston_output_transform_coordinate(device->output, x, y, &x, &y); > notify_motion_absolute(device->seat, time, x, y); > @@ -203,7 +198,7 @@ handle_pointer_axis(struct libinput_device > *libinput_device, > notify_axis(device->seat, > libinput_event_pointer_get_time(pointer_event), > WL_POINTER_AXIS_VERTICAL_SCROLL, > - wl_fixed_from_double(value)); > + value); > } > > axis = LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL; > @@ -212,7 +207,7 @@ handle_pointer_axis(struct libinput_device > *libinput_device, > notify_axis(device->seat, > libinput_event_pointer_get_time(pointer_event), > WL_POINTER_AXIS_HORIZONTAL_SCROLL, > - wl_fixed_from_double(value)); > + value); > } > } > > @@ -223,8 +218,8 @@ handle_touch_with_coords(struct libinput_device > *libinput_device, > { > struct evdev_device *device = > libinput_device_get_user_data(libinput_device); > - wl_fixed_t x; > - wl_fixed_t y; > + double x; > + double y; > uint32_t width, height; > uint32_t time; > int32_t slot; > @@ -237,10 +232,8 @@ handle_touch_with_coords(struct libinput_device > *libinput_device, > > width = device->output->current_mode->width; > height = device->output->current_mode->height; > - x = wl_fixed_from_double( > - libinput_event_touch_get_x_transformed(touch_event, width)); > - y = wl_fixed_from_double( > - libinput_event_touch_get_y_transformed(touch_event, height)); > + x = libinput_event_touch_get_x_transformed(touch_event, width); > + y = libinput_event_touch_get_y_transformed(touch_event, height); > > weston_output_transform_coordinate(device->output, > x, y, &x, &y); > diff --git a/src/screen-share.c b/src/screen-share.c > index d961c89..b38c394 100644 > --- a/src/screen-share.c > +++ b/src/screen-share.c > @@ -142,7 +142,8 @@ ss_seat_handle_motion(void *data, struct wl_pointer > *pointer, > /* No transformation of input position is required here because we are > * always receiving the input in the same coordinates as the output. */ > > - notify_motion_absolute(&seat->base, time, x, y); > + notify_motion_absolute(&seat->base, time, > + wl_fixed_to_double(x), wl_fixed_to_double(y)); > } > > static void > @@ -161,7 +162,7 @@ ss_seat_handle_axis(void *data, struct wl_pointer > *pointer, > { > struct ss_seat *seat = data; > > - notify_axis(&seat->base, time, axis, value); > + notify_axis(&seat->base, time, axis, wl_fixed_to_double(value)); > } > > static const struct wl_pointer_listener ss_seat_pointer_listener = { > diff --git a/tests/weston-test.c b/tests/weston-test.c > index b593f1e..057b816 100644 > --- a/tests/weston-test.c > +++ b/tests/weston-test.c > @@ -147,8 +147,8 @@ move_pointer(struct wl_client *client, struct wl_resource > *resource, > struct weston_pointer *pointer = weston_seat_get_pointer(seat); > > notify_motion(seat, 100, > - wl_fixed_from_int(x) - pointer->x, > - wl_fixed_from_int(y) - pointer->y); > + (double)x - wl_fixed_to_double(pointer->x), > + (double)y - wl_fixed_to_double(pointer->y)); > > notify_pointer_position(test, resource); > } > -- > 2.6.1 > > _______________________________________________ > wayland-devel mailing list > wayland-devel@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/wayland-devel _______________________________________________ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel