microsoft / terminal

The new Windows Terminal and the original Windows console host, all in the same place!
MIT License
94.92k stars 8.22k forks source link

New window is opened in background #15895

Closed oldium closed 1 day ago

oldium commented 1 year ago

Windows Terminal version

1.18.1462.0

Windows build number

10.0.22621.0

Other Software

No response

Steps to reproduce

  1. Open File Explorer, place it on the screen so that new Windows Terminal window must open over it.
  2. On address bar of File Explorer, write wt and press Enter.
  3. New Windows Terminal window opens in front of other windows and gets focus.
  4. Switch back to File Explorer's address bar, write wt and press Enter.
  5. New Windows Terminal window opens in front of other windows and gets focus.
  6. Click on the first Windows Terminal window's title bar.
  7. Switch back to File Explorer's address bar, write wt and press Enter.
  8. Observe that the Windows Terminal window is opened in background (not over File Explorer, but below it), has blinking cursor like it has focus, but it does not have focus.

Expected Behavior

The new window is opened in foreground and gets focus.

Actual Behavior

The new window is not a foreground window and does not have focus.

The new window is opened in foreground as long as you do not click on any previously opened window. When you do, next Windows Terminal window (and any further) opens in background.

lhecker commented 1 year ago

Hey! Thanks for the report. This appears to be /duplicate of #15763. 🙂

microsoft-github-policy-service[bot] commented 1 year ago

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

oldium commented 1 year ago

Hey! Thanks for the report. This appears to be /duplicate of #15763. 🙂

@lhecker I do not have problem with Alt-Tab. I have problem with the window opened in background. I do not think this is a duplicate.

lhecker commented 1 year ago

Oh you're right. (Although I do think they're related.) But there are multiple other reports of this issue like for instance #13130. I think something's wrong with bringing packaged applications (AppX/MSIX) to the foreground in general. Internally Windows is littered with special handlings for packaged applications throughout the code base so it at least wouldn't be entirely surprising to me if it deviated from the behavior of regular applications.

microsoft-github-policy-service[bot] commented 1 year ago

This issue has been marked as duplicate and has not had any activity for 1 day. It will be closed for housekeeping purposes.

lhecker commented 10 months ago

I didn't notice that this issue was closed again. I'll reopen it. I don't really think it's the exact same issue as the other one...

zadjii-msft commented 9 months ago

This is the "wt.exe should probably AllowSetForeground / CoAllowSetForeground on the monarch" thing.

KerimG commented 9 months ago

I ahve been having this issue for a couple weeks too now. I'm opening the Windows Terminal by pressing the Win button to open the start menu and type "Terminal". I think the problem occurs if the Windows Terminal app is pinned to the task bar.

EDIT: This is incorrect.

willuhn commented 9 months ago

I'm having the same issue, not related to pinned task bar here. I'm starting wt.exe using an autohotkey script. Terminal windows randomly appears in background.

KerimG commented 9 months ago

@willuhn you're correct, after working for a while I just had the same issue again.

Cyanide0210 commented 6 months ago

Its always appearing on the background for me, I do not like that at all

MaverickMartyn commented 6 months ago

I too have this issue. In my case I use PowerToys Keyboard Manager to launch C:\Users\USER\AppData\Local\Microsoft\WindowsApps\wt.exe I do not have Terminal pinned to the taskbar, and it happens to the first create Window, not just any subsequent ones. Here's my launch settings, in case that matters: (EDIT: I am currently running version 1.19.10573.0. I believe that was also the case when I originally commented.) image

jacko-png commented 5 months ago

I used to have this issue until I updated to 1.19.10821.0 via Winget. From memory, I used Microsoft Store to get WT at first. I open WT via the context menu (right click → t) and a shortcut on my desktop mapped to a keybind. I'm on Windows 10 22H2 build 19045.4170. I feel like this issue is either contextual (the fix seems to persist through restarts though) or resolved.

McSneaky commented 5 months ago

Have version 1.19.10821.0 installed thro Microsoft Store and it has been happening for months. Still happening

Doesn't matter how I open terminal, always goes to background

zadjii-msft commented 2 weeks ago

fwiw I can't repro this on 10.0.26282.5000 & 1.23.2391.0. This may have been fixed by #17368 in 1.22 Preview - can anyone confirm/?

oldium commented 1 week ago

Yeah! I can confirm it works for me with version 1.21.1772.0 on Win 11 22631.4112.

oldium commented 1 week ago

fwiw I can't repro this on 10.0.26282.5000 & 1.23.2391.0. This may have been fixed by #17368 in 1.22 Preview - can anyone confirm/?

I am on version which you have not mentioned, which is really strange, but with 1.21.1772.0 it works for me. I tried exactly the repro steps and also my usual work flow, it works. It might be working for longer time, I just have not noticed it.

oldium commented 1 day ago

Works for me, closing.