-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
Add Minimize to Tray and Tray Icon #10368
Conversation
// TODO: Other useful options may include: | ||
// - Summon All | ||
// - Summon MRU or Monarch | ||
// - Though that's technically already available with a left click | ||
// but may be a reasonable request to also put it explicitly in the | ||
// context menu | ||
// - Quit All |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget to tag up this bare TODO
This should be a requirement. So many applications provide this option that it should be considered a defacto standard (like Xterm). (I also personally like seeing all my tray icons. If I don't want to see one, I'll close the application instead, usually from left clicking on the icon, if it's supported, which it usually is.) |
Yep, there's already a whole spec with a section devoted to this idea. |
wait uh, I don't think we need this. Win+down will minimize a window |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blocking for discussion on the minimizeToTray
action and the #if TIL_FEATURE
thing
@@ -637,6 +637,17 @@ | |||
<data name="CommandPaletteMenuItem" xml:space="preserve"> | |||
<value>Command Palette</value> | |||
</data> | |||
<data name="AppName" xml:space="preserve"> | |||
<value>Windows Terminal</value> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wait uh, if you're gonna pull it from the CascadiaPackage
resources, do we need this string still?
Ah crap I didn't even know about this shortcut 😅 |
Hmm. Interesting. Okay, I'm convinced. I kinda think it should be a separate PR, but it's already here so ¯\_(ツ)_/¯ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay most of these are just notes to self as I read the code. Mostly just indicators of where I might have been confused as I was following the logic.
I think at this point I'm mostly blocking on the "add a try/catch here" one.
I don't know how I feel about the minimize to tray action, but I don't feel like blocking that element of it.
This is ∞% better without all the ifdefs, thanks for that
const ActionEventArgs& args) | ||
{ | ||
#if TIL_FEATURE_TRAYICON_ENABLED | ||
if (_settings.GlobalSettings().MinimizeToTray() || _settings.GlobalSettings().AlwaysShowTrayIcon()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait so if they don't have either of these features on, then this will do nothing. I thought the point of this action was to allow minimizing a window to the tray even when neither setting is on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right okay so this action only works when there is a tray icon. Right, cause otherwise the window would just disappear into the void. And we're not doing any sort of per-window tracking of "this window wanted to be able to minimize to the tray, so we must have a tray icon".
IDK I still feel weird about this action and almost wish it was a separate PR to review/discuss
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, pretty much I don't want to let the user do be able to minimize if there won't be a tray icon. The idea was to be able to minimize when minimizeToTray = false, alwaysShowTrayIcon = true
.
The per-window tracking would definitely be useful especially for big sweeping actions like "summon all" - I'll add it to the list.
I'll also split this off into its own PR and we could discuss some more there - makes the PR smaller too 😉
// work properly. | ||
nid.uVersion = NOTIFYICON_VERSION_4; | ||
Shell_NotifyIcon(NIM_SETVERSION, &nid); | ||
void AppHost::_ShowTrayIconRequested() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we need to make sure to hop onto the BG thread at the top of this (and _HideTrayIconRequested
)? Usually the COM x-proc calls end up throwing exceptions/gracefully doing nothing when called on the main thread.
Is this really never called on the main thread?
-
_IsQuakeWindowChanged
- pretty sure that can be on the main thread... unsure tho -
_windowManager.ShowTrayIconRequested
okay this one's on the bg thread
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I've never observed it doing weird stuff, I'll throw it on a resume_background
in the beginning of the functions just to be safe.
src/cascadia/Remoting/Monarch.cpp
Outdated
{ | ||
SummonWindowBehavior args{}; | ||
args.ToggleVisibility(false); | ||
peasant.Summon(args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrap this boy up in a try/catch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm actually doing the _forAllPeasantsIgnoringTheDead
thing for this little snippet, that has error handling in it so I should be good right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yep, you're good
// - <none> | ||
void TrayIcon::DestroyTrayIcon() | ||
{ | ||
Shell_NotifyIcon(NIM_DELETE, &_trayIconData); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also do a
_trayIconData.reset();
here, like we used to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was intending for this function to be more of a RemoveIconFromTray
instead of a "destroy" (I'll rename). I wanted the actual "destruction" of the tray icon to be when AppHost
sets its _trayIcon
ptr to null, and if it ever wanted to get a new tray icon, it should instantiate a new one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okeydokey, good enough for me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets do it
Hello @leonMSFT! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I think we should be using
if constexpr (Feature_XXX::IsEnabled())
when possible - the
gsl::narrow
vsgsl::narrow_cast
thing is a bit concerning, so I just want to double check that - the one copyright header that's missing
{ | ||
Shell_NotifyIcon(NIM_DELETE, &_trayIconData.value()); | ||
_trayIconData.reset(); | ||
_windowManager.RequestHideTrayIcon(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw there's no guarantee that this destructs 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
argh I used the wrong one here it should be AppHost::_HideTrayIconRequested
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just kidding that's not the right one either
@@ -662,6 +655,20 @@ void AppHost::_BecomeMonarch(const winrt::Windows::Foundation::IInspectable& /*s | |||
const winrt::Windows::Foundation::IInspectable& /*args*/) | |||
{ | |||
_setupGlobalHotkeys(); | |||
|
|||
// The monarch is just going to be THE listener for inbound connections. | |||
_listenForInboundConnections(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't break the defapp server?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh shit good catch
Some followups to #10368: - Accidentally reverted a defapp change where the Monarch should not by default register itself as a handoff server. - Destroy the tray icon if we're a monarch otherwise if we're a quake window we request the monarch to hide the icon.
A brief summary of the behavior of the tray icon:
Settings Changes
Two new global settings are introduced:
alwaysShowTrayIcon
andminimizeToTray
. Here's a chart explaining the behavior with the two settings.alwaysShowTrayIcon:true
alwaysShowTrayIcon:false
minimizeToTray:true
minimizeToTray:false
Closes #5727
References
Spec for Minimize to Tray
Docs PR - MicrosoftDocs/terminal#352
#10448 - My list of TODOs