How and when to update the keymap is left to each backend. --- src/compositor.h | 2 ++ src/input.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+)
diff --git a/src/compositor.h b/src/compositor.h index a19d966..041758a 100644 --- a/src/compositor.h +++ b/src/compositor.h @@ -1115,6 +1115,8 @@ void weston_seat_init_touch(struct weston_seat *seat); void weston_seat_repick(struct weston_seat *seat); +void +weston_seat_update_keyboard(struct weston_seat *seat, struct xkb_keymap *keymap); void weston_seat_release(struct weston_seat *seat); diff --git a/src/input.c b/src/input.c index 1313b52..e769554 100644 --- a/src/input.c +++ b/src/input.c @@ -1623,6 +1623,44 @@ weston_compositor_xkb_destroy(struct weston_compositor *ec) } #endif +WL_EXPORT void +weston_seat_update_keyboard(struct weston_seat *seat, struct xkb_keymap *keymap) +{ + struct wl_resource *resource; + + if (!seat->keyboard) + return; + +#ifdef ENABLE_XKBCOMMON + if (seat->compositor->use_xkbcommon) { + if (seat->xkb_info != NULL) + weston_xkb_info_destroy(seat->xkb_info); + seat->xkb_info = weston_xkb_info_create(keymap); + if (seat->xkb_info == NULL) { + weston_log("failed to create XKB info\n"); + return; + } + + if (seat->xkb_state.state != NULL) + xkb_state_unref(seat->xkb_state.state); + seat->xkb_state.state = xkb_state_new(seat->xkb_info->keymap); + if (seat->xkb_state.state == NULL) { + weston_log("failed to initialise XKB state\n"); + return; + } + + wl_resource_for_each(resource, &seat->keyboard->resource_list) { + wl_keyboard_send_keymap(resource, + WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, + seat->xkb_info->keymap_fd, + seat->xkb_info->keymap_size); + } + + notify_modifiers(seat, wl_display_next_serial(seat->compositor->wl_display)); + } +#endif +} + WL_EXPORT int weston_seat_init_keyboard(struct weston_seat *seat, struct xkb_keymap *keymap) { -- 1.8.3.1 _______________________________________________ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel