mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2026-05-07 14:18:32 +02:00
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 <sichem.zh@gmail.com>
This commit is contained in:
parent
bac1a7a71f
commit
04c7f5fae3
1 changed files with 16 additions and 0 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue