Skip to content

Windows window constantly losing focus and flickering #443

Open

Description

@FireFoxAhri

Environment

Windows build number: 10.0.22449.0
Your Distribution version: Ubuntu
Your WSLg version: 1.0.27

Two of my PC faced the same issue. The Intel one occurred more times than the first.

1. AMD 5800x + NVIDIA 1070ti latest driver 471.96
2. Intel i7-10510U   UHD620 latest driver 30.0.100.9805

Steps to reproduce

It appears itself sometime after using WSL, even don't start a wslg window.

Then the window with focus will constantly losing focus. E.g. Windows Terminal, The title bar is flickering showing it is losing focus and gaining focus. But I can't type any word into it. Only a quick Mouse click and type can input one char into terminal. After input wsl --shutdown then everything is normal.

VID_20210909_135128.mp4
VID_20210909_135320.mp4

WSL logs:

  • Attach WSLg logs from /mnt/wslg

You can access the wslg logs using explorer at: \\wsl$\<Distro-Name>\mnt\wslg (e.g.: \\wsl$\Ubuntu-20.04\mnt\wslg)

WSLg ( x86_64 ): 1.0.27+Branch.main.Sha.88b37acc845d5608873211ab7a3fc09bc49151d1
Mariner: VERSION="1.0.20210224"
FreeRDP: b05321cd4e6a862aef76163a69db4e1910245736
weston: 7c0bbd09f40f796eb0d2c0974e8f91347d9ef08f
pulseaudio: 2f0f0b8c3872780f15e275fc12899f4564f01bd5
mesa:

Expected behavior

All is OK.

Actual behavior

After using WSL. Windows is unable to use.

Activity

  1. hideyukn88 commented on Sep 9, 2021

    @hideyukn88
    Contributor

    FireFox (@FireFoxAhri), thanks for reporting the issue. For diagnostics purpose, would you please disable Linux GUI support by adding below to .wslconfig (refer https://docs.microsoft.com/en-us/windows/wsl/wsl-config#configure-global-options-with-wslconfig), and if the problem persist? thanks!

    [wsl2]
    guiapplications=false

  2. FireFoxAhri commented on Sep 10, 2021

    @FireFoxAhri
    Author

    After set this option. I don't faced the issue.

    My typical usage of WSL is VS Code remote WSL and compile and debug C/C++ projects.

    Then I delete the config the problem comes again quickly.

  3. hideyukn88 commented on Sep 10, 2021

    @hideyukn88
    Contributor

    FireFox (@FireFoxAhri), thanks for additional info, by looking at your weston.log, it looks weston (WSLg's wayland compositor) is keep restarting, (while it shouldn't case the focus lost in Windows side, but) I would like to know why it's restarting first. Do you see any core dumps are created at /mnt/wslg/dumps? thanks!

  4. FireFoxAhri commented on Sep 11, 2021

    @FireFoxAhri
    Author

    Hideyuki Nagase (@hideyukn88) ,Thanks for helping to solve this problem. the Intel one is my working PC. So I need to wait until Monday to see it. Sorry for the inconvenience. I'll try to see if I can reproduce in my home PC, It happens rarely than Intel one.

  5. FireFoxAhri commented on Sep 13, 2021

    @FireFoxAhri
    Author

    core.zip
    After this issue appears again, there is one core.weston. Hideyuki Nagase (@hideyukn88)

  6. hideyukn88 commented on Sep 16, 2021

    @hideyukn88
    Contributor

    FireFox (@FireFoxAhri), thanks for sharing the core dump with me. I looked at the dump and confirmed this is fixed by microsoft/weston-mirror#39, and the fix is a part of https://github.com/microsoft/wslg/releases/tag/v1.0.28 release. Thanks!

  7. BladeMF commented on Nov 1, 2021

    @BladeMF

    Guys, I am suffering from the same thing - it's impossible to work as the focus is being stolen by the mstsc process spawned by wslhost. Looking at my Windows update I see I have last installed "Windows Subsystem for Linux WSLg Preview - 1.0.26" on Oct 29. Is the solution to disable it and wait for 1.0.28?

  8. ielbury commented on Nov 12, 2021

    @ielbury

    This issue makes the Greenshot screen capture utility non-functional. I only see the problem with systems that have a NVIDIA GPU. On my laptop, if I disable the NVIDIA GPU and only use the Intel GPU, Greenshot works fine.

    Disabling WSLg works fine for all GPU's.

  9. RodrigoGroener commented on Nov 24, 2021

    @RodrigoGroener

    FireFox (@FireFoxAhri), thanks for sharing the core dump with me. I looked at the dump and confirmed this is fixed by microsoft/weston-mirror#39, and the fix is a part of https://github.com/microsoft/wslg/releases/tag/v1.0.28 release. Thanks!

    maybe it's a dump question, but how can i install the 1.0.28 prerelease edition?

  10. Biswa96 commented on Nov 24, 2021

    @Biswa96
    Contributor

    The installer is just a MSI file. So, a simple double click may do the trick 🤞

  11. RodrigoGroener commented on Nov 25, 2021

    @RodrigoGroener

    After installing the 1.0.28 prerelease version I'm not able to reproduce the error.

  12. sharpjs commented on Dec 7, 2021

    @sharpjs

    I experienced a similar problem with 1.0.26 on Win11 22000.348: mstsc stole focus (verified with WindowFocusLogger) once every minute or so when any WSL distros were running, including those used by Docker Desktop. After installing 1.0.28 prerelease, it has not happened. I'll update if it does.

    My GPU is AMD RX 6700 XT with driver 21.11.3.

    EDIT: Have not noticed this problem since installing 1.0.28 prerelease.

  13. 37 remaining items

  14. hideyukn88 commented on Jan 23, 2023

    @hideyukn88
    Contributor

    Mitch (@eightbit), you do not need to uninstall previous WSL, and no need to reinstall docker containers, thanks!

  15. eightbit commented on Jan 23, 2023

    @eightbit

    Hideyuki Nagase (@hideyukn88) That worked. Thanks a ton!

  16. rommeswi commented on Apr 20, 2023

    @rommeswi

    There is a terminal issue that references to here. Unless one sets guiapplications=false, the terminal window loses focus right after launch. The terminal issue has been closed as a duplicate of this, but even despite running the most recent WSL, the issue persists.

    WSL version: 1.2.0.0
    Kernel version: 5.15.90.1
    WSLg version: 1.0.51
    MSRDC version: 1.2.3770
    Direct3D version: 1.608.2-61064218
    DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
    Windows version: 10.0.22621.1555

  17. olaf-k commented on May 5, 2023

    @olaf-k

    same here with a fresh Ubuntu install on wsl2.
    opening a fresh terminal session launches a new tab which loses focus right away. it doesn't happen once wsl is up and running when opening subsequent tabs.

    WSL version: 1.2.5.0
    Kernel version: 5.15.90.1
    WSLg version: 1.0.51
    MSRDC version: 1.2.3770
    Direct3D version: 1.608.2-61064218
    DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
    Windows version: 10.0.22621.1555
    
  18. nx-frost commented on Jun 10, 2023

    @nx-frost

    I have the same issue as mentioned by rommeswi and Olaf (@olaf-k), The issue only occurs with wslg in Windows Terminal (but works as expected when guiapplications=false is set in .wslconfig). The issue is very similar to microsoft/terminal #13388. It does not occur with Command Prompt or Powershell, only WSL, and only on the first launch; once running, new Terminal windows open as expected. If one runs wsl --shutdown and then relaunches, the issue occurs once again.

    WSL version: 1.2.5.0
    Kernel version: 5.15.90.1
    WSLg version: 1.0.51
    MSRDC version: 1.2.3770
    Direct3D version: 1.608.2-61064218
    DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
    Windows version: 10.0.22623.1250
    
  19. lsborg commented on Jun 14, 2023

    @lsborg

    Same here using powershell. Very annoying!!!!

    Versão do WSL: 1.2.5.0
    Versão do kernel: 5.15.90.1
    Versão do WSLg: 1.0.51
    Versão do MSRDC: 1.2.3770
    Versão do Direct3D: 1.608.2-61064218
    Versão do DXCore: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
    Versão do Windows: 10.0.22621.1702
    
  20. MallocArray commented on Jun 28, 2023

    @MallocArray

    Same issue for me after installing the latest WSL on a new machine using wsl --install -d Ubuntu-22.04 --web-download since business restrictions prevent using the Store directly.
    After starting Ubuntu 22.04 in WSL, focus was constantly being removed from any window until WSL was shutdown.

    Accessing Windows 10 VM via Citrix

     wsl --version
    WSL version: 1.2.5.0
    Kernel version: 5.15.90.1
    WSLg version: 1.0.51
    MSRDC version: 1.2.3770
    Direct3D version: 1.608.2-61064218
    DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
    Windows version: 10.0.19044.2965
    

    adding guiApplications=false to .wslconfig got me working for now.

  21. tig commented on Jul 20, 2023

    @tig

    Same issue just started happening for me.

    guiApplications=false stops the flickering.

    [wsl2]
    guiApplications=false
    
    WSL version: 1.3.14.0
    Kernel version: 5.15.90.3-1
    WSLg version: 1.0.55
    MSRDC version: 1.2.4419
    Direct3D version: 1.608.2-61064218
    DXCore version: 10.0.25880.1000-230602-1350.main
    Windows version: 10.0.25236.1010
    
  22. hideyukn88 commented on Jul 20, 2023

    @hideyukn88
    Contributor

    Thanks for reporting the issue, this is known issue and there are several root causes, some fixes are underway, some is understood, but no fix, and there might be unknowns. Below is cut & paste from what I posted at other issue.

    Currently there is a few known issues can lead this situation.

    1: If you have Citrix application installed, this applies to any Microsoft remote desktop software usage including WSLg, Citrix has KB published at https://support.citrix.com/article/CTX107825/how-to-disable-citrix-api-hooks-on-a-perapplication-basis. We have possible solution for this from Microsoft side, currently it's estimated to be released as WSL update by end of August.

    2: Your organization deployed certain group policies to block remote desktop connection from your local computer. One of the most common policies we are aware of is, RDP signing requirement policy, when it is enabled, msrdc.exe for WSLg failed and enter restarting loop silently. This is because RDP file used with WSLg is not signed by Microsoft or any certificate your local computer trust. (Given WSLg is open source project, currently there is difficulties to have Microsoft signed RDP file). We are actively working with related groups within Microsoft to have solution, but not yet at this point.

    3: There is another group policy let silently fail remote desktop connection, which we are not aware of. If your local computer is managed by your organization and experiencing this issue, please share the output from reg QUERY "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /S.

    4: If none of above, there is some unknown things happen in WSLg VM, this case, we will need dumps/logs from /mnt/wslg/dumps or /mnt/wslg/*.log. If you hesitate to share files directly at here. please submit file via Feedback Hub. and let us know the feedback ID. (Note: these folders are clean up at every WSL startup, thus files need to be captured while active WSL instance is experiencing the issue).

    5: There is one known issue causing WSLg compositor in Linux (weston) during handshake with msrdc.exe, which is tracked by #901.

    6: at last, in order to mitigate this issue, #1082 is submitted.

    If there is any question, feel free to post question here, thanks!

  23. tig commented on Jul 20, 2023

    @tig

    1: If you have Citrix application installed, this applies to any Microsoft remote desktop software usage including WSLg, Citrix has KB published at https://support.citrix.com/article/CTX107825/how-to-disable-citrix-api-hooks-on-a-perapplication-basis. We have possible solution for this from Microsoft side, currently it's estimated to be released as WSL update by end of August.

    I don't use Citrix.

    2: Your organization deployed certain group policies to block remote desktop connection from your local computer. One of the most common policies we are aware of is, RDP signing requirement policy, when it is enabled, msrdc.exe for WSLg failed and enter restarting loop silently. This is because RDP file used with WSLg is not signed by Microsoft or any certificate your local computer trust. (Given WSLg is open source project, currently there is difficulties to have Microsoft signed RDP file). We are actively working with related groups within Microsoft to have solution, but not yet at this point.

    How can I see if this policy impacts me?

    3: There is another group policy let silently fail remote desktop connection, which we are not aware of. If your local computer is managed by your organization and experiencing this issue, please share the output from reg QUERY "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /S.

     reg QUERY "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /S
    
    HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services\Client
        fEnableUsbBlockDeviceBySetupClass    REG_DWORD    0x1
        fEnableUsbNoAckIsochWriteToDevice    REG_DWORD    0x50
        fEnableUsbSelectDeviceByInterface    REG_DWORD    0x1
    
    HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services\Client\UsbBlockDeviceBySetupClasses
        1000    REG_SZ    {3376f4ce-ff8d-40a2-a80f-bb4359d1415c}
    
    HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services\Client\UsbSelectDeviceByInterfaces
        1000    REG_SZ    {6bdd1fc6-810f-11d0-bec7-08002be2092f}
    

    4: If none of above, there is some unknown things happen in WSLg VM, this case, we will need dumps/logs from /mnt/wslg/dumps or /mnt/wslg/*.log. If you hesitate to share files directly at here. please submit file via Feedback Hub. and let us know the feedback ID. (Note: these folders are clean up at every WSL startup, thus files need to be captured while active WSL instance is experiencing the issue).

    See attached.

    pulseaudio.log
    stderr.log
    wlog.zip

    5: There is one known issue causing WSLg compositor in Linux (weston) during handshake with msrdc.exe, which is tracked by #901.

    weston.log

    6: at last, in order to mitigate this issue, #1082 is submitted.

  24. FilipMitrevFugro commented on Sep 6, 2023

    @FilipMitrevFugro

    Confirming this on a fresh Win10. disabling GUIs is not really a solution to the problem.

  25. FilipMitrevFugro commented on Sep 7, 2023

    @FilipMitrevFugro

    Update: The issue was being caused from a enterprise policy registry entry.
    Please check Computer\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Terminal Server Client in registry for an entry called EnableAdvancedRemoteFXRemoteAppSupport. Removing this helped me solve the issue, I can run UIs again after disabling the flag.
    More info here:
    microsoft/WSL#9752

  26. shafayetejaman commented on Dec 29, 2024

    @shafayetejaman

    Image
    EnableAdvancedRemoteFXRemoteAppSupport entry does not exist for me
    the loss of focus on startup is still not solved

  27. mbravorus commented on May 10, 2025

    @mbravorus

    same, suggested registry entry doesn't exist for me, and WSL2 terminal window does ALWAYS lose focus on startup

  28. groutoutlook commented on Aug 31, 2025

    @groutoutlook

    as of today while using wt and wsl pre-release:

    $ wt --version
    Windows Terminal Preview 
    1.24.2372.0
    
    $ wsl --version
    
    WSL version: 2.6.1.0
    Kernel version: 6.6.87.2-1
    WSLg version: 1.0.66
    MSRDC version: 1.2.6353
    Direct3D version: 1.611.1-81528511
    DXCore version: 10.0.26100.1-240331-1435.ge-release
    Windows version: 10.0.26200.5761

    I dont have the losing focus and flickering anymore, but I seriously dont know how to report this to Windows terminal through a lot of closed issues (came from wt's issue repo) so I will leave it here. for future seekers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingclipboard-integrationWindows clipboard integrationduplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions