Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rdp-backend: Fall back to weston.ini keymap if no mapping is found #144

Merged
merged 2 commits into from
May 2, 2023

Conversation

fargiolas
Copy link

@fargiolas fargiolas commented Apr 15, 2023

When no keyboard mapping can be found at the moment we fallback to "us" layout preventing the user to use XKB layouts that have no Windows counterpart. We should instead fallback to the keymap in weston.ini and only fallback to us when no keymap is set there.

Should partially fix microsoft/wslg#173 but it still needs an easy way to export weston.ini to the user. See also that issue for some example use cases for this pull request.

Do not force "us" layout when no xkb mapping is found. Weston will this
way fallback to the keymap defined in compositor xkb_names which falls
back to "us" if no layout is defined in weston.ini.
@fargiolas
Copy link
Author

fargiolas commented Apr 15, 2023 via email

Reload default global compositor keymap when no xkb mapping is found for
current keyboard layout. This will default to the keymap in weston.ini
or to "us" if no keymap is defined there. Should allow to use custom KLC
layouts for keymaps that exist in Linux but have no correspondence in
Windows (e.g. altgr-intl). This should also partially fix #173. Still
need a way to export weston.ini to the user.
@fargiolas
Copy link
Author

@hideyukn88 any feedback about this pull request?

@hideyukn88
Copy link
Member

Please refer my feedback at microsoft/wslg#1046 (comment), thanks!

@fargiolas
Copy link
Author

fargiolas commented Apr 27, 2023

Please refer my feedback at microsoft/wslg#1046 (comment), thanks!

Thanks for looking into this. I'll see if is there an easy way to import keyboard layout configuration into weston using .wslgconfig without exposing the full weston.ini configuration.

Meanwhile, I believe this PR could be reviewed and merged independently. At the moment when no keymap mapping can be found between Windows and XKB you hard code an "us" fall back. With the proposed changes you would still have the same result (fallback to us, as weston already does this without hard coding) in the normal scenario without ignoring weston configuration.

That would allow power users to e.g. build a custom system image with their weston.ini or even modify weston.ini on the fly like in the ugly way some user were suggesting.

@hideyukn88
Copy link
Member

@fargiolas, thanks for submiting PR. If I understand correctly, TS_RAIL_ORDER_LANGUAGEIMEINFO RDP message (https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-rdperp/f09de18b-902c-413c-bbd7-4560a4493d2a) is used in RemoteApp (aka RAIL) only, so I think defaulting to keyboard layout from weston.ini still needs to be done at convert_rdp_keyboard_to_xkb_rule_names, otherwise it doesn't work with Fullscreen desktop Linux mode, you can enable that by having below file.

c:\Users\[Your Windows Username]\.wslgconfig

[system-distro-env]
WSL2_WESTON_SHELL_OVERRIDE=desktop-shell
WSL2_RDP_CONFIG_OVERRIDE=wslg_desktop.rdp

@fargiolas
Copy link
Author

fargiolas commented May 2, 2023

so I think defaulting to keyboard layout from weston.ini still needs to be done at convert_rdp_keyboard_to_xkb_rule_names

@hideyukn88, if I get this correctly, if you remove the code that defaults to "us", when no matching keyboard is found xkRuleNames->layout in convert_rdp_keyboard_to_xkb_rule_names is NULL.

So keymap in xf_peer_activate is NULL too and you call weston_seat_init_keyboard with a NULL keymap.

This leads to weston initializing a global keymap in libweston/input.c with weston_compositor_build_global_keymap that builds a keymap from ec->xkb_names which was initialized at startup with weston.ini values by weston_compositor_init_config. This by the way calls weston_set_xkb_rule_names in libweston/input.c which defaults to "us" when no keymap is configured in weston.ini, hence no need to force "us" in convert_rdp_keyboard_to_xkb_rule_names.

This is what happens at startup both with full screen mode and with RAIL apps.

With RAIL apps you also need to handle the layout update that sends a LANGUAGEIMEINFO message, and that's what my second commit is for. When no matching layout is found it creates a new keymap from compositor xkb_names (which is initialized at startup from weston.ini as described above) and calls weston_seat_update_keymap with that.

@hideyukn88
Copy link
Member

@fargiolas, right, thanks for clarification, your change looks good to me, thanks again for submitting the PR.

0);
weston_seat_update_keymap(peer_ctx->item.seat, keymap);
xkb_keymap_unref(keymap);
settings->KeyboardLayout = new_keyboard_layout;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally "new_keyboard_layout" should reflect the default.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately that's not always possible because you may have a xkb layout in weston.ini that doesn't have a windows counter-part. E.g. us-intl with altgr dead keys is a pretty popular one for europeans using us keyboards that doesn't exist in windows unless you use MSKLC layouts.

Still you need to save the layout in settings->KeyboardLayout otherwise the if (new_keyboard_layout != settings->KeyboardLayout) a few lines above will fail and prevent you to actually change layout.

@hideyukn88 hideyukn88 merged commit b5e22ba into microsoft:working May 2, 2023
@hideyukn88 hideyukn88 changed the title Fall back to weston.ini keymap if no mapping is found rdp-backend: Fall back to weston.ini keymap if no mapping is found May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support customized keyboard layout (with KLC file)
2 participants