From 80321942e769f89e76f5372d4283aaad8fb4bd9e Mon Sep 17 00:00:00 2001 From: Alexandros Frantzis Date: Thu, 16 Nov 2017 18:20:56 +0200 Subject: [PATCH] libweston: Use struct timespec for axis events Change code related to axis events to use struct timespec to represent time. This commit is part of a larger effort to transition the Weston codebase to struct timespec. Signed-off-by: Alexandros Frantzis Reviewed-by: Pekka Paalanen --- compositor/screen-share.c | 5 ++++- desktop-shell/exposay.c | 3 ++- desktop-shell/shell.c | 18 ++++++++++++------ ivi-shell/hmi-controller.c | 2 +- libweston-desktop/seat.c | 2 +- libweston/bindings.c | 2 +- libweston/compositor-rdp.c | 5 +++-- libweston/compositor-wayland.c | 10 ++++++++-- libweston/compositor-x11.c | 20 ++++++++------------ libweston/compositor.h | 11 ++++++----- libweston/data-device.c | 3 ++- libweston/input.c | 16 +++++++++------- libweston/libinput-device.c | 12 ++++++------ 13 files changed, 63 insertions(+), 46 deletions(-) diff --git a/compositor/screen-share.c b/compositor/screen-share.c index 368d0cd..8b2decf 100644 --- a/compositor/screen-share.c +++ b/compositor/screen-share.c @@ -173,12 +173,15 @@ ss_seat_handle_axis(void *data, struct wl_pointer *pointer, { struct ss_seat *seat = data; struct weston_pointer_axis_event weston_event; + struct timespec ts; weston_event.axis = axis; weston_event.value = wl_fixed_to_double(value); weston_event.has_discrete = false; - notify_axis(&seat->base, time, &weston_event); + timespec_from_msec(&ts, time); + + notify_axis(&seat->base, &ts, &weston_event); notify_pointer_frame(&seat->base); } diff --git a/desktop-shell/exposay.c b/desktop-shell/exposay.c index 3571c5d..5b23adf 100644 --- a/desktop-shell/exposay.c +++ b/desktop-shell/exposay.c @@ -390,7 +390,8 @@ exposay_button(struct weston_pointer_grab *grab, const struct timespec *time, static void exposay_axis(struct weston_pointer_grab *grab, - uint32_t time, struct weston_pointer_axis_event *event) + const struct timespec *time, + struct weston_pointer_axis_event *event) { } diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c index 2d2a6c8..5f6c6d1 100644 --- a/desktop-shell/shell.c +++ b/desktop-shell/shell.c @@ -1431,7 +1431,8 @@ noop_grab_focus(struct weston_pointer_grab *grab) static void noop_grab_axis(struct weston_pointer_grab *grab, - uint32_t time, struct weston_pointer_axis_event *event) + const struct timespec *time, + struct weston_pointer_axis_event *event) { } @@ -3344,7 +3345,8 @@ resize_binding(struct weston_pointer *pointer, const struct timespec *time, } static void -surface_opacity_binding(struct weston_pointer *pointer, uint32_t time, +surface_opacity_binding(struct weston_pointer *pointer, + const struct timespec *time, struct weston_pointer_axis_event *event, void *data) { @@ -3374,8 +3376,8 @@ surface_opacity_binding(struct weston_pointer *pointer, uint32_t time, } static void -do_zoom(struct weston_seat *seat, uint32_t time, uint32_t key, uint32_t axis, - double value) +do_zoom(struct weston_seat *seat, const struct timespec *time, uint32_t key, + uint32_t axis, double value) { struct weston_compositor *compositor = seat->compositor; struct weston_pointer *pointer = weston_seat_get_pointer(seat); @@ -3424,7 +3426,7 @@ do_zoom(struct weston_seat *seat, uint32_t time, uint32_t key, uint32_t axis, } static void -zoom_axis_binding(struct weston_pointer *pointer, uint32_t time, +zoom_axis_binding(struct weston_pointer *pointer, const struct timespec *time, struct weston_pointer_axis_event *event, void *data) { @@ -3435,7 +3437,11 @@ static void zoom_key_binding(struct weston_keyboard *keyboard, uint32_t time, uint32_t key, void *data) { - do_zoom(keyboard->seat, time, key, 0, 0); + struct timespec ts; + + timespec_from_msec(&ts, time); + + do_zoom(keyboard->seat, &ts, key, 0, 0); } static void diff --git a/ivi-shell/hmi-controller.c b/ivi-shell/hmi-controller.c index b91b7f2..d61e26b 100644 --- a/ivi-shell/hmi-controller.c +++ b/ivi-shell/hmi-controller.c @@ -1461,7 +1461,7 @@ pointer_noop_grab_focus(struct weston_pointer_grab *grab) static void pointer_default_grab_axis(struct weston_pointer_grab *grab, - uint32_t time, + const struct timespec *time, struct weston_pointer_axis_event *event) { weston_pointer_send_axis(grab->pointer, time, event); diff --git a/libweston-desktop/seat.c b/libweston-desktop/seat.c index 2c62f4f..150229f 100644 --- a/libweston-desktop/seat.c +++ b/libweston-desktop/seat.c @@ -139,7 +139,7 @@ weston_desktop_seat_popup_grab_pointer_button(struct weston_pointer_grab *grab, static void weston_desktop_seat_popup_grab_pointer_axis(struct weston_pointer_grab *grab, - uint32_t time, + const struct timespec *time, struct weston_pointer_axis_event *event) { weston_pointer_send_axis(grab->pointer, time, event); diff --git a/libweston/bindings.c b/libweston/bindings.c index ae61674..82a56f4 100644 --- a/libweston/bindings.c +++ b/libweston/bindings.c @@ -392,7 +392,7 @@ weston_compositor_run_touch_binding(struct weston_compositor *compositor, int weston_compositor_run_axis_binding(struct weston_compositor *compositor, struct weston_pointer *pointer, - uint32_t time, + const struct timespec *time, struct weston_pointer_axis_event *event) { struct weston_binding *b, *tmp; diff --git a/libweston/compositor-rdp.c b/libweston/compositor-rdp.c index ad435b1..05e11ee 100644 --- a/libweston/compositor-rdp.c +++ b/libweston/compositor-rdp.c @@ -1076,8 +1076,9 @@ xf_mouseEvent(rdpInput *input, UINT16 flags, UINT16 x, UINT16 y) weston_event.discrete = (int)value; weston_event.has_discrete = true; - notify_axis(peerContext->item.seat, weston_compositor_get_time(), - &weston_event); + timespec_from_msec(&time, weston_compositor_get_time()); + + notify_axis(peerContext->item.seat, &time, &weston_event); need_frame = true; } diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c index 46f7aba..6a1a50f 100644 --- a/libweston/compositor-wayland.c +++ b/libweston/compositor-wayland.c @@ -1696,6 +1696,7 @@ input_handle_axis(void *data, struct wl_pointer *pointer, { struct wayland_input *input = data; struct weston_pointer_axis_event weston_event; + struct timespec ts; weston_event.axis = axis; weston_event.value = wl_fixed_to_double(value); @@ -1712,7 +1713,9 @@ input_handle_axis(void *data, struct wl_pointer *pointer, input->horiz.has_discrete = false; } - notify_axis(&input->base, time, &weston_event); + timespec_from_msec(&ts, time); + + notify_axis(&input->base, &ts, &weston_event); if (input->seat_version < WL_POINTER_FRAME_SINCE_VERSION) notify_pointer_frame(&input->base); @@ -1741,11 +1744,14 @@ input_handle_axis_stop(void *data, struct wl_pointer *pointer, { struct wayland_input *input = data; struct weston_pointer_axis_event weston_event; + struct timespec ts; weston_event.axis = axis; weston_event.value = 0; - notify_axis(&input->base, time, &weston_event); + timespec_from_msec(&ts, time); + + notify_axis(&input->base, &ts, &weston_event); } static void diff --git a/libweston/compositor-x11.c b/libweston/compositor-x11.c index 32622c0..13643a1 100644 --- a/libweston/compositor-x11.c +++ b/libweston/compositor-x11.c @@ -1178,9 +1178,8 @@ x11_backend_deliver_button_event(struct x11_backend *b, weston_event.has_discrete = true; weston_event.axis = WL_POINTER_AXIS_VERTICAL_SCROLL; - notify_axis(&b->core_seat, - weston_compositor_get_time(), - &weston_event); + timespec_from_msec(&time, weston_compositor_get_time()); + notify_axis(&b->core_seat, &time, &weston_event); notify_pointer_frame(&b->core_seat); } return; @@ -1191,9 +1190,8 @@ x11_backend_deliver_button_event(struct x11_backend *b, weston_event.has_discrete = true; weston_event.axis = WL_POINTER_AXIS_VERTICAL_SCROLL; - notify_axis(&b->core_seat, - weston_compositor_get_time(), - &weston_event); + timespec_from_msec(&time, weston_compositor_get_time()); + notify_axis(&b->core_seat, &time, &weston_event); notify_pointer_frame(&b->core_seat); } return; @@ -1204,9 +1202,8 @@ x11_backend_deliver_button_event(struct x11_backend *b, weston_event.has_discrete = true; weston_event.axis = WL_POINTER_AXIS_HORIZONTAL_SCROLL; - notify_axis(&b->core_seat, - weston_compositor_get_time(), - &weston_event); + timespec_from_msec(&time, weston_compositor_get_time()); + notify_axis(&b->core_seat, &time, &weston_event); notify_pointer_frame(&b->core_seat); } return; @@ -1217,9 +1214,8 @@ x11_backend_deliver_button_event(struct x11_backend *b, weston_event.has_discrete = true; weston_event.axis = WL_POINTER_AXIS_HORIZONTAL_SCROLL; - notify_axis(&b->core_seat, - weston_compositor_get_time(), - &weston_event); + timespec_from_msec(&time, weston_compositor_get_time()); + notify_axis(&b->core_seat, &time, &weston_event); notify_pointer_frame(&b->core_seat); } return; diff --git a/libweston/compositor.h b/libweston/compositor.h index cd42006..ec76248 100644 --- a/libweston/compositor.h +++ b/libweston/compositor.h @@ -275,7 +275,7 @@ struct weston_pointer_grab_interface { const struct timespec *time, uint32_t button, uint32_t state); void (*axis)(struct weston_pointer_grab *grab, - uint32_t time, + const struct timespec *time, struct weston_pointer_axis_event *event); void (*axis_source)(struct weston_pointer_grab *grab, uint32_t source); void (*frame)(struct weston_pointer_grab *grab); @@ -436,7 +436,7 @@ weston_pointer_send_button(struct weston_pointer *pointer, uint32_t button, uint32_t state_w); void weston_pointer_send_axis(struct weston_pointer *pointer, - uint32_t time, + const struct timespec *time, struct weston_pointer_axis_event *event); void weston_pointer_send_axis_source(struct weston_pointer *pointer, @@ -1376,7 +1376,7 @@ void notify_button(struct weston_seat *seat, const struct timespec *time, int32_t button, enum wl_pointer_button_state state); void -notify_axis(struct weston_seat *seat, uint32_t time, +notify_axis(struct weston_seat *seat, const struct timespec *time, struct weston_pointer_axis_event *event); void notify_axis_source(struct weston_seat *seat, uint32_t source); @@ -1514,7 +1514,7 @@ weston_compositor_add_touch_binding(struct weston_compositor *compositor, void *data); typedef void (*weston_axis_binding_handler_t)(struct weston_pointer *pointer, - uint32_t time, + const struct timespec *time, struct weston_pointer_axis_event *event, void *data); struct weston_binding * @@ -1562,7 +1562,8 @@ weston_compositor_run_touch_binding(struct weston_compositor *compositor, int touch_type); int weston_compositor_run_axis_binding(struct weston_compositor *compositor, - struct weston_pointer *pointer, uint32_t time, + struct weston_pointer *pointer, + const struct timespec *time, struct weston_pointer_axis_event *event); int weston_compositor_run_debug_binding(struct weston_compositor *compositor, diff --git a/libweston/data-device.c b/libweston/data-device.c index 20de9b8..26898aa 100644 --- a/libweston/data-device.c +++ b/libweston/data-device.c @@ -680,7 +680,8 @@ drag_grab_button(struct weston_pointer_grab *grab, static void drag_grab_axis(struct weston_pointer_grab *grab, - uint32_t time, struct weston_pointer_axis_event *event) + const struct timespec *time, + struct weston_pointer_axis_event *event) { } diff --git a/libweston/input.c b/libweston/input.c index 7f78933..877b0b8 100644 --- a/libweston/input.c +++ b/libweston/input.c @@ -514,16 +514,18 @@ default_grab_pointer_button(struct weston_pointer_grab *grab, */ WL_EXPORT void weston_pointer_send_axis(struct weston_pointer *pointer, - uint32_t time, + const struct timespec *time, struct weston_pointer_axis_event *event) { struct wl_resource *resource; struct wl_list *resource_list; + uint32_t msecs; if (!weston_pointer_has_focus_resource(pointer)) return; resource_list = &pointer->focus_client->pointer_resources; + msecs = timespec_to_msec(time); wl_resource_for_each(resource, resource_list) { if (event->has_discrete && wl_resource_get_version(resource) >= @@ -532,12 +534,12 @@ weston_pointer_send_axis(struct weston_pointer *pointer, event->discrete); if (event->value) - wl_pointer_send_axis(resource, time, + wl_pointer_send_axis(resource, msecs, event->axis, wl_fixed_from_double(event->value)); else if (wl_resource_get_version(resource) >= WL_POINTER_AXIS_STOP_SINCE_VERSION) - wl_pointer_send_axis_stop(resource, time, + wl_pointer_send_axis_stop(resource, msecs, event->axis); } } @@ -603,7 +605,7 @@ weston_pointer_send_frame(struct weston_pointer *pointer) static void default_grab_pointer_axis(struct weston_pointer_grab *grab, - uint32_t time, + const struct timespec *time, struct weston_pointer_axis_event *event) { weston_pointer_send_axis(grab->pointer, time, event); @@ -1685,7 +1687,7 @@ notify_button(struct weston_seat *seat, const struct timespec *time, } WL_EXPORT void -notify_axis(struct weston_seat *seat, uint32_t time, +notify_axis(struct weston_seat *seat, const struct timespec *time, struct weston_pointer_axis_event *event) { struct weston_compositor *compositor = seat->compositor; @@ -3339,7 +3341,7 @@ locked_pointer_grab_pointer_button(struct weston_pointer_grab *grab, static void locked_pointer_grab_pointer_axis(struct weston_pointer_grab *grab, - uint32_t time, + const struct timespec *time, struct weston_pointer_axis_event *event) { weston_pointer_send_axis(grab->pointer, time, event); @@ -4347,7 +4349,7 @@ confined_pointer_grab_pointer_button(struct weston_pointer_grab *grab, static void confined_pointer_grab_pointer_axis(struct weston_pointer_grab *grab, - uint32_t time, + const struct timespec *time, struct weston_pointer_axis_event *event) { weston_pointer_send_axis(grab->pointer, time, event); diff --git a/libweston/libinput-device.c b/libweston/libinput-device.c index e2f2046..4d8cf2e 100644 --- a/libweston/libinput-device.c +++ b/libweston/libinput-device.c @@ -230,6 +230,7 @@ handle_pointer_axis(struct libinput_device *libinput_device, enum libinput_pointer_axis_source source; uint32_t wl_axis_source; bool has_vert, has_horiz; + struct timespec time; has_vert = libinput_event_pointer_has_axis(pointer_event, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL); @@ -260,6 +261,9 @@ handle_pointer_axis(struct libinput_device *libinput_device, notify_axis_source(device->seat, wl_axis_source); + timespec_from_usec(&time, + libinput_event_pointer_get_time_usec(pointer_event)); + if (has_vert) { axis = LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL; vert_discrete = get_axis_discrete(pointer_event, axis); @@ -270,9 +274,7 @@ handle_pointer_axis(struct libinput_device *libinput_device, weston_event.discrete = vert_discrete; weston_event.has_discrete = (vert_discrete != 0); - notify_axis(device->seat, - libinput_event_pointer_get_time(pointer_event), - &weston_event); + notify_axis(device->seat, &time, &weston_event); } if (has_horiz) { @@ -285,9 +287,7 @@ handle_pointer_axis(struct libinput_device *libinput_device, weston_event.discrete = horiz_discrete; weston_event.has_discrete = (horiz_discrete != 0); - notify_axis(device->seat, - libinput_event_pointer_get_time(pointer_event), - &weston_event); + notify_axis(device->seat, &time, &weston_event); } return true; -- 2.7.4