From: Gonglei <arei.gong...@huawei.com> In order to support changing vnc keyboard layout dynamically.
Signed-off-by: Gonglei <arei.gong...@huawei.com> --- include/ui/console.h | 5 +++++ ui/vnc.c | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/ui/console.h b/include/ui/console.h index 887ed91..4645dc3 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -333,6 +333,7 @@ void vnc_display_add_client(const char *id, int csock, bool skipauth); char *vnc_display_local_addr(const char *id); #ifdef CONFIG_VNC int vnc_display_password(const char *id, const char *password); +int vnc_display_kbd_layout(const char *id, const char *kbd_layout); int vnc_display_pw_expire(const char *id, time_t expires); QemuOpts *vnc_parse_func(const char *str); int vnc_init_func(QemuOpts *opts, void *opaque); @@ -341,6 +342,10 @@ static inline int vnc_display_password(const char *id, const char *password) { return -ENODEV; } +int vnc_display_kbd_layout(const char *id, const char *kbd_layout) +{ + return -ENODEV; +} static inline int vnc_display_pw_expire(const char *id, time_t expires) { return -ENODEV; diff --git a/ui/vnc.c b/ui/vnc.c index 8d189e7..35aad70 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -3090,6 +3090,27 @@ int vnc_display_password(const char *id, const char *password) return 0; } +int vnc_display_kbd_layout(const char *id, const char *kbd_layout) +{ + VncDisplay *vs = vnc_display_find(id); + kbd_layout_t *k = NULL; + + if (!vs) { + return -EINVAL; + } + + k = init_keyboard_layout(name2keysym, kbd_layout); + if (!k) { + return -EINVAL; + } + + trace_vnc_key_map_init(kbd_layout); + g_free(vs->kbd_layout); + vs->kbd_layout = k; + + return 0; +} + int vnc_display_pw_expire(const char *id, time_t expires) { VncDisplay *vs = vnc_display_find(id); -- 1.7.12.4