libweston: Use struct timespec for button events

Change code related to button 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 84b31f8956
commit 215bedc88b
  1. 5
      compositor/screen-share.c
  2. 4
      desktop-shell/exposay.c
  3. 22
      desktop-shell/shell.c
  4. 2
      ivi-shell/hmi-controller.c
  5. 3
      ivi-shell/ivi-shell.c
  6. 7
      libweston-desktop/seat.c
  7. 3
      libweston/bindings.c
  8. 3
      libweston/compositor-rdp.c
  9. 4
      libweston/compositor-wayland.c
  10. 6
      libweston/compositor-x11.c
  11. 18
      libweston/compositor.h
  12. 3
      libweston/data-device.c
  13. 18
      libweston/input.c
  14. 7
      libweston/libinput-device.c
  15. 6
      tests/weston-test.c

@ -159,8 +159,11 @@ ss_seat_handle_button(void *data, struct wl_pointer *pointer,
uint32_t state)
{
struct ss_seat *seat = data;
struct timespec ts;
timespec_from_msec(&ts, time);
notify_button(&seat->base, time, button, state);
notify_button(&seat->base, &ts, button, state);
notify_pointer_frame(&seat->base);
}

@ -364,8 +364,8 @@ exposay_motion(struct weston_pointer_grab *grab,
}
static void
exposay_button(struct weston_pointer_grab *grab, uint32_t time, uint32_t button,
uint32_t state_w)
exposay_button(struct weston_pointer_grab *grab, const struct timespec *time,
uint32_t button, uint32_t state_w)
{
struct desktop_shell *shell =
container_of(grab, struct desktop_shell, exposay.grab_ptr);

@ -1507,7 +1507,7 @@ move_grab_motion(struct weston_pointer_grab *grab,
static void
move_grab_button(struct weston_pointer_grab *grab,
uint32_t time, uint32_t button, uint32_t state_w)
const struct timespec *time, uint32_t button, uint32_t state_w)
{
struct shell_grab *shell_grab = container_of(grab, struct shell_grab,
grab);
@ -1634,7 +1634,8 @@ resize_grab_motion(struct weston_pointer_grab *grab,
static void
resize_grab_button(struct weston_pointer_grab *grab,
uint32_t time, uint32_t button, uint32_t state_w)
const struct timespec *time,
uint32_t button, uint32_t state_w)
{
struct weston_resize_grab *resize = (struct weston_resize_grab *) grab;
struct weston_pointer *pointer = grab->pointer;
@ -1778,7 +1779,8 @@ busy_cursor_grab_motion(struct weston_pointer_grab *grab,
static void
busy_cursor_grab_button(struct weston_pointer_grab *base,
uint32_t time, uint32_t button, uint32_t state)
const struct timespec *time,
uint32_t button, uint32_t state)
{
struct shell_grab *grab = (struct shell_grab *) base;
struct shell_surface *shsurf = grab->shsurf;
@ -3203,7 +3205,7 @@ static const struct weston_desktop_shell_interface desktop_shell_implementation
};
static void
move_binding(struct weston_pointer *pointer, uint32_t time,
move_binding(struct weston_pointer *pointer, const struct timespec *time,
uint32_t button, void *data)
{
struct weston_surface *focus;
@ -3295,7 +3297,7 @@ touch_move_binding(struct weston_touch *touch, uint32_t time, void *data)
}
static void
resize_binding(struct weston_pointer *pointer, uint32_t time,
resize_binding(struct weston_pointer *pointer, const struct timespec *time,
uint32_t button, void *data)
{
struct weston_surface *focus;
@ -3515,7 +3517,8 @@ rotate_grab_motion(struct weston_pointer_grab *grab,
static void
rotate_grab_button(struct weston_pointer_grab *grab,
uint32_t time, uint32_t button, uint32_t state_w)
const struct timespec *time,
uint32_t button, uint32_t state_w)
{
struct rotate_grab *rotate =
container_of(grab, struct rotate_grab, base.grab);
@ -3593,8 +3596,8 @@ surface_rotate(struct shell_surface *shsurf, struct weston_pointer *pointer)
}
static void
rotate_binding(struct weston_pointer *pointer, uint32_t time, uint32_t button,
void *data)
rotate_binding(struct weston_pointer *pointer, const struct timespec *time,
uint32_t button, void *data)
{
struct weston_surface *focus;
struct weston_surface *base_surface;
@ -3754,7 +3757,8 @@ activate_binding(struct weston_seat *seat,
}
static void
click_to_activate_binding(struct weston_pointer *pointer, uint32_t time,
click_to_activate_binding(struct weston_pointer *pointer,
const struct timespec *time,
uint32_t button, void *data)
{
if (pointer->grab != &pointer->default_grab)

@ -1571,7 +1571,7 @@ touch_move_grab_motion(struct weston_touch_grab *grab, uint32_t time,
static void
pointer_move_workspace_grab_button(struct weston_pointer_grab *grab,
uint32_t time, uint32_t button,
const struct timespec *time, uint32_t button,
uint32_t state_w)
{
if (BTN_LEFT == button &&

@ -450,7 +450,8 @@ activate_binding(struct weston_seat *seat,
}
static void
click_to_activate_binding(struct weston_pointer *pointer, uint32_t time,
click_to_activate_binding(struct weston_pointer *pointer,
const struct timespec *time,
uint32_t button, void *data)
{
if (pointer->grab != &pointer->default_grab)

@ -35,6 +35,7 @@
#include "libweston-desktop.h"
#include "internal.h"
#include "shared/timespec-util.h"
struct weston_desktop_seat {
struct wl_listener seat_destroy_listener;
@ -116,7 +117,8 @@ weston_desktop_seat_popup_grab_pointer_motion(struct weston_pointer_grab *grab,
static void
weston_desktop_seat_popup_grab_pointer_button(struct weston_pointer_grab *grab,
uint32_t time, uint32_t button,
const struct timespec *time,
uint32_t button,
enum wl_pointer_button_state state)
{
struct weston_desktop_seat *seat =
@ -130,7 +132,8 @@ weston_desktop_seat_popup_grab_pointer_button(struct weston_pointer_grab *grab,
if (weston_pointer_has_focus_resource(pointer))
weston_pointer_send_button(pointer, time, button, state);
else if (state == WL_POINTER_BUTTON_STATE_RELEASED &&
(initial_up || (time - grab->pointer->grab_time) > 500))
(initial_up ||
(timespec_sub_to_msec(time, &grab->pointer->grab_time) > 500)))
weston_desktop_seat_popup_grab_end(seat);
}

@ -349,7 +349,8 @@ weston_compositor_run_modifier_binding(struct weston_compositor *compositor,
void
weston_compositor_run_button_binding(struct weston_compositor *compositor,
struct weston_pointer *pointer,
uint32_t time, uint32_t button,
const struct timespec *time,
uint32_t button,
enum wl_pointer_button_state state)
{
struct weston_binding *b, *tmp;

@ -1050,7 +1050,8 @@ xf_mouseEvent(rdpInput *input, UINT16 flags, UINT16 x, UINT16 y)
button = BTN_MIDDLE;
if (button) {
notify_button(peerContext->item.seat, weston_compositor_get_time(), button,
timespec_from_msec(&time, weston_compositor_get_time());
notify_button(peerContext->item.seat, &time, button,
(flags & PTR_FLAGS_DOWN) ? WL_POINTER_BUTTON_STATE_PRESSED : WL_POINTER_BUTTON_STATE_RELEASED
);
need_frame = true;

@ -1644,6 +1644,7 @@ input_handle_button(void *data, struct wl_pointer *pointer,
{
struct wayland_input *input = data;
enum theme_location location;
struct timespec ts;
if (!input->output)
return;
@ -1682,7 +1683,8 @@ input_handle_button(void *data, struct wl_pointer *pointer,
}
if (location == THEME_LOCATION_CLIENT_AREA) {
notify_button(&input->base, time, button, state);
timespec_from_msec(&ts, time);
notify_button(&input->base, &ts, button, state);
if (input->seat_version < WL_POINTER_FRAME_SINCE_VERSION)
notify_pointer_frame(&input->base);
}

@ -1133,6 +1133,7 @@ x11_backend_deliver_button_event(struct x11_backend *b,
struct x11_output *output;
struct weston_pointer_axis_event weston_event;
bool is_button_pressed = event->response_type == XCB_BUTTON_PRESS;
struct timespec time = { 0 };
assert(event->response_type == XCB_BUTTON_PRESS ||
event->response_type == XCB_BUTTON_RELEASE);
@ -1227,8 +1228,9 @@ x11_backend_deliver_button_event(struct x11_backend *b,
break;
}
notify_button(&b->core_seat,
weston_compositor_get_time(), button,
timespec_from_msec(&time, weston_compositor_get_time());
notify_button(&b->core_seat, &time, button,
is_button_pressed ? WL_POINTER_BUTTON_STATE_PRESSED :
WL_POINTER_BUTTON_STATE_RELEASED);
notify_pointer_frame(&b->core_seat);

@ -272,7 +272,8 @@ struct weston_pointer_grab_interface {
const struct timespec *time,
struct weston_pointer_motion_event *event);
void (*button)(struct weston_pointer_grab *grab,
uint32_t time, uint32_t button, uint32_t state);
const struct timespec *time,
uint32_t button, uint32_t state);
void (*axis)(struct weston_pointer_grab *grab,
uint32_t time,
struct weston_pointer_axis_event *event);
@ -383,7 +384,7 @@ struct weston_pointer {
wl_fixed_t grab_x, grab_y;
uint32_t grab_button;
uint32_t grab_serial;
uint32_t grab_time;
struct timespec grab_time;
wl_fixed_t x, y;
wl_fixed_t sx, sy;
@ -431,7 +432,8 @@ bool
weston_pointer_has_focus_resource(struct weston_pointer *pointer);
void
weston_pointer_send_button(struct weston_pointer *pointer,
uint32_t time, uint32_t button, uint32_t state_w);
const struct timespec *time,
uint32_t button, uint32_t state_w);
void
weston_pointer_send_axis(struct weston_pointer *pointer,
uint32_t time,
@ -1371,8 +1373,8 @@ void
notify_motion_absolute(struct weston_seat *seat, const struct timespec *time,
double x, double y);
void
notify_button(struct weston_seat *seat, uint32_t time, int32_t button,
enum wl_pointer_button_state state);
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,
struct weston_pointer_axis_event *event);
@ -1492,7 +1494,8 @@ weston_compositor_add_modifier_binding(struct weston_compositor *compositor,
void *data);
typedef void (*weston_button_binding_handler_t)(struct weston_pointer *pointer,
uint32_t time, uint32_t button,
const struct timespec *time,
uint32_t button,
void *data);
struct weston_binding *
weston_compositor_add_button_binding(struct weston_compositor *compositor,
@ -1549,7 +1552,8 @@ weston_compositor_run_modifier_binding(struct weston_compositor *compositor,
enum wl_keyboard_key_state state);
void
weston_compositor_run_button_binding(struct weston_compositor *compositor,
struct weston_pointer *pointer, uint32_t time,
struct weston_pointer *pointer,
const struct timespec *time,
uint32_t button,
enum wl_pointer_button_state value);
void

@ -638,7 +638,8 @@ data_device_end_pointer_drag_grab(struct weston_pointer_drag *drag)
static void
drag_grab_button(struct weston_pointer_grab *grab,
uint32_t time, uint32_t button, uint32_t state_w)
const struct timespec *time,
uint32_t button, uint32_t state_w)
{
struct weston_pointer_drag *drag =
container_of(grab, struct weston_pointer_drag, grab);

@ -460,26 +460,28 @@ weston_pointer_has_focus_resource(struct weston_pointer *pointer)
*/
WL_EXPORT void
weston_pointer_send_button(struct weston_pointer *pointer,
uint32_t time, uint32_t button,
const struct timespec *time, uint32_t button,
enum wl_pointer_button_state state)
{
struct wl_display *display = pointer->seat->compositor->wl_display;
struct wl_list *resource_list;
struct wl_resource *resource;
uint32_t serial;
uint32_t msecs;
if (!weston_pointer_has_focus_resource(pointer))
return;
resource_list = &pointer->focus_client->pointer_resources;
serial = wl_display_next_serial(display);
msecs = timespec_to_msec(time);
wl_resource_for_each(resource, resource_list)
wl_pointer_send_button(resource, serial, time, button, state);
wl_pointer_send_button(resource, serial, msecs, button, state);
}
static void
default_grab_pointer_button(struct weston_pointer_grab *grab,
uint32_t time, uint32_t button,
const struct timespec *time, uint32_t button,
enum wl_pointer_button_state state)
{
struct weston_pointer *pointer = grab->pointer;
@ -1652,8 +1654,8 @@ weston_view_activate(struct weston_view *view,
}
WL_EXPORT void
notify_button(struct weston_seat *seat, uint32_t time, int32_t button,
enum wl_pointer_button_state state)
notify_button(struct weston_seat *seat, const struct timespec *time,
int32_t button, enum wl_pointer_button_state state)
{
struct weston_compositor *compositor = seat->compositor;
struct weston_pointer *pointer = weston_seat_get_pointer(seat);
@ -1662,7 +1664,7 @@ notify_button(struct weston_seat *seat, uint32_t time, int32_t button,
weston_compositor_idle_inhibit(compositor);
if (pointer->button_count == 0) {
pointer->grab_button = button;
pointer->grab_time = time;
pointer->grab_time = *time;
pointer->grab_x = pointer->x;
pointer->grab_y = pointer->y;
}
@ -3328,7 +3330,7 @@ locked_pointer_grab_pointer_motion(struct weston_pointer_grab *grab,
static void
locked_pointer_grab_pointer_button(struct weston_pointer_grab *grab,
uint32_t time,
const struct timespec *time,
uint32_t button,
uint32_t state_w)
{
@ -4336,7 +4338,7 @@ confined_pointer_grab_pointer_motion(struct weston_pointer_grab *grab,
static void
confined_pointer_grab_pointer_button(struct weston_pointer_grab *grab,
uint32_t time,
const struct timespec *time,
uint32_t button,
uint32_t state_w)
{

@ -151,6 +151,7 @@ handle_pointer_button(struct libinput_device *libinput_device,
libinput_event_pointer_get_button_state(pointer_event);
int seat_button_count =
libinput_event_pointer_get_seat_button_count(pointer_event);
struct timespec time;
/* Ignore button events that are not seat wide state changes. */
if ((button_state == LIBINPUT_BUTTON_STATE_PRESSED &&
@ -159,8 +160,10 @@ handle_pointer_button(struct libinput_device *libinput_device,
seat_button_count != 0))
return false;
notify_button(device->seat,
libinput_event_pointer_get_time(pointer_event),
timespec_from_usec(&time,
libinput_event_pointer_get_time_usec(pointer_event));
notify_button(device->seat, &time,
libinput_event_pointer_get_button(pointer_event),
button_state);

@ -171,10 +171,14 @@ static void
send_button(struct wl_client *client, struct wl_resource *resource,
int32_t button, uint32_t state)
{
struct timespec time;
struct weston_test *test = wl_resource_get_user_data(resource);
struct weston_seat *seat = get_seat(test);
notify_button(seat, 100, button, state);
timespec_from_msec(&time, 100);
notify_button(seat, &time, button, state);
}
static void

Loading…
Cancel
Save