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>
This commit is contained in:
parent
47e79c860b
commit
9448deb073
@ -1331,7 +1331,8 @@ take_surface_to_workspace_by_seat(struct desktop_shell *shell,
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
}
|
||||
@ -3274,7 +3275,7 @@ fullscreen_binding(struct weston_keyboard *keyboard,
|
||||
}
|
||||
|
||||
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 *surface;
|
||||
@ -3774,7 +3775,8 @@ click_to_activate_binding(struct weston_pointer *pointer,
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if (touch->grab != &touch->default_grab)
|
||||
|
@ -1584,7 +1584,8 @@ pointer_move_workspace_grab_button(struct weston_pointer_grab *grab,
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
@ -463,7 +463,8 @@ click_to_activate_binding(struct weston_pointer *pointer,
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if (touch->grab != &touch->default_grab)
|
||||
|
@ -180,7 +180,8 @@ static const struct weston_pointer_grab_interface weston_desktop_seat_pointer_po
|
||||
|
||||
static void
|
||||
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)
|
||||
{
|
||||
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
|
||||
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)
|
||||
{
|
||||
struct weston_binding *b, *tmp;
|
||||
|
@ -1974,10 +1974,13 @@ input_handle_touch_down(void *data, struct wl_touch *wl_touch,
|
||||
bool first_touch;
|
||||
int32_t fx, fy;
|
||||
double x, y;
|
||||
struct timespec ts;
|
||||
|
||||
x = wl_fixed_to_double(fixed_x);
|
||||
y = wl_fixed_to_double(fixed_y);
|
||||
|
||||
timespec_from_msec(&ts, time);
|
||||
|
||||
first_touch = (input->touch_points == 0);
|
||||
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);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -2026,6 +2029,9 @@ input_handle_touch_up(void *data, struct wl_touch *wl_touch,
|
||||
struct wayland_input *input = data;
|
||||
struct wayland_output *output = input->touch_focus;
|
||||
bool active = input->touch_active;
|
||||
struct timespec ts;
|
||||
|
||||
timespec_from_msec(&ts, time);
|
||||
|
||||
input->touch_points--;
|
||||
if (input->touch_points == 0) {
|
||||
@ -2053,7 +2059,7 @@ input_handle_touch_up(void *data, struct wl_touch *wl_touch,
|
||||
}
|
||||
|
||||
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
|
||||
@ -2065,9 +2071,11 @@ input_handle_touch_motion(void *data, struct wl_touch *wl_touch,
|
||||
struct wayland_output *output = input->touch_focus;
|
||||
int32_t fx, fy;
|
||||
double x, y;
|
||||
struct timespec ts;
|
||||
|
||||
x = wl_fixed_to_double(fixed_x);
|
||||
y = wl_fixed_to_double(fixed_y);
|
||||
timespec_from_msec(&ts, time);
|
||||
|
||||
if (!output || !input->touch_active)
|
||||
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);
|
||||
|
||||
notify_touch(&input->base, time, id, x, y, WL_TOUCH_MOTION);
|
||||
notify_touch(&input->base, &ts, id, x, y, WL_TOUCH_MOTION);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -305,7 +305,7 @@ struct weston_keyboard_grab {
|
||||
struct weston_touch_grab;
|
||||
struct weston_touch_grab_interface {
|
||||
void (*down)(struct weston_touch_grab *grab,
|
||||
uint32_t time,
|
||||
const struct timespec *time,
|
||||
int touch_id,
|
||||
wl_fixed_t sx,
|
||||
wl_fixed_t sy);
|
||||
@ -412,7 +412,7 @@ struct weston_touch {
|
||||
int grab_touch_id;
|
||||
wl_fixed_t grab_x, grab_y;
|
||||
uint32_t grab_serial;
|
||||
uint32_t grab_time;
|
||||
struct timespec grab_time;
|
||||
};
|
||||
|
||||
void
|
||||
@ -516,7 +516,7 @@ weston_touch_end_grab(struct weston_touch *touch);
|
||||
bool
|
||||
weston_touch_has_focus_resource(struct weston_touch *touch);
|
||||
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);
|
||||
void
|
||||
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);
|
||||
|
||||
void
|
||||
notify_touch(struct weston_seat *seat, uint32_t time, int touch_id,
|
||||
double x, double y, int touch_type);
|
||||
notify_touch(struct weston_seat *seat, const struct timespec *time,
|
||||
int touch_id, double x, double y, int touch_type);
|
||||
void
|
||||
notify_touch_frame(struct weston_seat *seat);
|
||||
|
||||
@ -1506,7 +1506,7 @@ weston_compositor_add_button_binding(struct weston_compositor *compositor,
|
||||
void *data);
|
||||
|
||||
typedef void (*weston_touch_binding_handler_t)(struct weston_touch *touch,
|
||||
uint32_t time,
|
||||
const struct timespec *time,
|
||||
void *data);
|
||||
struct weston_binding *
|
||||
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);
|
||||
void
|
||||
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
|
||||
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
|
||||
drag_grab_touch_down(struct weston_touch_grab *grab, uint32_t time,
|
||||
int touch_id, wl_fixed_t sx, wl_fixed_t sy)
|
||||
drag_grab_touch_down(struct weston_touch_grab *grab,
|
||||
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.
|
||||
*/
|
||||
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)
|
||||
{
|
||||
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_list *resource_list;
|
||||
wl_fixed_t sx, sy;
|
||||
uint32_t msecs;
|
||||
|
||||
if (!weston_touch_has_focus_resource(touch))
|
||||
return;
|
||||
@ -686,15 +687,17 @@ weston_touch_send_down(struct weston_touch *touch, uint32_t time,
|
||||
|
||||
resource_list = &touch->focus_resource_list;
|
||||
serial = wl_display_next_serial(display);
|
||||
msecs = timespec_to_msec(time);
|
||||
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_id, sx, sy);
|
||||
}
|
||||
|
||||
static void
|
||||
default_grab_touch_down(struct weston_touch_grab *grab, uint32_t time,
|
||||
int touch_id, wl_fixed_t x, wl_fixed_t y)
|
||||
default_grab_touch_down(struct weston_touch_grab *grab,
|
||||
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);
|
||||
}
|
||||
@ -2140,8 +2143,8 @@ 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,
|
||||
double double_x, double double_y, int touch_type)
|
||||
notify_touch(struct weston_seat *seat, const struct timespec *time,
|
||||
int touch_id, double double_x, double double_y, int touch_type)
|
||||
{
|
||||
struct weston_compositor *ec = seat->compositor;
|
||||
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 =
|
||||
wl_display_get_serial(ec->wl_display);
|
||||
touch->grab_touch_id = touch_id;
|
||||
touch->grab_time = time;
|
||||
touch->grab_time = *time;
|
||||
touch->grab_x = x;
|
||||
touch->grab_y = y;
|
||||
}
|
||||
@ -2197,7 +2200,8 @@ notify_touch(struct weston_seat *seat, uint32_t time, int touch_id,
|
||||
if (!ev)
|
||||
break;
|
||||
|
||||
grab->interface->motion(grab, time, touch_id, x, y);
|
||||
grab->interface->motion(grab, timespec_to_msec(time),
|
||||
touch_id, x, y);
|
||||
break;
|
||||
case WL_TOUCH_UP:
|
||||
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);
|
||||
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)
|
||||
weston_touch_set_focus(touch, NULL);
|
||||
break;
|
||||
|
@ -306,13 +306,14 @@ handle_touch_with_coords(struct libinput_device *libinput_device,
|
||||
double x;
|
||||
double y;
|
||||
uint32_t width, height;
|
||||
uint32_t time;
|
||||
struct timespec time;
|
||||
int32_t slot;
|
||||
|
||||
if (!device->output)
|
||||
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);
|
||||
|
||||
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,
|
||||
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
|
||||
@ -346,10 +347,13 @@ handle_touch_up(struct libinput_device *libinput_device,
|
||||
{
|
||||
struct evdev_device *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);
|
||||
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user