Repository navigation
Set AppUserModelID for unpackaged - #20018
Conversation
| #endif | ||
| const auto path = wil::QueryFullProcessImageNameW<std::wstring>(); | ||
| const auto hash = til::hash(path); | ||
| fmt::format_to(std::back_inserter(aumid), FMT_COMPILE(L".{:016x}"), hash); |
There was a problem hiding this comment.
what does this do on x86? just have a bunch of 0s in?
There was a problem hiding this comment.
til::hash returns a size_t, so {:016x} would have the first 8 digits be 0s.
That said, I added the #ifdef _WIN64 branches for consistency with the other places that's done in this file.
There was a problem hiding this comment.
If you move this up, before the GetCurrentProcessToken block, couldn't you just use the windowClassName as an argument to SetCurrentProcessExplicitAppUserModelID?
There was a problem hiding this comment.
Sorry for missing this! We wouldn't be able to use the windowClassName as the AUMID because it can't contain spaces (reference).
That said, I can reuse the ifdefs to set the aumid, IsPackaged() check, and hash. Making the change now.
There was a problem hiding this comment.
You can also just remove the spaces from the window class! It bears no real meaning.
There was a problem hiding this comment.
I'm OK with having them be separate for now.
Dustin L. Howett (DHowett)
left a comment
There was a problem hiding this comment.
(also worth looking at Leonard's comment!)
|
/azp run |
1 similar comment
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
The bug was caused by an AUMID mismatch between the Taskbar's .lnk file and Windows Terminal. Since no AUMID was associated with the .exe, the OS automatically creates one for us. However, #20018 added an AUMID for unpackaged scenarios, so now there was a mismatch, resulting in a new taskbar entry being created. To fix this, we check if a .lnk points to our .exe in the taskbar. There's 3 cases here: 1. no .lnk of interest exists --> set the AUMID normally 2. the .lnk carries our AUMID --> set the AUMID normally 3. the .lnk doesn't have an AUMID (aka uses the auto-resolved one) --> - for this launch: don't set the AUMID so that we both use the auto-resolved one - on next launch: set the AUMID on the .lnk and process so that they all agree ## Validation Steps Performed In unpackaged folder, move WindowsTerminal.exe to the taskbar (creates .lnk)... ✅ Double-click the .exe --> Same taskbar entry is used ✅ Double-click the .exe _again_ --> second window goes to same taskbar entry The first window doesn't have to close for this to work. It just * works *! Bug introduced in #20018 Closes #20053
The bug was caused by an AUMID mismatch between the Taskbar's .lnk file and Windows Terminal. Since no AUMID was associated with the .exe, the OS automatically creates one for us. However, microsoft#20018 added an AUMID for unpackaged scenarios, so now there was a mismatch, resulting in a new taskbar entry being created. To fix this, we check if a .lnk points to our .exe in the taskbar. There's 3 cases here: 1. no .lnk of interest exists --> set the AUMID normally 2. the .lnk carries our AUMID --> set the AUMID normally 3. the .lnk doesn't have an AUMID (aka uses the auto-resolved one) --> - for this launch: don't set the AUMID so that we both use the auto-resolved one - on next launch: set the AUMID on the .lnk and process so that they all agree ## Validation Steps Performed In unpackaged folder, move WindowsTerminal.exe to the taskbar (creates .lnk)... ✅ Double-click the .exe --> Same taskbar entry is used ✅ Double-click the .exe _again_ --> second window goes to same taskbar entry The first window doesn't have to close for this to work. It just * works *! Bug introduced in microsoft#20018 Closes microsoft#20053
Summary of the Pull Request
Does what it says on the tin. Sets the AUMID to
WindowsTerminal.<hash>with a slightly different prefix based on the branding. The hash is based on the full process image name and user SID.Extracted from #20013