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

New session loses focus on startup (WSL issue) #329

Open
bobf32 opened this issue Mar 4, 2023 · 12 comments
Open

New session loses focus on startup (WSL issue) #329

bobf32 opened this issue Mar 4, 2023 · 12 comments
Labels

Comments

@bobf32
Copy link

bobf32 commented Mar 4, 2023

Windows 10 Pro 22H2 Build 19045.2604
wsltty 3.6.1.2

Every so often, but not all the time, when I start a new session the newly opened window does not have focus.

The problem doesn't occur every time I start a wsltty session, but these steps seem to be repeatable:

  1. Open new Windows command prompt / powershell
  2. wsl --shutdown
  3. %LOCALAPPDATA%\wsltty\bin\mintty.exe --WSL="Ubuntu" --configdir="%APPDATA%\wsltty" -~ -

Actual result: A new wsltty window appears, but the window does not have focus.

Expected result: the new window has focus on opening.

@mintty
Copy link
Owner

mintty commented Mar 4, 2023

Does it also happen if you start wsltty the "regular" way? (e.g. via desktop shortcut, or from the Start Menu)
Is it the window from which you start it that regains the focus? Maybe it "steals" the focus for some reason?

@mintty
Copy link
Owner

mintty commented Mar 4, 2023

Sounds as if being related to mintty/mintty#1113 but more analysis is needed, as that issue was assumedly fixed. Do you type anything quickly after starting wsltty?

@Biswa96
Copy link
Contributor

Biswa96 commented Mar 5, 2023

There were some 'focus' related issue in GUI part of WSL2 also, see https://github.com/microsoft/WSLg/issues?q=is%3Aissue+is%3Aopen+focus. Make sure if the issue can be reproduced after disabling GUI feature with WSL2.

@bobf32
Copy link
Author

bobf32 commented Mar 5, 2023

Does it also happen if you start wsltty the "regular" way? (e.g. via desktop shortcut, or from the Start Menu) Is it the window from which you start it that regains the focus? Maybe it "steals" the focus for some reason?

I am starting wsltty from shortcut. The path I posted originally is that of the shortcut. Wherever focus goes, it is not back to the window that had focus immediately before.

@bobf32
Copy link
Author

bobf32 commented Mar 5, 2023

Sounds as if being related to mintty/mintty#1113 but more analysis is needed, as that issue was assumedly fixed. Do you type anything quickly after starting wsltty?

I don't really understand the question. I start a terminal session because I want to start typing, but I can't because I have to manually set focus first. I don't recall ever having to do this before.

@bobf32
Copy link
Author

bobf32 commented Mar 5, 2023

There were some 'focus' related issue in GUI part of WSL2 also, see https://github.com/microsoft/WSLg/issues?q=is%3Aissue+is%3Aopen+focus. Make sure if the issue can be reproduced after disabling GUI feature with WSL2.

How would I do that?

@Biswa96
Copy link
Contributor

Biswa96 commented Mar 5, 2023

How would I do that?

Add the following lines in %USERPROFILE%\.wslconfig file.

[wsl2]
guiApplications=false

More info https://learn.microsoft.com/en-us/windows/wsl/wsl-config#wslconfig

@bobf32
Copy link
Author

bobf32 commented Mar 5, 2023

How would I do that?

Add the following lines in %USERPROFILE%\.wslconfig file.

[wsl2]
guiApplications=false

More info https://learn.microsoft.com/en-us/windows/wsl/wsl-config#wslconfig

Thanks. That does indeed fix the issue. And as I am still able to run gitk I wonder if, as I am running Windows 10, there is a downside.

@Biswa96
Copy link
Contributor

Biswa96 commented Mar 5, 2023

Can you see the issue with wsl.exe when those lines are not present in .wslconfig file?

@bobf32
Copy link
Author

bobf32 commented Mar 5, 2023

Can you see the issue with wsl.exe when those lines are not present in .wslconfig file?

Yes. Without guiApplications=false, wsl --shutdown followed by wsl.exe at a powershell prompt causes focus from the PS console window to be lost.

@bobf32 bobf32 changed the title New window loses focus on startup New session loses focus on startup Mar 5, 2023
@Biswa96
Copy link
Contributor

Biswa96 commented Mar 5, 2023

So, this does not look like mintty/wsltty issue, right? You can see those issues in wslg repository.

@bobf32
Copy link
Author

bobf32 commented Mar 5, 2023

So, this does not look like mintty/wsltty issue, right? You can see those issues in wslg repository.

Seems fair.

@mintty mintty added the invalid label Mar 12, 2023
@mintty mintty changed the title New session loses focus on startup New session loses focus on startup (WSL issue) Mar 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants