Open tusharsnx opened 3 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!
Note: You can give me feedback by thumbs upping or thumbs downing this comment.
As wsl is a background service, it shouldn't steal focus when starting up.
This is most likely caused by wslg, transferring.
@tusharsnx, would you please collect log and share with us? thanks!
@hideyukn88 I am using Windows 11 23H2 on two systems. Could reproduce that issue on both system this afternoon. On one system, I had the impression that when the focus got lost, the language selector (the ENG
guy below) flickered; but that may have been a consequence of the focus switch itself. Disabling it did not help.
Now, I cannot reproduce this behavior on either system. Will update this issue with traces if it occurs again.
@hideyukn88 TBH, I couldn't reproduce it at the moment, but I do see it sometimes. I think after I created this issue the severity has gone down a little. Previously, I used to see it at every wsl boot, but now seems like it only happens at the first wsl boot up after the system is restarted. I'm also on the latest pre-release version, so maybe something was fixed between this version and the earlier versions.
I'll try to submit the trace if I see it again. For now, since bersbersbers can repro it, I should keep it open?
Okay, I've got a perfect repro. When I'm debugging any application and run wsl --shutdown && wsl
while the debugging session is on, the windows terminal loses focus 100% of the time.
#include <iostream>
int main() { std::cout << "hello world"; // I tried to put a breakpoint to keep the program running, // but that doesn't repro the issue. // So, it seems like program must be in running state, // which we do by blocking on cin.get(). std::cin.get(); return 0; }
2. Start a debugging session by clicking on "Local Windows Debugger".
3. A terminal window would open with the output of "hello world".
4. Create a new terminal tab within the same window.
5. run `wsl --shutdown && wsl`.
6. In a moment, the terminal window would lose focus.
---
### Trace:
_I repeated the step (5) 3 times._
![image](https://github.com/microsoft/wslg/assets/55626797/71d2b0e7-5be7-43ac-acc8-2de3f445f1e0)
[foregroundTracing.zip](https://github.com/microsoft/wslg/files/15164706/foregroundTracing.zip)
[wsl-focus-lost-repro-video.zip](https://github.com/microsoft/wslg/files/15164928/wsl-focus-lost-video.zip)
---
> On one system, I had the impression that when the focus got lost, the language selector (the ENG guy below) flickered; but that may have been a consequence of the focus switch itself.
@bersbersbers You're right, I just realized that too (I usually have my taskbar autohide so I couldn't notice it earlier) you can see in the repro video 😄
Windows Version
Microsoft Windows [Version 10.0.22631.3235]
WSL Version
2.1.4.0
Are you using WSL 1 or WSL 2?
Kernel Version
5.15.146.1-2
Distro Version
No response
Other Software
No response
Repro Steps
wsl --shutdown
.wsl
This repros on VScode and Visual Studio integrated terminals, and Windows Terminal also.
Expected Behavior
Focus is still on the foreground (terminal) app.
Actual Behavior
Focus is lost from the foreground app.
Diagnostic Logs
No response