BringWindowToTop doesn't set active tab #18429
Labels
Area-Windowing
Window frame, quake mode, tearout
Issue-Feature
Complex enough to require an in depth planning process and actual budgeted, scheduled work.
Product-Conpty
For console issues specifically related to conpty
Milestone
Description of the new feature
Currently, BringWindowToTop only brings the terminal window to the foreground; however, it does not activate the correct tab. In certain scenarios, the user's focus is not restored to the intended location if the active tab isn't the one that initiated the BringWindowToTop call.
Using the information from this StackOverflow post, I created a functional example. The example demonstrates BringWindowToTop being used to ensure the user focus returns to the correct command line.
A current workaround for this limitation is to avoid using tabs altogether and stick with individual console windows instead.
As a side note, it would be nice if the built-in windows
start
command also had a/refocus
option, so the functional example I created wouldn't be necessary. We could aliasstart /wait /refocus myapp $*
to achieve this workflow behavior.Proposed technical implementation details
If BringWindowToTop() can't be hooked to automatically switch to the active tab, is there an alternative approach to programmatically identify the correct tab using some sort of ID or identifier, and then invoke a function to set that tab as active?
I see a possible way of doing it on line 940 in src/cascadia/TerminalControl/HwndTerminal.cpp
void __stdcall TerminalSetFocus(void* terminal)
but it doesn't seem to me that is exposed as a public API.Which leads me to this
I can imagine trying to send the terminal host process some kind of IPC message which would trigger the TerminalSetFocus allowing us to call BringWindowToTop as well as this additional trick to bring the correct tab up too. But ideally, the host process detects BringWindowToTop() and also brings the tab to top.
The text was updated successfully, but these errors were encountered: