From 04c7f5fae3a1a2c2e7459d6957692d5c0cf2f904 Mon Sep 17 00:00:00 2001 From: Sichem Zhou Date: Mon, 26 Aug 2019 19:33:19 -0400 Subject: [PATCH] libweston: have 'weston_compositor_set_xkb_rule_names' have effect after running Updating keyboards keymap as well in 'weston_compositor_set_xkb_rule_names' for the function to take effect in runtime. Signed-off-by: xichen zhou --- libweston/input.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/libweston/input.c b/libweston/input.c index 28dcb0b9a..1a7e7b874 100644 --- a/libweston/input.c +++ b/libweston/input.c @@ -3119,6 +3119,9 @@ WL_EXPORT int weston_compositor_set_xkb_rule_names(struct weston_compositor *ec, struct xkb_rule_names *names) { + struct weston_seat *seat; + struct xkb_keymap *keymap; + if (ec->xkb_context == NULL) { ec->xkb_context = xkb_context_new(0); if (ec->xkb_context == NULL) { @@ -3136,6 +3139,19 @@ weston_compositor_set_xkb_rule_names(struct weston_compositor *ec, if (!ec->xkb_names.layout) ec->xkb_names.layout = strdup("us"); + keymap = xkb_keymap_new_from_names(ec->xkb_context, names, 0); + if (!keymap) { + weston_log("failed to create XKB keymap\n"); + return -1; + } + /* destroy the global keymap since no one is using it any more */ + if (ec->xkb_info) { + weston_xkb_info_destroy(ec->xkb_info); + xkb_context_unref(ec->xkb_context); + } + wl_list_for_each(seat, &ec->seat_list, link) + weston_seat_update_keymap(seat, keymap); + xkb_keymap_unref(keymap); return 0; }