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 <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
dev
Alexandros Frantzis 7 years ago committed by Pekka Paalanen
parent 215bedc88b
commit 80321942e7
  1. 5
      compositor/screen-share.c
  2. 3
      desktop-shell/exposay.c
  3. 18
      desktop-shell/shell.c
  4. 2
      ivi-shell/hmi-controller.c
  5. 2
      libweston-desktop/seat.c
  6. 2
      libweston/bindings.c
  7. 5
      libweston/compositor-rdp.c
  8. 10
      libweston/compositor-wayland.c
  9. 20
      libweston/compositor-x11.c
  10. 11
      libweston/compositor.h
  11. 3
      libweston/data-device.c
  12. 16
      libweston/input.c
  13. 12
      libweston/libinput-device.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);
}

@ -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)
{
}

@ -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

@ -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);

@ -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);

@ -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;

@ -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;
}

@ -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

@ -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;

@ -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,

@ -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)
{
}

@ -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);

@ -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;

Loading…
Cancel
Save