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

Windows keyboard stops producing expected key inputs after copying from a buffer in emacs/Ubuntu/WSL2 and pasting to a Windows progarm, vice versa #1234

Closed yubrshen closed 1 month ago

yubrshen commented 2 months ago

Windows build number:

Microsoft Windows [Version 10.0.19045.4170]

Your Distribution version:

Release: 22.04 (Ubuntu)

Your WSL versions:

WSL version: 2.1.5.0 Kernel version: 5.15.146.1-2 WSLg version: 1.0.60 MSRDC version: 1.2.5105 Direct3D version: 1.611.1-81528511 DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp Windows version: 10.0.19045.4170

Steps to reproduce:

  1. Copy some text from a program in Windows (tried, Chrome, MS Edge, Slack)
  2. Paste it to a buffer in emacs
  3. Sometimes, the keyboard would stop producing expected keys when type on the keys. When typing it seemed that the produced output was with some combination of control key. For example, in emacs, pressing p, but emacs would show M-p (Alt p). The problem applies to all applications in both Windows and emacs.

Alternatively (less frequently experienced)

  1. Copy some text from a buffer in emacs
  2. Paste it to a Windows program (tried with Edge and Chrome)
  3. Sometimes, the keyboard stopped working to all applications in both Windows and emacs.

When the problem happens, restart would clear it.

WSL logs:

No response

WSL dumps:

No response

Expected behavior:

The keyboard should always produce the expected input.

Actual behavior:

Sometimes, it produces unexpected outcomes.

yubrshen commented 2 months ago

I cannot capture the logs, or dumps, when the problems happened, as the keyboard does not work. If the logs or dumps after restart are still useful and needed, I can try to provide.

yubrshen commented 1 month ago

With more observation that once my laptop's keyboard stopped producing the expected output, with emacs, I found that when I pressed 'p' key, emacs shows me that the 'M-p' was received. 'M-p' in emacs on Windows is for the key combination of key p and modifier Alt key. I tried to pressed Alt key, then the keyboard resume working correctly. It seems that for some reason, when copying selected text in some Windows app (e.g. Chrome browser, etc.), it causes Alt modifier key pressed and sticky. But press Alt again, then Alt would be released, which makes the keyboard working normally.

With the observation, and the work-round the problem is solved. It seems that this problem might not be related to WSLg, but might be Windows 10's.

This closed the issue.