diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c index fffb3d68a..8d93b18aa 100644 --- a/desktop-shell/shell.c +++ b/desktop-shell/shell.c @@ -758,20 +758,18 @@ surface_keyboard_focus_lost(struct weston_surface *surface) static void touch_move_grab_down(struct weston_touch_grab *grab, - const struct timespec *time, - int touch_id, struct weston_coord_global c) + const struct weston_touch_event *event) { } static void -touch_move_grab_up(struct weston_touch_grab *grab, const struct timespec *time, - int touch_id) +touch_move_grab_up(struct weston_touch_grab *grab, const struct weston_touch_event *event) { struct weston_touch_move_grab *move = (struct weston_touch_move_grab *) container_of( grab, struct shell_touch_grab, grab); - if (touch_id == 0) + if (event->touch_id == 0) move->active = 0; if (grab->touch->num_tp == 0) { @@ -781,9 +779,7 @@ touch_move_grab_up(struct weston_touch_grab *grab, const struct timespec *time, } static void -touch_move_grab_motion(struct weston_touch_grab *grab, - const struct timespec *time, int touch_id, - struct weston_coord_global unused) +touch_move_grab_motion(struct weston_touch_grab *grab, const struct weston_touch_event *event) { struct weston_touch_move_grab *move = (struct weston_touch_move_grab *) grab; struct shell_surface *shsurf = move->base.shsurf; @@ -854,8 +850,7 @@ noop_grab_focus(struct weston_pointer_grab *grab) static void noop_grab_axis(struct weston_pointer_grab *grab, - const struct timespec *time, - struct weston_pointer_axis_event *event) + const struct weston_pointer_axis_event *event) { } @@ -911,8 +906,7 @@ constrain_position(struct weston_move_grab *move) static void move_grab_motion(struct weston_pointer_grab *grab, - const struct timespec *time, - struct weston_pointer_motion_event *event) + const struct weston_pointer_motion_event *event) { struct weston_move_grab *move = (struct weston_move_grab *) grab; struct weston_pointer *pointer = grab->pointer; @@ -929,12 +923,12 @@ move_grab_motion(struct weston_pointer_grab *grab, static void move_grab_button(struct weston_pointer_grab *grab, - const struct timespec *time, uint32_t button, uint32_t state_w) + const struct weston_pointer_button_event *button_event) { struct shell_grab *shell_grab = container_of(grab, struct shell_grab, grab); struct weston_pointer *pointer = grab->pointer; - enum wl_pointer_button_state state = state_w; + enum wl_pointer_button_state state = button_event->button_state; if (pointer->button_count == 0 && state == WL_POINTER_BUTTON_STATE_RELEASED) { @@ -1141,8 +1135,7 @@ surface_tablet_tool_move(struct shell_surface *shsurf, struct weston_tablet_tool static void resize_grab_motion(struct weston_pointer_grab *grab, - const struct timespec *time, - struct weston_pointer_motion_event *event) + const struct weston_pointer_motion_event *event) { struct weston_resize_grab *resize = (struct weston_resize_grab *) grab; struct weston_pointer *pointer = grab->pointer; @@ -1200,12 +1193,11 @@ resize_grab_motion(struct weston_pointer_grab *grab, static void resize_grab_button(struct weston_pointer_grab *grab, - const struct timespec *time, - uint32_t button, uint32_t state_w) + const struct weston_pointer_button_event *button_event) { struct weston_resize_grab *resize = (struct weston_resize_grab *) grab; struct weston_pointer *pointer = grab->pointer; - enum wl_pointer_button_state state = state_w; + enum wl_pointer_button_state state = button_event->button_state; if (pointer->button_count == 0 && state == WL_POINTER_BUTTON_STATE_RELEASED) { @@ -1311,27 +1303,27 @@ busy_cursor_grab_focus(struct weston_pointer_grab *base) static void busy_cursor_grab_motion(struct weston_pointer_grab *grab, - const struct timespec *time, - struct weston_pointer_motion_event *event) + const struct weston_pointer_motion_event *event) { weston_pointer_move(grab->pointer, event); } static void busy_cursor_grab_button(struct weston_pointer_grab *base, - const struct timespec *time, - uint32_t button, uint32_t state) + const struct weston_pointer_button_event *button_event) { struct shell_grab *grab = (struct shell_grab *) base; struct shell_surface *shsurf = grab->shsurf; struct weston_pointer *pointer = grab->grab.pointer; struct weston_seat *seat = pointer->seat; - if (shsurf && button == BTN_LEFT && state) { + if (shsurf && button_event->button == BTN_LEFT && + button_event->button_state) { activate(shsurf->shell, shsurf->view, seat, WESTON_ACTIVATE_FLAG_CONFIGURE); surface_move(shsurf, pointer, false); - } else if (shsurf && button == BTN_RIGHT && state) { + } else if (shsurf && button_event->button == BTN_RIGHT && + button_event->button_state) { activate(shsurf->shell, shsurf->view, seat, WESTON_ACTIVATE_FLAG_CONFIGURE); surface_rotate(shsurf, pointer); @@ -3185,7 +3177,7 @@ resize_binding(struct weston_pointer *pointer, const struct timespec *time, static void surface_opacity_binding(struct weston_pointer *pointer, const struct timespec *time, - struct weston_pointer_axis_event *event, + const struct weston_pointer_axis_event *event, void *data) { float step = 0.005; @@ -3220,8 +3212,7 @@ terminate_binding(struct weston_keyboard *keyboard, const struct timespec *time, static void rotate_grab_motion(struct weston_pointer_grab *grab, - const struct timespec *time, - struct weston_pointer_motion_event *event) + const struct weston_pointer_motion_event *event) { struct rotate_grab *rotate = container_of(grab, struct rotate_grab, base.grab); @@ -3287,14 +3278,13 @@ rotate_grab_motion(struct weston_pointer_grab *grab, static void rotate_grab_button(struct weston_pointer_grab *grab, - const struct timespec *time, - uint32_t button, uint32_t state_w) + const struct weston_pointer_button_event *button_event) { struct rotate_grab *rotate = container_of(grab, struct rotate_grab, base.grab); struct weston_pointer *pointer = grab->pointer; struct shell_surface *shsurf = rotate->base.shsurf; - enum wl_pointer_button_state state = state_w; + enum wl_pointer_button_state state = button_event->button_state; if (pointer->button_count == 0 && state == WL_POINTER_BUTTON_STATE_RELEASED) { @@ -4189,11 +4179,11 @@ switcher_destroy(struct switcher *switcher) } static void -switcher_key(struct weston_keyboard_grab *grab, - const struct timespec *time, uint32_t key, uint32_t state_w) +switcher_key(struct weston_keyboard_grab *grab, const struct weston_key_event *key_event) { struct switcher *switcher = container_of(grab, struct switcher, grab); - enum wl_keyboard_key_state state = state_w; + enum wl_keyboard_key_state state = key_event->key_state; + uint32_t key = key_event->key; if (key == KEY_TAB && state == WL_KEYBOARD_KEY_STATE_PRESSED) switcher_next(switcher); diff --git a/frontend/text-backend.c b/frontend/text-backend.c index 73a1eda30..7eeb96873 100644 --- a/frontend/text-backend.c +++ b/frontend/text-backend.c @@ -621,13 +621,15 @@ unbind_keyboard(struct wl_resource *resource) static void input_method_context_grab_key(struct weston_keyboard_grab *grab, - const struct timespec *time, uint32_t key, - uint32_t state_w) + const struct weston_key_event *key_event) { struct weston_keyboard *keyboard = grab->keyboard; struct wl_display *display; uint32_t serial; uint32_t msecs; + uint32_t key = key_event->key; + struct timespec *time = key_event->base_event.ts; + uint32_t state_w = key_event->key_state; if (!keyboard->input_method_resource) return; @@ -712,10 +714,14 @@ input_method_context_key(struct wl_client *client, struct weston_keyboard *keyboard = weston_seat_get_keyboard(seat); struct weston_keyboard_grab *default_grab = &keyboard->default_grab; struct timespec ts; + struct weston_key_event key_event; timespec_from_msec(&ts, time); - default_grab->interface->key(default_grab, &ts, key, state_w); + weston_input_event_init(&key_event.base_event, &ts, seat); + weston_key_event_init(&key_event, key, state_w, STATE_UPDATE_NONE); + + default_grab->interface->key(default_grab, &key_event); } static void diff --git a/include/libweston/li b/include/libweston/li new file mode 100644 index 000000000..e69de29bb diff --git a/include/libweston/libweston.h b/include/libweston/libweston.h index aa787386c..55faa5fa0 100644 --- a/include/libweston/libweston.h +++ b/include/libweston/libweston.h @@ -188,6 +188,11 @@ struct weston_spring { uint32_t clip; }; +enum weston_key_state_update { + STATE_UPDATE_AUTOMATIC, + STATE_UPDATE_NONE, +}; + /* bit compatible with drm definitions. */ enum dpms_enum { WESTON_DPMS_ON, @@ -600,33 +605,58 @@ enum weston_pointer_motion_mask { WESTON_POINTER_MOTION_REL_UNACCEL = 1 << 2, }; +/* base/common struct which all weston_xxx_event should "inherit" */ +struct weston_input_event { + struct timespec *ts; + struct weston_seat *seat; +}; + struct weston_pointer_motion_event { + struct weston_input_event base_event; uint32_t mask; - struct timespec time; - struct weston_coord_global abs; - struct weston_coord rel; - struct weston_coord rel_unaccel; + const struct weston_coord_global *abs; + const struct weston_coord *rel; + const struct weston_coord *rel_unaccel; +}; + +struct weston_pointer_button_event { + struct weston_input_event base_event; + uint32_t button; + enum wl_pointer_button_state button_state; }; struct weston_pointer_axis_event { + struct weston_input_event base_event; uint32_t axis; double value; bool has_discrete; int32_t discrete; }; +struct weston_key_event { + struct weston_input_event base_event; + uint32_t key; + enum wl_keyboard_key_state key_state; + enum weston_key_state_update key_update_state; +}; + +struct weston_touch_event { + struct weston_input_event base_event; + int32_t touch_type; + int32_t touch_id; + const struct weston_coord_global *pos; +}; + + struct weston_pointer_grab; struct weston_pointer_grab_interface { void (*focus)(struct weston_pointer_grab *grab); void (*motion)(struct weston_pointer_grab *grab, - const struct timespec *time, - struct weston_pointer_motion_event *event); + const struct weston_pointer_motion_event *event); void (*button)(struct weston_pointer_grab *grab, - const struct timespec *time, - uint32_t button, uint32_t state); + const struct weston_pointer_button_event *button_event); void (*axis)(struct weston_pointer_grab *grab, - const struct timespec *time, - struct weston_pointer_axis_event *event); + const struct weston_pointer_axis_event *event); void (*axis_source)(struct weston_pointer_grab *grab, uint32_t source); void (*frame)(struct weston_pointer_grab *grab); void (*cancel)(struct weston_pointer_grab *grab); @@ -640,7 +670,7 @@ struct weston_pointer_grab { struct weston_keyboard_grab; struct weston_keyboard_grab_interface { void (*key)(struct weston_keyboard_grab *grab, - const struct timespec *time, uint32_t key, uint32_t state); + const struct weston_key_event *key_event); void (*modifiers)(struct weston_keyboard_grab *grab, uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group); @@ -655,16 +685,11 @@ struct weston_keyboard_grab { struct weston_touch_grab; struct weston_touch_grab_interface { void (*down)(struct weston_touch_grab *grab, - const struct timespec *time, - int touch_id, - struct weston_coord_global c); + const struct weston_touch_event *event); void (*up)(struct weston_touch_grab *grab, - const struct timespec *time, - int touch_id); + const struct weston_touch_event *event); void (*motion)(struct weston_touch_grab *grab, - const struct timespec *time, - int touch_id, - struct weston_coord_global c); + const struct weston_touch_event *event); void (*frame)(struct weston_touch_grab *grab); void (*cancel)(struct weston_touch_grab *grab); }; @@ -948,23 +973,19 @@ struct weston_color_representation_matrix { struct weston_coord_global weston_pointer_motion_to_abs(struct weston_pointer *pointer, - struct weston_pointer_motion_event *event); + const struct weston_pointer_motion_event *event); void weston_pointer_send_motion(struct weston_pointer *pointer, - const struct timespec *time, - struct weston_pointer_motion_event *event); + const struct weston_pointer_motion_event *event); bool weston_pointer_has_focus_resource(struct weston_pointer *pointer); void weston_pointer_send_button(struct weston_pointer *pointer, - const struct timespec *time, - uint32_t button, - enum wl_pointer_button_state state); + const struct weston_pointer_button_event *button_event); void weston_pointer_send_axis(struct weston_pointer *pointer, - const struct timespec *time, - struct weston_pointer_axis_event *event); + const struct weston_pointer_axis_event *event); void weston_pointer_send_axis_source(struct weston_pointer *pointer, enum wl_pointer_axis_source source); @@ -984,7 +1005,7 @@ void weston_pointer_end_grab(struct weston_pointer *pointer); void weston_pointer_move(struct weston_pointer *pointer, - struct weston_pointer_motion_event *event); + const struct weston_pointer_motion_event *event); void weston_keyboard_set_focus(struct weston_keyboard *keyboard, struct weston_surface *surface); @@ -1003,8 +1024,36 @@ weston_keyboard_set_locks(struct weston_keyboard *keyboard, void weston_keyboard_send_key(struct weston_keyboard *keyboard, - const struct timespec *time, uint32_t key, - enum wl_keyboard_key_state state); + const struct weston_key_event *key_event); + +void +weston_input_event_init(struct weston_input_event *ievent, struct timespec *ts, struct weston_seat *seat); + +void +weston_key_event_init(struct weston_key_event *event, uint32_t key, + enum wl_keyboard_key_state key_state, + enum weston_key_state_update key_update_state); + +void +weston_pointer_motion_event_init(struct weston_pointer_motion_event *event, + uint32_t mask, + const struct weston_coord_global *abs, + const struct weston_coord *rel, + const struct weston_coord *rel_unaccel); + +void +weston_pointer_button_event_init(struct weston_pointer_button_event *event, + uint32_t button, enum wl_pointer_button_state button_state); + +void +weston_pointer_axis_event_init(struct weston_pointer_axis_event *event, + uint32_t axis, double value, bool has_value, + int32_t discrete); + +void +weston_touch_event_init(struct weston_touch_event *event, int32_t touch_type, + int32_t touch_id, const struct weston_coord_global *pos); + void weston_keyboard_send_modifiers(struct weston_keyboard *keyboard, uint32_t serial, uint32_t mods_depressed, @@ -1021,15 +1070,11 @@ void weston_touch_end_grab(struct weston_touch *touch); void -weston_touch_send_down(struct weston_touch *touch, const struct timespec *time, - int touch_id, struct weston_coord_global pos); +weston_touch_send_down(struct weston_touch *touch, const struct weston_touch_event *event); void -weston_touch_send_up(struct weston_touch *touch, const struct timespec *time, - int touch_id); +weston_touch_send_up(struct weston_touch *touch, const struct weston_touch_event *event); void -weston_touch_send_motion(struct weston_touch *touch, - const struct timespec *time, int touch_id, - struct weston_coord_global pos); +weston_touch_send_motion(struct weston_touch *touch, const struct weston_touch_event *event); void weston_touch_send_frame(struct weston_touch *touch); @@ -1198,6 +1243,7 @@ struct weston_seat { struct wl_list tablet_tool_list; struct wl_list tablet_seat_resource_list; struct wl_signal tablet_tool_added_signal; + uint64_t track_id; }; enum { @@ -2125,12 +2171,6 @@ struct content_protection { struct wl_event_source *surface_protection_update; }; - -enum weston_key_state_update { - STATE_UPDATE_AUTOMATIC, - STATE_UPDATE_NONE, -}; - enum weston_activate_flag { WESTON_ACTIVATE_FLAG_NONE = 0, WESTON_ACTIVATE_FLAG_CONFIGURE = 1 << 0, @@ -2295,7 +2335,7 @@ weston_compositor_add_tablet_tool_binding(struct weston_compositor *compositor, typedef void (*weston_axis_binding_handler_t)(struct weston_pointer *pointer, const struct timespec *time, - struct weston_pointer_axis_event *event, + const struct weston_pointer_axis_event *event, void *data); struct weston_binding * weston_compositor_add_axis_binding(struct weston_compositor *compositor, diff --git a/ivi-shell/hmi-controller.c b/ivi-shell/hmi-controller.c index 0bbfa2c6e..7b4affbe5 100644 --- a/ivi-shell/hmi-controller.c +++ b/ivi-shell/hmi-controller.c @@ -1639,10 +1639,9 @@ pointer_noop_grab_focus(struct weston_pointer_grab *grab) static void pointer_default_grab_axis(struct weston_pointer_grab *grab, - const struct timespec *time, - struct weston_pointer_axis_event *event) + const struct weston_pointer_axis_event *event) { - weston_pointer_send_axis(grab->pointer, time, event); + weston_pointer_send_axis(grab->pointer, event); } static void @@ -1713,8 +1712,7 @@ layer_set_pos(struct hmi_controller *hmi_ctrl, struct ivi_layout_layer *layer, static void pointer_move_grab_motion(struct weston_pointer_grab *grab, - const struct timespec *time, - struct weston_pointer_motion_event *event) + const struct weston_pointer_motion_event *event) { struct pointer_move_grab *pnt_move_grab = (struct pointer_move_grab *)grab; @@ -1733,9 +1731,7 @@ pointer_move_grab_motion(struct weston_pointer_grab *grab, } static void -touch_move_grab_motion(struct weston_touch_grab *grab, - const struct timespec *time, int touch_id, - struct weston_coord_global c) +touch_move_grab_motion(struct weston_touch_grab *grab, const struct weston_touch_event *event) { struct touch_move_grab *tch_move_grab = (struct touch_move_grab *)grab; struct hmi_controller *hmi_ctrl = @@ -1756,11 +1752,10 @@ touch_move_grab_motion(struct weston_touch_grab *grab, static void pointer_move_workspace_grab_button(struct weston_pointer_grab *grab, - const struct timespec *time, uint32_t button, - uint32_t state_w) + const struct weston_pointer_button_event *button_event) { - if (BTN_LEFT == button && - WL_POINTER_BUTTON_STATE_RELEASED == state_w) { + if (BTN_LEFT == button_event->button && + WL_POINTER_BUTTON_STATE_RELEASED == button_event->button_state) { struct pointer_grab *pg = (struct pointer_grab *)grab; pointer_move_workspace_grab_end(pg); @@ -1769,20 +1764,16 @@ pointer_move_workspace_grab_button(struct weston_pointer_grab *grab, } static void -touch_nope_grab_down(struct weston_touch_grab *grab, - const struct timespec *time, - int touch_id, struct weston_coord_global c) +touch_nope_grab_down(struct weston_touch_grab *grab, const struct weston_touch_event *event) { } static void -touch_move_workspace_grab_up(struct weston_touch_grab *grab, - const struct timespec *time, - int touch_id) +touch_move_workspace_grab_up(struct weston_touch_grab *grab, const struct weston_touch_event *event) { struct touch_move_grab *tch_move_grab = (struct touch_move_grab *)grab; - if (0 == touch_id) + if (0 == event->touch_id) tch_move_grab->is_active = 0; if (0 == grab->touch->num_tp) { diff --git a/kiosk-shell/kiosk-shell-grab.c b/kiosk-shell/kiosk-shell-grab.c index bff706fb3..c609dd8bf 100644 --- a/kiosk-shell/kiosk-shell-grab.c +++ b/kiosk-shell/kiosk-shell-grab.c @@ -50,8 +50,7 @@ pointer_move_grab_focus(struct weston_pointer_grab *grab) static void pointer_move_grab_axis(struct weston_pointer_grab *grab, - const struct timespec *time, - struct weston_pointer_axis_event *event) + const struct weston_pointer_axis_event *event) { } @@ -68,8 +67,7 @@ pointer_move_grab_frame(struct weston_pointer_grab *grab) static void pointer_move_grab_motion(struct weston_pointer_grab *pointer_grab, - const struct timespec *time, - struct weston_pointer_motion_event *event) + const struct weston_pointer_motion_event *event) { struct kiosk_shell_grab *shgrab = container_of(pointer_grab, struct kiosk_shell_grab, pointer_grab); @@ -94,13 +92,12 @@ pointer_move_grab_motion(struct weston_pointer_grab *pointer_grab, static void pointer_move_grab_button(struct weston_pointer_grab *pointer_grab, - const struct timespec *time, - uint32_t button, uint32_t state_w) + const struct weston_pointer_button_event *button_event) { struct kiosk_shell_grab *shgrab = container_of(pointer_grab, struct kiosk_shell_grab, pointer_grab); struct weston_pointer *pointer = pointer_grab->pointer; - enum wl_pointer_button_state state = state_w; + enum wl_pointer_button_state state = button_event->button_state; if (pointer->button_count == 0 && state == WL_POINTER_BUTTON_STATE_RELEASED) @@ -132,19 +129,18 @@ static const struct weston_pointer_grab_interface pointer_move_grab_interface = static void touch_move_grab_down(struct weston_touch_grab *grab, - const struct timespec *time, - int touch_id, struct weston_coord_global c) + const struct weston_touch_event *event) { } static void touch_move_grab_up(struct weston_touch_grab *touch_grab, - const struct timespec *time, int touch_id) + const struct weston_touch_event *event) { struct kiosk_shell_grab *shgrab = container_of(touch_grab, struct kiosk_shell_grab, touch_grab); - if (touch_id == 0) + if (event->touch_id == 0) shgrab->active = false; if (touch_grab->touch->num_tp == 0) @@ -153,8 +149,7 @@ touch_move_grab_up(struct weston_touch_grab *touch_grab, static void touch_move_grab_motion(struct weston_touch_grab *touch_grab, - const struct timespec *time, int touch_id, - struct weston_coord_global unused) + const struct weston_touch_event *event) { struct kiosk_shell_grab *shgrab = container_of(touch_grab, struct kiosk_shell_grab, touch_grab); diff --git a/libweston/backend-rdp/rdp.c b/libweston/backend-rdp/rdp.c index d4d0af858..e79709062 100644 --- a/libweston/backend-rdp/rdp.c +++ b/libweston/backend-rdp/rdp.c @@ -1282,9 +1282,15 @@ rdp_translate_and_notify_mouse_position(RdpPeerContext *peerContext, UINT16 x, U different scaling. In such case, hit test to that window area on non primary-resident monitor (surface->output) dosn't work. */ if (to_weston_coordinate(peerContext, &sx, &sy)) { + struct weston_pointer_motion_event event; + pos.c = weston_coord(sx, sy); weston_compositor_get_time(&time); - notify_motion_absolute(peerContext->item.seat, &time, pos); + + weston_input_event_init(&event.base_event, &time, peerContext->item.seat); + weston_pointer_motion_event_init(&event, WESTON_POINTER_MOTION_ABS, + &pos, NULL, NULL); + notify_motion(peerContext->item.seat, &event); return TRUE; } return FALSE; @@ -1357,7 +1363,6 @@ rdp_notify_wheel_scroll(RdpPeerContext *peerContext, UINT16 flags, uint32_t axis struct weston_pointer_axis_event weston_event; struct rdp_backend *b = peerContext->rdpBackend; int ivalue; - double value; struct timespec time; int *accumWheelRotationPrecise; int *accumWheelRotationDiscrete; @@ -1401,19 +1406,18 @@ rdp_notify_wheel_scroll(RdpPeerContext *peerContext, UINT16 flags, uint32_t axis ivalue, *accumWheelRotationPrecise, *accumWheelRotationDiscrete); if (abs(*accumWheelRotationPrecise) >= 12) { - value = (double)(*accumWheelRotationPrecise / 12); + weston_compositor_get_time(&time); - weston_event.axis = axis; - weston_event.value = value; - weston_event.discrete = *accumWheelRotationDiscrete / 120; - weston_event.has_discrete = true; + weston_input_event_init(&weston_event.base_event, + &time, peerContext->item.seat); + weston_pointer_axis_event_init(&weston_event, axis, + (double) *accumWheelRotationPrecise / 12, + true, *accumWheelRotationDiscrete / 120); rdp_debug_verbose(b, "wheel: value:%f discrete:%d\n", weston_event.value, weston_event.discrete); - weston_compositor_get_time(&time); - - notify_axis(peerContext->item.seat, &time, &weston_event); + notify_axis(peerContext->item.seat, &weston_event); *accumWheelRotationPrecise %= 12; *accumWheelRotationDiscrete %= 120; @@ -1459,10 +1463,17 @@ xf_mouseEvent(rdpInput *input, UINT16 flags, UINT16 x, UINT16 y) } if (button) { + struct weston_pointer_button_event button_event; + weston_compositor_get_time(&time); - notify_button(peerContext->item.seat, &time, button, - (flags & PTR_FLAGS_DOWN) ? WL_POINTER_BUTTON_STATE_PRESSED : WL_POINTER_BUTTON_STATE_RELEASED - ); + + weston_input_event_init(&button_event.base_event, &time, + peerContext->item.seat); + weston_pointer_button_event_init(&button_event, button, + (flags & PTR_FLAGS_DOWN) ? + WL_POINTER_BUTTON_STATE_PRESSED : + WL_POINTER_BUTTON_STATE_RELEASED); + notify_button(peerContext->item.seat, &button_event); need_frame = true; } @@ -1507,17 +1518,30 @@ xf_extendedMouseEvent(rdpInput *input, UINT16 flags, UINT16 x, UINT16 y) } if (button) { + struct weston_pointer_button_event button_event; weston_compositor_get_time(&time); - notify_button(peerContext->item.seat, &time, button, - (flags & PTR_XFLAGS_DOWN) ? WL_POINTER_BUTTON_STATE_PRESSED : WL_POINTER_BUTTON_STATE_RELEASED); + + weston_input_event_init(&button_event.base_event, &time, + peerContext->item.seat); + weston_pointer_button_event_init(&button_event, button, + (flags & PTR_XFLAGS_DOWN) ? + WL_POINTER_BUTTON_STATE_PRESSED : + WL_POINTER_BUTTON_STATE_RELEASED); + notify_button(peerContext->item.seat, &button_event); need_frame = true; } output = rdp_get_first_output(peerContext->rdpBackend); if (x < output->base.width && y < output->base.height) { + struct weston_pointer_motion_event event; + weston_compositor_get_time(&time); pos.c = weston_coord(x, y); - notify_motion_absolute(peerContext->item.seat, &time, pos); + + weston_input_event_init(&event.base_event, &time, peerContext->item.seat); + weston_pointer_motion_event_init(&event, WESTON_POINTER_MOTION_ABS, + &pos, NULL, NULL); + notify_motion(peerContext->item.seat, &event); need_frame = true; } @@ -1573,6 +1597,7 @@ xf_input_keyboard_event(rdpInput *input, UINT16 flags, XF_KEV_CODE_TYPE code) bool send_release_key = false; int notify = 0; struct timespec time; + struct weston_key_event key_event; rdp_debug_verbose(peerContext->rdpBackend, "RDP backend: %s flags:0x%x, code:0x%x\n", __func__, flags, code); @@ -1638,14 +1663,18 @@ xf_input_keyboard_event(rdpInput *input, UINT16 flags, XF_KEV_CODE_TYPE code) /*weston_log("code=%x ext=%d vk_code=%x scan_code=%x\n", code, (flags & KBD_FLAGS_EXTENDED) ? 1 : 0, vk_code, scan_code);*/ weston_compositor_get_time(&time); - notify_key(peerContext->item.seat, &time, - scan_code - 8, keyState, STATE_UPDATE_AUTOMATIC); + + weston_input_event_init(&key_event.base_event, + &time, peerContext->item.seat); + weston_key_event_init(&key_event, scan_code - 8, + keyState, STATE_UPDATE_AUTOMATIC); + notify_key(peerContext->item.seat, &key_event); if (send_release_key) { - notify_key(peerContext->item.seat, &time, - scan_code - 8, - WL_KEYBOARD_KEY_STATE_RELEASED, - STATE_UPDATE_AUTOMATIC); + weston_key_event_init(&key_event, scan_code - 8, + WL_KEYBOARD_KEY_STATE_RELEASED, + STATE_UPDATE_AUTOMATIC); + notify_key(peerContext->item.seat, &key_event); } } diff --git a/libweston/backend-vnc/vnc.c b/libweston/backend-vnc/vnc.c index ae689d855..4f5b69b1e 100644 --- a/libweston/backend-vnc/vnc.c +++ b/libweston/backend-vnc/vnc.c @@ -301,6 +301,7 @@ vnc_handle_key_event(struct nvnc_client *client, uint32_t keysym, bool needs_shift = false; enum weston_key_state_update state_update; enum wl_keyboard_key_state state; + struct weston_key_event key_event; struct timespec time; int i; @@ -336,20 +337,27 @@ vnc_handle_key_event(struct nvnc_client *client, uint32_t keysym, return; } + weston_input_event_init(&key_event.base_event, &time, peer->seat); + /* emulate lshift press */ - if (needs_shift) - notify_key(peer->seat, &time, KEY_LEFTSHIFT, - WL_KEYBOARD_KEY_STATE_PRESSED, - STATE_UPDATE_AUTOMATIC); + if (needs_shift) { + weston_key_event_init(&key_event, KEY_LEFTSHIFT, + WL_KEYBOARD_KEY_STATE_PRESSED, + STATE_UPDATE_AUTOMATIC); + notify_key(peer->seat, &key_event); + } /* send detected key code */ - notify_key(peer->seat, &time, key, state, state_update); + weston_key_event_init(&key_event, key, state, state_update); + notify_key(peer->seat, &key_event); /* emulate lshift release */ - if (needs_shift) - notify_key(peer->seat, &time, KEY_LEFTSHIFT, - WL_KEYBOARD_KEY_STATE_RELEASED, - STATE_UPDATE_AUTOMATIC); + if (needs_shift) { + weston_key_event_init(&key_event, KEY_LEFTSHIFT, + WL_KEYBOARD_KEY_STATE_RELEASED, + STATE_UPDATE_AUTOMATIC); + notify_key(peer->seat, &key_event); + } } static void @@ -359,6 +367,7 @@ vnc_handle_key_code_event(struct nvnc_client *client, uint32_t key, struct vnc_peer *peer = nvnc_get_userdata(client); enum wl_keyboard_key_state state; struct timespec time; + struct weston_key_event key_event; weston_compositor_get_time(&time); @@ -367,7 +376,9 @@ vnc_handle_key_code_event(struct nvnc_client *client, uint32_t key, else state = WL_KEYBOARD_KEY_STATE_RELEASED; - notify_key(peer->seat, &time, key, state, STATE_UPDATE_AUTOMATIC); + weston_input_event_init(&key_event.base_event, &time, peer->seat); + weston_key_event_init(&key_event, key, state, STATE_UPDATE_AUTOMATIC); + notify_key(peer->seat, &key_event); } static void @@ -431,50 +442,66 @@ vnc_pointer_event(struct nvnc_client *client, uint16_t x, uint16_t y, struct vnc_output *output = peer->backend->output; struct timespec time; enum nvnc_button_mask changed_button_mask; + struct weston_pointer_button_event button_event; weston_compositor_get_time(&time); if (x < output->base.width && y < output->base.height) { struct weston_coord_global pos; + struct weston_pointer_motion_event event; pos = weston_coord_global_from_output_point(x, y, &output->base); - notify_motion_absolute(peer->seat, &time, pos); + + weston_input_event_init(&event.base_event, &time, peer->seat); + weston_pointer_motion_event_init(&event, WESTON_POINTER_MOTION_ABS, + &pos, NULL, NULL); + notify_motion(peer->seat, &event); } changed_button_mask = peer->last_button_mask ^ button_mask; - if (changed_button_mask & NVNC_BUTTON_LEFT) - notify_button(peer->seat, &time, BTN_LEFT, - (button_mask & NVNC_BUTTON_LEFT) ? - WL_POINTER_BUTTON_STATE_PRESSED : - WL_POINTER_BUTTON_STATE_RELEASED); + weston_input_event_init(&button_event.base_event, &time, peer->seat); + if (changed_button_mask & NVNC_BUTTON_LEFT) { + weston_pointer_button_event_init(&button_event, BTN_LEFT, + (button_mask & NVNC_BUTTON_LEFT) ? + WL_POINTER_BUTTON_STATE_PRESSED : + WL_POINTER_BUTTON_STATE_RELEASED); + notify_button(peer->seat, &button_event); + } - if (changed_button_mask & NVNC_BUTTON_MIDDLE) - notify_button(peer->seat, &time, BTN_MIDDLE, - (button_mask & NVNC_BUTTON_MIDDLE) ? - WL_POINTER_BUTTON_STATE_PRESSED : - WL_POINTER_BUTTON_STATE_RELEASED); + if (changed_button_mask & NVNC_BUTTON_MIDDLE) { + weston_pointer_button_event_init(&button_event, BTN_MIDDLE, + (button_mask & NVNC_BUTTON_MIDDLE) ? + WL_POINTER_BUTTON_STATE_PRESSED : + WL_POINTER_BUTTON_STATE_RELEASED); + notify_button(peer->seat, &button_event); + } + + if (changed_button_mask & NVNC_BUTTON_RIGHT) { + weston_pointer_button_event_init(&button_event, BTN_RIGHT, + (button_mask & NVNC_BUTTON_RIGHT) ? + WL_POINTER_BUTTON_STATE_PRESSED : + WL_POINTER_BUTTON_STATE_RELEASED); + notify_button(peer->seat, &button_event); + } - if (changed_button_mask & NVNC_BUTTON_RIGHT) - notify_button(peer->seat, &time, BTN_RIGHT, - (button_mask & NVNC_BUTTON_RIGHT) ? - WL_POINTER_BUTTON_STATE_PRESSED : - WL_POINTER_BUTTON_STATE_RELEASED); if ((button_mask & NVNC_SCROLL_UP) || (button_mask & NVNC_SCROLL_DOWN)) { struct weston_pointer_axis_event weston_event; - - weston_event.axis = WL_POINTER_AXIS_VERTICAL_SCROLL; + double value = 0; /* DEFAULT_AXIS_STEP_DISTANCE is stolen from compositor-x11.c */ if (button_mask & NVNC_SCROLL_UP) - weston_event.value = -DEFAULT_AXIS_STEP_DISTANCE; + value = -DEFAULT_AXIS_STEP_DISTANCE; if (button_mask & NVNC_SCROLL_DOWN) - weston_event.value = DEFAULT_AXIS_STEP_DISTANCE; - weston_event.has_discrete = false; + value = DEFAULT_AXIS_STEP_DISTANCE; - notify_axis(peer->seat, &time, &weston_event); + weston_input_event_init(&weston_event.base_event, + &time, peer->seat); + weston_pointer_axis_event_init(&weston_event, WL_POINTER_AXIS_VERTICAL_SCROLL, + value, false, 0); + notify_axis(peer->seat, &weston_event); } peer->last_button_mask = button_mask; diff --git a/libweston/backend-wayland/wayland.c b/libweston/backend-wayland/wayland.c index 6ad1d7b49..78a4a6abd 100644 --- a/libweston/backend-wayland/wayland.c +++ b/libweston/backend-wayland/wayland.c @@ -1677,7 +1677,9 @@ input_handle_motion(void *data, struct wl_pointer *pointer, bool want_frame = false; double x, y; struct weston_coord_global pos; + struct weston_pointer_motion_event event; struct timespec ts; + struct weston_seat *seat; if (!input->output) return; @@ -1715,9 +1717,14 @@ input_handle_motion(void *data, struct wl_pointer *pointer, want_frame = true; } + seat = input->touch_device->aggregate->seat; if (location == THEME_LOCATION_CLIENT_AREA) { timespec_from_msec(&ts, time); - notify_motion_absolute(&input->base, &ts, pos); + + weston_input_event_init(&event.base_event, &ts, seat); + weston_pointer_motion_event_init(&event, WESTON_POINTER_MOTION_ABS, + &pos, NULL, NULL); + notify_motion(&input->base, &event); want_frame = true; } @@ -1733,6 +1740,7 @@ input_handle_button(void *data, struct wl_pointer *pointer, struct wayland_input *input = data; enum theme_location location; struct timespec ts; + struct weston_pointer_button_event button_event; if (!input->output) return; @@ -1776,7 +1784,11 @@ input_handle_button(void *data, struct wl_pointer *pointer, if (location == THEME_LOCATION_CLIENT_AREA) { timespec_from_msec(&ts, time); - notify_button(&input->base, &ts, button, state); + + weston_input_event_init(&button_event.base_event, &ts, &input->base); + weston_pointer_button_event_init(&button_event, button, state); + notify_button(&input->base, &button_event); + if (input->seat_version < WL_POINTER_FRAME_SINCE_VERSION) notify_pointer_frame(&input->base); } @@ -1789,26 +1801,27 @@ 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); - weston_event.has_discrete = false; + bool has_discrete = false; + int32_t discrete = 0; if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL && input->vert.has_discrete) { - weston_event.has_discrete = true; - weston_event.discrete = input->vert.discrete; + has_discrete = true; + discrete = input->vert.discrete; input->vert.has_discrete = false; } else if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL && input->horiz.has_discrete) { - weston_event.has_discrete = true; - weston_event.discrete = input->horiz.discrete; + has_discrete = true; + discrete = input->horiz.discrete; input->horiz.has_discrete = false; } timespec_from_msec(&ts, time); - notify_axis(&input->base, &ts, &weston_event); + weston_input_event_init(&weston_event.base_event, &ts, &input->base); + weston_pointer_axis_event_init(&weston_event, axis, wl_fixed_to_double(value), + has_discrete, discrete); + notify_axis(&input->base, &weston_event); if (input->seat_version < WL_POINTER_FRAME_SINCE_VERSION) notify_pointer_frame(&input->base); @@ -1839,12 +1852,11 @@ input_handle_axis_stop(void *data, struct wl_pointer *pointer, struct weston_pointer_axis_event weston_event; struct timespec ts; - weston_event.axis = axis; - weston_event.value = 0; - timespec_from_msec(&ts, time); - notify_axis(&input->base, &ts, &weston_event); + weston_input_event_init(&weston_event.base_event, &ts, &input->base); + weston_pointer_axis_event_init(&weston_event, axis, 0, false, 0); + notify_axis(&input->base, &weston_event); } static void @@ -2004,6 +2016,7 @@ input_handle_key(void *data, struct wl_keyboard *keyboard, { struct wayland_input *input = data; struct timespec ts; + struct weston_key_event key_event; if (!input->keyboard_focus) return; @@ -2011,10 +2024,11 @@ input_handle_key(void *data, struct wl_keyboard *keyboard, timespec_from_msec(&ts, time); input->key_serial = serial; - notify_key(&input->base, &ts, key, - state ? WL_KEYBOARD_KEY_STATE_PRESSED : - WL_KEYBOARD_KEY_STATE_RELEASED, - input->keyboard_state_update); + + weston_input_event_init(&key_event.base_event, &ts, &input->base); + weston_key_event_init(&key_event, key, state ? WL_KEYBOARD_KEY_STATE_PRESSED : + WL_KEYBOARD_KEY_STATE_RELEASED, input->keyboard_state_update); + notify_key(&input->base, &key_event); } static void @@ -2077,6 +2091,8 @@ input_handle_touch_down(void *data, struct wl_touch *wl_touch, struct weston_coord_global pos; double x, y; struct timespec ts; + struct weston_touch_event event; + struct weston_seat *seat; x = wl_fixed_to_double(fixed_x); y = wl_fixed_to_double(fixed_y); @@ -2091,6 +2107,7 @@ input_handle_touch_down(void *data, struct wl_touch *wl_touch, if (!first_touch && !input->touch_active) return; + seat = input->touch_device->aggregate->seat; if (output->frame) { location = frame_touch_down(output->frame, input, id, x, y); @@ -2117,7 +2134,9 @@ input_handle_touch_down(void *data, struct wl_touch *wl_touch, pos = weston_coord_global_from_output_point(x,y, &output->base); - notify_touch(input->touch_device, &ts, id, &pos, WL_TOUCH_DOWN); + weston_input_event_init(&event.base_event, &ts, seat); + weston_touch_event_init(&event, WL_TOUCH_DOWN, id, &pos); + notify_touch(input->touch_device, &event); input->touch_active = true; } @@ -2129,6 +2148,8 @@ input_handle_touch_up(void *data, struct wl_touch *wl_touch, struct wayland_output *output = input->touch_focus; bool active = input->touch_active; struct timespec ts; + struct weston_touch_event event; + struct weston_seat *seat; timespec_from_msec(&ts, time); @@ -2137,6 +2158,7 @@ input_handle_touch_up(void *data, struct wl_touch *wl_touch, if (!output) return; + seat = input->touch_device->aggregate->seat; if (output->frame) { frame_touch_up(output->frame, input, id); @@ -2153,8 +2175,11 @@ input_handle_touch_up(void *data, struct wl_touch *wl_touch, weston_output_schedule_repaint(&output->base); } + weston_input_event_init(&event.base_event, &ts, seat); + weston_touch_event_init(&event, WL_TOUCH_UP, id, NULL); + if (active) - notify_touch(input->touch_device, &ts, id, NULL, WL_TOUCH_UP); + notify_touch(input->touch_device, &event); } static void @@ -2168,6 +2193,8 @@ input_handle_touch_motion(void *data, struct wl_touch *wl_touch, double x, y; struct weston_coord_global pos; struct timespec ts; + struct weston_touch_event event; + struct weston_seat *seat; x = wl_fixed_to_double(fixed_x); y = wl_fixed_to_double(fixed_y); @@ -2176,6 +2203,7 @@ input_handle_touch_motion(void *data, struct wl_touch *wl_touch, if (!output || !input->touch_active) return; + seat = input->touch_device->aggregate->seat; if (output->frame) { frame_interior(output->frame, &fx, &fy, NULL, NULL); x -= fx; @@ -2183,8 +2211,9 @@ input_handle_touch_motion(void *data, struct wl_touch *wl_touch, } pos = weston_coord_global_from_output_point(x, y, &output->base); - - notify_touch(input->touch_device, &ts, id, &pos, WL_TOUCH_MOTION); + weston_input_event_init(&event.base_event, &ts, seat); + weston_touch_event_init(&event, WL_TOUCH_MOTION, id, &pos); + notify_touch(input->touch_device, &event); } static void diff --git a/libweston/backend-x11/x11.c b/libweston/backend-x11/x11.c index 182baf6aa..dc26cdc95 100644 --- a/libweston/backend-x11/x11.c +++ b/libweston/backend-x11/x11.c @@ -1414,6 +1414,7 @@ x11_backend_deliver_button_event(struct x11_backend *b, uint32_t button; struct x11_output *output; struct weston_pointer_axis_event weston_event; + struct weston_pointer_button_event b_event; bool is_button_pressed = event->response_type == XCB_BUTTON_PRESS; struct timespec time = { 0 }; @@ -1455,49 +1456,53 @@ x11_backend_deliver_button_event(struct x11_backend *b, /* Axis are measured in pixels, but the xcb events are discrete * steps. Therefore move the axis by some pixels every step. */ if (is_button_pressed) { - weston_event.value = -DEFAULT_AXIS_STEP_DISTANCE; - weston_event.discrete = -1; - weston_event.has_discrete = true; - weston_event.axis = - WL_POINTER_AXIS_VERTICAL_SCROLL; weston_compositor_get_time(&time); - notify_axis(&b->core_seat, &time, &weston_event); + + weston_input_event_init(&weston_event.base_event, + &time, &b->core_seat); + weston_pointer_axis_event_init(&weston_event, + WL_POINTER_AXIS_VERTICAL_SCROLL, + -DEFAULT_AXIS_STEP_DISTANCE, true, -1); + notify_axis(&b->core_seat, &weston_event); notify_pointer_frame(&b->core_seat); } return; case 5: if (is_button_pressed) { - weston_event.value = DEFAULT_AXIS_STEP_DISTANCE; - weston_event.discrete = 1; - weston_event.has_discrete = true; - weston_event.axis = - WL_POINTER_AXIS_VERTICAL_SCROLL; weston_compositor_get_time(&time); - notify_axis(&b->core_seat, &time, &weston_event); + + weston_input_event_init(&weston_event.base_event, + &time, &b->core_seat); + weston_pointer_axis_event_init(&weston_event, + WL_POINTER_AXIS_VERTICAL_SCROLL, + DEFAULT_AXIS_STEP_DISTANCE, true, 1); + notify_axis(&b->core_seat, &weston_event); notify_pointer_frame(&b->core_seat); } return; case 6: if (is_button_pressed) { - weston_event.value = -DEFAULT_AXIS_STEP_DISTANCE; - weston_event.discrete = -1; - weston_event.has_discrete = true; - weston_event.axis = - WL_POINTER_AXIS_HORIZONTAL_SCROLL; weston_compositor_get_time(&time); - notify_axis(&b->core_seat, &time, &weston_event); + + weston_input_event_init(&weston_event.base_event, + &time, &b->core_seat); + weston_pointer_axis_event_init(&weston_event, + WL_POINTER_AXIS_HORIZONTAL_SCROLL, + -DEFAULT_AXIS_STEP_DISTANCE, true, -1); + notify_axis(&b->core_seat, &weston_event); notify_pointer_frame(&b->core_seat); } return; case 7: if (is_button_pressed) { - weston_event.value = DEFAULT_AXIS_STEP_DISTANCE; - weston_event.discrete = 1; - weston_event.has_discrete = true; - weston_event.axis = - WL_POINTER_AXIS_HORIZONTAL_SCROLL; weston_compositor_get_time(&time); - notify_axis(&b->core_seat, &time, &weston_event); + + weston_input_event_init(&weston_event.base_event, + &time, &b->core_seat); + weston_pointer_axis_event_init(&weston_event, + WL_POINTER_AXIS_HORIZONTAL_SCROLL, + DEFAULT_AXIS_STEP_DISTANCE, true, 1); + notify_axis(&b->core_seat, &weston_event); notify_pointer_frame(&b->core_seat); } return; @@ -1507,10 +1512,13 @@ x11_backend_deliver_button_event(struct x11_backend *b, } weston_compositor_get_time(&time); + weston_input_event_init(&b_event.base_event, &time, &b->core_seat); + weston_pointer_button_event_init(&b_event, button, + is_button_pressed ? + WL_POINTER_BUTTON_STATE_PRESSED : + WL_POINTER_BUTTON_STATE_RELEASED); - notify_button(&b->core_seat, &time, button, - is_button_pressed ? WL_POINTER_BUTTON_STATE_PRESSED : - WL_POINTER_BUTTON_STATE_RELEASED); + notify_button(&b->core_seat, &b_event); notify_pointer_frame(&b->core_seat); } @@ -1520,7 +1528,8 @@ x11_backend_deliver_motion_event(struct x11_backend *b, { struct x11_output *output; struct weston_coord_global pos; - struct weston_pointer_motion_event motion_event = { 0 }; + struct weston_pointer_motion_event motion_event; + struct weston_coord rel; xcb_motion_notify_event_t *motion_notify = (xcb_motion_notify_event_t *) event; struct timespec time; @@ -1535,12 +1544,13 @@ x11_backend_deliver_motion_event(struct x11_backend *b, motion_notify->event_y, &output->base); - motion_event = (struct weston_pointer_motion_event) { - .mask = WESTON_POINTER_MOTION_REL, - .rel = weston_coord_global_sub(pos, b->prev_pos).c, - }; + rel = weston_coord_global_sub(pos, b->prev_pos).c; weston_compositor_get_time(&time); - notify_motion(&b->core_seat, &time, &motion_event); + + weston_input_event_init(&motion_event.base_event, &time, &b->core_seat); + weston_pointer_motion_event_init(&motion_event, WESTON_POINTER_MOTION_REL, + NULL, &rel, NULL); + notify_motion(&b->core_seat, &motion_event); notify_pointer_frame(&b->core_seat); b->prev_pos = pos; @@ -1630,11 +1640,15 @@ x11_backend_handle_event(int fd, uint32_t mask, void *data) * event below. */ update_xkb_state_from_core(b, key_release->state); weston_compositor_get_time(&time); - notify_key(&b->core_seat, - &time, - key_release->detail - 8, - WL_KEYBOARD_KEY_STATE_RELEASED, - STATE_UPDATE_AUTOMATIC); + + struct weston_key_event key_event; + + weston_input_event_init(&key_event.base_event, &time, &b->core_seat); + weston_key_event_init(&key_event, key_release->detail - 8, + WL_KEYBOARD_KEY_STATE_RELEASED, + STATE_UPDATE_AUTOMATIC); + + notify_key(&b->core_seat, &key_event); free(b->prev_event); b->prev_event = NULL; break; @@ -1675,12 +1689,15 @@ x11_backend_handle_event(int fd, uint32_t mask, void *data) if (!b->has_xkb) update_xkb_state_from_core(b, key_press->state); weston_compositor_get_time(&time); - notify_key(&b->core_seat, - &time, - key_press->detail - 8, - WL_KEYBOARD_KEY_STATE_PRESSED, - b->has_xkb ? STATE_UPDATE_NONE : - STATE_UPDATE_AUTOMATIC); + + struct weston_key_event key_event; + + weston_input_event_init(&key_event.base_event, &time, &b->core_seat); + weston_key_event_init(&key_event, key_release->detail - 8, + WL_KEYBOARD_KEY_STATE_PRESSED, + b->has_xkb ? STATE_UPDATE_NONE : STATE_UPDATE_AUTOMATIC); + notify_key(&b->core_seat, &key_event); + break; case XCB_KEY_RELEASE: /* If we don't have XKB, we need to use the lame @@ -1691,11 +1708,13 @@ x11_backend_handle_event(int fd, uint32_t mask, void *data) } key_release = (xcb_key_press_event_t *) event; weston_compositor_get_time(&time); - notify_key(&b->core_seat, - &time, - key_release->detail - 8, - WL_KEYBOARD_KEY_STATE_RELEASED, - STATE_UPDATE_NONE); + + struct weston_key_event w_key_event; + + weston_input_event_init(&w_key_event.base_event, &time, &b->core_seat); + weston_key_event_init(&w_key_event, key_release->detail - 8, + WL_KEYBOARD_KEY_STATE_RELEASED, STATE_UPDATE_NONE); + notify_key(&b->core_seat, &w_key_event); break; case XCB_BUTTON_PRESS: case XCB_BUTTON_RELEASE: @@ -1824,11 +1843,14 @@ x11_backend_handle_event(int fd, uint32_t mask, void *data) key_release = (xcb_key_press_event_t *) b->prev_event; update_xkb_state_from_core(b, key_release->state); weston_compositor_get_time(&time); - notify_key(&b->core_seat, - &time, - key_release->detail - 8, - WL_KEYBOARD_KEY_STATE_RELEASED, - STATE_UPDATE_AUTOMATIC); + + struct weston_key_event lshift_key_event; + + weston_input_event_init(&lshift_key_event.base_event, &time, &b->core_seat); + weston_key_event_init(&lshift_key_event, key_release->detail - 8, + WL_KEYBOARD_KEY_STATE_RELEASED, STATE_UPDATE_AUTOMATIC); + notify_key(&b->core_seat, &lshift_key_event); + free(b->prev_event); b->prev_event = NULL; break; diff --git a/libweston/backend.h b/libweston/backend.h index cb4d575d8..4fdd3d868 100644 --- a/libweston/backend.h +++ b/libweston/backend.h @@ -232,19 +232,16 @@ weston_output_finish_frame_from_timer(struct weston_output *output); /* weston_seat */ void -notify_axis(struct weston_seat *seat, const struct timespec *time, - struct weston_pointer_axis_event *event); +notify_axis(struct weston_seat *seat, const struct weston_pointer_axis_event *event); void notify_axis_source(struct weston_seat *seat, uint32_t source); void -notify_button(struct weston_seat *seat, const struct timespec *time, - int32_t button, enum wl_pointer_button_state state); +notify_button(struct weston_seat *seat, struct weston_pointer_button_event *b_event); void -notify_key(struct weston_seat *seat, const struct timespec *time, uint32_t key, - enum wl_keyboard_key_state state, - enum weston_key_state_update update_state); +notify_key(struct weston_seat *seat, const struct weston_key_event *key_event); + void notify_keyboard_focus_in(struct weston_seat *seat, struct wl_array *keys, enum weston_key_state_update update_state); @@ -252,11 +249,8 @@ void notify_keyboard_focus_out(struct weston_seat *seat); void -notify_motion(struct weston_seat *seat, const struct timespec *time, - struct weston_pointer_motion_event *event); -void -notify_motion_absolute(struct weston_seat *seat, const struct timespec *time, - struct weston_coord_global pos); +notify_motion(struct weston_seat *seat, const struct weston_pointer_motion_event *event); + void notify_modifiers(struct weston_seat *seat, uint32_t serial); @@ -274,21 +268,17 @@ clear_pointer_focus(struct weston_seat *seat); void notify_touch_normalized(struct weston_touch_device *device, - const struct timespec *time, - int touch_id, - const struct weston_coord_global *pos, - const struct weston_point2d_device_normalized *norm, - int touch_type); + const struct weston_touch_event *event, + const struct weston_point2d_device_normalized *norm); /** Feed in touch down, motion, and up events, non-calibratable device. * * @sa notify_touch_cal */ static inline void -notify_touch(struct weston_touch_device *device, const struct timespec *time, - int touch_id, const struct weston_coord_global *pos, int touch_type) +notify_touch(struct weston_touch_device *device, const struct weston_touch_event *event) { - notify_touch_normalized(device, time, touch_id, pos, NULL, touch_type); + notify_touch_normalized(device, event, NULL); } void @@ -298,10 +288,8 @@ void notify_touch_cancel(struct weston_touch_device *device); void -notify_touch_calibrator(struct weston_touch_device *device, - const struct timespec *time, int32_t slot, - const struct weston_point2d_device_normalized *norm, - int touch_type); +notify_touch_calibrator(struct weston_touch_device *device, const struct weston_touch_event *event, + const struct weston_point2d_device_normalized *norm); void notify_touch_calibrator_cancel(struct weston_touch_device *device); void diff --git a/libweston/bindings.c b/libweston/bindings.c index 4d2ad94f6..dd0e201f8 100644 --- a/libweston/bindings.c +++ b/libweston/bindings.c @@ -216,13 +216,14 @@ struct binding_keyboard_grab { }; static void -binding_key(struct weston_keyboard_grab *grab, - const struct timespec *time, uint32_t key, uint32_t state_w) +binding_key(struct weston_keyboard_grab *grab, const struct weston_key_event *key_event) { struct binding_keyboard_grab *b = container_of(grab, struct binding_keyboard_grab, grab); struct wl_resource *resource; - enum wl_keyboard_key_state state = state_w; + enum wl_keyboard_key_state state = key_event->key_state; + struct timespec *time = key_event->base_event.ts; + uint32_t key = key_event->key; uint32_t serial; struct weston_keyboard *keyboard = grab->keyboard; struct wl_display *display = keyboard->seat->compositor->wl_display; @@ -441,7 +442,7 @@ int weston_compositor_run_axis_binding(struct weston_compositor *compositor, struct weston_pointer *pointer, const struct timespec *time, - struct weston_pointer_axis_event *event) + const struct weston_pointer_axis_event *event) { struct weston_binding *b, *tmp; @@ -491,8 +492,8 @@ struct debug_binding_grab { }; static void -debug_binding_key(struct weston_keyboard_grab *grab, const struct timespec *time, - uint32_t key, uint32_t state) +debug_binding_key(struct weston_keyboard_grab *grab, + const struct weston_key_event *key_event) { struct debug_binding_grab *db = (struct debug_binding_grab *) grab; struct weston_compositor *ec = db->seat->compositor; @@ -501,6 +502,9 @@ debug_binding_key(struct weston_keyboard_grab *grab, const struct timespec *time uint32_t serial; int send = 0, terminate = 0; int check_binding = 1; + struct timespec *time = key_event->base_event.ts; + uint32_t key = key_event->key; + uint32_t state = key_event->key_state; int i; struct wl_list *resource_list; uint32_t msecs; diff --git a/libweston/compositor.c b/libweston/compositor.c index 8259f9795..cc0ba27f7 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -8012,6 +8012,7 @@ weston_output_set_transform(struct weston_output *output, uint32_t transform) { struct weston_pointer_motion_event ev; + struct weston_coord_global pos; struct wl_resource *resource; struct weston_seat *seat; pixman_region32_t old_region; @@ -8067,7 +8068,8 @@ weston_output_set_transform(struct weston_output *output, mid_y = output->pos.c.y + output->height / 2; ev.mask = WESTON_POINTER_MOTION_ABS; - ev.abs.c = weston_coord(mid_x, mid_y); + pos.c = weston_coord(mid_x, mid_y); + ev.abs = &pos; wl_list_for_each(seat, &output->compositor->seat_list, link) { struct weston_pointer *pointer = weston_seat_get_pointer(seat); diff --git a/libweston/data-device.c b/libweston/data-device.c index 905d002c1..1a3cc8f8c 100644 --- a/libweston/data-device.c +++ b/libweston/data-device.c @@ -591,8 +591,7 @@ drag_grab_focus(struct weston_pointer_grab *grab) static void drag_grab_motion(struct weston_pointer_grab *grab, - const struct timespec *time, - struct weston_pointer_motion_event *event) + const struct weston_pointer_motion_event *event) { struct weston_pointer_drag *drag = container_of(grab, struct weston_pointer_drag, grab); @@ -610,7 +609,7 @@ drag_grab_motion(struct weston_pointer_grab *grab, if (drag->base.focus_resource) { struct weston_coord_surface surf_pos; - msecs = timespec_to_msec(time); + msecs = timespec_to_msec(event->base_event.ts); surf_pos = weston_coord_global_to_surface(drag->base.focus, pointer->pos); @@ -653,17 +652,16 @@ data_device_end_pointer_drag_grab(struct weston_pointer_drag *drag) static void drag_grab_button(struct weston_pointer_grab *grab, - const struct timespec *time, - uint32_t button, uint32_t state_w) + const struct weston_pointer_button_event *button_event) { struct weston_pointer_drag *drag = container_of(grab, struct weston_pointer_drag, grab); struct weston_pointer *pointer = drag->grab.pointer; - enum wl_pointer_button_state state = state_w; + enum wl_pointer_button_state state = button_event->button_state; struct weston_data_source *data_source = drag->base.data_source; if (data_source && - pointer->grab_button == button && + pointer->grab_button == button_event->button && state == WL_POINTER_BUTTON_STATE_RELEASED) { if (drag->base.focus_resource && data_source->accepted && @@ -695,8 +693,7 @@ drag_grab_button(struct weston_pointer_grab *grab, static void drag_grab_axis(struct weston_pointer_grab *grab, - const struct timespec *time, - struct weston_pointer_axis_event *event) + const struct weston_pointer_axis_event *event) { } @@ -733,9 +730,7 @@ static const struct weston_pointer_grab_interface pointer_drag_grab_interface = }; static void -drag_grab_touch_down(struct weston_touch_grab *grab, - const struct timespec *time, int touch_id, - struct weston_coord_global c) +drag_grab_touch_down(struct weston_touch_grab *grab, const struct weston_touch_event *event) { } @@ -753,14 +748,13 @@ data_device_end_touch_drag_grab(struct weston_touch_drag *drag) } static void -drag_grab_touch_up(struct weston_touch_grab *grab, - const struct timespec *time, int touch_id) +drag_grab_touch_up(struct weston_touch_grab *grab, const struct weston_touch_event *event) { struct weston_touch_drag *touch_drag = container_of(grab, struct weston_touch_drag, grab); struct weston_touch *touch = grab->touch; - if (touch_id != touch->grab_touch_id) + if (event->touch_id != touch->grab_touch_id) return; if (touch_drag->base.focus_resource) @@ -782,15 +776,14 @@ drag_grab_touch_focus(struct weston_touch_drag *drag) static void drag_grab_touch_motion(struct weston_touch_grab *grab, - const struct timespec *time, - int touch_id, struct weston_coord_global unused) + const struct weston_touch_event *event) { struct weston_touch_drag *touch_drag = container_of(grab, struct weston_touch_drag, grab); struct weston_touch *touch = grab->touch; uint32_t msecs; - if (touch_id != touch->grab_touch_id) + if (event->touch_id != touch->grab_touch_id) return; drag_grab_touch_focus(touch_drag); @@ -802,7 +795,7 @@ drag_grab_touch_motion(struct weston_touch_grab *grab, if (touch_drag->base.focus_resource) { struct weston_coord_surface surf_pos; - msecs = timespec_to_msec(time); + msecs = timespec_to_msec(event->base_event.ts); surf_pos = weston_coord_global_to_surface(touch_drag->base.focus, touch->grab_pos); wl_data_device_send_motion(touch_drag->base.focus_resource, @@ -838,7 +831,7 @@ static const struct weston_touch_grab_interface touch_drag_grab_interface = { static void drag_grab_keyboard_key(struct weston_keyboard_grab *grab, - const struct timespec *time, uint32_t key, uint32_t state) + const struct weston_key_event *key_event) { } diff --git a/libweston/desktop/seat.c b/libweston/desktop/seat.c index d45719de0..4bdd016df 100644 --- a/libweston/desktop/seat.c +++ b/libweston/desktop/seat.c @@ -57,11 +57,9 @@ static void weston_desktop_seat_popup_grab_end(struct weston_desktop_seat *seat) static void weston_desktop_seat_popup_grab_keyboard_key(struct weston_keyboard_grab *grab, - const struct timespec *time, - uint32_t key, - enum wl_keyboard_key_state state) + const struct weston_key_event *key_event) { - weston_keyboard_send_key(grab->keyboard, time, key, state); + weston_keyboard_send_key(grab->keyboard, key_event); } static void @@ -119,28 +117,27 @@ weston_desktop_seat_popup_grab_pointer_focus(struct weston_pointer_grab *grab) static void weston_desktop_seat_popup_grab_pointer_motion(struct weston_pointer_grab *grab, - const struct timespec *time, - struct weston_pointer_motion_event *event) + const struct weston_pointer_motion_event *event) { - weston_pointer_send_motion(grab->pointer, time, event); + weston_pointer_send_motion(grab->pointer, event); } static void weston_desktop_seat_popup_grab_pointer_button(struct weston_pointer_grab *grab, - const struct timespec *time, - uint32_t button, - enum wl_pointer_button_state state) + const struct weston_pointer_button_event *button_event) { struct weston_desktop_seat *seat = wl_container_of(grab, seat, popup_grab.pointer); struct weston_pointer *pointer = grab->pointer; bool initial_up = seat->popup_grab.initial_up; + enum wl_pointer_button_state state = button_event->button_state; + struct timespec *time = button_event->base_event.ts; if (state == WL_POINTER_BUTTON_STATE_RELEASED) seat->popup_grab.initial_up = true; if (weston_pointer_has_focus_resource(pointer)) - weston_pointer_send_button(pointer, time, button, state); + weston_pointer_send_button(pointer, button_event); else if (state == WL_POINTER_BUTTON_STATE_RELEASED && (initial_up || (timespec_sub_to_msec(time, &grab->pointer->grab_time) > 500))) @@ -149,10 +146,9 @@ 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, - const struct timespec *time, - struct weston_pointer_axis_event *event) + const struct weston_pointer_axis_event *event) { - weston_pointer_send_axis(grab->pointer, time, event); + weston_pointer_send_axis(grab->pointer, event); } static void @@ -189,28 +185,23 @@ 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, - const struct timespec *time, - int touch_id, - struct weston_coord_global pos) + const struct weston_touch_event *event) { - weston_touch_send_down(grab->touch, time, touch_id, pos); + weston_touch_send_down(grab->touch, event); } static void weston_desktop_seat_popup_grab_touch_up(struct weston_touch_grab *grab, - const struct timespec *time, - int touch_id) + const struct weston_touch_event *event) { - weston_touch_send_up(grab->touch, time, touch_id); + weston_touch_send_up(grab->touch, event); } static void weston_desktop_seat_popup_grab_touch_motion(struct weston_touch_grab *grab, - const struct timespec *time, - int touch_id, - struct weston_coord_global pos) + const struct weston_touch_event *event) { - weston_touch_send_motion(grab->touch, time, touch_id, pos); + weston_touch_send_motion(grab->touch, event); } static void diff --git a/libweston/input.c b/libweston/input.c index e51faf78a..ec3781ec8 100644 --- a/libweston/input.c +++ b/libweston/input.c @@ -41,6 +41,7 @@ #include #include "shared/helpers.h" +#include "shared/weston-assert.h" #include "shared/os-compatibility.h" #include "shared/timespec-util.h" #include @@ -51,6 +52,7 @@ #include "pointer-constraints-unstable-v1-server-protocol.h" #include "input-timestamps-unstable-v1-server-protocol.h" #include "tablet-unstable-v2-server-protocol.h" +#include "timeline.h" enum pointer_constraint_type { POINTER_CONSTRAINT_TYPE_LOCK, @@ -304,14 +306,14 @@ static void unbind_resource(struct wl_resource *resource) WL_EXPORT struct weston_coord_global weston_pointer_motion_to_abs(struct weston_pointer *pointer, - struct weston_pointer_motion_event *event) + const struct weston_pointer_motion_event *event) { struct weston_coord_global pos; if (event->mask & WESTON_POINTER_MOTION_ABS) { - return event->abs; + return *event->abs; } else if (event->mask & WESTON_POINTER_MOTION_REL) { - pos.c = weston_coord_add(pointer->pos.c, event->rel); + pos.c = weston_coord_add(pointer->pos.c, *event->rel); return pos; } @@ -322,22 +324,22 @@ weston_pointer_motion_to_abs(struct weston_pointer *pointer, static bool weston_pointer_motion_to_rel(struct weston_pointer *pointer, - struct weston_pointer_motion_event *event, + const struct weston_pointer_motion_event *event, struct weston_coord *rel, struct weston_coord *rel_unaccel) { if (event->mask & WESTON_POINTER_MOTION_REL && event->mask & WESTON_POINTER_MOTION_REL_UNACCEL) { - *rel = event->rel; - *rel_unaccel = event->rel_unaccel; + *rel = *event->rel; + *rel_unaccel = *event->rel_unaccel; return true; } else if (event->mask & WESTON_POINTER_MOTION_REL) { - *rel = event->rel; - *rel_unaccel = event->rel; + *rel = *event->rel; + *rel_unaccel = *event->rel; return true; } else if (event->mask & WESTON_POINTER_MOTION_REL_UNACCEL) { - *rel = event->rel_unaccel; - *rel_unaccel = event->rel_unaccel; + *rel = *event->rel_unaccel; + *rel_unaccel = *event->rel_unaccel; return true; } else { return false; @@ -546,7 +548,7 @@ weston_pointer_move_to(struct weston_pointer *pointer, WL_EXPORT void weston_pointer_move(struct weston_pointer *pointer, - struct weston_pointer_motion_event *event) + const struct weston_pointer_motion_event *event) { struct weston_coord_global pos; @@ -556,8 +558,7 @@ weston_pointer_move(struct weston_pointer *pointer, static void pointer_send_relative_motion(struct weston_pointer *pointer, - const struct timespec *time, - struct weston_pointer_motion_event *event) + const struct weston_pointer_motion_event *event) { uint64_t time_usec; struct weston_coord rel, rel_unaccel; @@ -573,9 +574,9 @@ pointer_send_relative_motion(struct weston_pointer *pointer, return; resource_list = &pointer->focus_client->relative_pointer_resources; - time_usec = timespec_to_usec(&event->time); + time_usec = timespec_to_usec(event->base_event.ts); if (time_usec == 0) - time_usec = timespec_to_usec(time); + time_usec = timespec_to_usec(event->base_event.ts); wl_resource_for_each(resource, resource_list) { zwp_relative_pointer_v1_send_relative_motion( @@ -590,9 +591,8 @@ pointer_send_relative_motion(struct weston_pointer *pointer, } static void -pointer_send_motion(struct weston_pointer *pointer, - const struct timespec *time, - wl_fixed_t sx, wl_fixed_t sy) +pointer_send_motion(struct weston_pointer *pointer, wl_fixed_t sx, wl_fixed_t sy, + const struct weston_pointer_motion_event *event) { struct wl_list *resource_list; struct wl_resource *resource; @@ -602,19 +602,18 @@ pointer_send_motion(struct weston_pointer *pointer, return; resource_list = &pointer->focus_client->pointer_resources; - msecs = timespec_to_msec(time); + msecs = timespec_to_msec(event->base_event.ts); wl_resource_for_each(resource, resource_list) { send_timestamps_for_input_resource(resource, &pointer->timestamps_list, - time); + event->base_event.ts); wl_pointer_send_motion(resource, msecs, sx, sy); } } WL_EXPORT void weston_pointer_send_motion(struct weston_pointer *pointer, - const struct timespec *time, - struct weston_pointer_motion_event *event) + const struct weston_pointer_motion_event *event) { wl_fixed_t old_sx; wl_fixed_t old_sy; @@ -622,7 +621,7 @@ weston_pointer_send_motion(struct weston_pointer *pointer, struct weston_coord_global pos; pos = weston_pointer_motion_to_abs(pointer, event); - pos = weston_pointer_clamp(pointer,pos); + pos = weston_pointer_clamp(pointer, pos); if (pointer->focus) { struct weston_coord_surface surf_pos; @@ -642,19 +641,17 @@ weston_pointer_send_motion(struct weston_pointer *pointer, if (pointer->focus && old_focus == pointer->focus && (old_sx != pointer->sx || old_sy != pointer->sy)) { - pointer_send_motion(pointer, time, - pointer->sx, pointer->sy); + pointer_send_motion(pointer, pointer->sx, pointer->sy, event); } - pointer_send_relative_motion(pointer, time, event); + pointer_send_relative_motion(pointer, event); } static void default_grab_pointer_motion(struct weston_pointer_grab *grab, - const struct timespec *time, - struct weston_pointer_motion_event *event) + const struct weston_pointer_motion_event *event) { - weston_pointer_send_motion(grab->pointer, time, event); + weston_pointer_send_motion(grab->pointer, event); } /** Check if the pointer has focused resources. @@ -677,9 +674,7 @@ weston_pointer_has_focus_resource(struct weston_pointer *pointer) /** Send wl_pointer.button events to focused resources. * * \param pointer The pointer where the button events originates from. - * \param time The timestamp of the event - * \param button The button value of the event - * \param state The state enum value of the event + * \param button_event A pointer to weston_pointer_button_event * * For every resource that is currently in focus, send a wl_pointer.button event * with the passed parameters. The focused resources are the wl_pointer @@ -687,14 +682,16 @@ weston_pointer_has_focus_resource(struct weston_pointer *pointer) */ WL_EXPORT void weston_pointer_send_button(struct weston_pointer *pointer, - const struct timespec *time, uint32_t button, - enum wl_pointer_button_state state) + const struct weston_pointer_button_event *button_event) { struct wl_display *display = pointer->seat->compositor->wl_display; struct wl_list *resource_list; struct wl_resource *resource; uint32_t serial; uint32_t msecs; + struct timespec *time = button_event->base_event.ts; + uint32_t button = button_event->button; + enum wl_pointer_button_state state = button_event->button_state; if (!weston_pointer_has_focus_resource(pointer)) return; @@ -712,14 +709,14 @@ weston_pointer_send_button(struct weston_pointer *pointer, static void default_grab_pointer_button(struct weston_pointer_grab *grab, - const struct timespec *time, uint32_t button, - enum wl_pointer_button_state state) + const struct weston_pointer_button_event *button_event) { struct weston_pointer *pointer = grab->pointer; struct weston_compositor *compositor = pointer->seat->compositor; struct weston_view *view; + enum wl_pointer_button_state state = button_event->button_state; - weston_pointer_send_button(pointer, time, button, state); + weston_pointer_send_button(pointer, button_event); if (pointer->button_count == 0 && state == WL_POINTER_BUTTON_STATE_RELEASED) { @@ -733,7 +730,6 @@ default_grab_pointer_button(struct weston_pointer_grab *grab, /** Send wl_pointer.axis events to focused resources. * * \param pointer The pointer where the axis events originates from. - * \param time The timestamp of the event * \param event The axis value of the event * * For every resource that is currently in focus, send a wl_pointer.axis event @@ -742,8 +738,7 @@ default_grab_pointer_button(struct weston_pointer_grab *grab, */ WL_EXPORT void weston_pointer_send_axis(struct weston_pointer *pointer, - const struct timespec *time, - struct weston_pointer_axis_event *event) + const struct weston_pointer_axis_event *event) { struct wl_resource *resource; struct wl_list *resource_list; @@ -753,7 +748,7 @@ weston_pointer_send_axis(struct weston_pointer *pointer, return; resource_list = &pointer->focus_client->pointer_resources; - msecs = timespec_to_msec(time); + msecs = timespec_to_msec(event->base_event.ts); wl_resource_for_each(resource, resource_list) { if (event->has_discrete && wl_resource_get_version(resource) >= @@ -764,7 +759,7 @@ weston_pointer_send_axis(struct weston_pointer *pointer, if (event->value) { send_timestamps_for_input_resource(resource, &pointer->timestamps_list, - time); + event->base_event.ts); wl_pointer_send_axis(resource, msecs, event->axis, wl_fixed_from_double(event->value)); @@ -772,7 +767,7 @@ weston_pointer_send_axis(struct weston_pointer *pointer, WL_POINTER_AXIS_STOP_SINCE_VERSION) { send_timestamps_for_input_resource(resource, &pointer->timestamps_list, - time); + event->base_event.ts); wl_pointer_send_axis_stop(resource, msecs, event->axis); } @@ -840,10 +835,9 @@ weston_pointer_send_frame(struct weston_pointer *pointer) static void default_grab_pointer_axis(struct weston_pointer_grab *grab, - const struct timespec *time, - struct weston_pointer_axis_event *event) + const struct weston_pointer_axis_event *event) { - weston_pointer_send_axis(grab->pointer, time, event); + weston_pointer_send_axis(grab->pointer, event); } static void @@ -895,17 +889,15 @@ weston_touch_has_focus_resource(struct weston_touch *touch) /** Send wl_touch.down events to focused resources. * * \param touch The touch where the down events originates from. - * \param time The timestamp of the event - * \param touch_id The touch_id value of the event - * \param pos The global coordinate of the event + * \param event The weston_touch_event * * For every resource that is currently in focus, send a wl_touch.down event * with the passed parameters. The focused resources are the wl_touch * resources of the client which currently has the surface with touch focus. */ WL_EXPORT void -weston_touch_send_down(struct weston_touch *touch, const struct timespec *time, - int touch_id, struct weston_coord_global pos) +weston_touch_send_down(struct weston_touch *touch, + const struct weston_touch_event *event) { struct wl_display *display = touch->seat->compositor->wl_display; uint32_t serial; @@ -917,18 +909,19 @@ weston_touch_send_down(struct weston_touch *touch, const struct timespec *time, if (!weston_touch_has_focus_resource(touch)) return; - surf_pos = weston_coord_global_to_surface(touch->focus, pos); + surf_pos = weston_coord_global_to_surface(touch->focus, *event->pos); + weston_view_update_transform(touch->focus); resource_list = &touch->focus_resource_list; serial = wl_display_next_serial(display); - msecs = timespec_to_msec(time); + msecs = timespec_to_msec(event->base_event.ts); wl_resource_for_each(resource, resource_list) { send_timestamps_for_input_resource(resource, &touch->timestamps_list, - time); + event->base_event.ts); wl_touch_send_down(resource, serial, msecs, touch->focus->surface->resource, - touch_id, + event->touch_id, wl_fixed_from_double(surf_pos.c.x), wl_fixed_from_double(surf_pos.c.y)); } @@ -936,25 +929,23 @@ weston_touch_send_down(struct weston_touch *touch, const struct timespec *time, static void default_grab_touch_down(struct weston_touch_grab *grab, - const struct timespec *time, int touch_id, - struct weston_coord_global pos) + const struct weston_touch_event *event) { - weston_touch_send_down(grab->touch, time, touch_id, pos); + weston_touch_send_down(grab->touch, event); } /** Send wl_touch.up events to focused resources. * * \param touch The touch where the up events originates from. - * \param time The timestamp of the event - * \param touch_id The touch_id value of the event + * \param event The weston_touch_event * * For every resource that is currently in focus, send a wl_touch.up event * with the passed parameters. The focused resources are the wl_touch * resources of the client which currently has the surface with touch focus. */ WL_EXPORT void -weston_touch_send_up(struct weston_touch *touch, const struct timespec *time, - int touch_id) +weston_touch_send_up(struct weston_touch *touch, + const struct weston_touch_event *event) { struct wl_display *display = touch->seat->compositor->wl_display; uint32_t serial; @@ -967,28 +958,26 @@ weston_touch_send_up(struct weston_touch *touch, const struct timespec *time, resource_list = &touch->focus_resource_list; serial = wl_display_next_serial(display); - msecs = timespec_to_msec(time); + msecs = timespec_to_msec(event->base_event.ts); wl_resource_for_each(resource, resource_list) { send_timestamps_for_input_resource(resource, &touch->timestamps_list, - time); - wl_touch_send_up(resource, serial, msecs, touch_id); + event->base_event.ts); + wl_touch_send_up(resource, serial, msecs, event->touch_id); } } static void default_grab_touch_up(struct weston_touch_grab *grab, - const struct timespec *time, int touch_id) + const struct weston_touch_event *event) { - weston_touch_send_up(grab->touch, time, touch_id); + weston_touch_send_up(grab->touch, event); } /** Send wl_touch.motion events to focused resources. * * \param touch The touch where the motion events originates from. - * \param time The timestamp of the event - * \param touch_id The touch_id value of the event - * \param pos The global coordinate of the event + * \param event The weston_touch_event * * For every resource that is currently in focus, send a wl_touch.motion event * with the passed parameters. The focused resources are the wl_touch @@ -996,8 +985,7 @@ default_grab_touch_up(struct weston_touch_grab *grab, */ WL_EXPORT void weston_touch_send_motion(struct weston_touch *touch, - const struct timespec *time, int touch_id, - struct weston_coord_global pos) + const struct weston_touch_event *event) { struct wl_resource *resource; struct wl_list *resource_list; @@ -1007,15 +995,16 @@ weston_touch_send_motion(struct weston_touch *touch, if (!weston_touch_has_focus_resource(touch)) return; - surf_pos = weston_coord_global_to_surface(touch->focus, pos); + surf_pos = weston_coord_global_to_surface(touch->focus, *event->pos); + weston_view_update_transform(touch->focus); resource_list = &touch->focus_resource_list; - msecs = timespec_to_msec(time); + msecs = timespec_to_msec(event->base_event.ts); wl_resource_for_each(resource, resource_list) { send_timestamps_for_input_resource(resource, &touch->timestamps_list, - time); - wl_touch_send_motion(resource, msecs, touch_id, + event->base_event.ts); + wl_touch_send_motion(resource, msecs, event->touch_id, wl_fixed_from_double(surf_pos.c.x), wl_fixed_from_double(surf_pos.c.y)); } @@ -1023,10 +1012,9 @@ weston_touch_send_motion(struct weston_touch *touch, static void default_grab_touch_motion(struct weston_touch_grab *grab, - const struct timespec *time, int touch_id, - struct weston_coord_global pos) + const struct weston_touch_event *event) { - weston_touch_send_motion(grab->touch, time, touch_id, pos); + weston_touch_send_motion(grab->touch, event); } @@ -1089,24 +1077,24 @@ weston_keyboard_has_focus_resource(struct weston_keyboard *keyboard) /** Send wl_keyboard.key events to focused resources. * * \param keyboard The keyboard where the key events originates from. - * \param time The timestamp of the event - * \param key The key value of the event - * \param state The state enum value of the event + * \param key_event The weston_key_event as a pointer * - * For every resource that is currently in focus, send a wl_keyboard.key event + * For every resource that is currently in focus, send a key event * with the passed parameters. The focused resources are the wl_keyboard * resources of the client which currently has the surface with keyboard focus. */ WL_EXPORT void weston_keyboard_send_key(struct weston_keyboard *keyboard, - const struct timespec *time, uint32_t key, - enum wl_keyboard_key_state state) + const struct weston_key_event *key_event) { struct wl_resource *resource; struct wl_display *display = keyboard->seat->compositor->wl_display; uint32_t serial; struct wl_list *resource_list; uint32_t msecs; + struct timespec *time = key_event->base_event.ts; + uint32_t key = key_event->key; + enum wl_keyboard_key_state state = key_event->key_state; if (!weston_keyboard_has_focus_resource(keyboard)) return; @@ -1124,10 +1112,9 @@ weston_keyboard_send_key(struct weston_keyboard *keyboard, static void default_grab_keyboard_key(struct weston_keyboard_grab *grab, - const struct timespec *time, uint32_t key, - uint32_t state) + const struct weston_key_event *key_event) { - weston_keyboard_send_key(grab->keyboard, time, key, state); + weston_keyboard_send_key(grab->keyboard, key_event); } static void @@ -2245,14 +2232,13 @@ weston_pointer_handle_output_destroy(struct wl_listener *listener, void *data) WL_EXPORT void notify_motion(struct weston_seat *seat, - const struct timespec *time, - struct weston_pointer_motion_event *event) + const struct weston_pointer_motion_event *event) { struct weston_compositor *ec = seat->compositor; struct weston_pointer *pointer = weston_seat_get_pointer(seat); weston_compositor_wake(ec); - pointer->grab->interface->motion(pointer->grab, time, event); + pointer->grab->interface->motion(pointer->grab, event); } static void @@ -2291,23 +2277,6 @@ run_modifier_bindings(struct weston_seat *seat, uint32_t old, uint32_t new) } } -WL_EXPORT void -notify_motion_absolute(struct weston_seat *seat, const struct timespec *time, - struct weston_coord_global pos) -{ - struct weston_compositor *ec = seat->compositor; - struct weston_pointer *pointer = weston_seat_get_pointer(seat); - struct weston_pointer_motion_event event = { 0 }; - - weston_compositor_wake(ec); - - event = (struct weston_pointer_motion_event) { - .mask = WESTON_POINTER_MOTION_ABS, - .abs = pos, - }; - pointer->grab->interface->motion(pointer->grab, time, &event); -} - static unsigned int peek_next_activate_serial(struct weston_compositor *c) { @@ -2348,17 +2317,16 @@ weston_view_activate_input(struct weston_view *view, } WL_EXPORT void -notify_button(struct weston_seat *seat, const struct timespec *time, - int32_t button, enum wl_pointer_button_state state) +notify_button(struct weston_seat *seat, struct weston_pointer_button_event *event) { struct weston_compositor *compositor = seat->compositor; struct weston_pointer *pointer = weston_seat_get_pointer(seat); - if (state == WL_POINTER_BUTTON_STATE_PRESSED) { + if (event->button_state == WL_POINTER_BUTTON_STATE_PRESSED) { weston_compositor_idle_inhibit(compositor); if (pointer->button_count == 0) { - pointer->grab_button = button; - pointer->grab_time = *time; + pointer->grab_button = event->button; + pointer->grab_time = *event->base_event.ts; pointer->grab_pos = pointer->pos; } pointer->button_count++; @@ -2367,10 +2335,10 @@ notify_button(struct weston_seat *seat, const struct timespec *time, pointer->button_count--; } - weston_compositor_run_button_binding(compositor, pointer, time, button, - state); + weston_compositor_run_button_binding(compositor, pointer, event->base_event.ts, + event->button, event->button_state); - pointer->grab->interface->button(pointer->grab, time, button, state); + pointer->grab->interface->button(pointer->grab, event); if (pointer->button_count == 1) pointer->grab_serial = @@ -2378,19 +2346,17 @@ notify_button(struct weston_seat *seat, const struct timespec *time, } WL_EXPORT void -notify_axis(struct weston_seat *seat, const struct timespec *time, - struct weston_pointer_axis_event *event) +notify_axis(struct weston_seat *seat, const struct weston_pointer_axis_event *event) { struct weston_compositor *compositor = seat->compositor; struct weston_pointer *pointer = weston_seat_get_pointer(seat); weston_compositor_wake(compositor); - if (weston_compositor_run_axis_binding(compositor, pointer, - time, event)) + if (weston_compositor_run_axis_binding(compositor, pointer, event->base_event.ts, event)) return; - pointer->grab->interface->axis(pointer->grab, time, event); + pointer->grab->interface->axis(pointer->grab, event); } WL_EXPORT void @@ -2664,13 +2630,15 @@ update_keymap(struct weston_seat *seat) } WL_EXPORT void -notify_key(struct weston_seat *seat, const struct timespec *time, uint32_t key, - enum wl_keyboard_key_state state, - enum weston_key_state_update update_state) +notify_key(struct weston_seat *seat, const struct weston_key_event *key_event) { + struct timespec *time = key_event->base_event.ts; struct weston_compositor *compositor = seat->compositor; struct weston_keyboard *keyboard = weston_seat_get_keyboard(seat); struct weston_keyboard_grab *grab = keyboard->grab; + enum wl_keyboard_key_state state = key_event->key_state; + uint32_t key = key_event->key; + enum weston_key_state_update update_state = key_event->key_update_state; uint32_t *k, *end; end = keyboard->keys.data + keyboard->keys.size; @@ -2702,7 +2670,7 @@ notify_key(struct weston_seat *seat, const struct timespec *time, uint32_t key, grab = keyboard->grab; } - grab->interface->key(grab, time, key, state); + grab->interface->key(grab, key_event); if (keyboard->pending_keymap && keyboard->keys.size == 0) @@ -2861,28 +2829,24 @@ weston_touch_set_focus(struct weston_touch *touch, struct weston_view *view) static void process_touch_normal(struct weston_touch_device *device, - const struct timespec *time, int touch_id, - const struct weston_coord_global *pos, int touch_type) + const struct weston_touch_event *event) { struct weston_touch *touch = device->aggregate; struct weston_touch_grab *grab = device->aggregate->grab; struct weston_compositor *ec = device->aggregate->seat->compositor; struct weston_view *ev; - if (touch_type != WL_TOUCH_UP) - assert(pos); - /* Update grab's global coordinates. */ - if (touch_id == touch->grab_touch_id && touch_type != WL_TOUCH_UP) - touch->grab_pos = *pos; + if (event->touch_id == touch->grab_touch_id && event->touch_type != WL_TOUCH_UP) + touch->grab_pos = *event->pos; - switch (touch_type) { + switch (event->touch_type) { case WL_TOUCH_DOWN: /* the first finger down picks the view, and all further go * to that view for the remainder of the touch session i.e. * until all touch points are up again. */ if (touch->num_tp == 1) { - ev = weston_compositor_pick_view(ec, *pos); + ev = weston_compositor_pick_view(ec, *event->pos); weston_touch_set_focus(touch, ev); } else if (!touch->focus) { /* Unexpected condition: We have non-initial touch but @@ -2894,15 +2858,16 @@ process_touch_normal(struct weston_touch_device *device, } weston_compositor_run_touch_binding(ec, touch, - time, touch_type); + event->base_event.ts, + event->touch_type); - grab->interface->down(grab, time, touch_id, *pos); + grab->interface->down(grab, event); if (touch->num_tp == 1) { touch->grab_serial = wl_display_get_serial(ec->wl_display); - touch->grab_touch_id = touch_id; - touch->grab_time = *time; - touch->grab_pos = *pos; + touch->grab_touch_id = event->touch_id; + touch->grab_time = *event->base_event.ts; + touch->grab_pos = *event->pos; } break; @@ -2911,10 +2876,10 @@ process_touch_normal(struct weston_touch_device *device, if (!ev) break; - grab->interface->motion(grab, time, touch_id, *pos); + grab->interface->motion(grab, event); break; case WL_TOUCH_UP: - grab->interface->up(grab, time, touch_id); + grab->interface->up(grab, event); touch->pending_focus_reset = true; break; } @@ -3026,11 +2991,8 @@ weston_compositor_set_touch_mode_calib(struct weston_compositor *compositor) * for sending along such order. * * \param device The physical device that generated the event. - * \param time The event timestamp. - * \param touch_id ID for the touch point of this event (multi-touch). - * \param pos X,Y coordinate in compositor global space, or NULL for WL_TOUCH_UP. + * \param event The weston_touch_event event * \param norm Normalized device X, Y coordinates in calibration space, or NULL. - * \param touch_type Either WL_TOUCH_DOWN, WL_TOUCH_UP, or WL_TOUCH_MOTION. * * Coordinates double_x and double_y are used for normal operation. * @@ -3044,28 +3006,21 @@ weston_compositor_set_touch_mode_calib(struct weston_compositor *compositor) */ WL_EXPORT void notify_touch_normalized(struct weston_touch_device *device, - const struct timespec *time, - int touch_id, - const struct weston_coord_global *pos, - const struct weston_point2d_device_normalized *norm, - int touch_type) + const struct weston_touch_event *event, + const struct weston_point2d_device_normalized *norm) { struct weston_seat *seat = device->aggregate->seat; struct weston_touch *touch = device->aggregate; - if (touch_type != WL_TOUCH_UP) { - assert(pos); - + if (event->touch_type != WL_TOUCH_UP) { if (weston_touch_device_can_calibrate(device)) assert(norm != NULL); else assert(norm == NULL); - } else { - assert(!pos); } /* Update touchpoints count regardless of the current mode. */ - switch (touch_type) { + switch (event->touch_type) { case WL_TOUCH_DOWN: weston_compositor_idle_inhibit(seat->compositor); @@ -3093,12 +3048,11 @@ notify_touch_normalized(struct weston_touch_device *device, switch (weston_touch_device_get_mode(device)) { case WESTON_TOUCH_MODE_NORMAL: case WESTON_TOUCH_MODE_PREP_CALIB: - process_touch_normal(device, time, touch_id, pos, touch_type); + process_touch_normal(device, event); break; case WESTON_TOUCH_MODE_CALIB: case WESTON_TOUCH_MODE_PREP_NORMAL: - notify_touch_calibrator(device, time, touch_id, - norm, touch_type); + notify_touch_calibrator(device, event, norm); break; } } @@ -4733,27 +4687,23 @@ locked_pointer_grab_pointer_focus(struct weston_pointer_grab *grab) static void locked_pointer_grab_pointer_motion(struct weston_pointer_grab *grab, - const struct timespec *time, - struct weston_pointer_motion_event *event) + const struct weston_pointer_motion_event *event) { - pointer_send_relative_motion(grab->pointer, time, event); + pointer_send_relative_motion(grab->pointer, event); } static void locked_pointer_grab_pointer_button(struct weston_pointer_grab *grab, - const struct timespec *time, - uint32_t button, - uint32_t state_w) + const struct weston_pointer_button_event *button_event) { - weston_pointer_send_button(grab->pointer, time, button, state_w); + weston_pointer_send_button(grab->pointer, button_event); } static void locked_pointer_grab_pointer_axis(struct weston_pointer_grab *grab, - const struct timespec *time, - struct weston_pointer_axis_event *event) + const struct weston_pointer_axis_event *event) { - weston_pointer_send_axis(grab->pointer, time, event); + weston_pointer_send_axis(grab->pointer, event); } static void @@ -5537,7 +5487,7 @@ get_motion_directions(struct line *motion) static struct weston_coord_global weston_pointer_clamp_event_to_region(struct weston_pointer *pointer, - struct weston_pointer_motion_event *event, + const struct weston_pointer_motion_event *event, pixman_region32_t *region) { wl_fixed_t old_sx = pointer->sx; @@ -5704,8 +5654,7 @@ maybe_warp_confined_pointer(struct weston_pointer_constraint *constraint) static void confined_pointer_grab_pointer_motion(struct weston_pointer_grab *grab, - const struct timespec *time, - struct weston_pointer_motion_event *event) + const struct weston_pointer_motion_event *event) { struct weston_pointer_constraint *constraint = container_of(grab, struct weston_pointer_constraint, grab); @@ -5736,28 +5685,24 @@ confined_pointer_grab_pointer_motion(struct weston_pointer_grab *grab, pointer->sy = wl_fixed_from_double(surf_pos.c.y); if (old_sx != pointer->sx || old_sy != pointer->sy) { - pointer_send_motion(pointer, time, - pointer->sx, pointer->sy); + pointer_send_motion(pointer, pointer->sx, pointer->sy, event); } - pointer_send_relative_motion(pointer, time, event); + pointer_send_relative_motion(pointer, event); } static void confined_pointer_grab_pointer_button(struct weston_pointer_grab *grab, - const struct timespec *time, - uint32_t button, - uint32_t state_w) + const struct weston_pointer_button_event *button_event) { - weston_pointer_send_button(grab->pointer, time, button, state_w); + weston_pointer_send_button(grab->pointer, button_event); } static void confined_pointer_grab_pointer_axis(struct weston_pointer_grab *grab, - const struct timespec *time, - struct weston_pointer_axis_event *event) + const struct weston_pointer_axis_event *event) { - weston_pointer_send_axis(grab->pointer, time, event); + weston_pointer_send_axis(grab->pointer, event); } static void @@ -6027,3 +5972,74 @@ weston_input_init(struct weston_compositor *compositor) return 0; } + +WL_EXPORT void +weston_input_event_init(struct weston_input_event *ievent, struct timespec *ts, + struct weston_seat *seat) +{ + ievent->ts = ts; + ievent->seat = seat; + + TL_POINT(seat->compositor, TLP_INPUT_KERNEL_TS, TLP_INPUT_EVENT(ievent), TLP_END); +} + +WL_EXPORT void +weston_key_event_init(struct weston_key_event *event, uint32_t key, enum wl_keyboard_key_state key_state, + enum weston_key_state_update key_update_state) +{ + event->key = key; + event->key_state = key_state; + event->key_update_state = key_update_state; +} + +WL_EXPORT void +weston_pointer_motion_event_init(struct weston_pointer_motion_event *event, + uint32_t mask, + const struct weston_coord_global *abs, + const struct weston_coord *rel, + const struct weston_coord *rel_unaccel) +{ + + if (mask & WESTON_POINTER_MOTION_ABS) + weston_assert_ptr_not_null(event->base_event.seat->compositor, abs); + + if (mask & WESTON_POINTER_MOTION_REL) + weston_assert_ptr_not_null(event->base_event.seat->compositor, rel); + + if (mask & WESTON_POINTER_MOTION_REL_UNACCEL) + weston_assert_ptr_not_null(event->base_event.seat->compositor, rel_unaccel); + + event->mask = mask; + event->abs = abs; + event->rel = rel; + event->rel_unaccel = rel_unaccel; +} + +WL_EXPORT void +weston_pointer_button_event_init(struct weston_pointer_button_event *event, + uint32_t button, enum wl_pointer_button_state button_state) +{ + event->button = button; + event->button_state = button_state; +} + +WL_EXPORT void +weston_pointer_axis_event_init(struct weston_pointer_axis_event *event, + uint32_t axis, double value, bool has_discrete, + int32_t discrete) +{ + + event->axis = axis; + event->value = value; + event->has_discrete = has_discrete; + event->discrete = discrete; +} + +WL_EXPORT void +weston_touch_event_init(struct weston_touch_event *event, int32_t touch_type, + int32_t touch_id, const struct weston_coord_global *pos) +{ + event->touch_type = touch_type; + event->touch_id = touch_id; + event->pos = pos; +} diff --git a/libweston/libinput-device.c b/libweston/libinput-device.c index c79d03db6..d42991404 100644 --- a/libweston/libinput-device.c +++ b/libweston/libinput-device.c @@ -98,6 +98,8 @@ handle_keyboard_key(struct libinput_device *libinput_device, int seat_key_count = libinput_event_keyboard_get_seat_key_count(keyboard_event); struct timespec time; + uint32_t key = libinput_event_keyboard_get_key(keyboard_event); + struct weston_key_event key_event; /* Ignore key events that are not seat wide state changes. */ if ((key_state == LIBINPUT_KEY_STATE_PRESSED && @@ -106,12 +108,12 @@ handle_keyboard_key(struct libinput_device *libinput_device, seat_key_count != 0)) return; - timespec_from_usec(&time, - libinput_event_keyboard_get_time_usec(keyboard_event)); + timespec_from_usec(&time, libinput_event_keyboard_get_time_usec(keyboard_event)); - notify_key(device->seat, &time, - libinput_event_keyboard_get_key(keyboard_event), - key_state, STATE_UPDATE_AUTOMATIC); + weston_input_event_init(&key_event.base_event, &time, device->seat); + weston_key_event_init(&key_event, key, key_state, STATE_UPDATE_AUTOMATIC); + + notify_key(device->seat, &key_event); } static bool @@ -120,9 +122,10 @@ handle_pointer_motion(struct libinput_device *libinput_device, { struct evdev_device *device = libinput_device_get_user_data(libinput_device); - struct weston_pointer_motion_event event = { 0 }; + struct weston_pointer_motion_event event; struct timespec time; double dx_unaccel, dy_unaccel; + struct weston_coord rel, rel_unaccel; ensure_pointer_capability(libinput_device); @@ -131,15 +134,14 @@ handle_pointer_motion(struct libinput_device *libinput_device, dx_unaccel = libinput_event_pointer_get_dx_unaccelerated(pointer_event); dy_unaccel = libinput_event_pointer_get_dy_unaccelerated(pointer_event); - event = (struct weston_pointer_motion_event) { - .mask = WESTON_POINTER_MOTION_REL | - WESTON_POINTER_MOTION_REL_UNACCEL, - .time = time, - }; - event.rel = weston_coord(libinput_event_pointer_get_dx(pointer_event), - libinput_event_pointer_get_dy(pointer_event)); - event.rel_unaccel = weston_coord(dx_unaccel, dy_unaccel); - notify_motion(device->seat, &time, &event); + rel = weston_coord(libinput_event_pointer_get_dx(pointer_event), + libinput_event_pointer_get_dy(pointer_event)); + rel_unaccel = weston_coord(dx_unaccel, dy_unaccel); + + weston_input_event_init(&event.base_event, &time, device->seat); + weston_pointer_motion_event_init(&event, WESTON_POINTER_MOTION_REL | + WESTON_POINTER_MOTION_REL_UNACCEL, NULL, &rel, &rel_unaccel); + notify_motion(device->seat, &event); return true; } @@ -154,6 +156,7 @@ handle_pointer_motion_absolute( struct weston_output *output = device->output; struct weston_coord_global pos; struct timespec time; + struct weston_pointer_motion_event event; double x, y; uint32_t width, height; @@ -172,7 +175,10 @@ handle_pointer_motion_absolute( y = libinput_event_pointer_get_absolute_y_transformed(pointer_event, height); pos = weston_coord_global_from_output_point(x, y, output); - notify_motion_absolute(device->seat, &time, pos); + weston_input_event_init(&event.base_event, &time, device->seat); + weston_pointer_motion_event_init(&event, WESTON_POINTER_MOTION_ABS, + &pos, NULL, NULL); + notify_motion(device->seat, &event); return true; } @@ -188,6 +194,7 @@ handle_pointer_button(struct libinput_device *libinput_device, int seat_button_count = libinput_event_pointer_get_seat_button_count(pointer_event); struct timespec time; + struct weston_pointer_button_event button_event; ensure_pointer_capability(libinput_device); @@ -201,9 +208,11 @@ handle_pointer_button(struct libinput_device *libinput_device, 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); + weston_input_event_init(&button_event.base_event, &time, device->seat); + weston_pointer_button_event_init(&button_event, + libinput_event_pointer_get_button(pointer_event), + button_state); + notify_button(device->seat, &button_event); return true; } @@ -306,12 +315,10 @@ handle_pointer_axis(struct libinput_device *libinput_device, vert_discrete = get_axis_discrete(pointer_event, axis); vert = normalize_scroll(pointer_event, axis); - weston_event.axis = WL_POINTER_AXIS_VERTICAL_SCROLL; - weston_event.value = vert; - weston_event.discrete = vert_discrete; - weston_event.has_discrete = (vert_discrete != 0); - - notify_axis(device->seat, &time, &weston_event); + weston_input_event_init(&weston_event.base_event, &time, device->seat); + weston_pointer_axis_event_init(&weston_event, WL_POINTER_AXIS_VERTICAL_SCROLL, + vert, (vert_discrete != 0), vert_discrete); + notify_axis(device->seat, &weston_event); } if (has_horiz) { @@ -319,12 +326,10 @@ handle_pointer_axis(struct libinput_device *libinput_device, horiz_discrete = get_axis_discrete(pointer_event, axis); horiz = normalize_scroll(pointer_event, axis); - weston_event.axis = WL_POINTER_AXIS_HORIZONTAL_SCROLL; - weston_event.value = horiz; - weston_event.discrete = horiz_discrete; - weston_event.has_discrete = (horiz_discrete != 0); - - notify_axis(device->seat, &time, &weston_event); + weston_input_event_init(&weston_event.base_event, &time, device->seat); + weston_pointer_axis_event_init(&weston_event, WL_POINTER_AXIS_HORIZONTAL_SCROLL, + horiz, (horiz_discrete != 0), horiz_discrete); + notify_axis(device->seat, &weston_event); } return true; @@ -454,15 +459,18 @@ handle_touch_with_coords(struct libinput_device *libinput_device, struct weston_point2d_device_normalized norm; uint32_t width, height; struct timespec time; - int32_t slot; + int32_t touch_id; struct weston_coord_global pos; + struct weston_touch_event event; + struct weston_seat *seat; if (!device->output) return; + seat = device->touch_device->aggregate->seat; timespec_from_usec(&time, libinput_event_touch_get_time_usec(touch_event)); - slot = libinput_event_touch_get_seat_slot(touch_event); + touch_id = libinput_event_touch_get_seat_slot(touch_event); width = device->output->current_mode->width; height = device->output->current_mode->height; @@ -471,14 +479,15 @@ handle_touch_with_coords(struct libinput_device *libinput_device, pos = weston_coord_global_from_output_point(x, y, device->output); + weston_input_event_init(&event.base_event, &time, seat); + weston_touch_event_init(&event, touch_type, touch_id, &pos); + if (weston_touch_device_can_calibrate(device->touch_device)) { norm.x = libinput_event_touch_get_x_transformed(touch_event, 1); norm.y = libinput_event_touch_get_y_transformed(touch_event, 1); - notify_touch_normalized(device->touch_device, &time, slot, - &pos, &norm, touch_type); + notify_touch_normalized(device->touch_device, &event, &norm); } else { - notify_touch(device->touch_device, &time, slot, - &pos, touch_type); + notify_touch(device->touch_device, &event); } } @@ -503,15 +512,20 @@ handle_touch_up(struct libinput_device *libinput_device, struct evdev_device *device = libinput_device_get_user_data(libinput_device); struct timespec time; - int32_t slot = libinput_event_touch_get_seat_slot(touch_event); + struct weston_touch_event event; + struct weston_seat *seat; if (!device->output) return; + seat = device->touch_device->aggregate->seat; timespec_from_usec(&time, libinput_event_touch_get_time_usec(touch_event)); - notify_touch(device->touch_device, &time, slot, NULL, WL_TOUCH_UP); + weston_input_event_init(&event.base_event, &time, seat); + weston_touch_event_init(&event, WL_TOUCH_UP, + libinput_event_touch_get_seat_slot(touch_event), NULL); + notify_touch(device->touch_device, &event); } static void diff --git a/libweston/libweston-internal.h b/libweston/libweston-internal.h index 79212d0ce..ea15ee536 100644 --- a/libweston/libweston-internal.h +++ b/libweston/libweston-internal.h @@ -341,7 +341,7 @@ int weston_compositor_run_axis_binding(struct weston_compositor *compositor, struct weston_pointer *pointer, const struct timespec *time, - struct weston_pointer_axis_event *event); + const struct weston_pointer_axis_event *event); void weston_compositor_run_button_binding(struct weston_compositor *compositor, struct weston_pointer *pointer, diff --git a/libweston/perfetto/u_perfetto.cc b/libweston/perfetto/u_perfetto.cc index 9d0a2eb99..431cf4d25 100644 --- a/libweston/perfetto/u_perfetto.cc +++ b/libweston/perfetto/u_perfetto.cc @@ -145,6 +145,32 @@ util_perfetto_counter_set(const char *name, double value) perfetto::DynamicString(name), value); } +void +util_perfetto_trace_instant_timestamp(const char *name, uint64_t track_id, uint64_t id, clockid_t clock, uint64_t ts) +{ + if (id) { + TRACE_EVENT_INSTANT(UTIL_PERFETTO_CATEGORY_DEFAULT_STR, + nullptr, + perfetto::Track(track_id), + perfetto::TraceTimestamp{clockid_to_perfetto_clock(clock), ts}, + perfetto::Flow::ProcessScoped(id), + [&](perfetto::EventContext ctx) { + ctx.event()->set_name(name); + ctx.AddDebugAnnotation(name, ts); + }); + return; + } + + TRACE_EVENT_INSTANT(UTIL_PERFETTO_CATEGORY_DEFAULT_STR, + nullptr, + perfetto::Track(track_id), + perfetto::TraceTimestamp{clockid_to_perfetto_clock(clock), ts}, + [&](perfetto::EventContext ctx) { + ctx.event()->set_name(name); + ctx.AddDebugAnnotation(name, ts); + }); +} + uint64_t util_perfetto_next_id(void) { diff --git a/libweston/perfetto/u_perfetto.h b/libweston/perfetto/u_perfetto.h index 576348fce..602a0bcc4 100644 --- a/libweston/perfetto/u_perfetto.h +++ b/libweston/perfetto/u_perfetto.h @@ -63,10 +63,13 @@ void util_perfetto_trace_full_begin(const char *name, uint64_t track_id, uint64_ void util_perfetto_trace_full_end(const char *name, uint64_t track_id, clockid_t clock, uint64_t timestamp); +void util_perfetto_trace_instant_timestamp(const char *name, uint64_t track_id, uint64_t id, clockid_t clock, uint64_t ts); + uint64_t util_perfetto_next_id(void); uint64_t util_perfetto_new_track(const char *name); + #else /* HAVE_PERFETTO */ static inline void @@ -104,6 +107,11 @@ util_perfetto_trace_full_end(const char *name, uint64_t track_id, clockid_t cloc { } +static inline void +util_perfetto_trace_instant_timestamp(const char *name, uint64_t track_id, clockid_t clock, uint64_t ts) +{ +} + static inline void util_perfetto_counter_set(const char *name, double value) { } diff --git a/libweston/timeline-perfetto.c b/libweston/timeline-perfetto.c index 54dfbb341..c6dac3779 100644 --- a/libweston/timeline-perfetto.c +++ b/libweston/timeline-perfetto.c @@ -64,6 +64,14 @@ build_track_name(struct weston_surface *surface, char *name, int size) snprintf(name, size, "%s #%d", surface->label, surface->s_id); } +static void +build_seat_track_name(struct weston_seat *seat, char *name, int size) +{ + assert(seat->track_id == 0); + + snprintf(name, size, "seat: %s", seat->seat_name); +} + static void weston_perfetto_ensure_surface_id(struct weston_surface *surface) { @@ -77,6 +85,19 @@ weston_perfetto_ensure_surface_id(struct weston_surface *surface) surface->damage_track_id = util_perfetto_new_track(track_name); } +static void +weston_perfetto_ensure_seat_id(struct weston_seat *seat) +{ + char track_name[600]; + + if (seat->track_id) + return; + + build_seat_track_name(seat, track_name, sizeof(track_name)); + + seat->track_id = util_perfetto_new_track(track_name); +} + /** * Translates a timeline point for perfetto. * @@ -94,9 +115,11 @@ weston_timeline_perfetto(struct weston_log_scope *timeline_scope, { struct weston_output *output = NULL; struct weston_surface *surface = NULL; + struct weston_seat *seat = NULL; + struct weston_input_event *ievent = NULL; struct timespec ts; uint64_t now_ns; - uint64_t vblank_ns = 0, gpu_ns = 0; + uint64_t vblank_ns = 0, gpu_ns = 0, kernel_input_ts = 0; va_list argp; if (!util_perfetto_is_tracing_enabled()) @@ -130,6 +153,18 @@ weston_timeline_perfetto(struct weston_log_scope *timeline_scope, case TLT_GPU: gpu_ns = timespec_to_nsec(obj); break; + case TLT_SEAT: + seat = obj; + weston_perfetto_ensure_seat_id(seat); + break; + case TLT_KERNEL_TS: + kernel_input_ts = timespec_to_nsec(obj); + break; + case TLT_INPUT_EVENT: + ievent = obj; + weston_perfetto_ensure_seat_id(ievent->seat); + kernel_input_ts = timespec_to_nsec(ievent->ts); + break; default: assert(!"not reached"); } @@ -170,6 +205,9 @@ weston_timeline_perfetto(struct weston_log_scope *timeline_scope, case TLP_RENDERER_GPU_END: WESTON_TRACE_TIMESTAMP_END("Active", output->gpu_track_id, CLOCK_MONOTONIC, gpu_ns); break; + case TLP_INPUT_KERNEL_TS: + WESTON_TRACE_INSTANT_TIMESTAMP("event ts", seat->track_id, 0, CLOCK_MONOTONIC, kernel_input_ts); + break; default: assert(!"not reached"); } diff --git a/libweston/timeline.c b/libweston/timeline.c index f919ebc3b..11e47d0bd 100644 --- a/libweston/timeline.c +++ b/libweston/timeline.c @@ -222,6 +222,24 @@ weston_timeline_subscription_surface_ensure(struct weston_timeline_subscription return sub_obj; } +static struct weston_timeline_subscription_object * +weston_timeline_subscription_seat_ensure(struct weston_timeline_subscription *tl_sub, + struct weston_seat *seat) +{ + struct weston_timeline_subscription_object *sub_obj; + + sub_obj = weston_timeline_subscription_search(tl_sub, seat); + if (!sub_obj) { + sub_obj = weston_timeline_subscription_object_create(seat, tl_sub); + + sub_obj->destroy_listener.notify = + weston_timeline_destroy_subscription_object_notify; + wl_signal_add(&seat->destroy_signal, + &sub_obj->destroy_listener); + } + return sub_obj; +} + static void fprint_quoted_string(struct weston_log_subscription *sub, const char *str) { @@ -265,6 +283,47 @@ emit_weston_output(struct timeline_emit_context *ctx, void *obj) return 1; } +static void +emit_weston_seat_print_id(struct weston_log_subscription *sub, + struct weston_timeline_subscription_object *sub_obj, + const char *name) +{ + if (!weston_timeline_check_object_refresh(sub_obj)) + return; + + weston_log_subscription_printf(sub, "{ \"id\":%u, " + "\"type\":\"weston_seat\", \"name\":", sub_obj->id); + fprint_quoted_string(sub, name); + weston_log_subscription_printf(sub, " }\n"); +} + +static int +common_emit_seat(struct timeline_emit_context *ctx, struct weston_seat *seat) +{ + struct weston_log_subscription *sub = ctx->subscription; + struct weston_timeline_subscription_object *sub_obj; + struct weston_timeline_subscription *tl_sub; + + tl_sub = weston_log_subscription_get_data(sub); + sub_obj = weston_timeline_subscription_seat_ensure(tl_sub, seat); + emit_weston_seat_print_id(sub, sub_obj, seat->seat_name); + + assert(sub_obj->id != 0); + fprintf(ctx->cur, "\"seat\":%u", sub_obj->id); + + return 1; +} + +static int +emit_seat(struct timeline_emit_context *ctx, void *obj) +{ + struct weston_seat *seat = obj; + + common_emit_seat(ctx, seat); + + return 1; +} + static struct weston_timeline_subscription_object * check_weston_surface_description(struct weston_log_subscription *sub, @@ -342,6 +401,32 @@ emit_gpu_timestamp(struct timeline_emit_context *ctx, void *obj) return 1; } +static int +emit_kernel_input_timestamp(struct timeline_emit_context *ctx, void *obj) +{ + struct timespec *ts = obj; + + fprintf(ctx->cur, "\"event ts\":[%" PRId64 ", %ld]", + (int64_t)ts->tv_sec, ts->tv_nsec); + + return 1; +} + +static int +emit_input_event(struct timeline_emit_context *ctx, void *obj) +{ + struct weston_input_event *ievent = obj; + struct timespec *ts = ievent->ts; + struct weston_seat *seat = ievent->seat; + + common_emit_seat(ctx, seat); + + fprintf(ctx->cur, ", \"event ts\":[%" PRId64 ", %ld]", + (int64_t)ts->tv_sec, ts->tv_nsec); + + return 1; +} + static struct weston_timeline_subscription_object * weston_timeline_get_subscription_object(struct weston_log_subscription *sub, void *object) @@ -392,6 +477,9 @@ static const type_func type_dispatch[] = { [TLT_SURFACE] = emit_weston_surface, [TLT_VBLANK] = emit_vblank_timestamp, [TLT_GPU] = emit_gpu_timestamp, + [TLT_SEAT] = emit_seat, + [TLT_KERNEL_TS] = emit_kernel_input_timestamp, + [TLT_INPUT_EVENT] = emit_input_event, }; static const char * @@ -420,6 +508,10 @@ tlp_to_string(enum timeline_point_name tlp) return "renderer_gpu_begin"; case TLP_RENDERER_GPU_END: return "renderer_gpu_end"; + case TLP_INPUT_SEAT: + return "seat"; + case TLP_INPUT_KERNEL_TS: + return "kernel_ts"; } assert(!"not reached"); } diff --git a/libweston/timeline.h b/libweston/timeline.h index 95b65b52c..38134ec6a 100644 --- a/libweston/timeline.h +++ b/libweston/timeline.h @@ -43,6 +43,9 @@ enum timeline_type { TLT_SURFACE, TLT_VBLANK, TLT_GPU, + TLT_SEAT, + TLT_KERNEL_TS, + TLT_INPUT_EVENT, }; enum timeline_point_name { @@ -56,7 +59,9 @@ enum timeline_point_name { TLP_CORE_REPAINT_ENTER_LOOP, TLP_CORE_COMMIT_DAMAGE, TLP_RENDERER_GPU_BEGIN, - TLP_RENDERER_GPU_END + TLP_RENDERER_GPU_END, + TLP_INPUT_SEAT, + TLP_INPUT_KERNEL_TS, }; /** Timeline subscription created for each subscription @@ -96,6 +101,9 @@ struct weston_timeline_subscription_object { #define TLP_SURFACE(s) TLT_SURFACE, TYPEVERIFY(struct weston_surface *, (s)) #define TLP_VBLANK(t) TLT_VBLANK, TYPEVERIFY(const struct timespec *, (t)) #define TLP_GPU(t) TLT_GPU, TYPEVERIFY(const struct timespec *, (t)) +#define TLP_SEAT(t) TLT_SEAT, TYPEVERIFY(const struct weston_seat *, (t)) +#define TLP_KERNEL_TS(t) TLT_KERNEL_TS, TYPEVERIFY(const struct timespec *, (t)) +#define TLP_INPUT_EVENT(t) TLT_INPUT_EVENT, TYPEVERIFY(const struct weston_input_event *, (t)) /** This macro is used to add timeline points. * diff --git a/libweston/touch-calibration.c b/libweston/touch-calibration.c index f4c9366a0..7851a2ebb 100644 --- a/libweston/touch-calibration.c +++ b/libweston/touch-calibration.c @@ -87,9 +87,8 @@ normalized_is_valid(const struct weston_point2d_device_normalized *p) WL_EXPORT void notify_touch_calibrator(struct weston_touch_device *device, - const struct timespec *time, int32_t slot, - const struct weston_point2d_device_normalized *norm, - int touch_type) + const struct weston_touch_event *event, + const struct weston_point2d_device_normalized *norm) { struct weston_touch_calibrator *calibrator; struct wl_resource *res; @@ -105,7 +104,7 @@ notify_touch_calibrator(struct weston_touch_device *device, /* Ignore any touch events coming from another device */ if (device != calibrator->device) { - if (touch_type == WL_TOUCH_DOWN) + if (event->touch_type == WL_TOUCH_DOWN) weston_touch_calibrator_send_invalid_touch(res); return; } @@ -115,20 +114,20 @@ notify_touch_calibrator(struct weston_touch_device *device, */ if (calibrator->touch_cancelled) { if (calibrator->device->aggregate->num_tp == 0) { - assert(touch_type == WL_TOUCH_UP); + assert(event->touch_type == WL_TOUCH_UP); calibrator->touch_cancelled = false; } return; } - msecs = timespec_to_msec(time); - if (touch_type != WL_TOUCH_UP) { + msecs = timespec_to_msec(event->base_event.ts); + if (event->touch_type != WL_TOUCH_UP) { if (normalized_is_valid(norm)) { x = wire_uint_from_double(norm->x); y = wire_uint_from_double(norm->y); } else { /* Coordinates are out of bounds */ - if (touch_type == WL_TOUCH_MOTION) { + if (event->touch_type == WL_TOUCH_MOTION) { weston_touch_calibrator_send_cancel(res); calibrator->touch_cancelled = true; } @@ -137,15 +136,15 @@ notify_touch_calibrator(struct weston_touch_device *device, } } - switch (touch_type) { + switch (event->touch_type) { case WL_TOUCH_UP: - weston_touch_calibrator_send_up(res, msecs, slot); + weston_touch_calibrator_send_up(res, msecs, event->touch_id); break; case WL_TOUCH_DOWN: - weston_touch_calibrator_send_down(res, msecs, slot, x, y); + weston_touch_calibrator_send_down(res, msecs, event->touch_id, x, y); break; case WL_TOUCH_MOTION: - weston_touch_calibrator_send_motion(res, msecs, slot, x, y); + weston_touch_calibrator_send_motion(res, msecs, event->touch_id, x, y); break; default: return; diff --git a/libweston/weston-trace.h b/libweston/weston-trace.h index 154663157..b39b65a93 100644 --- a/libweston/weston-trace.h +++ b/libweston/weston-trace.h @@ -69,6 +69,14 @@ clock, timestamp); \ } while (0) +#define _WESTON_TRACE_INSTANT_TIMESTAMP(name, track_id, id, clock, timestamp) \ + do { \ + if (unlikely(util_perfetto_is_tracing_enabled())) \ + util_perfetto_trace_instant_timestamp(name, track_id, \ + id, clock, \ + timestamp); \ + } while (0) + #if __has_attribute(cleanup) && __has_attribute(unused) #define _WESTON_TRACE_SCOPE_VAR_CONCAT(name, suffix) name##suffix @@ -129,6 +137,7 @@ _weston_trace_scope_end(int *scope) #define _WESTON_TRACE_SET_COUNTER(name, value) #define _WESTON_TRACE_TIMESTAMP_BEGIN(name, track_id, flow_id, clock, timestamp) #define _WESTON_TRACE_TIMESTAMP_END(name, track_id, clock, timestamp) +#define _WESTON_TRACE_INSTANT_TIMESTAMP(name, track_id, id, clock, timestamp) #endif /* HAVE_PERFETTO */ @@ -141,5 +150,8 @@ _weston_trace_scope_end(int *scope) _WESTON_TRACE_TIMESTAMP_BEGIN(name, track_id, flow_id, clock, timestamp) #define WESTON_TRACE_TIMESTAMP_END(name, track_id, clock, timestamp) \ _WESTON_TRACE_TIMESTAMP_END(name, track_id, clock, timestamp) +#define WESTON_TRACE_INSTANT_TIMESTAMP(name, track_id, id, clock, timestamp) \ + _WESTON_TRACE_INSTANT_TIMESTAMP(name, track_id, id, clock, timestamp) + #endif /* WESTON_TRACE_H */ diff --git a/tests/harness/weston-test.c b/tests/harness/weston-test.c index 59f54644c..3f977d058 100644 --- a/tests/harness/weston-test.c +++ b/tests/harness/weston-test.c @@ -412,19 +412,19 @@ move_pointer(struct wl_client *client, struct wl_resource *resource, struct weston_test *test = wl_resource_get_user_data(resource); struct weston_seat *seat = get_seat(test); struct weston_pointer *pointer = weston_seat_get_pointer(seat); - struct weston_pointer_motion_event event = { 0 }; + struct weston_pointer_motion_event event; struct weston_coord_global pos; + struct weston_coord rel; struct timespec time; pos.c = weston_coord(x, y); - event = (struct weston_pointer_motion_event) { - .mask = WESTON_POINTER_MOTION_REL, - .rel = weston_coord_global_sub(pos, pointer->pos).c, - }; - timespec_from_proto(&time, tv_sec_hi, tv_sec_lo, tv_nsec); + rel = weston_coord_global_sub(pos, pointer->pos).c; - notify_motion(seat, &time, &event); + weston_input_event_init(&event.base_event, &time, seat); + weston_pointer_motion_event_init(&event, WESTON_POINTER_MOTION_REL, + NULL, &rel, NULL); + notify_motion(seat, &event); notify_pointer_position(test, resource); } @@ -434,14 +434,17 @@ send_button(struct wl_client *client, struct wl_resource *resource, uint32_t tv_sec_hi, uint32_t tv_sec_lo, uint32_t tv_nsec, int32_t button, uint32_t state) { - struct timespec time; + struct weston_pointer_button_event button_event; struct weston_test *test = wl_resource_get_user_data(resource); struct weston_seat *seat = get_seat(test); + struct timespec time; timespec_from_proto(&time, tv_sec_hi, tv_sec_lo, tv_nsec); + weston_input_event_init(&button_event.base_event, &time, seat); + weston_pointer_button_event_init(&button_event, button, state); - notify_button(seat, &time, button, state); + notify_button(seat, &button_event); } static void @@ -455,12 +458,11 @@ send_axis(struct wl_client *client, struct wl_resource *resource, struct weston_pointer_axis_event axis_event; timespec_from_proto(&time, tv_sec_hi, tv_sec_lo, tv_nsec); - axis_event.axis = axis; - axis_event.value = wl_fixed_to_double(value); - axis_event.has_discrete = false; - axis_event.discrete = 0; - notify_axis(seat, &time, &axis_event); + weston_input_event_init(&axis_event.base_event, &time, seat); + weston_pointer_axis_event_init(&axis_event, axis, + wl_fixed_to_double(value), false, 0); + notify_axis(seat, &axis_event); } static void @@ -494,10 +496,13 @@ send_key(struct wl_client *client, struct wl_resource *resource, struct weston_test *test = wl_resource_get_user_data(resource); struct weston_seat *seat = get_seat(test); struct timespec time; + struct weston_key_event key_event; timespec_from_proto(&time, tv_sec_hi, tv_sec_lo, tv_nsec); - notify_key(seat, &time, key, state, STATE_UPDATE_AUTOMATIC); + weston_input_event_init(&key_event.base_event, &time, seat); + weston_key_event_init(&key_event, key, state, STATE_UPDATE_AUTOMATIC); + notify_key(seat, &key_event); } static void @@ -551,10 +556,14 @@ send_touch(struct wl_client *client, struct wl_resource *resource, struct weston_touch_device *device = test->touch_device[0]; struct timespec time; struct weston_coord_global pos; + struct weston_touch_event event; + struct weston_seat *seat; assert(device); + seat = device->aggregate->seat; timespec_from_proto(&time, tv_sec_hi, tv_sec_lo, tv_nsec); + weston_input_event_init(&event.base_event, &time, seat); if (touch_type == WL_TOUCH_UP) { if (x != 0 || y != 0) { @@ -565,11 +574,12 @@ send_touch(struct wl_client *client, struct wl_resource *resource, return; } - - notify_touch(device, &time, touch_id, NULL, touch_type); + weston_touch_event_init(&event, touch_type, touch_id, NULL); + notify_touch(device, &event); } else { pos.c = weston_coord_from_fixed(x, y); - notify_touch(device, &time, touch_id, &pos, touch_type); + weston_touch_event_init(&event, touch_type, touch_id, &pos); + notify_touch(device, &event); } }