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 <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
dev
Alexandros Frantzis 7 years ago committed by Pekka Paalanen
parent 80321942e7
commit 47e79c860b
  1. 8
      compositor/screen-share.c
  2. 13
      compositor/text-backend.c
  3. 6
      compositor/weston-screenshooter.c
  4. 4
      desktop-shell/exposay.c
  5. 44
      desktop-shell/shell.c
  6. 2
      ivi-shell/ivi-shell.c
  7. 3
      libweston-desktop/seat.c
  8. 24
      libweston/bindings.c
  9. 16
      libweston/compositor-drm.c
  10. 4
      libweston/compositor-rdp.c
  11. 9
      libweston/compositor-wayland.c
  12. 14
      libweston/compositor-x11.c
  13. 5
      libweston/compositor.c
  14. 18
      libweston/compositor.h
  15. 2
      libweston/data-device.c
  16. 6
      libweston/gl-renderer.c
  17. 13
      libweston/input.c
  18. 2
      libweston/launcher-util.c
  19. 7
      libweston/libinput-device.c
  20. 4
      libweston/pixman-renderer.c
  21. 4
      tests/surface-screenshot.c
  22. 5
      tests/weston-test.c

@ -277,9 +277,11 @@ ss_seat_handle_key(void *data, struct wl_keyboard *keyboard,
uint32_t key, uint32_t state) uint32_t key, uint32_t state)
{ {
struct ss_seat *seat = data; struct ss_seat *seat = data;
struct timespec ts;
timespec_from_msec(&ts, time);
seat->key_serial = serial; seat->key_serial = serial;
notify_key(&seat->base, time, key, notify_key(&seat->base, &ts, key,
state ? WL_KEYBOARD_KEY_STATE_PRESSED : state ? WL_KEYBOARD_KEY_STATE_PRESSED :
WL_KEYBOARD_KEY_STATE_RELEASED, WL_KEYBOARD_KEY_STATE_RELEASED,
seat->keyboard_state_update); seat->keyboard_state_update);
@ -1092,8 +1094,8 @@ weston_output_find(struct weston_compositor *c, int32_t x, int32_t y)
} }
static void static void
share_output_binding(struct weston_keyboard *keyboard, uint32_t time, uint32_t key, share_output_binding(struct weston_keyboard *keyboard,
void *data) const struct timespec *time, uint32_t key, void *data)
{ {
struct weston_output *output; struct weston_output *output;
struct weston_pointer *pointer; struct weston_pointer *pointer;

@ -38,6 +38,7 @@
#include "text-input-unstable-v1-server-protocol.h" #include "text-input-unstable-v1-server-protocol.h"
#include "input-method-unstable-v1-server-protocol.h" #include "input-method-unstable-v1-server-protocol.h"
#include "shared/helpers.h" #include "shared/helpers.h"
#include "shared/timespec-util.h"
struct text_input_manager; struct text_input_manager;
struct input_method; struct input_method;
@ -607,11 +608,13 @@ unbind_keyboard(struct wl_resource *resource)
static void static void
input_method_context_grab_key(struct weston_keyboard_grab *grab, 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 weston_keyboard *keyboard = grab->keyboard;
struct wl_display *display; struct wl_display *display;
uint32_t serial; uint32_t serial;
uint32_t msecs;
if (!keyboard->input_method_resource) if (!keyboard->input_method_resource)
return; return;
@ -619,8 +622,9 @@ input_method_context_grab_key(struct weston_keyboard_grab *grab,
display = wl_client_get_display( display = wl_client_get_display(
wl_resource_get_client(keyboard->input_method_resource)); wl_resource_get_client(keyboard->input_method_resource));
serial = wl_display_next_serial(display); serial = wl_display_next_serial(display);
msecs = timespec_to_msec(time);
wl_keyboard_send_key(keyboard->input_method_resource, wl_keyboard_send_key(keyboard->input_method_resource,
serial, time, key, state_w); serial, msecs, key, state_w);
} }
static void static void
@ -693,8 +697,11 @@ input_method_context_key(struct wl_client *client,
struct weston_seat *seat = context->input_method->seat; struct weston_seat *seat = context->input_method->seat;
struct weston_keyboard *keyboard = weston_seat_get_keyboard(seat); struct weston_keyboard *keyboard = weston_seat_get_keyboard(seat);
struct weston_keyboard_grab *default_grab = &keyboard->default_grab; struct weston_keyboard_grab *default_grab = &keyboard->default_grab;
struct timespec ts;
timespec_from_msec(&ts, time);
default_grab->interface->key(default_grab, time, key, state_w); default_grab->interface->key(default_grab, &ts, key, state_w);
} }
static void static void

@ -112,8 +112,8 @@ screenshooter_sigchld(struct weston_process *process, int status)
} }
static void static void
screenshooter_binding(struct weston_keyboard *keyboard, uint32_t time, screenshooter_binding(struct weston_keyboard *keyboard,
uint32_t key, void *data) const struct timespec *time, uint32_t key, void *data)
{ {
struct screenshooter *shooter = data; struct screenshooter *shooter = data;
char *screenshooter_exe; char *screenshooter_exe;
@ -135,7 +135,7 @@ screenshooter_binding(struct weston_keyboard *keyboard, uint32_t time,
} }
static void 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) uint32_t key, void *data)
{ {
struct weston_compositor *ec = keyboard->seat->compositor; struct weston_compositor *ec = keyboard->seat->compositor;

@ -442,8 +442,8 @@ exposay_maybe_move(struct desktop_shell *shell, int row, int column)
} }
static void static void
exposay_key(struct weston_keyboard_grab *grab, uint32_t time, uint32_t key, exposay_key(struct weston_keyboard_grab *grab, const struct timespec *time,
uint32_t state_w) uint32_t key, uint32_t state_w)
{ {
struct weston_seat *seat = grab->keyboard->seat; struct weston_seat *seat = grab->keyboard->seat;
struct desktop_shell *shell = struct desktop_shell *shell =

@ -3232,7 +3232,7 @@ move_binding(struct weston_pointer *pointer, const struct timespec *time,
} }
static void 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) uint32_t button, void *data)
{ {
struct weston_surface *focus = keyboard->focus; struct weston_surface *focus = keyboard->focus;
@ -3251,8 +3251,8 @@ maximize_binding(struct weston_keyboard *keyboard, uint32_t time,
} }
static void static void
fullscreen_binding(struct weston_keyboard *keyboard, uint32_t time, fullscreen_binding(struct weston_keyboard *keyboard,
uint32_t button, void *data) const struct timespec *time, uint32_t button, void *data)
{ {
struct weston_surface *focus = keyboard->focus; struct weston_surface *focus = keyboard->focus;
struct weston_surface *surface; struct weston_surface *surface;
@ -3434,18 +3434,14 @@ zoom_axis_binding(struct weston_pointer *pointer, const struct timespec *time,
} }
static void 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) uint32_t key, void *data)
{ {
struct timespec ts; do_zoom(keyboard->seat, time, key, 0, 0);
timespec_from_msec(&ts, time);
do_zoom(keyboard->seat, &ts, key, 0, 0);
} }
static void 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) uint32_t key, void *data)
{ {
struct weston_compositor *compositor = data; struct weston_compositor *compositor = data;
@ -4421,7 +4417,7 @@ switcher_destroy(struct switcher *switcher)
static void static void
switcher_key(struct weston_keyboard_grab *grab, 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); struct switcher *switcher = container_of(grab, struct switcher, grab);
enum wl_keyboard_key_state state = state_w; enum wl_keyboard_key_state state = state_w;
@ -4457,7 +4453,7 @@ static const struct weston_keyboard_grab_interface switcher_grab = {
}; };
static void 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) uint32_t key, void *data)
{ {
struct desktop_shell *shell = data; struct desktop_shell *shell = data;
@ -4478,7 +4474,7 @@ switcher_binding(struct weston_keyboard *keyboard, uint32_t time,
} }
static void 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) uint32_t key, void *data)
{ {
struct weston_compositor *compositor = data; struct weston_compositor *compositor = data;
@ -4511,8 +4507,8 @@ backlight_binding(struct weston_keyboard *keyboard, uint32_t time,
} }
static void static void
force_kill_binding(struct weston_keyboard *keyboard, uint32_t time, force_kill_binding(struct weston_keyboard *keyboard,
uint32_t key, void *data) const struct timespec *time, uint32_t key, void *data)
{ {
struct weston_surface *focus_surface; struct weston_surface *focus_surface;
struct wl_client *client; struct wl_client *client;
@ -4538,8 +4534,8 @@ force_kill_binding(struct weston_keyboard *keyboard, uint32_t time,
} }
static void static void
workspace_up_binding(struct weston_keyboard *keyboard, uint32_t time, workspace_up_binding(struct weston_keyboard *keyboard,
uint32_t key, void *data) const struct timespec *time, uint32_t key, void *data)
{ {
struct desktop_shell *shell = data; struct desktop_shell *shell = data;
unsigned int new_index = shell->workspaces.current; unsigned int new_index = shell->workspaces.current;
@ -4553,8 +4549,8 @@ workspace_up_binding(struct weston_keyboard *keyboard, uint32_t time,
} }
static void static void
workspace_down_binding(struct weston_keyboard *keyboard, uint32_t time, workspace_down_binding(struct weston_keyboard *keyboard,
uint32_t key, void *data) const struct timespec *time, uint32_t key, void *data)
{ {
struct desktop_shell *shell = data; struct desktop_shell *shell = data;
unsigned int new_index = shell->workspaces.current; unsigned int new_index = shell->workspaces.current;
@ -4568,8 +4564,8 @@ workspace_down_binding(struct weston_keyboard *keyboard, uint32_t time,
} }
static void static void
workspace_f_binding(struct weston_keyboard *keyboard, uint32_t time, workspace_f_binding(struct weston_keyboard *keyboard,
uint32_t key, void *data) const struct timespec *time, uint32_t key, void *data)
{ {
struct desktop_shell *shell = data; struct desktop_shell *shell = data;
unsigned int new_index; unsigned int new_index;
@ -4585,7 +4581,8 @@ workspace_f_binding(struct weston_keyboard *keyboard, uint32_t time,
static void static void
workspace_move_surface_up_binding(struct weston_keyboard *keyboard, 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; struct desktop_shell *shell = data;
unsigned int new_index = shell->workspaces.current; unsigned int new_index = shell->workspaces.current;
@ -4601,7 +4598,8 @@ workspace_move_surface_up_binding(struct weston_keyboard *keyboard,
static void static void
workspace_move_surface_down_binding(struct weston_keyboard *keyboard, 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; struct desktop_shell *shell = data;
unsigned int new_index = shell->workspaces.current; unsigned int new_index = shell->workspaces.current;

@ -376,7 +376,7 @@ shell_destroy(struct wl_listener *listener, void *data)
} }
static void 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) uint32_t key, void *data)
{ {
struct weston_compositor *compositor = data; struct weston_compositor *compositor = data;

@ -54,7 +54,8 @@ static void weston_desktop_seat_popup_grab_end(struct weston_desktop_seat *seat)
static void static void
weston_desktop_seat_popup_grab_keyboard_key(struct weston_keyboard_grab *grab, 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) enum wl_keyboard_key_state state)
{ {
weston_keyboard_send_key(grab->keyboard, time, key, state); weston_keyboard_send_key(grab->keyboard, time, key, state);

@ -31,6 +31,7 @@
#include "compositor.h" #include "compositor.h"
#include "shared/helpers.h" #include "shared/helpers.h"
#include "shared/timespec-util.h"
struct weston_binding { struct weston_binding {
uint32_t key; uint32_t key;
@ -192,7 +193,7 @@ struct binding_keyboard_grab {
static void static void
binding_key(struct weston_keyboard_grab *grab, 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 = struct binding_keyboard_grab *b =
container_of(grab, struct binding_keyboard_grab, grab); container_of(grab, struct binding_keyboard_grab, grab);
@ -201,6 +202,7 @@ binding_key(struct weston_keyboard_grab *grab,
uint32_t serial; uint32_t serial;
struct weston_keyboard *keyboard = grab->keyboard; struct weston_keyboard *keyboard = grab->keyboard;
struct wl_display *display = keyboard->seat->compositor->wl_display; struct wl_display *display = keyboard->seat->compositor->wl_display;
uint32_t msecs;
if (key == b->key) { if (key == b->key) {
if (state == WL_KEYBOARD_KEY_STATE_RELEASED) { 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)) { if (!wl_list_empty(&keyboard->focus_resource_list)) {
serial = wl_display_next_serial(display); serial = wl_display_next_serial(display);
msecs = timespec_to_msec(time);
wl_resource_for_each(resource, &keyboard->focus_resource_list) { wl_resource_for_each(resource, &keyboard->focus_resource_list) {
wl_keyboard_send_key(resource, wl_keyboard_send_key(resource,
serial, serial,
time, msecs,
key, key,
state); state);
} }
@ -255,8 +258,9 @@ static const struct weston_keyboard_grab_interface binding_grab = {
}; };
static void static void
install_binding_grab(struct weston_keyboard *keyboard, uint32_t time, install_binding_grab(struct weston_keyboard *keyboard,
uint32_t key, struct weston_surface *focus) const struct timespec *time, uint32_t key,
struct weston_surface *focus)
{ {
struct binding_keyboard_grab *grab; struct binding_keyboard_grab *grab;
@ -282,7 +286,7 @@ install_binding_grab(struct weston_keyboard *keyboard, uint32_t time,
void void
weston_compositor_run_key_binding(struct weston_compositor *compositor, weston_compositor_run_key_binding(struct weston_compositor *compositor,
struct weston_keyboard *keyboard, struct weston_keyboard *keyboard,
uint32_t time, uint32_t key, const struct timespec *time, uint32_t key,
enum wl_keyboard_key_state state) enum wl_keyboard_key_state state)
{ {
struct weston_binding *b, *tmp; struct weston_binding *b, *tmp;
@ -416,7 +420,7 @@ weston_compositor_run_axis_binding(struct weston_compositor *compositor,
int int
weston_compositor_run_debug_binding(struct weston_compositor *compositor, weston_compositor_run_debug_binding(struct weston_compositor *compositor,
struct weston_keyboard *keyboard, struct weston_keyboard *keyboard,
uint32_t time, uint32_t key, const struct timespec *time, uint32_t key,
enum wl_keyboard_key_state state) enum wl_keyboard_key_state state)
{ {
weston_key_binding_handler_t handler; weston_key_binding_handler_t handler;
@ -443,7 +447,7 @@ struct debug_binding_grab {
}; };
static void 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) uint32_t key, uint32_t state)
{ {
struct debug_binding_grab *db = (struct debug_binding_grab *) grab; 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 check_binding = 1;
int i; int i;
struct wl_list *resource_list; struct wl_list *resource_list;
uint32_t msecs;
if (state == WL_KEYBOARD_KEY_STATE_RELEASED) { if (state == WL_KEYBOARD_KEY_STATE_RELEASED) {
/* Do not run bindings on key releases */ /* Do not run bindings on key releases */
@ -503,8 +508,9 @@ debug_binding_key(struct weston_keyboard_grab *grab, uint32_t time,
if (send) { if (send) {
serial = wl_display_next_serial(display); serial = wl_display_next_serial(display);
resource_list = &grab->keyboard->focus_resource_list; resource_list = &grab->keyboard->focus_resource_list;
msecs = timespec_to_msec(time);
wl_resource_for_each(resource, resource_list) { 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 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) uint32_t key, void *data)
{ {
struct debug_binding_grab *grab; struct debug_binding_grab *grab;

@ -3804,8 +3804,8 @@ find_primary_gpu(struct drm_backend *b, const char *seat)
} }
static void static void
planes_binding(struct weston_keyboard *keyboard, uint32_t time, uint32_t key, planes_binding(struct weston_keyboard *keyboard, const struct timespec *time,
void *data) uint32_t key, void *data)
{ {
struct drm_backend *b = data; struct drm_backend *b = data;
@ -3885,8 +3885,8 @@ create_recorder(struct drm_backend *b, int width, int height,
} }
static void static void
recorder_binding(struct weston_keyboard *keyboard, uint32_t time, uint32_t key, recorder_binding(struct weston_keyboard *keyboard, const struct timespec *time,
void *data) uint32_t key, void *data)
{ {
struct drm_backend *b = data; struct drm_backend *b = data;
struct drm_output *output; struct drm_output *output;
@ -3927,8 +3927,8 @@ recorder_binding(struct weston_keyboard *keyboard, uint32_t time, uint32_t key,
} }
#else #else
static void static void
recorder_binding(struct weston_keyboard *keyboard, uint32_t time, uint32_t key, recorder_binding(struct weston_keyboard *keyboard, const struct timespec *time,
void *data) uint32_t key, void *data)
{ {
weston_log("Compiled without libva support\n"); weston_log("Compiled without libva support\n");
} }
@ -3979,8 +3979,8 @@ switch_to_gl_renderer(struct drm_backend *b)
} }
static void static void
renderer_switch_binding(struct weston_keyboard *keyboard, uint32_t time, renderer_switch_binding(struct weston_keyboard *keyboard,
uint32_t key, void *data) const struct timespec *time, uint32_t key, void *data)
{ {
struct drm_backend *b = struct drm_backend *b =
to_drm_backend(keyboard->seat->compositor); to_drm_backend(keyboard->seat->compositor);

@ -1135,6 +1135,7 @@ xf_input_keyboard_event(rdpInput *input, UINT16 flags, UINT16 code)
enum wl_keyboard_key_state keyState; enum wl_keyboard_key_state keyState;
RdpPeerContext *peerContext = (RdpPeerContext *)input->context; RdpPeerContext *peerContext = (RdpPeerContext *)input->context;
int notify = 0; int notify = 0;
struct timespec time;
if (!(peerContext->item.flags & RDP_PEER_ACTIVATED)) if (!(peerContext->item.flags & RDP_PEER_ACTIVATED))
FREERDP_CB_RETURN(TRUE); 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, /*weston_log("code=%x ext=%d vk_code=%x scan_code=%x\n", code, (flags & KBD_FLAGS_EXTENDED) ? 1 : 0,
vk_code, scan_code);*/ 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); scan_code - 8, keyState, STATE_UPDATE_AUTOMATIC);
} }

@ -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) uint32_t serial, uint32_t time, uint32_t key, uint32_t state)
{ {
struct wayland_input *input = data; struct wayland_input *input = data;
struct timespec ts;
timespec_from_msec(&ts, time);
input->key_serial = serial; input->key_serial = serial;
notify_key(&input->base, time, key, notify_key(&input->base, &ts, key,
state ? WL_KEYBOARD_KEY_STATE_PRESSED : state ? WL_KEYBOARD_KEY_STATE_PRESSED :
WL_KEYBOARD_KEY_STATE_RELEASED, WL_KEYBOARD_KEY_STATE_RELEASED,
input->keyboard_state_update); input->keyboard_state_update);
@ -2515,8 +2518,8 @@ create_cursor(struct wayland_backend *b,
} }
static void static void
fullscreen_binding(struct weston_keyboard *keyboard, uint32_t time, fullscreen_binding(struct weston_keyboard *keyboard,
uint32_t key, void *data) const struct timespec *time, uint32_t key, void *data)
{ {
struct wayland_backend *b = data; struct wayland_backend *b = data;
struct wayland_input *input = NULL; struct wayland_input *input = NULL;

@ -1325,6 +1325,7 @@ x11_backend_handle_event(int fd, uint32_t mask, void *data)
uint32_t i, set; uint32_t i, set;
uint8_t response_type; uint8_t response_type;
int count; int count;
struct timespec time;
prev = NULL; prev = NULL;
count = 0; count = 0;
@ -1351,8 +1352,10 @@ x11_backend_handle_event(int fd, uint32_t mask, void *data)
* and fall through and handle the new * and fall through and handle the new
* event below. */ * event below. */
update_xkb_state_from_core(b, key_release->state); update_xkb_state_from_core(b, key_release->state);
timespec_from_msec(&time,
weston_compositor_get_time());
notify_key(&b->core_seat, notify_key(&b->core_seat,
weston_compositor_get_time(), &time,
key_release->detail - 8, key_release->detail - 8,
WL_KEYBOARD_KEY_STATE_RELEASED, WL_KEYBOARD_KEY_STATE_RELEASED,
STATE_UPDATE_AUTOMATIC); 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; key_press = (xcb_key_press_event_t *) event;
if (!b->has_xkb) if (!b->has_xkb)
update_xkb_state_from_core(b, key_press->state); update_xkb_state_from_core(b, key_press->state);
timespec_from_msec(&time, weston_compositor_get_time());
notify_key(&b->core_seat, notify_key(&b->core_seat,
weston_compositor_get_time(), &time,
key_press->detail - 8, key_press->detail - 8,
WL_KEYBOARD_KEY_STATE_PRESSED, WL_KEYBOARD_KEY_STATE_PRESSED,
b->has_xkb ? STATE_UPDATE_NONE : b->has_xkb ? STATE_UPDATE_NONE :
@ -1410,8 +1414,9 @@ x11_backend_handle_event(int fd, uint32_t mask, void *data)
break; break;
} }
key_release = (xcb_key_press_event_t *) event; key_release = (xcb_key_press_event_t *) event;
timespec_from_msec(&time, weston_compositor_get_time());
notify_key(&b->core_seat, notify_key(&b->core_seat,
weston_compositor_get_time(), &time,
key_release->detail - 8, key_release->detail - 8,
WL_KEYBOARD_KEY_STATE_RELEASED, WL_KEYBOARD_KEY_STATE_RELEASED,
STATE_UPDATE_NONE); STATE_UPDATE_NONE);
@ -1517,8 +1522,9 @@ x11_backend_handle_event(int fd, uint32_t mask, void *data)
case XCB_KEY_RELEASE: case XCB_KEY_RELEASE:
key_release = (xcb_key_press_event_t *) prev; key_release = (xcb_key_press_event_t *) prev;
update_xkb_state_from_core(b, key_release->state); update_xkb_state_from_core(b, key_release->state);
timespec_from_msec(&time, weston_compositor_get_time());
notify_key(&b->core_seat, notify_key(&b->core_seat,
weston_compositor_get_time(), &time,
key_release->detail - 8, key_release->detail - 8,
WL_KEYBOARD_KEY_STATE_RELEASED, WL_KEYBOARD_KEY_STATE_RELEASED,
STATE_UPDATE_AUTOMATIC); STATE_UPDATE_AUTOMATIC);

@ -5241,8 +5241,9 @@ weston_environment_get_fd(const char *env)
} }
static void static void
timeline_key_binding_handler(struct weston_keyboard *keyboard, uint32_t time, timeline_key_binding_handler(struct weston_keyboard *keyboard,
uint32_t key, void *data) const struct timespec *time, uint32_t key,
void *data)
{ {
struct weston_compositor *compositor = data; struct weston_compositor *compositor = data;

@ -289,8 +289,8 @@ struct weston_pointer_grab {
struct weston_keyboard_grab; struct weston_keyboard_grab;
struct weston_keyboard_grab_interface { struct weston_keyboard_grab_interface {
void (*key)(struct weston_keyboard_grab *grab, uint32_t time, void (*key)(struct weston_keyboard_grab *grab,
uint32_t key, uint32_t state); const struct timespec *time, uint32_t key, uint32_t state);
void (*modifiers)(struct weston_keyboard_grab *grab, uint32_t serial, void (*modifiers)(struct weston_keyboard_grab *grab, uint32_t serial,
uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_depressed, uint32_t mods_latched,
uint32_t mods_locked, uint32_t group); uint32_t mods_locked, uint32_t group);
@ -492,7 +492,7 @@ bool
weston_keyboard_has_focus_resource(struct weston_keyboard *keyboard); weston_keyboard_has_focus_resource(struct weston_keyboard *keyboard);
void void
weston_keyboard_send_key(struct weston_keyboard *keyboard, 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); enum wl_keyboard_key_state state);
void void
weston_keyboard_send_modifiers(struct weston_keyboard *keyboard, weston_keyboard_send_modifiers(struct weston_keyboard *keyboard,
@ -583,7 +583,7 @@ struct weston_keyboard {
struct weston_keyboard_grab default_grab; struct weston_keyboard_grab default_grab;
uint32_t grab_key; uint32_t grab_key;
uint32_t grab_serial; uint32_t grab_serial;
uint32_t grab_time; struct timespec grab_time;
struct wl_array keys; struct wl_array keys;
@ -1385,7 +1385,7 @@ void
notify_pointer_frame(struct weston_seat *seat); notify_pointer_frame(struct weston_seat *seat);
void 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 wl_keyboard_key_state state,
enum weston_key_state_update update_state); enum weston_key_state_update update_state);
void void
@ -1475,7 +1475,8 @@ weston_compositor_pick_view(struct weston_compositor *compositor,
struct weston_binding; struct weston_binding;
typedef void (*weston_key_binding_handler_t)(struct weston_keyboard *keyboard, 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); void *data);
struct weston_binding * struct weston_binding *
weston_compositor_add_key_binding(struct weston_compositor *compositor, weston_compositor_add_key_binding(struct weston_compositor *compositor,
@ -1541,7 +1542,7 @@ weston_binding_list_destroy_all(struct wl_list *list);
void void
weston_compositor_run_key_binding(struct weston_compositor *compositor, weston_compositor_run_key_binding(struct weston_compositor *compositor,
struct weston_keyboard *keyboard, struct weston_keyboard *keyboard,
uint32_t time, const struct timespec *time,
uint32_t key, uint32_t key,
enum wl_keyboard_key_state state); 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); struct weston_pointer_axis_event *event);
int int
weston_compositor_run_debug_binding(struct weston_compositor *compositor, 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, uint32_t key,
enum wl_keyboard_key_state state); enum wl_keyboard_key_state state);

@ -824,7 +824,7 @@ static const struct weston_touch_grab_interface touch_drag_grab_interface = {
static void static void
drag_grab_keyboard_key(struct weston_keyboard_grab *grab, 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)
{ {
} }

@ -3534,7 +3534,8 @@ compile_shaders(struct weston_compositor *ec)
} }
static void 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) uint32_t key, void *data)
{ {
struct weston_compositor *ec = data; struct weston_compositor *ec = data;
@ -3560,7 +3561,8 @@ fragment_debug_binding(struct weston_keyboard *keyboard, uint32_t time,
} }
static void 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) uint32_t key, void *data)
{ {
struct weston_compositor *compositor = data; struct weston_compositor *compositor = data;

@ -842,26 +842,29 @@ weston_keyboard_has_focus_resource(struct weston_keyboard *keyboard)
*/ */
WL_EXPORT void WL_EXPORT void
weston_keyboard_send_key(struct weston_keyboard *keyboard, 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) enum wl_keyboard_key_state state)
{ {
struct wl_resource *resource; struct wl_resource *resource;
struct wl_display *display = keyboard->seat->compositor->wl_display; struct wl_display *display = keyboard->seat->compositor->wl_display;
uint32_t serial; uint32_t serial;
struct wl_list *resource_list; struct wl_list *resource_list;
uint32_t msecs;
if (!weston_keyboard_has_focus_resource(keyboard)) if (!weston_keyboard_has_focus_resource(keyboard))
return; return;
resource_list = &keyboard->focus_resource_list; resource_list = &keyboard->focus_resource_list;
serial = wl_display_next_serial(display); serial = wl_display_next_serial(display);
msecs = timespec_to_msec(time);
wl_resource_for_each(resource, resource_list) wl_resource_for_each(resource, resource_list)
wl_keyboard_send_key(resource, serial, time, key, state); wl_keyboard_send_key(resource, serial, msecs, key, state);
}; };
static void static void
default_grab_keyboard_key(struct weston_keyboard_grab *grab, 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); weston_keyboard_send_key(grab->keyboard, time, key, state);
} }
@ -1944,7 +1947,7 @@ update_keymap(struct weston_seat *seat)
} }
WL_EXPORT void 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 wl_keyboard_key_state state,
enum weston_key_state_update update_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); keyboard->grab_serial = wl_display_get_serial(compositor->wl_display);
if (state == WL_KEYBOARD_KEY_STATE_PRESSED) { if (state == WL_KEYBOARD_KEY_STATE_PRESSED) {
keyboard->grab_time = time; keyboard->grab_time = *time;
keyboard->grab_key = key; keyboard->grab_key = key;
} }
} }

@ -95,7 +95,7 @@ weston_launcher_restore(struct weston_launcher *launcher)
static void static void
switch_vt_binding(struct weston_keyboard *keyboard, 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_compositor *compositor = data;
struct weston_launcher *launcher = compositor->launcher; struct weston_launcher *launcher = compositor->launcher;

@ -66,6 +66,7 @@ handle_keyboard_key(struct libinput_device *libinput_device,
libinput_event_keyboard_get_key_state(keyboard_event); libinput_event_keyboard_get_key_state(keyboard_event);
int seat_key_count = int seat_key_count =
libinput_event_keyboard_get_seat_key_count(keyboard_event); libinput_event_keyboard_get_seat_key_count(keyboard_event);
struct timespec time;
/* Ignore key events that are not seat wide state changes. */ /* Ignore key events that are not seat wide state changes. */
if ((key_state == LIBINPUT_KEY_STATE_PRESSED && if ((key_state == LIBINPUT_KEY_STATE_PRESSED &&
@ -74,8 +75,10 @@ handle_keyboard_key(struct libinput_device *libinput_device,
seat_key_count != 0)) seat_key_count != 0))
return; return;
notify_key(device->seat, timespec_from_usec(&time,
libinput_event_keyboard_get_time(keyboard_event), libinput_event_keyboard_get_time_usec(keyboard_event));
notify_key(device->seat, &time,
libinput_event_keyboard_get_key(keyboard_event), libinput_event_keyboard_get_key(keyboard_event),
key_state, STATE_UPDATE_AUTOMATIC); key_state, STATE_UPDATE_AUTOMATIC);
} }

@ -804,8 +804,8 @@ pixman_renderer_surface_copy_content(struct weston_surface *surface,
} }
static void static void
debug_binding(struct weston_keyboard *keyboard, uint32_t time, uint32_t key, debug_binding(struct weston_keyboard *keyboard, const struct timespec *time,
void *data) uint32_t key, void *data)
{ {
struct weston_compositor *ec = data; struct weston_compositor *ec = data;
struct pixman_renderer *pr = (struct pixman_renderer *) ec->renderer; struct pixman_renderer *pr = (struct pixman_renderer *) ec->renderer;

@ -133,8 +133,8 @@ unpremultiply_and_swap_a8b8g8r8_to_PAMrgba(void *pixels, size_t size)
} }
static void static void
trigger_binding(struct weston_keyboard *keyboard, uint32_t time, uint32_t key, trigger_binding(struct weston_keyboard *keyboard, const struct timespec *time,
void *data) uint32_t key, void *data)
{ {
const char *prefix = "surfaceshot-"; const char *prefix = "surfaceshot-";
const char *suffix = ".pam"; const char *suffix = ".pam";

@ -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_test *test = wl_resource_get_user_data(resource);
struct weston_seat *seat = get_seat(test); 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 static void

Loading…
Cancel
Save