From 4d5605b3a0fc7a5cd3bab6414e92e0727e2f3c56 Mon Sep 17 00:00:00 2001 From: Hideyuki Nagase Date: Tue, 22 Mar 2022 11:57:42 -0500 Subject: [PATCH] rdp: refactor xkbRuleNames code This code will eventually be used by RAIL as well, so let's split it out now. Co-authored-by: Steve Pronovost Co-authored-by: Brenton DeGeer Signed-off-by: Hideyuki Nagase Signed-off-by: Steve Pronovost Signed-off-by: Brenton DeGeer --- libweston/backend-rdp/rdp.c | 39 +++++++++++++++++++++++++------------ libweston/backend-rdp/rdp.h | 3 +++ 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/libweston/backend-rdp/rdp.c b/libweston/backend-rdp/rdp.c index d79a9cec..9ca9ddf7 100644 --- a/libweston/backend-rdp/rdp.c +++ b/libweston/backend-rdp/rdp.c @@ -818,6 +818,29 @@ struct rdp_to_xkb_keyboard_layout rdp_keyboards[] = { {0x00000000, 0, 0}, }; +void +convert_rdp_keyboard_to_xkb_rule_names(UINT32 KeyboardType, + UINT32 KeyboardSubType, + UINT32 KeyboardLayout, + struct xkb_rule_names *xkbRuleNames) +{ + int i; + + memset(xkbRuleNames, 0, sizeof(*xkbRuleNames)); + xkbRuleNames->model = "pc105"; + for (i = 0; rdp_keyboards[i].rdpLayoutCode; i++) { + if (rdp_keyboards[i].rdpLayoutCode == KeyboardLayout) { + xkbRuleNames->layout = rdp_keyboards[i].xkbLayout; + xkbRuleNames->variant = rdp_keyboards[i].xkbVariant; + break; + } + } + + weston_log("%s: matching model=%s layout=%s variant=%s options=%s\n", + __func__, xkbRuleNames->model, xkbRuleNames->layout, + xkbRuleNames->variant, xkbRuleNames->options); +} + static BOOL xf_peer_activate(freerdp_peer* client) { @@ -830,7 +853,6 @@ xf_peer_activate(freerdp_peer* client) struct xkb_rule_names xkbRuleNames; struct xkb_keymap *keymap; struct weston_output *weston_output; - int i; pixman_box32_t box; pixman_region32_t damage; char seat_name[50]; @@ -895,17 +917,10 @@ xf_peer_activate(freerdp_peer* client) settings->KeyboardLayout, settings->KeyboardType, settings->KeyboardSubType, settings->KeyboardFunctionKey); - memset(&xkbRuleNames, 0, sizeof(xkbRuleNames)); - xkbRuleNames.model = "pc105"; - for (i = 0; rdp_keyboards[i].rdpLayoutCode; i++) { - if (rdp_keyboards[i].rdpLayoutCode == settings->KeyboardLayout) { - xkbRuleNames.layout = rdp_keyboards[i].xkbLayout; - xkbRuleNames.variant = rdp_keyboards[i].xkbVariant; - weston_log("%s: matching layout=%s variant=%s\n", __FUNCTION__, - xkbRuleNames.layout, xkbRuleNames.variant); - break; - } - } + convert_rdp_keyboard_to_xkb_rule_names(settings->KeyboardType, + settings->KeyboardSubType, + settings->KeyboardLayout, + &xkbRuleNames); keymap = NULL; if (xkbRuleNames.layout) { diff --git a/libweston/backend-rdp/rdp.h b/libweston/backend-rdp/rdp.h index b60c81db..a102b008 100644 --- a/libweston/backend-rdp/rdp.h +++ b/libweston/backend-rdp/rdp.h @@ -134,6 +134,9 @@ typedef struct rdp_peer_context RdpPeerContext; void rdp_debug_print(struct weston_log_scope *log_scope, bool cont, char *fmt, ...); +void +convert_rdp_keyboard_to_xkb_rule_names(UINT32 KeyboardType, UINT32 KeyboardSubType, UINT32 KeyboardLayout, struct xkb_rule_names *xkbRuleNames); + static inline struct rdp_head * to_rdp_head(struct weston_head *base) {