libweston: Use struct timespec for touch down events

Change code related to touch down 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 47e79c860b
commit 9448deb073
  1. 8
      desktop-shell/shell.c
  2. 3
      ivi-shell/hmi-controller.c
  3. 3
      ivi-shell/ivi-shell.c
  4. 3
      libweston-desktop/seat.c
  5. 3
      libweston/bindings.c
  6. 14
      libweston/compositor-wayland.c
  7. 15
      libweston/compositor.h
  8. 5
      libweston/data-device.c
  9. 22
      libweston/input.c
  10. 14
      libweston/libinput-device.c

@ -1331,7 +1331,8 @@ take_surface_to_workspace_by_seat(struct desktop_shell *shell,
} }
static void static void
touch_move_grab_down(struct weston_touch_grab *grab, uint32_t time, touch_move_grab_down(struct weston_touch_grab *grab,
const struct timespec *time,
int touch_id, wl_fixed_t x, wl_fixed_t y) int touch_id, wl_fixed_t x, wl_fixed_t y)
{ {
} }
@ -3274,7 +3275,7 @@ fullscreen_binding(struct weston_keyboard *keyboard,
} }
static void static void
touch_move_binding(struct weston_touch *touch, uint32_t time, void *data) touch_move_binding(struct weston_touch *touch, const struct timespec *time, void *data)
{ {
struct weston_surface *focus; struct weston_surface *focus;
struct weston_surface *surface; struct weston_surface *surface;
@ -3774,7 +3775,8 @@ click_to_activate_binding(struct weston_pointer *pointer,
} }
static void static void
touch_to_activate_binding(struct weston_touch *touch, uint32_t time, touch_to_activate_binding(struct weston_touch *touch,
const struct timespec *time,
void *data) void *data)
{ {
if (touch->grab != &touch->default_grab) if (touch->grab != &touch->default_grab)

@ -1584,7 +1584,8 @@ pointer_move_workspace_grab_button(struct weston_pointer_grab *grab,
} }
static void static void
touch_nope_grab_down(struct weston_touch_grab *grab, uint32_t time, touch_nope_grab_down(struct weston_touch_grab *grab,
const struct timespec *time,
int touch_id, wl_fixed_t sx, wl_fixed_t sy) int touch_id, wl_fixed_t sx, wl_fixed_t sy)
{ {
} }

@ -463,7 +463,8 @@ click_to_activate_binding(struct weston_pointer *pointer,
} }
static void static void
touch_to_activate_binding(struct weston_touch *touch, uint32_t time, touch_to_activate_binding(struct weston_touch *touch,
const struct timespec *time,
void *data) void *data)
{ {
if (touch->grab != &touch->default_grab) if (touch->grab != &touch->default_grab)

@ -180,7 +180,8 @@ static const struct weston_pointer_grab_interface weston_desktop_seat_pointer_po
static void static void
weston_desktop_seat_popup_grab_touch_down(struct weston_touch_grab *grab, weston_desktop_seat_popup_grab_touch_down(struct weston_touch_grab *grab,
uint32_t time, int touch_id, const struct timespec *time,
int touch_id,
wl_fixed_t sx, wl_fixed_t sy) wl_fixed_t sx, wl_fixed_t sy)
{ {
weston_touch_send_down(grab->touch, time, touch_id, sx, sy); weston_touch_send_down(grab->touch, time, touch_id, sx, sy);

@ -377,7 +377,8 @@ weston_compositor_run_button_binding(struct weston_compositor *compositor,
void void
weston_compositor_run_touch_binding(struct weston_compositor *compositor, weston_compositor_run_touch_binding(struct weston_compositor *compositor,
struct weston_touch *touch, uint32_t time, struct weston_touch *touch,
const struct timespec *time,
int touch_type) int touch_type)
{ {
struct weston_binding *b, *tmp; struct weston_binding *b, *tmp;

@ -1974,10 +1974,13 @@ input_handle_touch_down(void *data, struct wl_touch *wl_touch,
bool first_touch; bool first_touch;
int32_t fx, fy; int32_t fx, fy;
double x, y; double x, y;
struct timespec ts;
x = wl_fixed_to_double(fixed_x); x = wl_fixed_to_double(fixed_x);
y = wl_fixed_to_double(fixed_y); y = wl_fixed_to_double(fixed_y);
timespec_from_msec(&ts, time);
first_touch = (input->touch_points == 0); first_touch = (input->touch_points == 0);
input->touch_points++; input->touch_points++;
@ -2015,7 +2018,7 @@ input_handle_touch_down(void *data, struct wl_touch *wl_touch,
weston_output_transform_coordinate(&output->base, x, y, &x, &y); weston_output_transform_coordinate(&output->base, x, y, &x, &y);
notify_touch(&input->base, time, id, x, y, WL_TOUCH_DOWN); notify_touch(&input->base, &ts, id, x, y, WL_TOUCH_DOWN);
input->touch_active = true; input->touch_active = true;
} }
@ -2026,6 +2029,9 @@ input_handle_touch_up(void *data, struct wl_touch *wl_touch,
struct wayland_input *input = data; struct wayland_input *input = data;
struct wayland_output *output = input->touch_focus; struct wayland_output *output = input->touch_focus;
bool active = input->touch_active; bool active = input->touch_active;
struct timespec ts;
timespec_from_msec(&ts, time);
input->touch_points--; input->touch_points--;
if (input->touch_points == 0) { if (input->touch_points == 0) {
@ -2053,7 +2059,7 @@ input_handle_touch_up(void *data, struct wl_touch *wl_touch,
} }
if (active) if (active)
notify_touch(&input->base, time, id, 0, 0, WL_TOUCH_UP); notify_touch(&input->base, &ts, id, 0, 0, WL_TOUCH_UP);
} }
static void static void
@ -2065,9 +2071,11 @@ input_handle_touch_motion(void *data, struct wl_touch *wl_touch,
struct wayland_output *output = input->touch_focus; struct wayland_output *output = input->touch_focus;
int32_t fx, fy; int32_t fx, fy;
double x, y; double x, y;
struct timespec ts;
x = wl_fixed_to_double(fixed_x); x = wl_fixed_to_double(fixed_x);
y = wl_fixed_to_double(fixed_y); y = wl_fixed_to_double(fixed_y);
timespec_from_msec(&ts, time);
if (!output || !input->touch_active) if (!output || !input->touch_active)
return; return;
@ -2080,7 +2088,7 @@ input_handle_touch_motion(void *data, struct wl_touch *wl_touch,
weston_output_transform_coordinate(&output->base, x, y, &x, &y); weston_output_transform_coordinate(&output->base, x, y, &x, &y);
notify_touch(&input->base, time, id, x, y, WL_TOUCH_MOTION); notify_touch(&input->base, &ts, id, x, y, WL_TOUCH_MOTION);
} }
static void static void

@ -305,7 +305,7 @@ struct weston_keyboard_grab {
struct weston_touch_grab; struct weston_touch_grab;
struct weston_touch_grab_interface { struct weston_touch_grab_interface {
void (*down)(struct weston_touch_grab *grab, void (*down)(struct weston_touch_grab *grab,
uint32_t time, const struct timespec *time,
int touch_id, int touch_id,
wl_fixed_t sx, wl_fixed_t sx,
wl_fixed_t sy); wl_fixed_t sy);
@ -412,7 +412,7 @@ struct weston_touch {
int grab_touch_id; int grab_touch_id;
wl_fixed_t grab_x, grab_y; wl_fixed_t grab_x, grab_y;
uint32_t grab_serial; uint32_t grab_serial;
uint32_t grab_time; struct timespec grab_time;
}; };
void void
@ -516,7 +516,7 @@ weston_touch_end_grab(struct weston_touch *touch);
bool bool
weston_touch_has_focus_resource(struct weston_touch *touch); weston_touch_has_focus_resource(struct weston_touch *touch);
void void
weston_touch_send_down(struct weston_touch *touch, uint32_t time, weston_touch_send_down(struct weston_touch *touch, const struct timespec *time,
int touch_id, wl_fixed_t x, wl_fixed_t y); int touch_id, wl_fixed_t x, wl_fixed_t y);
void void
weston_touch_send_up(struct weston_touch *touch, uint32_t time, int touch_id); weston_touch_send_up(struct weston_touch *touch, uint32_t time, int touch_id);
@ -1402,8 +1402,8 @@ void
notify_keyboard_focus_out(struct weston_seat *seat); notify_keyboard_focus_out(struct weston_seat *seat);
void void
notify_touch(struct weston_seat *seat, uint32_t time, int touch_id, notify_touch(struct weston_seat *seat, const struct timespec *time,
double x, double y, int touch_type); int touch_id, double x, double y, int touch_type);
void void
notify_touch_frame(struct weston_seat *seat); notify_touch_frame(struct weston_seat *seat);
@ -1506,7 +1506,7 @@ weston_compositor_add_button_binding(struct weston_compositor *compositor,
void *data); void *data);
typedef void (*weston_touch_binding_handler_t)(struct weston_touch *touch, typedef void (*weston_touch_binding_handler_t)(struct weston_touch *touch,
uint32_t time, const struct timespec *time,
void *data); void *data);
struct weston_binding * struct weston_binding *
weston_compositor_add_touch_binding(struct weston_compositor *compositor, weston_compositor_add_touch_binding(struct weston_compositor *compositor,
@ -1559,7 +1559,8 @@ weston_compositor_run_button_binding(struct weston_compositor *compositor,
enum wl_pointer_button_state value); enum wl_pointer_button_state value);
void void
weston_compositor_run_touch_binding(struct weston_compositor *compositor, weston_compositor_run_touch_binding(struct weston_compositor *compositor,
struct weston_touch *touch, uint32_t time, struct weston_touch *touch,
const struct timespec *time,
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,

@ -718,8 +718,9 @@ static const struct weston_pointer_grab_interface pointer_drag_grab_interface =
}; };
static void static void
drag_grab_touch_down(struct weston_touch_grab *grab, uint32_t time, drag_grab_touch_down(struct weston_touch_grab *grab,
int touch_id, wl_fixed_t sx, wl_fixed_t sy) const struct timespec *time, int touch_id,
wl_fixed_t sx, wl_fixed_t sy)
{ {
} }

@ -670,7 +670,7 @@ weston_touch_has_focus_resource(struct weston_touch *touch)
* resources of the client which currently has the surface with touch focus. * resources of the client which currently has the surface with touch focus.
*/ */
WL_EXPORT void WL_EXPORT void
weston_touch_send_down(struct weston_touch *touch, uint32_t time, weston_touch_send_down(struct weston_touch *touch, const struct timespec *time,
int touch_id, wl_fixed_t x, wl_fixed_t y) int touch_id, wl_fixed_t x, wl_fixed_t y)
{ {
struct wl_display *display = touch->seat->compositor->wl_display; struct wl_display *display = touch->seat->compositor->wl_display;
@ -678,6 +678,7 @@ weston_touch_send_down(struct weston_touch *touch, uint32_t time,
struct wl_resource *resource; struct wl_resource *resource;
struct wl_list *resource_list; struct wl_list *resource_list;
wl_fixed_t sx, sy; wl_fixed_t sx, sy;
uint32_t msecs;
if (!weston_touch_has_focus_resource(touch)) if (!weston_touch_has_focus_resource(touch))
return; return;
@ -686,15 +687,17 @@ weston_touch_send_down(struct weston_touch *touch, uint32_t time,
resource_list = &touch->focus_resource_list; resource_list = &touch->focus_resource_list;
serial = wl_display_next_serial(display); serial = wl_display_next_serial(display);
msecs = timespec_to_msec(time);
wl_resource_for_each(resource, resource_list) wl_resource_for_each(resource, resource_list)
wl_touch_send_down(resource, serial, time, wl_touch_send_down(resource, serial, msecs,
touch->focus->surface->resource, touch->focus->surface->resource,
touch_id, sx, sy); touch_id, sx, sy);
} }
static void static void
default_grab_touch_down(struct weston_touch_grab *grab, uint32_t time, default_grab_touch_down(struct weston_touch_grab *grab,
int touch_id, wl_fixed_t x, wl_fixed_t y) const struct timespec *time, int touch_id,
wl_fixed_t x, wl_fixed_t y)
{ {
weston_touch_send_down(grab->touch, time, touch_id, x, y); weston_touch_send_down(grab->touch, time, touch_id, x, y);
} }
@ -2140,8 +2143,8 @@ weston_touch_set_focus(struct weston_touch *touch, struct weston_view *view)
* *
*/ */
WL_EXPORT void WL_EXPORT void
notify_touch(struct weston_seat *seat, uint32_t time, int touch_id, notify_touch(struct weston_seat *seat, const struct timespec *time,
double double_x, double double_y, int touch_type) int touch_id, double double_x, double double_y, int touch_type)
{ {
struct weston_compositor *ec = seat->compositor; struct weston_compositor *ec = seat->compositor;
struct weston_touch *touch = weston_seat_get_touch(seat); struct weston_touch *touch = weston_seat_get_touch(seat);
@ -2186,7 +2189,7 @@ notify_touch(struct weston_seat *seat, uint32_t time, int touch_id,
touch->grab_serial = touch->grab_serial =
wl_display_get_serial(ec->wl_display); wl_display_get_serial(ec->wl_display);
touch->grab_touch_id = touch_id; touch->grab_touch_id = touch_id;
touch->grab_time = time; touch->grab_time = *time;
touch->grab_x = x; touch->grab_x = x;
touch->grab_y = y; touch->grab_y = y;
} }
@ -2197,7 +2200,8 @@ notify_touch(struct weston_seat *seat, uint32_t time, int touch_id,
if (!ev) if (!ev)
break; break;
grab->interface->motion(grab, time, touch_id, x, y); grab->interface->motion(grab, timespec_to_msec(time),
touch_id, x, y);
break; break;
case WL_TOUCH_UP: case WL_TOUCH_UP:
if (touch->num_tp == 0) { if (touch->num_tp == 0) {
@ -2211,7 +2215,7 @@ notify_touch(struct weston_seat *seat, uint32_t time, int touch_id,
weston_compositor_idle_release(ec); weston_compositor_idle_release(ec);
touch->num_tp--; touch->num_tp--;
grab->interface->up(grab, time, touch_id); grab->interface->up(grab, timespec_to_msec(time), touch_id);
if (touch->num_tp == 0) if (touch->num_tp == 0)
weston_touch_set_focus(touch, NULL); weston_touch_set_focus(touch, NULL);
break; break;

@ -306,13 +306,14 @@ handle_touch_with_coords(struct libinput_device *libinput_device,
double x; double x;
double y; double y;
uint32_t width, height; uint32_t width, height;
uint32_t time; struct timespec time;
int32_t slot; int32_t slot;
if (!device->output) if (!device->output)
return; return;
time = libinput_event_touch_get_time(touch_event); timespec_from_usec(&time,
libinput_event_touch_get_time_usec(touch_event));
slot = libinput_event_touch_get_seat_slot(touch_event); slot = libinput_event_touch_get_seat_slot(touch_event);
width = device->output->current_mode->width; width = device->output->current_mode->width;
@ -323,7 +324,7 @@ handle_touch_with_coords(struct libinput_device *libinput_device,
weston_output_transform_coordinate(device->output, weston_output_transform_coordinate(device->output,
x, y, &x, &y); x, y, &x, &y);
notify_touch(device->seat, time, slot, x, y, touch_type); notify_touch(device->seat, &time, slot, x, y, touch_type);
} }
static void static void
@ -346,10 +347,13 @@ handle_touch_up(struct libinput_device *libinput_device,
{ {
struct evdev_device *device = struct evdev_device *device =
libinput_device_get_user_data(libinput_device); libinput_device_get_user_data(libinput_device);
uint32_t time = libinput_event_touch_get_time(touch_event); struct timespec time;
int32_t slot = libinput_event_touch_get_seat_slot(touch_event); int32_t slot = libinput_event_touch_get_seat_slot(touch_event);
notify_touch(device->seat, time, slot, 0, 0, WL_TOUCH_UP); timespec_from_usec(&time,
libinput_event_touch_get_time_usec(touch_event));
notify_touch(device->seat, &time, slot, 0, 0, WL_TOUCH_UP);
} }
static void static void

Loading…
Cancel
Save