From 47e79c860b3bd90de757230ff7db4822d95b9113 Mon Sep 17 00:00:00 2001 From: Alexandros Frantzis Date: Thu, 16 Nov 2017 18:20:57 +0200 Subject: [PATCH] libweston: Use struct timespec for key events Change code related to key events to use struct timespec to represent time. This commit is part of a larger effort to transition the Weston codebase to struct timespec. Signed-off-by: Alexandros Frantzis Reviewed-by: Pekka Paalanen --- compositor/screen-share.c | 8 +++--- compositor/text-backend.c | 13 ++++++--- compositor/weston-screenshooter.c | 6 ++--- desktop-shell/exposay.c | 4 +-- desktop-shell/shell.c | 44 +++++++++++++++---------------- ivi-shell/ivi-shell.c | 2 +- libweston-desktop/seat.c | 3 ++- libweston/bindings.c | 24 ++++++++++------- libweston/compositor-drm.c | 16 +++++------ libweston/compositor-rdp.c | 4 ++- libweston/compositor-wayland.c | 9 ++++--- libweston/compositor-x11.c | 14 +++++++--- libweston/compositor.c | 5 ++-- libweston/compositor.h | 18 +++++++------ libweston/data-device.c | 2 +- libweston/gl-renderer.c | 6 +++-- libweston/input.c | 13 +++++---- libweston/launcher-util.c | 2 +- libweston/libinput-device.c | 7 +++-- libweston/pixman-renderer.c | 4 +-- tests/surface-screenshot.c | 4 +-- tests/weston-test.c | 5 +++- 22 files changed, 126 insertions(+), 87 deletions(-) diff --git a/compositor/screen-share.c b/compositor/screen-share.c index 8b2decfd..33de2b1f 100644 --- a/compositor/screen-share.c +++ b/compositor/screen-share.c @@ -277,9 +277,11 @@ ss_seat_handle_key(void *data, struct wl_keyboard *keyboard, uint32_t key, uint32_t state) { struct ss_seat *seat = data; + struct timespec ts; + timespec_from_msec(&ts, time); seat->key_serial = serial; - notify_key(&seat->base, time, key, + notify_key(&seat->base, &ts, key, state ? WL_KEYBOARD_KEY_STATE_PRESSED : WL_KEYBOARD_KEY_STATE_RELEASED, seat->keyboard_state_update); @@ -1092,8 +1094,8 @@ weston_output_find(struct weston_compositor *c, int32_t x, int32_t y) } static void -share_output_binding(struct weston_keyboard *keyboard, uint32_t time, uint32_t key, - void *data) +share_output_binding(struct weston_keyboard *keyboard, + const struct timespec *time, uint32_t key, void *data) { struct weston_output *output; struct weston_pointer *pointer; diff --git a/compositor/text-backend.c b/compositor/text-backend.c index bf5c45cc..5f6b5d80 100644 --- a/compositor/text-backend.c +++ b/compositor/text-backend.c @@ -38,6 +38,7 @@ #include "text-input-unstable-v1-server-protocol.h" #include "input-method-unstable-v1-server-protocol.h" #include "shared/helpers.h" +#include "shared/timespec-util.h" struct text_input_manager; struct input_method; @@ -607,11 +608,13 @@ unbind_keyboard(struct wl_resource *resource) static void input_method_context_grab_key(struct weston_keyboard_grab *grab, - uint32_t time, uint32_t key, uint32_t state_w) + const struct timespec *time, uint32_t key, + uint32_t state_w) { struct weston_keyboard *keyboard = grab->keyboard; struct wl_display *display; uint32_t serial; + uint32_t msecs; if (!keyboard->input_method_resource) return; @@ -619,8 +622,9 @@ input_method_context_grab_key(struct weston_keyboard_grab *grab, display = wl_client_get_display( wl_resource_get_client(keyboard->input_method_resource)); serial = wl_display_next_serial(display); + msecs = timespec_to_msec(time); wl_keyboard_send_key(keyboard->input_method_resource, - serial, time, key, state_w); + serial, msecs, key, state_w); } static void @@ -693,8 +697,11 @@ input_method_context_key(struct wl_client *client, struct weston_seat *seat = context->input_method->seat; struct weston_keyboard *keyboard = weston_seat_get_keyboard(seat); struct weston_keyboard_grab *default_grab = &keyboard->default_grab; + struct timespec ts; - default_grab->interface->key(default_grab, time, key, state_w); + timespec_from_msec(&ts, time); + + default_grab->interface->key(default_grab, &ts, key, state_w); } static void diff --git a/compositor/weston-screenshooter.c b/compositor/weston-screenshooter.c index f874c3eb..f0bc0e1e 100644 --- a/compositor/weston-screenshooter.c +++ b/compositor/weston-screenshooter.c @@ -112,8 +112,8 @@ screenshooter_sigchld(struct weston_process *process, int status) } static void -screenshooter_binding(struct weston_keyboard *keyboard, uint32_t time, - uint32_t key, void *data) +screenshooter_binding(struct weston_keyboard *keyboard, + const struct timespec *time, uint32_t key, void *data) { struct screenshooter *shooter = data; char *screenshooter_exe; @@ -135,7 +135,7 @@ screenshooter_binding(struct weston_keyboard *keyboard, uint32_t time, } static void -recorder_binding(struct weston_keyboard *keyboard, uint32_t time, +recorder_binding(struct weston_keyboard *keyboard, const struct timespec *time, uint32_t key, void *data) { struct weston_compositor *ec = keyboard->seat->compositor; diff --git a/desktop-shell/exposay.c b/desktop-shell/exposay.c index 5b23adf7..9fd43834 100644 --- a/desktop-shell/exposay.c +++ b/desktop-shell/exposay.c @@ -442,8 +442,8 @@ exposay_maybe_move(struct desktop_shell *shell, int row, int column) } static void -exposay_key(struct weston_keyboard_grab *grab, uint32_t time, uint32_t key, - uint32_t state_w) +exposay_key(struct weston_keyboard_grab *grab, const struct timespec *time, + uint32_t key, uint32_t state_w) { struct weston_seat *seat = grab->keyboard->seat; struct desktop_shell *shell = diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c index 5f6c6d19..b8f00eb1 100644 --- a/desktop-shell/shell.c +++ b/desktop-shell/shell.c @@ -3232,7 +3232,7 @@ move_binding(struct weston_pointer *pointer, const struct timespec *time, } static void -maximize_binding(struct weston_keyboard *keyboard, uint32_t time, +maximize_binding(struct weston_keyboard *keyboard, const struct timespec *time, uint32_t button, void *data) { struct weston_surface *focus = keyboard->focus; @@ -3251,8 +3251,8 @@ maximize_binding(struct weston_keyboard *keyboard, uint32_t time, } static void -fullscreen_binding(struct weston_keyboard *keyboard, uint32_t time, - uint32_t button, void *data) +fullscreen_binding(struct weston_keyboard *keyboard, + const struct timespec *time, uint32_t button, void *data) { struct weston_surface *focus = keyboard->focus; struct weston_surface *surface; @@ -3434,18 +3434,14 @@ zoom_axis_binding(struct weston_pointer *pointer, const struct timespec *time, } static void -zoom_key_binding(struct weston_keyboard *keyboard, uint32_t time, +zoom_key_binding(struct weston_keyboard *keyboard, const struct timespec *time, uint32_t key, void *data) { - struct timespec ts; - - timespec_from_msec(&ts, time); - - do_zoom(keyboard->seat, &ts, key, 0, 0); + do_zoom(keyboard->seat, time, key, 0, 0); } static void -terminate_binding(struct weston_keyboard *keyboard, uint32_t time, +terminate_binding(struct weston_keyboard *keyboard, const struct timespec *time, uint32_t key, void *data) { struct weston_compositor *compositor = data; @@ -4421,7 +4417,7 @@ switcher_destroy(struct switcher *switcher) static void switcher_key(struct weston_keyboard_grab *grab, - uint32_t time, uint32_t key, uint32_t state_w) + const struct timespec *time, uint32_t key, uint32_t state_w) { struct switcher *switcher = container_of(grab, struct switcher, grab); enum wl_keyboard_key_state state = state_w; @@ -4457,7 +4453,7 @@ static const struct weston_keyboard_grab_interface switcher_grab = { }; static void -switcher_binding(struct weston_keyboard *keyboard, uint32_t time, +switcher_binding(struct weston_keyboard *keyboard, const struct timespec *time, uint32_t key, void *data) { struct desktop_shell *shell = data; @@ -4478,7 +4474,7 @@ switcher_binding(struct weston_keyboard *keyboard, uint32_t time, } static void -backlight_binding(struct weston_keyboard *keyboard, uint32_t time, +backlight_binding(struct weston_keyboard *keyboard, const struct timespec *time, uint32_t key, void *data) { struct weston_compositor *compositor = data; @@ -4511,8 +4507,8 @@ backlight_binding(struct weston_keyboard *keyboard, uint32_t time, } static void -force_kill_binding(struct weston_keyboard *keyboard, uint32_t time, - uint32_t key, void *data) +force_kill_binding(struct weston_keyboard *keyboard, + const struct timespec *time, uint32_t key, void *data) { struct weston_surface *focus_surface; struct wl_client *client; @@ -4538,8 +4534,8 @@ force_kill_binding(struct weston_keyboard *keyboard, uint32_t time, } static void -workspace_up_binding(struct weston_keyboard *keyboard, uint32_t time, - uint32_t key, void *data) +workspace_up_binding(struct weston_keyboard *keyboard, + const struct timespec *time, uint32_t key, void *data) { struct desktop_shell *shell = data; unsigned int new_index = shell->workspaces.current; @@ -4553,8 +4549,8 @@ workspace_up_binding(struct weston_keyboard *keyboard, uint32_t time, } static void -workspace_down_binding(struct weston_keyboard *keyboard, uint32_t time, - uint32_t key, void *data) +workspace_down_binding(struct weston_keyboard *keyboard, + const struct timespec *time, uint32_t key, void *data) { struct desktop_shell *shell = data; unsigned int new_index = shell->workspaces.current; @@ -4568,8 +4564,8 @@ workspace_down_binding(struct weston_keyboard *keyboard, uint32_t time, } static void -workspace_f_binding(struct weston_keyboard *keyboard, uint32_t time, - uint32_t key, void *data) +workspace_f_binding(struct weston_keyboard *keyboard, + const struct timespec *time, uint32_t key, void *data) { struct desktop_shell *shell = data; unsigned int new_index; @@ -4585,7 +4581,8 @@ workspace_f_binding(struct weston_keyboard *keyboard, uint32_t time, static void workspace_move_surface_up_binding(struct weston_keyboard *keyboard, - uint32_t time, uint32_t key, void *data) + const struct timespec *time, uint32_t key, + void *data) { struct desktop_shell *shell = data; unsigned int new_index = shell->workspaces.current; @@ -4601,7 +4598,8 @@ workspace_move_surface_up_binding(struct weston_keyboard *keyboard, static void workspace_move_surface_down_binding(struct weston_keyboard *keyboard, - uint32_t time, uint32_t key, void *data) + const struct timespec *time, uint32_t key, + void *data) { struct desktop_shell *shell = data; unsigned int new_index = shell->workspaces.current; diff --git a/ivi-shell/ivi-shell.c b/ivi-shell/ivi-shell.c index 7eef1cec..e675a3bd 100644 --- a/ivi-shell/ivi-shell.c +++ b/ivi-shell/ivi-shell.c @@ -376,7 +376,7 @@ shell_destroy(struct wl_listener *listener, void *data) } static void -terminate_binding(struct weston_keyboard *keyboard, uint32_t time, +terminate_binding(struct weston_keyboard *keyboard, const struct timespec *time, uint32_t key, void *data) { struct weston_compositor *compositor = data; diff --git a/libweston-desktop/seat.c b/libweston-desktop/seat.c index 150229f8..bba2605f 100644 --- a/libweston-desktop/seat.c +++ b/libweston-desktop/seat.c @@ -54,7 +54,8 @@ 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, - uint32_t time, uint32_t key, + const struct timespec *time, + uint32_t key, enum wl_keyboard_key_state state) { weston_keyboard_send_key(grab->keyboard, time, key, state); diff --git a/libweston/bindings.c b/libweston/bindings.c index 82a56f4a..79c043e9 100644 --- a/libweston/bindings.c +++ b/libweston/bindings.c @@ -31,6 +31,7 @@ #include "compositor.h" #include "shared/helpers.h" +#include "shared/timespec-util.h" struct weston_binding { uint32_t key; @@ -192,7 +193,7 @@ struct binding_keyboard_grab { static void binding_key(struct weston_keyboard_grab *grab, - uint32_t time, uint32_t key, uint32_t state_w) + const struct timespec *time, uint32_t key, uint32_t state_w) { struct binding_keyboard_grab *b = container_of(grab, struct binding_keyboard_grab, grab); @@ -201,6 +202,7 @@ binding_key(struct weston_keyboard_grab *grab, uint32_t serial; struct weston_keyboard *keyboard = grab->keyboard; struct wl_display *display = keyboard->seat->compositor->wl_display; + uint32_t msecs; if (key == b->key) { if (state == WL_KEYBOARD_KEY_STATE_RELEASED) { @@ -215,10 +217,11 @@ binding_key(struct weston_keyboard_grab *grab, } if (!wl_list_empty(&keyboard->focus_resource_list)) { serial = wl_display_next_serial(display); + msecs = timespec_to_msec(time); wl_resource_for_each(resource, &keyboard->focus_resource_list) { wl_keyboard_send_key(resource, serial, - time, + msecs, key, state); } @@ -255,8 +258,9 @@ static const struct weston_keyboard_grab_interface binding_grab = { }; static void -install_binding_grab(struct weston_keyboard *keyboard, uint32_t time, - uint32_t key, struct weston_surface *focus) +install_binding_grab(struct weston_keyboard *keyboard, + const struct timespec *time, uint32_t key, + struct weston_surface *focus) { struct binding_keyboard_grab *grab; @@ -282,7 +286,7 @@ install_binding_grab(struct weston_keyboard *keyboard, uint32_t time, void weston_compositor_run_key_binding(struct weston_compositor *compositor, struct weston_keyboard *keyboard, - uint32_t time, uint32_t key, + const struct timespec *time, uint32_t key, enum wl_keyboard_key_state state) { struct weston_binding *b, *tmp; @@ -416,7 +420,7 @@ weston_compositor_run_axis_binding(struct weston_compositor *compositor, int weston_compositor_run_debug_binding(struct weston_compositor *compositor, struct weston_keyboard *keyboard, - uint32_t time, uint32_t key, + const struct timespec *time, uint32_t key, enum wl_keyboard_key_state state) { weston_key_binding_handler_t handler; @@ -443,7 +447,7 @@ struct debug_binding_grab { }; static void -debug_binding_key(struct weston_keyboard_grab *grab, uint32_t time, +debug_binding_key(struct weston_keyboard_grab *grab, const struct timespec *time, uint32_t key, uint32_t state) { struct debug_binding_grab *db = (struct debug_binding_grab *) grab; @@ -455,6 +459,7 @@ debug_binding_key(struct weston_keyboard_grab *grab, uint32_t time, int check_binding = 1; int i; struct wl_list *resource_list; + uint32_t msecs; if (state == WL_KEYBOARD_KEY_STATE_RELEASED) { /* Do not run bindings on key releases */ @@ -503,8 +508,9 @@ debug_binding_key(struct weston_keyboard_grab *grab, uint32_t time, if (send) { serial = wl_display_next_serial(display); resource_list = &grab->keyboard->focus_resource_list; + msecs = timespec_to_msec(time); wl_resource_for_each(resource, resource_list) { - wl_keyboard_send_key(resource, serial, time, key, state); + wl_keyboard_send_key(resource, serial, msecs, key, state); } } @@ -548,7 +554,7 @@ struct weston_keyboard_grab_interface debug_binding_keyboard_grab = { }; static void -debug_binding(struct weston_keyboard *keyboard, uint32_t time, +debug_binding(struct weston_keyboard *keyboard, const struct timespec *time, uint32_t key, void *data) { struct debug_binding_grab *grab; diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c index b641d61e..0b243577 100644 --- a/libweston/compositor-drm.c +++ b/libweston/compositor-drm.c @@ -3804,8 +3804,8 @@ find_primary_gpu(struct drm_backend *b, const char *seat) } static void -planes_binding(struct weston_keyboard *keyboard, uint32_t time, uint32_t key, - void *data) +planes_binding(struct weston_keyboard *keyboard, const struct timespec *time, + uint32_t key, void *data) { struct drm_backend *b = data; @@ -3885,8 +3885,8 @@ create_recorder(struct drm_backend *b, int width, int height, } static void -recorder_binding(struct weston_keyboard *keyboard, uint32_t time, uint32_t key, - void *data) +recorder_binding(struct weston_keyboard *keyboard, const struct timespec *time, + uint32_t key, void *data) { struct drm_backend *b = data; struct drm_output *output; @@ -3927,8 +3927,8 @@ recorder_binding(struct weston_keyboard *keyboard, uint32_t time, uint32_t key, } #else static void -recorder_binding(struct weston_keyboard *keyboard, uint32_t time, uint32_t key, - void *data) +recorder_binding(struct weston_keyboard *keyboard, const struct timespec *time, + uint32_t key, void *data) { weston_log("Compiled without libva support\n"); } @@ -3979,8 +3979,8 @@ switch_to_gl_renderer(struct drm_backend *b) } static void -renderer_switch_binding(struct weston_keyboard *keyboard, uint32_t time, - uint32_t key, void *data) +renderer_switch_binding(struct weston_keyboard *keyboard, + const struct timespec *time, uint32_t key, void *data) { struct drm_backend *b = to_drm_backend(keyboard->seat->compositor); diff --git a/libweston/compositor-rdp.c b/libweston/compositor-rdp.c index 05e11ee8..3b984e41 100644 --- a/libweston/compositor-rdp.c +++ b/libweston/compositor-rdp.c @@ -1135,6 +1135,7 @@ xf_input_keyboard_event(rdpInput *input, UINT16 flags, UINT16 code) enum wl_keyboard_key_state keyState; RdpPeerContext *peerContext = (RdpPeerContext *)input->context; int notify = 0; + struct timespec time; if (!(peerContext->item.flags & RDP_PEER_ACTIVATED)) FREERDP_CB_RETURN(TRUE); @@ -1160,7 +1161,8 @@ xf_input_keyboard_event(rdpInput *input, UINT16 flags, UINT16 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);*/ - notify_key(peerContext->item.seat, weston_compositor_get_time(), + timespec_from_msec(&time, weston_compositor_get_time()); + notify_key(peerContext->item.seat, &time, scan_code - 8, keyState, STATE_UPDATE_AUTOMATIC); } diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c index 6a1a50f2..7b96b7be 100644 --- a/libweston/compositor-wayland.c +++ b/libweston/compositor-wayland.c @@ -1905,9 +1905,12 @@ input_handle_key(void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t time, uint32_t key, uint32_t state) { struct wayland_input *input = data; + struct timespec ts; + + timespec_from_msec(&ts, time); input->key_serial = serial; - notify_key(&input->base, time, key, + notify_key(&input->base, &ts, key, state ? WL_KEYBOARD_KEY_STATE_PRESSED : WL_KEYBOARD_KEY_STATE_RELEASED, input->keyboard_state_update); @@ -2515,8 +2518,8 @@ create_cursor(struct wayland_backend *b, } static void -fullscreen_binding(struct weston_keyboard *keyboard, uint32_t time, - uint32_t key, void *data) +fullscreen_binding(struct weston_keyboard *keyboard, + const struct timespec *time, uint32_t key, void *data) { struct wayland_backend *b = data; struct wayland_input *input = NULL; diff --git a/libweston/compositor-x11.c b/libweston/compositor-x11.c index 13643a11..edaa53ef 100644 --- a/libweston/compositor-x11.c +++ b/libweston/compositor-x11.c @@ -1325,6 +1325,7 @@ x11_backend_handle_event(int fd, uint32_t mask, void *data) uint32_t i, set; uint8_t response_type; int count; + struct timespec time; prev = NULL; count = 0; @@ -1351,8 +1352,10 @@ x11_backend_handle_event(int fd, uint32_t mask, void *data) * and fall through and handle the new * event below. */ update_xkb_state_from_core(b, key_release->state); + timespec_from_msec(&time, + weston_compositor_get_time()); notify_key(&b->core_seat, - weston_compositor_get_time(), + &time, key_release->detail - 8, WL_KEYBOARD_KEY_STATE_RELEASED, STATE_UPDATE_AUTOMATIC); @@ -1395,8 +1398,9 @@ x11_backend_handle_event(int fd, uint32_t mask, void *data) key_press = (xcb_key_press_event_t *) event; if (!b->has_xkb) update_xkb_state_from_core(b, key_press->state); + timespec_from_msec(&time, weston_compositor_get_time()); notify_key(&b->core_seat, - weston_compositor_get_time(), + &time, key_press->detail - 8, WL_KEYBOARD_KEY_STATE_PRESSED, b->has_xkb ? STATE_UPDATE_NONE : @@ -1410,8 +1414,9 @@ x11_backend_handle_event(int fd, uint32_t mask, void *data) break; } key_release = (xcb_key_press_event_t *) event; + timespec_from_msec(&time, weston_compositor_get_time()); notify_key(&b->core_seat, - weston_compositor_get_time(), + &time, key_release->detail - 8, WL_KEYBOARD_KEY_STATE_RELEASED, STATE_UPDATE_NONE); @@ -1517,8 +1522,9 @@ x11_backend_handle_event(int fd, uint32_t mask, void *data) case XCB_KEY_RELEASE: key_release = (xcb_key_press_event_t *) prev; update_xkb_state_from_core(b, key_release->state); + timespec_from_msec(&time, weston_compositor_get_time()); notify_key(&b->core_seat, - weston_compositor_get_time(), + &time, key_release->detail - 8, WL_KEYBOARD_KEY_STATE_RELEASED, STATE_UPDATE_AUTOMATIC); diff --git a/libweston/compositor.c b/libweston/compositor.c index cfa7eace..c130d92c 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -5241,8 +5241,9 @@ weston_environment_get_fd(const char *env) } static void -timeline_key_binding_handler(struct weston_keyboard *keyboard, uint32_t time, - uint32_t key, void *data) +timeline_key_binding_handler(struct weston_keyboard *keyboard, + const struct timespec *time, uint32_t key, + void *data) { struct weston_compositor *compositor = data; diff --git a/libweston/compositor.h b/libweston/compositor.h index ec76248e..964c3233 100644 --- a/libweston/compositor.h +++ b/libweston/compositor.h @@ -289,8 +289,8 @@ struct weston_pointer_grab { struct weston_keyboard_grab; struct weston_keyboard_grab_interface { - void (*key)(struct weston_keyboard_grab *grab, uint32_t time, - uint32_t key, uint32_t state); + void (*key)(struct weston_keyboard_grab *grab, + const struct timespec *time, uint32_t key, uint32_t state); 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); @@ -492,7 +492,7 @@ bool weston_keyboard_has_focus_resource(struct weston_keyboard *keyboard); void weston_keyboard_send_key(struct weston_keyboard *keyboard, - uint32_t time, uint32_t key, + const struct timespec *time, uint32_t key, enum wl_keyboard_key_state state); void weston_keyboard_send_modifiers(struct weston_keyboard *keyboard, @@ -583,7 +583,7 @@ struct weston_keyboard { struct weston_keyboard_grab default_grab; uint32_t grab_key; uint32_t grab_serial; - uint32_t grab_time; + struct timespec grab_time; struct wl_array keys; @@ -1385,7 +1385,7 @@ void notify_pointer_frame(struct weston_seat *seat); void -notify_key(struct weston_seat *seat, uint32_t time, uint32_t key, +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); void @@ -1475,7 +1475,8 @@ weston_compositor_pick_view(struct weston_compositor *compositor, struct weston_binding; typedef void (*weston_key_binding_handler_t)(struct weston_keyboard *keyboard, - uint32_t time, uint32_t key, + const struct timespec *time, + uint32_t key, void *data); struct weston_binding * weston_compositor_add_key_binding(struct weston_compositor *compositor, @@ -1541,7 +1542,7 @@ weston_binding_list_destroy_all(struct wl_list *list); void weston_compositor_run_key_binding(struct weston_compositor *compositor, struct weston_keyboard *keyboard, - uint32_t time, + const struct timespec *time, uint32_t key, enum wl_keyboard_key_state state); @@ -1567,7 +1568,8 @@ weston_compositor_run_axis_binding(struct weston_compositor *compositor, struct weston_pointer_axis_event *event); int weston_compositor_run_debug_binding(struct weston_compositor *compositor, - struct weston_keyboard *keyboard, uint32_t time, + struct weston_keyboard *keyboard, + const struct timespec *time, uint32_t key, enum wl_keyboard_key_state state); diff --git a/libweston/data-device.c b/libweston/data-device.c index 26898aa6..674d3a24 100644 --- a/libweston/data-device.c +++ b/libweston/data-device.c @@ -824,7 +824,7 @@ static const struct weston_touch_grab_interface touch_drag_grab_interface = { static void drag_grab_keyboard_key(struct weston_keyboard_grab *grab, - uint32_t time, uint32_t key, uint32_t state) + const struct timespec *time, uint32_t key, uint32_t state) { } diff --git a/libweston/gl-renderer.c b/libweston/gl-renderer.c index 244ce309..94d81ef4 100644 --- a/libweston/gl-renderer.c +++ b/libweston/gl-renderer.c @@ -3534,7 +3534,8 @@ compile_shaders(struct weston_compositor *ec) } static void -fragment_debug_binding(struct weston_keyboard *keyboard, uint32_t time, +fragment_debug_binding(struct weston_keyboard *keyboard, + const struct timespec *time, uint32_t key, void *data) { struct weston_compositor *ec = data; @@ -3560,7 +3561,8 @@ fragment_debug_binding(struct weston_keyboard *keyboard, uint32_t time, } static void -fan_debug_repaint_binding(struct weston_keyboard *keyboard, uint32_t time, +fan_debug_repaint_binding(struct weston_keyboard *keyboard, + const struct timespec *time, uint32_t key, void *data) { struct weston_compositor *compositor = data; diff --git a/libweston/input.c b/libweston/input.c index 877b0b83..a1085463 100644 --- a/libweston/input.c +++ b/libweston/input.c @@ -842,26 +842,29 @@ weston_keyboard_has_focus_resource(struct weston_keyboard *keyboard) */ WL_EXPORT void weston_keyboard_send_key(struct weston_keyboard *keyboard, - uint32_t time, uint32_t key, + const struct timespec *time, uint32_t key, enum wl_keyboard_key_state state) { struct wl_resource *resource; struct wl_display *display = keyboard->seat->compositor->wl_display; uint32_t serial; struct wl_list *resource_list; + uint32_t msecs; if (!weston_keyboard_has_focus_resource(keyboard)) return; resource_list = &keyboard->focus_resource_list; serial = wl_display_next_serial(display); + msecs = timespec_to_msec(time); wl_resource_for_each(resource, resource_list) - wl_keyboard_send_key(resource, serial, time, key, state); + wl_keyboard_send_key(resource, serial, msecs, key, state); }; static void default_grab_keyboard_key(struct weston_keyboard_grab *grab, - uint32_t time, uint32_t key, uint32_t state) + const struct timespec *time, uint32_t key, + uint32_t state) { weston_keyboard_send_key(grab->keyboard, time, key, state); } @@ -1944,7 +1947,7 @@ update_keymap(struct weston_seat *seat) } WL_EXPORT void -notify_key(struct weston_seat *seat, uint32_t time, uint32_t key, +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) { @@ -1996,7 +1999,7 @@ notify_key(struct weston_seat *seat, uint32_t time, uint32_t key, keyboard->grab_serial = wl_display_get_serial(compositor->wl_display); if (state == WL_KEYBOARD_KEY_STATE_PRESSED) { - keyboard->grab_time = time; + keyboard->grab_time = *time; keyboard->grab_key = key; } } diff --git a/libweston/launcher-util.c b/libweston/launcher-util.c index fa3ed13b..96a0ba6f 100644 --- a/libweston/launcher-util.c +++ b/libweston/launcher-util.c @@ -95,7 +95,7 @@ weston_launcher_restore(struct weston_launcher *launcher) static void switch_vt_binding(struct weston_keyboard *keyboard, - uint32_t time, uint32_t key, void *data) + const struct timespec *time, uint32_t key, void *data) { struct weston_compositor *compositor = data; struct weston_launcher *launcher = compositor->launcher; diff --git a/libweston/libinput-device.c b/libweston/libinput-device.c index 4d8cf2e6..69844a76 100644 --- a/libweston/libinput-device.c +++ b/libweston/libinput-device.c @@ -66,6 +66,7 @@ handle_keyboard_key(struct libinput_device *libinput_device, libinput_event_keyboard_get_key_state(keyboard_event); int seat_key_count = libinput_event_keyboard_get_seat_key_count(keyboard_event); + struct timespec time; /* Ignore key events that are not seat wide state changes. */ if ((key_state == LIBINPUT_KEY_STATE_PRESSED && @@ -74,8 +75,10 @@ handle_keyboard_key(struct libinput_device *libinput_device, seat_key_count != 0)) return; - notify_key(device->seat, - libinput_event_keyboard_get_time(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); } diff --git a/libweston/pixman-renderer.c b/libweston/pixman-renderer.c index 4ba13778..f7366cf6 100644 --- a/libweston/pixman-renderer.c +++ b/libweston/pixman-renderer.c @@ -804,8 +804,8 @@ pixman_renderer_surface_copy_content(struct weston_surface *surface, } static void -debug_binding(struct weston_keyboard *keyboard, uint32_t time, uint32_t key, - void *data) +debug_binding(struct weston_keyboard *keyboard, const struct timespec *time, + uint32_t key, void *data) { struct weston_compositor *ec = data; struct pixman_renderer *pr = (struct pixman_renderer *) ec->renderer; diff --git a/tests/surface-screenshot.c b/tests/surface-screenshot.c index 716eedae..f5199371 100644 --- a/tests/surface-screenshot.c +++ b/tests/surface-screenshot.c @@ -133,8 +133,8 @@ unpremultiply_and_swap_a8b8g8r8_to_PAMrgba(void *pixels, size_t size) } static void -trigger_binding(struct weston_keyboard *keyboard, uint32_t time, uint32_t key, - void *data) +trigger_binding(struct weston_keyboard *keyboard, const struct timespec *time, + uint32_t key, void *data) { const char *prefix = "surfaceshot-"; const char *suffix = ".pam"; diff --git a/tests/weston-test.c b/tests/weston-test.c index 306757a0..6e7beeb7 100644 --- a/tests/weston-test.c +++ b/tests/weston-test.c @@ -210,8 +210,11 @@ 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; + + timespec_from_msec(&time, 100); - notify_key(seat, 100, key, state, STATE_UPDATE_AUTOMATIC); + notify_key(seat, &time, key, state, STATE_UPDATE_AUTOMATIC); } static void