Commit 47e79c86 authored by Alexandros Frantzis's avatar Alexandros Frantzis Committed by Pekka Paalanen

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's avatarAlexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
parent 80321942
......@@ -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;
......
......@@ -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
......
......@@ -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;
......
......@@ -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 =
......
......@@ -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;
......
......@@ -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;
......
......@@ -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);
......
......@@ -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;
......
......@@ -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);
......
......@@ -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);
}
......
......@@ -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;
......
......@@ -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);
......
......@@ -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;
......
......@@ -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);
......
......@@ -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)
{
}
......
......@@ -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;
......
......@@ -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;
}
}
......
......@@ -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;
......
......@@ -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);
}
......
......@@ -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;
......
......@@ -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";
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment