mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2026-05-07 11:58:03 +02:00
input: Introduce weston_key_event struct
Rather than passing a time stamp, key, key state and key event state use a weston_key_event struct to pass by all that using it. This would allow in further patches to attach additional information like a flow id used by Perfetto debug annotations for input events. This patch has no functional change as it is now. All the callees will just will extract the required information out of struct weston_key_event. Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
This commit is contained in:
parent
e0c5b8a26b
commit
496e71f146
14 changed files with 169 additions and 88 deletions
|
|
@ -4189,11 +4189,11 @@ switcher_destroy(struct switcher *switcher)
|
|||
}
|
||||
|
||||
static void
|
||||
switcher_key(struct weston_keyboard_grab *grab,
|
||||
const struct timespec *time, uint32_t key, uint32_t state_w)
|
||||
switcher_key(struct weston_keyboard_grab *grab, const struct weston_key_event *key_event)
|
||||
{
|
||||
struct switcher *switcher = container_of(grab, struct switcher, grab);
|
||||
enum wl_keyboard_key_state state = state_w;
|
||||
enum wl_keyboard_key_state state = key_event->key_state;
|
||||
uint32_t key = key_event->key;
|
||||
|
||||
if (key == KEY_TAB && state == WL_KEYBOARD_KEY_STATE_PRESSED)
|
||||
switcher_next(switcher);
|
||||
|
|
|
|||
|
|
@ -621,13 +621,15 @@ unbind_keyboard(struct wl_resource *resource)
|
|||
|
||||
static void
|
||||
input_method_context_grab_key(struct weston_keyboard_grab *grab,
|
||||
const struct timespec *time, uint32_t key,
|
||||
uint32_t state_w)
|
||||
const struct weston_key_event *key_event)
|
||||
{
|
||||
struct weston_keyboard *keyboard = grab->keyboard;
|
||||
struct wl_display *display;
|
||||
uint32_t serial;
|
||||
uint32_t msecs;
|
||||
uint32_t key = key_event->key;
|
||||
struct timespec *time = key_event->base_event.ts;
|
||||
uint32_t state_w = key_event->key_state;
|
||||
|
||||
if (!keyboard->input_method_resource)
|
||||
return;
|
||||
|
|
@ -712,10 +714,14 @@ input_method_context_key(struct wl_client *client,
|
|||
struct weston_keyboard *keyboard = weston_seat_get_keyboard(seat);
|
||||
struct weston_keyboard_grab *default_grab = &keyboard->default_grab;
|
||||
struct timespec ts;
|
||||
struct weston_key_event key_event;
|
||||
|
||||
timespec_from_msec(&ts, time);
|
||||
|
||||
default_grab->interface->key(default_grab, &ts, key, state_w);
|
||||
weston_input_event_init(&key_event.base_event, &ts, seat);
|
||||
weston_key_event_init(&key_event, key, state_w, STATE_UPDATE_NONE);
|
||||
|
||||
default_grab->interface->key(default_grab, &key_event);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -188,6 +188,11 @@ struct weston_spring {
|
|||
uint32_t clip;
|
||||
};
|
||||
|
||||
enum weston_key_state_update {
|
||||
STATE_UPDATE_AUTOMATIC,
|
||||
STATE_UPDATE_NONE,
|
||||
};
|
||||
|
||||
/* bit compatible with drm definitions. */
|
||||
enum dpms_enum {
|
||||
WESTON_DPMS_ON,
|
||||
|
|
@ -615,6 +620,20 @@ struct weston_pointer_axis_event {
|
|||
int32_t discrete;
|
||||
};
|
||||
|
||||
/* base/common struct which all weston_xxx_event should "inherit" */
|
||||
struct weston_input_event {
|
||||
struct timespec *ts;
|
||||
struct weston_seat *seat;
|
||||
};
|
||||
|
||||
struct weston_key_event {
|
||||
struct weston_input_event base_event;
|
||||
uint32_t key;
|
||||
enum wl_keyboard_key_state key_state;
|
||||
enum weston_key_state_update key_update_state;
|
||||
};
|
||||
|
||||
|
||||
struct weston_pointer_grab;
|
||||
struct weston_pointer_grab_interface {
|
||||
void (*focus)(struct weston_pointer_grab *grab);
|
||||
|
|
@ -640,7 +659,7 @@ struct weston_pointer_grab {
|
|||
struct weston_keyboard_grab;
|
||||
struct weston_keyboard_grab_interface {
|
||||
void (*key)(struct weston_keyboard_grab *grab,
|
||||
const struct timespec *time, uint32_t key, uint32_t state);
|
||||
const struct weston_key_event *key_event);
|
||||
void (*modifiers)(struct weston_keyboard_grab *grab, uint32_t serial,
|
||||
uint32_t mods_depressed, uint32_t mods_latched,
|
||||
uint32_t mods_locked, uint32_t group);
|
||||
|
|
@ -1003,8 +1022,16 @@ weston_keyboard_set_locks(struct weston_keyboard *keyboard,
|
|||
|
||||
void
|
||||
weston_keyboard_send_key(struct weston_keyboard *keyboard,
|
||||
const struct timespec *time, uint32_t key,
|
||||
enum wl_keyboard_key_state state);
|
||||
const struct weston_key_event *key_event);
|
||||
|
||||
void
|
||||
weston_input_event_init(struct weston_input_event *ievent, struct timespec *ts, struct weston_seat *seat);
|
||||
|
||||
void
|
||||
weston_key_event_init(struct weston_key_event *event, uint32_t key,
|
||||
enum wl_keyboard_key_state key_state,
|
||||
enum weston_key_state_update key_update_state);
|
||||
|
||||
void
|
||||
weston_keyboard_send_modifiers(struct weston_keyboard *keyboard,
|
||||
uint32_t serial, uint32_t mods_depressed,
|
||||
|
|
@ -2125,12 +2152,6 @@ struct content_protection {
|
|||
struct wl_event_source *surface_protection_update;
|
||||
};
|
||||
|
||||
|
||||
enum weston_key_state_update {
|
||||
STATE_UPDATE_AUTOMATIC,
|
||||
STATE_UPDATE_NONE,
|
||||
};
|
||||
|
||||
enum weston_activate_flag {
|
||||
WESTON_ACTIVATE_FLAG_NONE = 0,
|
||||
WESTON_ACTIVATE_FLAG_CONFIGURE = 1 << 0,
|
||||
|
|
|
|||
|
|
@ -1573,6 +1573,7 @@ xf_input_keyboard_event(rdpInput *input, UINT16 flags, XF_KEV_CODE_TYPE code)
|
|||
bool send_release_key = false;
|
||||
int notify = 0;
|
||||
struct timespec time;
|
||||
struct weston_key_event key_event;
|
||||
|
||||
rdp_debug_verbose(peerContext->rdpBackend, "RDP backend: %s flags:0x%x, code:0x%x\n",
|
||||
__func__, flags, code);
|
||||
|
|
@ -1638,14 +1639,18 @@ xf_input_keyboard_event(rdpInput *input, UINT16 flags, XF_KEV_CODE_TYPE code)
|
|||
/*weston_log("code=%x ext=%d vk_code=%x scan_code=%x\n", code, (flags & KBD_FLAGS_EXTENDED) ? 1 : 0,
|
||||
vk_code, scan_code);*/
|
||||
weston_compositor_get_time(&time);
|
||||
notify_key(peerContext->item.seat, &time,
|
||||
scan_code - 8, keyState, STATE_UPDATE_AUTOMATIC);
|
||||
|
||||
weston_input_event_init(&key_event.base_event,
|
||||
&time, peerContext->item.seat);
|
||||
weston_key_event_init(&key_event, scan_code - 8,
|
||||
keyState, STATE_UPDATE_AUTOMATIC);
|
||||
notify_key(peerContext->item.seat, &key_event);
|
||||
|
||||
if (send_release_key) {
|
||||
notify_key(peerContext->item.seat, &time,
|
||||
scan_code - 8,
|
||||
WL_KEYBOARD_KEY_STATE_RELEASED,
|
||||
STATE_UPDATE_AUTOMATIC);
|
||||
weston_key_event_init(&key_event, scan_code - 8,
|
||||
WL_KEYBOARD_KEY_STATE_RELEASED,
|
||||
STATE_UPDATE_AUTOMATIC);
|
||||
notify_key(peerContext->item.seat, &key_event);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -301,6 +301,7 @@ vnc_handle_key_event(struct nvnc_client *client, uint32_t keysym,
|
|||
bool needs_shift = false;
|
||||
enum weston_key_state_update state_update;
|
||||
enum wl_keyboard_key_state state;
|
||||
struct weston_key_event key_event;
|
||||
struct timespec time;
|
||||
int i;
|
||||
|
||||
|
|
@ -336,20 +337,27 @@ vnc_handle_key_event(struct nvnc_client *client, uint32_t keysym,
|
|||
return;
|
||||
}
|
||||
|
||||
weston_input_event_init(&key_event.base_event, &time, peer->seat);
|
||||
|
||||
/* emulate lshift press */
|
||||
if (needs_shift)
|
||||
notify_key(peer->seat, &time, KEY_LEFTSHIFT,
|
||||
WL_KEYBOARD_KEY_STATE_PRESSED,
|
||||
STATE_UPDATE_AUTOMATIC);
|
||||
if (needs_shift) {
|
||||
weston_key_event_init(&key_event, KEY_LEFTSHIFT,
|
||||
WL_KEYBOARD_KEY_STATE_PRESSED,
|
||||
STATE_UPDATE_AUTOMATIC);
|
||||
notify_key(peer->seat, &key_event);
|
||||
}
|
||||
|
||||
/* send detected key code */
|
||||
notify_key(peer->seat, &time, key, state, state_update);
|
||||
weston_key_event_init(&key_event, key, state, state_update);
|
||||
notify_key(peer->seat, &key_event);
|
||||
|
||||
/* emulate lshift release */
|
||||
if (needs_shift)
|
||||
notify_key(peer->seat, &time, KEY_LEFTSHIFT,
|
||||
WL_KEYBOARD_KEY_STATE_RELEASED,
|
||||
STATE_UPDATE_AUTOMATIC);
|
||||
if (needs_shift) {
|
||||
weston_key_event_init(&key_event, KEY_LEFTSHIFT,
|
||||
WL_KEYBOARD_KEY_STATE_RELEASED,
|
||||
STATE_UPDATE_AUTOMATIC);
|
||||
notify_key(peer->seat, &key_event);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -359,6 +367,7 @@ vnc_handle_key_code_event(struct nvnc_client *client, uint32_t key,
|
|||
struct vnc_peer *peer = nvnc_get_userdata(client);
|
||||
enum wl_keyboard_key_state state;
|
||||
struct timespec time;
|
||||
struct weston_key_event key_event;
|
||||
|
||||
weston_compositor_get_time(&time);
|
||||
|
||||
|
|
@ -367,7 +376,9 @@ vnc_handle_key_code_event(struct nvnc_client *client, uint32_t key,
|
|||
else
|
||||
state = WL_KEYBOARD_KEY_STATE_RELEASED;
|
||||
|
||||
notify_key(peer->seat, &time, key, state, STATE_UPDATE_AUTOMATIC);
|
||||
weston_input_event_init(&key_event.base_event, &time, peer->seat);
|
||||
weston_key_event_init(&key_event, key, state, STATE_UPDATE_AUTOMATIC);
|
||||
notify_key(peer->seat, &key_event);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -2004,6 +2004,7 @@ input_handle_key(void *data, struct wl_keyboard *keyboard,
|
|||
{
|
||||
struct wayland_input *input = data;
|
||||
struct timespec ts;
|
||||
struct weston_key_event key_event;
|
||||
|
||||
if (!input->keyboard_focus)
|
||||
return;
|
||||
|
|
@ -2011,10 +2012,11 @@ input_handle_key(void *data, struct wl_keyboard *keyboard,
|
|||
timespec_from_msec(&ts, time);
|
||||
|
||||
input->key_serial = serial;
|
||||
notify_key(&input->base, &ts, key,
|
||||
state ? WL_KEYBOARD_KEY_STATE_PRESSED :
|
||||
WL_KEYBOARD_KEY_STATE_RELEASED,
|
||||
input->keyboard_state_update);
|
||||
|
||||
weston_input_event_init(&key_event.base_event, &ts, &input->base);
|
||||
weston_key_event_init(&key_event, key, state ? WL_KEYBOARD_KEY_STATE_PRESSED :
|
||||
WL_KEYBOARD_KEY_STATE_RELEASED, input->keyboard_state_update);
|
||||
notify_key(&input->base, &key_event);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -1630,11 +1630,15 @@ x11_backend_handle_event(int fd, uint32_t mask, void *data)
|
|||
* event below. */
|
||||
update_xkb_state_from_core(b, key_release->state);
|
||||
weston_compositor_get_time(&time);
|
||||
notify_key(&b->core_seat,
|
||||
&time,
|
||||
key_release->detail - 8,
|
||||
WL_KEYBOARD_KEY_STATE_RELEASED,
|
||||
STATE_UPDATE_AUTOMATIC);
|
||||
|
||||
struct weston_key_event key_event;
|
||||
|
||||
weston_input_event_init(&key_event.base_event, &time, &b->core_seat);
|
||||
weston_key_event_init(&key_event, key_release->detail - 8,
|
||||
WL_KEYBOARD_KEY_STATE_RELEASED,
|
||||
STATE_UPDATE_AUTOMATIC);
|
||||
|
||||
notify_key(&b->core_seat, &key_event);
|
||||
free(b->prev_event);
|
||||
b->prev_event = NULL;
|
||||
break;
|
||||
|
|
@ -1675,12 +1679,15 @@ x11_backend_handle_event(int fd, uint32_t mask, void *data)
|
|||
if (!b->has_xkb)
|
||||
update_xkb_state_from_core(b, key_press->state);
|
||||
weston_compositor_get_time(&time);
|
||||
notify_key(&b->core_seat,
|
||||
&time,
|
||||
key_press->detail - 8,
|
||||
WL_KEYBOARD_KEY_STATE_PRESSED,
|
||||
b->has_xkb ? STATE_UPDATE_NONE :
|
||||
STATE_UPDATE_AUTOMATIC);
|
||||
|
||||
struct weston_key_event key_event;
|
||||
|
||||
weston_input_event_init(&key_event.base_event, &time, &b->core_seat);
|
||||
weston_key_event_init(&key_event, key_release->detail - 8,
|
||||
WL_KEYBOARD_KEY_STATE_PRESSED,
|
||||
b->has_xkb ? STATE_UPDATE_NONE : STATE_UPDATE_AUTOMATIC);
|
||||
notify_key(&b->core_seat, &key_event);
|
||||
|
||||
break;
|
||||
case XCB_KEY_RELEASE:
|
||||
/* If we don't have XKB, we need to use the lame
|
||||
|
|
@ -1691,11 +1698,13 @@ x11_backend_handle_event(int fd, uint32_t mask, void *data)
|
|||
}
|
||||
key_release = (xcb_key_press_event_t *) event;
|
||||
weston_compositor_get_time(&time);
|
||||
notify_key(&b->core_seat,
|
||||
&time,
|
||||
key_release->detail - 8,
|
||||
WL_KEYBOARD_KEY_STATE_RELEASED,
|
||||
STATE_UPDATE_NONE);
|
||||
|
||||
struct weston_key_event w_key_event;
|
||||
|
||||
weston_input_event_init(&w_key_event.base_event, &time, &b->core_seat);
|
||||
weston_key_event_init(&w_key_event, key_release->detail - 8,
|
||||
WL_KEYBOARD_KEY_STATE_RELEASED, STATE_UPDATE_NONE);
|
||||
notify_key(&b->core_seat, &w_key_event);
|
||||
break;
|
||||
case XCB_BUTTON_PRESS:
|
||||
case XCB_BUTTON_RELEASE:
|
||||
|
|
@ -1824,11 +1833,14 @@ x11_backend_handle_event(int fd, uint32_t mask, void *data)
|
|||
key_release = (xcb_key_press_event_t *) b->prev_event;
|
||||
update_xkb_state_from_core(b, key_release->state);
|
||||
weston_compositor_get_time(&time);
|
||||
notify_key(&b->core_seat,
|
||||
&time,
|
||||
key_release->detail - 8,
|
||||
WL_KEYBOARD_KEY_STATE_RELEASED,
|
||||
STATE_UPDATE_AUTOMATIC);
|
||||
|
||||
struct weston_key_event lshift_key_event;
|
||||
|
||||
weston_input_event_init(&lshift_key_event.base_event, &time, &b->core_seat);
|
||||
weston_key_event_init(&lshift_key_event, key_release->detail - 8,
|
||||
WL_KEYBOARD_KEY_STATE_RELEASED, STATE_UPDATE_AUTOMATIC);
|
||||
notify_key(&b->core_seat, &lshift_key_event);
|
||||
|
||||
free(b->prev_event);
|
||||
b->prev_event = NULL;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -242,9 +242,8 @@ notify_button(struct weston_seat *seat, const struct timespec *time,
|
|||
int32_t button, enum wl_pointer_button_state state);
|
||||
|
||||
void
|
||||
notify_key(struct weston_seat *seat, const struct timespec *time, uint32_t key,
|
||||
enum wl_keyboard_key_state state,
|
||||
enum weston_key_state_update update_state);
|
||||
notify_key(struct weston_seat *seat, const struct weston_key_event *key_event);
|
||||
|
||||
void
|
||||
notify_keyboard_focus_in(struct weston_seat *seat, struct wl_array *keys,
|
||||
enum weston_key_state_update update_state);
|
||||
|
|
|
|||
|
|
@ -216,13 +216,14 @@ struct binding_keyboard_grab {
|
|||
};
|
||||
|
||||
static void
|
||||
binding_key(struct weston_keyboard_grab *grab,
|
||||
const struct timespec *time, uint32_t key, uint32_t state_w)
|
||||
binding_key(struct weston_keyboard_grab *grab, const struct weston_key_event *key_event)
|
||||
{
|
||||
struct binding_keyboard_grab *b =
|
||||
container_of(grab, struct binding_keyboard_grab, grab);
|
||||
struct wl_resource *resource;
|
||||
enum wl_keyboard_key_state state = state_w;
|
||||
enum wl_keyboard_key_state state = key_event->key_state;
|
||||
struct timespec *time = key_event->base_event.ts;
|
||||
uint32_t key = key_event->key;
|
||||
uint32_t serial;
|
||||
struct weston_keyboard *keyboard = grab->keyboard;
|
||||
struct wl_display *display = keyboard->seat->compositor->wl_display;
|
||||
|
|
@ -491,8 +492,8 @@ struct debug_binding_grab {
|
|||
};
|
||||
|
||||
static void
|
||||
debug_binding_key(struct weston_keyboard_grab *grab, const struct timespec *time,
|
||||
uint32_t key, uint32_t state)
|
||||
debug_binding_key(struct weston_keyboard_grab *grab,
|
||||
const struct weston_key_event *key_event)
|
||||
{
|
||||
struct debug_binding_grab *db = (struct debug_binding_grab *) grab;
|
||||
struct weston_compositor *ec = db->seat->compositor;
|
||||
|
|
@ -501,6 +502,9 @@ debug_binding_key(struct weston_keyboard_grab *grab, const struct timespec *time
|
|||
uint32_t serial;
|
||||
int send = 0, terminate = 0;
|
||||
int check_binding = 1;
|
||||
struct timespec *time = key_event->base_event.ts;
|
||||
uint32_t key = key_event->key;
|
||||
uint32_t state = key_event->key_state;
|
||||
int i;
|
||||
struct wl_list *resource_list;
|
||||
uint32_t msecs;
|
||||
|
|
|
|||
|
|
@ -838,7 +838,7 @@ static const struct weston_touch_grab_interface touch_drag_grab_interface = {
|
|||
|
||||
static void
|
||||
drag_grab_keyboard_key(struct weston_keyboard_grab *grab,
|
||||
const struct timespec *time, uint32_t key, uint32_t state)
|
||||
const struct weston_key_event *key_event)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,11 +57,9 @@ static void weston_desktop_seat_popup_grab_end(struct weston_desktop_seat *seat)
|
|||
|
||||
static void
|
||||
weston_desktop_seat_popup_grab_keyboard_key(struct weston_keyboard_grab *grab,
|
||||
const struct timespec *time,
|
||||
uint32_t key,
|
||||
enum wl_keyboard_key_state state)
|
||||
const struct weston_key_event *key_event)
|
||||
{
|
||||
weston_keyboard_send_key(grab->keyboard, time, key, state);
|
||||
weston_keyboard_send_key(grab->keyboard, key_event);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -1089,24 +1089,24 @@ weston_keyboard_has_focus_resource(struct weston_keyboard *keyboard)
|
|||
/** Send wl_keyboard.key events to focused resources.
|
||||
*
|
||||
* \param keyboard The keyboard where the key events originates from.
|
||||
* \param time The timestamp of the event
|
||||
* \param key The key value of the event
|
||||
* \param state The state enum value of the event
|
||||
* \param key_event The weston_key_event as a pointer
|
||||
*
|
||||
* For every resource that is currently in focus, send a wl_keyboard.key event
|
||||
* For every resource that is currently in focus, send a key event
|
||||
* with the passed parameters. The focused resources are the wl_keyboard
|
||||
* resources of the client which currently has the surface with keyboard focus.
|
||||
*/
|
||||
WL_EXPORT void
|
||||
weston_keyboard_send_key(struct weston_keyboard *keyboard,
|
||||
const struct timespec *time, uint32_t key,
|
||||
enum wl_keyboard_key_state state)
|
||||
const struct weston_key_event *key_event)
|
||||
{
|
||||
struct wl_resource *resource;
|
||||
struct wl_display *display = keyboard->seat->compositor->wl_display;
|
||||
uint32_t serial;
|
||||
struct wl_list *resource_list;
|
||||
uint32_t msecs;
|
||||
struct timespec *time = key_event->base_event.ts;
|
||||
uint32_t key = key_event->key;
|
||||
enum wl_keyboard_key_state state = key_event->key_state;
|
||||
|
||||
if (!weston_keyboard_has_focus_resource(keyboard))
|
||||
return;
|
||||
|
|
@ -1124,10 +1124,9 @@ weston_keyboard_send_key(struct weston_keyboard *keyboard,
|
|||
|
||||
static void
|
||||
default_grab_keyboard_key(struct weston_keyboard_grab *grab,
|
||||
const struct timespec *time, uint32_t key,
|
||||
uint32_t state)
|
||||
const struct weston_key_event *key_event)
|
||||
{
|
||||
weston_keyboard_send_key(grab->keyboard, time, key, state);
|
||||
weston_keyboard_send_key(grab->keyboard, key_event);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -2664,13 +2663,15 @@ update_keymap(struct weston_seat *seat)
|
|||
}
|
||||
|
||||
WL_EXPORT void
|
||||
notify_key(struct weston_seat *seat, const struct timespec *time, uint32_t key,
|
||||
enum wl_keyboard_key_state state,
|
||||
enum weston_key_state_update update_state)
|
||||
notify_key(struct weston_seat *seat, const struct weston_key_event *key_event)
|
||||
{
|
||||
struct timespec *time = key_event->base_event.ts;
|
||||
struct weston_compositor *compositor = seat->compositor;
|
||||
struct weston_keyboard *keyboard = weston_seat_get_keyboard(seat);
|
||||
struct weston_keyboard_grab *grab = keyboard->grab;
|
||||
enum wl_keyboard_key_state state = key_event->key_state;
|
||||
uint32_t key = key_event->key;
|
||||
enum weston_key_state_update update_state = key_event->key_update_state;
|
||||
uint32_t *k, *end;
|
||||
|
||||
end = keyboard->keys.data + keyboard->keys.size;
|
||||
|
|
@ -2702,7 +2703,7 @@ notify_key(struct weston_seat *seat, const struct timespec *time, uint32_t key,
|
|||
grab = keyboard->grab;
|
||||
}
|
||||
|
||||
grab->interface->key(grab, time, key, state);
|
||||
grab->interface->key(grab, key_event);
|
||||
|
||||
if (keyboard->pending_keymap &&
|
||||
keyboard->keys.size == 0)
|
||||
|
|
@ -6027,3 +6028,20 @@ weston_input_init(struct weston_compositor *compositor)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
WL_EXPORT void
|
||||
weston_input_event_init(struct weston_input_event *ievent, struct timespec *ts,
|
||||
struct weston_seat *seat)
|
||||
{
|
||||
ievent->ts = ts;
|
||||
ievent->seat = seat;
|
||||
}
|
||||
|
||||
WL_EXPORT void
|
||||
weston_key_event_init(struct weston_key_event *event, uint32_t key, enum wl_keyboard_key_state key_state,
|
||||
enum weston_key_state_update key_update_state)
|
||||
{
|
||||
event->key = key;
|
||||
event->key_state = key_state;
|
||||
event->key_update_state = key_update_state;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,6 +98,8 @@ handle_keyboard_key(struct libinput_device *libinput_device,
|
|||
int seat_key_count =
|
||||
libinput_event_keyboard_get_seat_key_count(keyboard_event);
|
||||
struct timespec time;
|
||||
uint32_t key = libinput_event_keyboard_get_key(keyboard_event);
|
||||
struct weston_key_event key_event;
|
||||
|
||||
/* Ignore key events that are not seat wide state changes. */
|
||||
if ((key_state == LIBINPUT_KEY_STATE_PRESSED &&
|
||||
|
|
@ -106,12 +108,12 @@ handle_keyboard_key(struct libinput_device *libinput_device,
|
|||
seat_key_count != 0))
|
||||
return;
|
||||
|
||||
timespec_from_usec(&time,
|
||||
libinput_event_keyboard_get_time_usec(keyboard_event));
|
||||
timespec_from_usec(&time, libinput_event_keyboard_get_time_usec(keyboard_event));
|
||||
|
||||
notify_key(device->seat, &time,
|
||||
libinput_event_keyboard_get_key(keyboard_event),
|
||||
key_state, STATE_UPDATE_AUTOMATIC);
|
||||
weston_input_event_init(&key_event.base_event, &time, device->seat);
|
||||
weston_key_event_init(&key_event, key, key_state, STATE_UPDATE_AUTOMATIC);
|
||||
|
||||
notify_key(device->seat, &key_event);
|
||||
}
|
||||
|
||||
static bool
|
||||
|
|
|
|||
|
|
@ -494,10 +494,13 @@ send_key(struct wl_client *client, struct wl_resource *resource,
|
|||
struct weston_test *test = wl_resource_get_user_data(resource);
|
||||
struct weston_seat *seat = get_seat(test);
|
||||
struct timespec time;
|
||||
struct weston_key_event key_event;
|
||||
|
||||
timespec_from_proto(&time, tv_sec_hi, tv_sec_lo, tv_nsec);
|
||||
|
||||
notify_key(seat, &time, key, state, STATE_UPDATE_AUTOMATIC);
|
||||
weston_input_event_init(&key_event.base_event, &time, seat);
|
||||
weston_key_event_init(&key_event, key, state, STATE_UPDATE_AUTOMATIC);
|
||||
notify_key(seat, &key_event);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue