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>
This commit is contained in:
Alexandros Frantzis
2017-11-16 18:20:57 +02:00
committed by Pekka Paalanen
parent 80321942e7
commit 47e79c860b
22 changed files with 126 additions and 87 deletions
+5 -3
View File
@@ -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;
+10 -3
View File
@@ -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
+3 -3
View File
@@ -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;