Commit 80321942 authored by Alexandros Frantzis's avatar Alexandros Frantzis Committed by Pekka Paalanen

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's avatarAlexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
parent 215bedc8
...@@ -173,12 +173,15 @@ ss_seat_handle_axis(void *data, struct wl_pointer *pointer, ...@@ -173,12 +173,15 @@ ss_seat_handle_axis(void *data, struct wl_pointer *pointer,
{ {
struct ss_seat *seat = data; struct ss_seat *seat = data;
struct weston_pointer_axis_event weston_event; struct weston_pointer_axis_event weston_event;
struct timespec ts;
weston_event.axis = axis; weston_event.axis = axis;
weston_event.value = wl_fixed_to_double(value); weston_event.value = wl_fixed_to_double(value);
weston_event.has_discrete = false; 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); notify_pointer_frame(&seat->base);
} }
......
...@@ -390,7 +390,8 @@ exposay_button(struct weston_pointer_grab *grab, const struct timespec *time, ...@@ -390,7 +390,8 @@ exposay_button(struct weston_pointer_grab *grab, const struct timespec *time,
static void static void
exposay_axis(struct weston_pointer_grab *grab, 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)
{ {
} }
......
...@@ -1431,7 +1431,8 @@ noop_grab_focus(struct weston_pointer_grab *grab) ...@@ -1431,7 +1431,8 @@ noop_grab_focus(struct weston_pointer_grab *grab)
static void static void
noop_grab_axis(struct weston_pointer_grab *grab, 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, ...@@ -3344,7 +3345,8 @@ resize_binding(struct weston_pointer *pointer, const struct timespec *time,
} }
static void 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, struct weston_pointer_axis_event *event,
void *data) void *data)
{ {
...@@ -3374,8 +3376,8 @@ surface_opacity_binding(struct weston_pointer *pointer, uint32_t time, ...@@ -3374,8 +3376,8 @@ surface_opacity_binding(struct weston_pointer *pointer, uint32_t time,
} }
static void static void
do_zoom(struct weston_seat *seat, uint32_t time, uint32_t key, uint32_t axis, do_zoom(struct weston_seat *seat, const struct timespec *time, uint32_t key,
double value) uint32_t axis, double value)
{ {
struct weston_compositor *compositor = seat->compositor; struct weston_compositor *compositor = seat->compositor;
struct weston_pointer *pointer = weston_seat_get_pointer(seat); 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, ...@@ -3424,7 +3426,7 @@ do_zoom(struct weston_seat *seat, uint32_t time, uint32_t key, uint32_t axis,
} }
static void 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, struct weston_pointer_axis_event *event,
void *data) void *data)
{ {
...@@ -3435,7 +3437,11 @@ static void ...@@ -3435,7 +3437,11 @@ static void
zoom_key_binding(struct weston_keyboard *keyboard, uint32_t time, zoom_key_binding(struct weston_keyboard *keyboard, uint32_t time,
uint32_t key, void *data) 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 static void
......
...@@ -1461,7 +1461,7 @@ pointer_noop_grab_focus(struct weston_pointer_grab *grab) ...@@ -1461,7 +1461,7 @@ pointer_noop_grab_focus(struct weston_pointer_grab *grab)
static void static void
pointer_default_grab_axis(struct weston_pointer_grab *grab, pointer_default_grab_axis(struct weston_pointer_grab *grab,
uint32_t time, const struct timespec *time,
struct weston_pointer_axis_event *event) struct weston_pointer_axis_event *event)
{ {
weston_pointer_send_axis(grab->pointer, time, event); weston_pointer_send_axis(grab->pointer, time, event);
......
...@@ -139,7 +139,7 @@ weston_desktop_seat_popup_grab_pointer_button(struct weston_pointer_grab *grab, ...@@ -139,7 +139,7 @@ weston_desktop_seat_popup_grab_pointer_button(struct weston_pointer_grab *grab,
static void static void
weston_desktop_seat_popup_grab_pointer_axis(struct weston_pointer_grab *grab, 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) struct weston_pointer_axis_event *event)
{ {
weston_pointer_send_axis(grab->pointer, time, event); weston_pointer_send_axis(grab->pointer, time, event);
......
...@@ -392,7 +392,7 @@ weston_compositor_run_touch_binding(struct weston_compositor *compositor, ...@@ -392,7 +392,7 @@ weston_compositor_run_touch_binding(struct weston_compositor *compositor,
int int
weston_compositor_run_axis_binding(struct weston_compositor *compositor, weston_compositor_run_axis_binding(struct weston_compositor *compositor,
struct weston_pointer *pointer, struct weston_pointer *pointer,
uint32_t time, const struct timespec *time,
struct weston_pointer_axis_event *event) struct weston_pointer_axis_event *event)
{ {
struct weston_binding *b, *tmp; struct weston_binding *b, *tmp;
......
...@@ -1076,8 +1076,9 @@ xf_mouseEvent(rdpInput *input, UINT16 flags, UINT16 x, UINT16 y) ...@@ -1076,8 +1076,9 @@ xf_mouseEvent(rdpInput *input, UINT16 flags, UINT16 x, UINT16 y)
weston_event.discrete = (int)value; weston_event.discrete = (int)value;
weston_event.has_discrete = true; weston_event.has_discrete = true;
notify_axis(peerContext->item.seat, weston_compositor_get_time(), timespec_from_msec(&time, weston_compositor_get_time());
&weston_event);
notify_axis(peerContext->item.seat, &time, &weston_event);
need_frame = true; need_frame = true;
} }
......
...@@ -1696,6 +1696,7 @@ input_handle_axis(void *data, struct wl_pointer *pointer, ...@@ -1696,6 +1696,7 @@ input_handle_axis(void *data, struct wl_pointer *pointer,
{ {
struct wayland_input *input = data; struct wayland_input *input = data;
struct weston_pointer_axis_event weston_event; struct weston_pointer_axis_event weston_event;
struct timespec ts;
weston_event.axis = axis; weston_event.axis = axis;
weston_event.value = wl_fixed_to_double(value); weston_event.value = wl_fixed_to_double(value);
...@@ -1712,7 +1713,9 @@ input_handle_axis(void *data, struct wl_pointer *pointer, ...@@ -1712,7 +1713,9 @@ input_handle_axis(void *data, struct wl_pointer *pointer,
input->horiz.has_discrete = false; 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) if (input->seat_version < WL_POINTER_FRAME_SINCE_VERSION)
notify_pointer_frame(&input->base); notify_pointer_frame(&input->base);
...@@ -1741,11 +1744,14 @@ input_handle_axis_stop(void *data, struct wl_pointer *pointer, ...@@ -1741,11 +1744,14 @@ input_handle_axis_stop(void *data, struct wl_pointer *pointer,
{ {
struct wayland_input *input = data; struct wayland_input *input = data;
struct weston_pointer_axis_event weston_event; struct weston_pointer_axis_event weston_event;
struct timespec ts;
weston_event.axis = axis; weston_event.axis = axis;
weston_event.value = 0; 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 static void
......
...@@ -1178,9 +1178,8 @@ x11_backend_deliver_button_event(struct x11_backend *b, ...@@ -1178,9 +1178,8 @@ x11_backend_deliver_button_event(struct x11_backend *b,
weston_event.has_discrete = true; weston_event.has_discrete = true;
weston_event.axis = weston_event.axis =
WL_POINTER_AXIS_VERTICAL_SCROLL; WL_POINTER_AXIS_VERTICAL_SCROLL;
notify_axis(&b->core_seat, timespec_from_msec(&time, weston_compositor_get_time());
weston_compositor_get_time(), notify_axis(&b->core_seat, &time, &weston_event);
&weston_event);
notify_pointer_frame(&b->core_seat); notify_pointer_frame(&b->core_seat);
} }
return; return;
...@@ -1191,9 +1190,8 @@ x11_backend_deliver_button_event(struct x11_backend *b, ...@@ -1191,9 +1190,8 @@ x11_backend_deliver_button_event(struct x11_backend *b,
weston_event.has_discrete = true; weston_event.has_discrete = true;
weston_event.axis = weston_event.axis =
WL_POINTER_AXIS_VERTICAL_SCROLL; WL_POINTER_AXIS_VERTICAL_SCROLL;
notify_axis(&b->core_seat, timespec_from_msec(&time, weston_compositor_get_time());
weston_compositor_get_time(), notify_axis(&b->core_seat, &time, &weston_event);
&weston_event);
notify_pointer_frame(&b->core_seat); notify_pointer_frame(&b->core_seat);
} }
return; return;
...@@ -1204,9 +1202,8 @@ x11_backend_deliver_button_event(struct x11_backend *b, ...@@ -1204,9 +1202,8 @@ x11_backend_deliver_button_event(struct x11_backend *b,
weston_event.has_discrete = true; weston_event.has_discrete = true;
weston_event.axis = weston_event.axis =
WL_POINTER_AXIS_HORIZONTAL_SCROLL; WL_POINTER_AXIS_HORIZONTAL_SCROLL;
notify_axis(&b->core_seat, timespec_from_msec(&time, weston_compositor_get_time());
weston_compositor_get_time(), notify_axis(&b->core_seat, &time, &weston_event);
&weston_event);
notify_pointer_frame(&b->core_seat); notify_pointer_frame(&b->core_seat);
} }
return; return;
...@@ -1217,9 +1214,8 @@ x11_backend_deliver_button_event(struct x11_backend *b, ...@@ -1217,9 +1214,8 @@ x11_backend_deliver_button_event(struct x11_backend *b,
weston_event.has_discrete = true; weston_event.has_discrete = true;
weston_event.axis = weston_event.axis =
WL_POINTER_AXIS_HORIZONTAL_SCROLL; WL_POINTER_AXIS_HORIZONTAL_SCROLL;
notify_axis(&b->core_seat, timespec_from_msec(&time, weston_compositor_get_time());
weston_compositor_get_time(), notify_axis(&b->core_seat, &time, &weston_event);
&weston_event);
notify_pointer_frame(&b->core_seat); notify_pointer_frame(&b->core_seat);
} }
return; return;
......
...@@ -275,7 +275,7 @@ struct weston_pointer_grab_interface { ...@@ -275,7 +275,7 @@ struct weston_pointer_grab_interface {
const struct timespec *time, const struct timespec *time,
uint32_t button, uint32_t state); uint32_t button, uint32_t state);
void (*axis)(struct weston_pointer_grab *grab, void (*axis)(struct weston_pointer_grab *grab,
uint32_t time, const struct timespec *time,
struct weston_pointer_axis_event *event); struct weston_pointer_axis_event *event);
void (*axis_source)(struct weston_pointer_grab *grab, uint32_t source); void (*axis_source)(struct weston_pointer_grab *grab, uint32_t source);
void (*frame)(struct weston_pointer_grab *grab); void (*frame)(struct weston_pointer_grab *grab);
...@@ -436,7 +436,7 @@ weston_pointer_send_button(struct weston_pointer *pointer, ...@@ -436,7 +436,7 @@ weston_pointer_send_button(struct weston_pointer *pointer,
uint32_t button, uint32_t state_w); uint32_t button, uint32_t state_w);
void void
weston_pointer_send_axis(struct weston_pointer *pointer, weston_pointer_send_axis(struct weston_pointer *pointer,
uint32_t time, const struct timespec *time,
struct weston_pointer_axis_event *event); struct weston_pointer_axis_event *event);
void void
weston_pointer_send_axis_source(struct weston_pointer *pointer, weston_pointer_send_axis_source(struct weston_pointer *pointer,
...@@ -1376,7 +1376,7 @@ void ...@@ -1376,7 +1376,7 @@ void
notify_button(struct weston_seat *seat, const struct timespec *time, notify_button(struct weston_seat *seat, const struct timespec *time,
int32_t button, enum wl_pointer_button_state state); int32_t button, enum wl_pointer_button_state state);
void 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_pointer_axis_event *event);
void void
notify_axis_source(struct weston_seat *seat, uint32_t source); notify_axis_source(struct weston_seat *seat, uint32_t source);
...@@ -1514,7 +1514,7 @@ weston_compositor_add_touch_binding(struct weston_compositor *compositor, ...@@ -1514,7 +1514,7 @@ weston_compositor_add_touch_binding(struct weston_compositor *compositor,
void *data); void *data);
typedef void (*weston_axis_binding_handler_t)(struct weston_pointer *pointer, typedef void (*weston_axis_binding_handler_t)(struct weston_pointer *pointer,
uint32_t time, const struct timespec *time,
struct weston_pointer_axis_event *event, struct weston_pointer_axis_event *event,
void *data); void *data);
struct weston_binding * struct weston_binding *
...@@ -1562,7 +1562,8 @@ weston_compositor_run_touch_binding(struct weston_compositor *compositor, ...@@ -1562,7 +1562,8 @@ weston_compositor_run_touch_binding(struct weston_compositor *compositor,
int touch_type); int touch_type);
int int
weston_compositor_run_axis_binding(struct weston_compositor *compositor, 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); struct weston_pointer_axis_event *event);
int int
weston_compositor_run_debug_binding(struct weston_compositor *compositor, weston_compositor_run_debug_binding(struct weston_compositor *compositor,
......
...@@ -680,7 +680,8 @@ drag_grab_button(struct weston_pointer_grab *grab, ...@@ -680,7 +680,8 @@ drag_grab_button(struct weston_pointer_grab *grab,
static void static void
drag_grab_axis(struct weston_pointer_grab *grab, 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)
{ {
} }
......
...@@ -514,16 +514,18 @@ default_grab_pointer_button(struct weston_pointer_grab *grab, ...@@ -514,16 +514,18 @@ default_grab_pointer_button(struct weston_pointer_grab *grab,
*/ */
WL_EXPORT void WL_EXPORT void
weston_pointer_send_axis(struct weston_pointer *pointer, weston_pointer_send_axis(struct weston_pointer *pointer,
uint32_t time, const struct timespec *time,
struct weston_pointer_axis_event *event) struct weston_pointer_axis_event *event)
{ {
struct wl_resource *resource; struct wl_resource *resource;
struct wl_list *resource_list; struct wl_list *resource_list;
uint32_t msecs;
if (!weston_pointer_has_focus_resource(pointer)) if (!weston_pointer_has_focus_resource(pointer))
return; return;
resource_list = &pointer->focus_client->pointer_resources; resource_list = &pointer->focus_client->pointer_resources;
msecs = timespec_to_msec(time);
wl_resource_for_each(resource, resource_list) { wl_resource_for_each(resource, resource_list) {
if (event->has_discrete && if (event->has_discrete &&
wl_resource_get_version(resource) >= wl_resource_get_version(resource) >=
...@@ -532,12 +534,12 @@ weston_pointer_send_axis(struct weston_pointer *pointer, ...@@ -532,12 +534,12 @@ weston_pointer_send_axis(struct weston_pointer *pointer,
event->discrete); event->discrete);
if (event->value) if (event->value)
wl_pointer_send_axis(resource, time, wl_pointer_send_axis(resource, msecs,
event->axis, event->axis,
wl_fixed_from_double(event->value)); wl_fixed_from_double(event->value));
else if (wl_resource_get_version(resource) >= else if (wl_resource_get_version(resource) >=
WL_POINTER_AXIS_STOP_SINCE_VERSION) WL_POINTER_AXIS_STOP_SINCE_VERSION)
wl_pointer_send_axis_stop(resource, time, wl_pointer_send_axis_stop(resource, msecs,
event->axis); event->axis);
} }
} }
...@@ -603,7 +605,7 @@ weston_pointer_send_frame(struct weston_pointer *pointer) ...@@ -603,7 +605,7 @@ weston_pointer_send_frame(struct weston_pointer *pointer)
static void static void
default_grab_pointer_axis(struct weston_pointer_grab *grab, default_grab_pointer_axis(struct weston_pointer_grab *grab,
uint32_t time, const struct timespec *time,
struct weston_pointer_axis_event *event) struct weston_pointer_axis_event *event)
{ {
weston_pointer_send_axis(grab->pointer, time, event); weston_pointer_send_axis(grab->pointer, time, event);
...@@ -1685,7 +1687,7 @@ notify_button(struct weston_seat *seat, const struct timespec *time, ...@@ -1685,7 +1687,7 @@ notify_button(struct weston_seat *seat, const struct timespec *time,
} }
WL_EXPORT void 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_pointer_axis_event *event)
{ {
struct weston_compositor *compositor = seat->compositor; struct weston_compositor *compositor = seat->compositor;
...@@ -3339,7 +3341,7 @@ locked_pointer_grab_pointer_button(struct weston_pointer_grab *grab, ...@@ -3339,7 +3341,7 @@ locked_pointer_grab_pointer_button(struct weston_pointer_grab *grab,
static void static void
locked_pointer_grab_pointer_axis(struct weston_pointer_grab *grab, locked_pointer_grab_pointer_axis(struct weston_pointer_grab *grab,
uint32_t time, const struct timespec *time,
struct weston_pointer_axis_event *event) struct weston_pointer_axis_event *event)
{ {
weston_pointer_send_axis(grab->pointer, time, event); weston_pointer_send_axis(grab->pointer, time, event);
...@@ -4347,7 +4349,7 @@ confined_pointer_grab_pointer_button(struct weston_pointer_grab *grab, ...@@ -4347,7 +4349,7 @@ confined_pointer_grab_pointer_button(struct weston_pointer_grab *grab,
static void static void
confined_pointer_grab_pointer_axis(struct weston_pointer_grab *grab, confined_pointer_grab_pointer_axis(struct weston_pointer_grab *grab,
uint32_t time, const struct timespec *time,
struct weston_pointer_axis_event *event) struct weston_pointer_axis_event *event)
{ {
weston_pointer_send_axis(grab->pointer, time, event); weston_pointer_send_axis(grab->pointer, time, event);
......
...@@ -230,6 +230,7 @@ handle_pointer_axis(struct libinput_device *libinput_device, ...@@ -230,6 +230,7 @@ handle_pointer_axis(struct libinput_device *libinput_device,
enum libinput_pointer_axis_source source; enum libinput_pointer_axis_source source;
uint32_t wl_axis_source; uint32_t wl_axis_source;
bool has_vert, has_horiz; bool has_vert, has_horiz;
struct timespec time;
has_vert = libinput_event_pointer_has_axis(pointer_event, has_vert = libinput_event_pointer_has_axis(pointer_event,
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL); LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL);
...@@ -260,6 +261,9 @@ handle_pointer_axis(struct libinput_device *libinput_device, ...@@ -260,6 +261,9 @@ handle_pointer_axis(struct libinput_device *libinput_device,
notify_axis_source(device->seat, wl_axis_source); notify_axis_source(device->seat, wl_axis_source);
timespec_from_usec(&time,
libinput_event_pointer_get_time_usec(pointer_event));
if (has_vert) { if (has_vert) {
axis = LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL; axis = LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL;
vert_discrete = get_axis_discrete(pointer_event, axis); vert_discrete = get_axis_discrete(pointer_event, axis);
...@@ -270,9 +274,7 @@ handle_pointer_axis(struct libinput_device *libinput_device, ...@@ -270,9 +274,7 @@ handle_pointer_axis(struct libinput_device *libinput_device,
weston_event.discrete = vert_discrete; weston_event.discrete = vert_discrete;
weston_event.has_discrete = (vert_discrete != 0); weston_event.has_discrete = (vert_discrete != 0);
notify_axis(device->seat, notify_axis(device->seat, &time, &weston_event);
libinput_event_pointer_get_time(pointer_event),
&weston_event);
} }
if (has_horiz) { if (has_horiz) {
...@@ -285,9 +287,7 @@ handle_pointer_axis(struct libinput_device *libinput_device, ...@@ -285,9 +287,7 @@ handle_pointer_axis(struct libinput_device *libinput_device,
weston_event.discrete = horiz_discrete; weston_event.discrete = horiz_discrete;
weston_event.has_discrete = (horiz_discrete != 0); weston_event.has_discrete = (horiz_discrete != 0);
notify_axis(device->seat, notify_axis(device->seat, &time, &weston_event);
libinput_event_pointer_get_time(pointer_event),
&weston_event);
} }
return true; return true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment