microsoft / wslg

Enabling the Windows Subsystem for Linux to include support for Wayland and X server related scenarios
MIT License
9.9k stars 296 forks source link

Keyboard in WSL2 Doesn't Follow Windows Input Language, GUI Applications Not Adhering to Set Default #1184

Open cassiocsantana opened 5 months ago

cassiocsantana commented 5 months ago

Windows Version

10.0.22621.3007

WSL Version

2.0.9.0

Are you using WSL 1 or WSL 2?

Kernel Version

5.15.133.1-1

Distro Version

Ubuntu 22.04

Other Software

No response

Repro Steps

Expected Behavior

When opening the installed application, such as GitKraken on WSL Ubuntu, the keyboard layout should adhere to the settings configured in Windows. In this case, the Portuguese (Brazil) International keyboard layout should be recognized and applied within the application, allowing for proper handling of accentuations and ensuring a seamless user experience.

Actual Behavior

Upon opening the installed application, such as GitKraken on WSL Ubuntu, the keyboard layout does not respect the settings configured in Windows. Despite having the Portuguese (Brazil) International keyboard layout selected in Windows, the application fails to recognize and apply this layout. As a consequence, accentuations are not handled correctly, leading to a loss of functionality. Following the steps outlined in the tutorial (https://github.com/microsoft/wslg/issues/27) did not resolve the issue, and the synchronization of keyboard layouts between WSL2 and Windows remains problematic.

Diagnostic Logs

No response

github-actions[bot] commented 5 months ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

cassiocsantana commented 5 months ago

All options were made, however none had a satisfactory result, because if the keyboard is changed, the GUI applications do not receive updates in real time

GuilhermeViterboGalvao commented 4 months ago

Same issue here...

cassiocsantana commented 3 months ago

Anyone, no solution or update for this problem?

pedrohsroque commented 3 months ago

try running this setxkbmap -layout us

cassiocsantana commented 3 months ago

So, I use a laptop with an external keyboard that is in the pt-br layout; The system does not trigger the layout change action for Linux, in fact it does not always trigger correctly, as at times it returns to Us.

ubaldot commented 2 months ago

I have a similar problem. I mapped some keys in Windows through powertoys and they are correctly inherited in WSL2 TUI but not in the GUI.

botmaster commented 1 month ago

Hello, Same as Ubaldot. Keyboard layout are correctly inherited in WSL2 TUI but not in the GUI.

beefeater7 commented 4 weeks ago

Same problem here,

All input languages work in the terminal, but GUI apps like Emacs, Neovim-Qt and gedit work as follows:

BrachystochroneSD commented 6 days ago

Same problem. GUI launched in wslg are using a qwerty layout and not the one configured in windows. It was working perfectly before, the ctrl-shift was shifting from one to an other. Then I decided to remove that functionality and remove the unused default languages to only keep the AZERTY that I use. and after that. The qwerty layout is kept in gui app launched in wsl

unfortunately using setxkbmap doesn't work at my end, I only manage to launch app using wayland it seems:

$ setxkbmap
Cannot open display ":0"

Locale-gen and setting X11 layout keymap doesn't help either.

Same problem on ubuntu, debian and arch.

BrachystochroneSD commented 6 days ago

Ok, it is resolved for me. Seems to be a problem with the entry deleted in the language option for windows. I readd the qwerty layout back and after a bunch of switch of layout in windows, the GUI switched too.

cassiocsantana commented 4 days ago

@BrachystochroneSD Could you explain better how you solved your problem?

BrachystochroneSD commented 4 days ago

The problem raised when I deleted the keyboard qwerty layouts in Time & Language > Language & region. The only layout kept was Belgian(Comma) AZERTY, which was correct on Windows and the terminal, but the keyword on X and Wayland GUI was stuck at QWERTY layout.

What I did, is re-adding the deleted keyboard layout for QWERTY in Time & Language > Language & region, and switch back and forth between qwerty and azerty, and the GUI keyboard layout now synchronize correctly with the switch.

Unfortunately, I am not able to replicate. The way windows manage keyboard layout is cryptic and despite having only one entry in the options: image

image

I still have three options in the list: image

cassiocsantana commented 3 days ago

I'll try to do something similar, as my problem is linked to the keyboard layout, from English to Brazilian Portuguese, keyboard with different accents

cassiocsantana commented 3 days ago

Good news, folks! Our friend @BrachystochroneSD's response motivated me to investigate different keyboard types, and it seems his solution is correct. What happens is that, from what I observed in the tests, if your keyboard layout is configured incorrectly, it doesn't work as expected.

In the case of WSL2, it doesn't read the keyboard layout correctly. In my case, I was using a standard ABNT QWERTY keyboard (which is from Brazil), but Brazil has another QWERTY standard (ABNT2). I just added the ABNT2 layout and everything worked correctly.

I advise you to investigate your keyboard's layout and try different ones; it might work.

Sorry, but my screenshots are in Brazilian Portuguese.

image

image

image

tmplt commented 2 days ago

Completed? Assuming the fix works for everyone else, the behavior still sounds like a bug.

ZeeD commented 1 day ago

I have the same issue: normally I have a custom (italian-based) keyboard layout, and found that was not possible to have any special key in only the gui application in WSLg.

The trick to add an "official" layout worked for me to, but

  1. it's a workaround, at best
  2. it also means that I need to switch back-and-forth between the standard layout and mine each time I switch from a windows app to a WSLg one and viceversa

(comment added just to follow the thread...)