-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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 the ability to quit all terminal instances #11143
Changes from all commits
bd4a3b5
aa74d9f
79c092d
5072358
d66a05c
cecf5af
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -304,6 +304,7 @@ | |
"toggleReadOnlyMode", | ||
"toggleShaderEffects", | ||
"wt", | ||
"quit", | ||
"unbound" | ||
], | ||
"type": "string" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -271,6 +271,7 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation | |
_monarch.FindTargetWindowRequested({ this, &WindowManager::_raiseFindTargetWindowRequested }); | ||
_monarch.ShowTrayIconRequested([this](auto&&, auto&&) { _ShowTrayIconRequestedHandlers(*this, nullptr); }); | ||
_monarch.HideTrayIconRequested([this](auto&&, auto&&) { _HideTrayIconRequestedHandlers(*this, nullptr); }); | ||
_monarch.QuitAllRequested([this](auto&&, auto&&) { _QuitAllRequestedHandlers(*this, nullptr); }); | ||
|
||
_BecameMonarchHandlers(*this, nullptr); | ||
} | ||
|
@@ -579,6 +580,19 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation | |
_peasant.RequestHideTrayIcon(); | ||
} | ||
|
||
// Method Description: | ||
// - Ask the monarch to quit all windows. | ||
// Arguments: | ||
// - <none> | ||
// Return Value: | ||
// - <none> | ||
winrt::fire_and_forget WindowManager::RequestQuitAll() | ||
{ | ||
auto strongThis{ get_strong() }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I just copied from the above There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, found something on it: #10938 (comment) |
||
co_await winrt::resume_background(); | ||
_peasant.RequestQuitAll(); | ||
} | ||
|
||
bool WindowManager::DoesQuakeWindowExist() | ||
{ | ||
return _monarch.DoesQuakeWindowExist(); | ||
|
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 curious, so if all windows get told to
quit
at roughly the same time, including the monarch, would it pose any issues if the monarch was the first to quit while all other peasants are in the middle of quitting (maybe if some peasants had more tabs and took longer to quit)?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 not sure. Since ultimately each of the
quit
actions is asynchronous (somewhere in the chain is a fire_and_forget method) it is hard to say. I imagine there might be some fighting for who becomes the monarch but I think that shouldn't matter since the other thread will continue quitting even while that happens. I haven't attempted to prove that behavior, so take what I just said with a grain of salt.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.
As a test I opened ~100 windows and initiated
quit
. All of the windows closed, but there remained a "runtime broker" process which exited a few seconds afterwards. I don't know what the "runtime broker" is or if I should be concerned that it hung around on its own for a little bit.Edit: doesn't seem like the runtime broker always gets closed immediately, or at least it can stick around for a little while if there were a lot of windows.
Edit Edit: Maybe a bug, but it doesn't seem like it really matters and it is unrelated anyways, when opening a bunch of windows sometimes the process is named
DesktopWindowXamlSource
.Edit Edit Edit: Opening a whole bunch of windows quickly can cause other problems. I managed to get memory corruption? Looks like the monarch died and a new one wasn't made, since quit/rename window/etc all fail to do anything.
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.
@leonMSFT With further testing, I was able to sometimes get it to close every window except one, that presumably became the new monarch, so I'll need to figure out how to fix that.