From d5a14f9a1f161c45943136700013a3246a868c76 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Wed, 14 Jul 2021 09:19:51 -0500 Subject: [PATCH 1/8] Fix a bug where error/warning -> indeterminate would not update the progress value correctly --- src/cascadia/WindowsTerminal/IslandWindow.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cascadia/WindowsTerminal/IslandWindow.cpp b/src/cascadia/WindowsTerminal/IslandWindow.cpp index 33b250c3da6..5d0e8f8229f 100644 --- a/src/cascadia/WindowsTerminal/IslandWindow.cpp +++ b/src/cascadia/WindowsTerminal/IslandWindow.cpp @@ -702,7 +702,12 @@ void IslandWindow::SetTaskbarProgress(const size_t state, const size_t progress) _taskbar->SetProgressValue(_window.get(), progress, 100); break; case 3: - // sets the progress indicator to an indeterminate state + // sets the progress indicator to an indeterminate state. + // FIRST, set the progress to "no progress". That'll clear out any + // progress value from the previous state. Otherwise, a transition + // from (error,x%) or (warning,x%) to indeterminate will leave the + // progress value unchanged, and not show the spinner. + _taskbar->SetProgressState(_window.get(), TBPF_NOPROGRESS); _taskbar->SetProgressState(_window.get(), TBPF_INDETERMINATE); break; case 4: From 95a26f09cc5a5ffbc155759525b42442fd57a83f Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Wed, 14 Jul 2021 09:21:22 -0500 Subject: [PATCH 2/8] This is a janky way of compining multiple pane's TB state in the icon at once. Not sure I love it. --- src/cascadia/TerminalApp/Pane.cpp | 44 ++++++++++++++++++++++++ src/cascadia/TerminalApp/Pane.h | 15 ++++++++ src/cascadia/TerminalApp/TerminalTab.cpp | 12 +++++-- 3 files changed, 68 insertions(+), 3 deletions(-) diff --git a/src/cascadia/TerminalApp/Pane.cpp b/src/cascadia/TerminalApp/Pane.cpp index cb8f4278a76..06fe62298c8 100644 --- a/src/cascadia/TerminalApp/Pane.cpp +++ b/src/cascadia/TerminalApp/Pane.cpp @@ -2133,6 +2133,50 @@ bool Pane::ContainsReadOnly() const return _IsLeaf() ? _control.ReadOnly() : (_firstChild->ContainsReadOnly() || _secondChild->ContainsReadOnly()); } +TaskbarState::TaskbarState(const uint64_t dispatchTypesState, const uint64_t progressParam) : + state{ dispatchTypesState }, + progress{ progressParam } {} + +uint64_t TaskbarState::_getPriority() const +{ + // This seemingly nonsensical ordering is from + // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist3-setprogressstate#how-the-taskbar-button-chooses-the-progress-indicator-for-a-group + switch (state) + { + case 0: // Clear = 0, + return 5; + case 1: // Set = 1, + return 3; + case 2: // Error = 2, + return 1; + case 3: // Indeterminate = 3, + return 4; + case 4: // Paused = 4 + return 2; + } + // Here, return 6, to definitely be greater than all the other valid values. + // This should never really happen. + return 6; +} + +int TaskbarState::ComparePriority(const TaskbarState& lhs, const TaskbarState& rhs) +{ + return lhs._getPriority() < rhs._getPriority(); +} + +void Pane::CollectTaskbarStates(std::vector& states) +{ + if (_IsLeaf()) + { + states.emplace_back(_control.TaskbarState(), _control.TaskbarProgress()); + } + else + { + _firstChild->CollectTaskbarStates(states); + _secondChild->CollectTaskbarStates(states); + } +} + DEFINE_EVENT(Pane, GotFocus, _GotFocusHandlers, winrt::delegate>); DEFINE_EVENT(Pane, LostFocus, _LostFocusHandlers, winrt::delegate>); DEFINE_EVENT(Pane, PaneRaiseBell, _PaneRaiseBellHandlers, winrt::Windows::Foundation::EventHandler); diff --git a/src/cascadia/TerminalApp/Pane.h b/src/cascadia/TerminalApp/Pane.h index 6e7f801b787..1f831f6d39b 100644 --- a/src/cascadia/TerminalApp/Pane.h +++ b/src/cascadia/TerminalApp/Pane.h @@ -32,6 +32,19 @@ enum class Borders : int }; DEFINE_ENUM_FLAG_OPERATORS(Borders); +class TaskbarState +{ +public: + TaskbarState(const uint64_t dispatchTypesState, const uint64_t progress); + static int ComparePriority(const TaskbarState& lhs, const TaskbarState& rhs); + + uint64_t state{ 0 }; + uint64_t progress{ 0 }; + +private: + uint64_t _getPriority() const; +}; + class Pane : public std::enable_shared_from_this { public: @@ -82,6 +95,8 @@ class Pane : public std::enable_shared_from_this bool ContainsReadOnly() const; + void CollectTaskbarStates(std::vector& states); + WINRT_CALLBACK(Closed, winrt::Windows::Foundation::EventHandler); DECLARE_EVENT(GotFocus, _GotFocusHandlers, winrt::delegate>); DECLARE_EVENT(LostFocus, _LostFocusHandlers, winrt::delegate>); diff --git a/src/cascadia/TerminalApp/TerminalTab.cpp b/src/cascadia/TerminalApp/TerminalTab.cpp index 4a09839407a..7e65aa41883 100644 --- a/src/cascadia/TerminalApp/TerminalTab.cpp +++ b/src/cascadia/TerminalApp/TerminalTab.cpp @@ -645,9 +645,15 @@ namespace winrt::TerminalApp::implementation // - void TerminalTab::_UpdateProgressState() { - if (const auto& activeControl{ GetActiveTerminalControl() }) + std::vector states; + _rootPane->CollectTaskbarStates(states); + std::sort(states.begin(), states.end(), TaskbarState::ComparePriority); + if (!states.empty()) { - const auto taskbarState = activeControl.TaskbarState(); + const auto& state{ states[0] }; + // if (const auto& activeControl{ GetActiveTerminalControl() }) + // { + const auto taskbarState = state.state; // The progress of the control changed, but not necessarily the progress of the tab. // Set the tab's progress ring to the active pane's progress if (taskbarState > 0) @@ -662,7 +668,7 @@ namespace winrt::TerminalApp::implementation // any non-indeterminate state has a value, set the progress ring as such _tabStatus.IsProgressRingIndeterminate(false); - const auto progressValue = gsl::narrow(activeControl.TaskbarProgress()); + const auto progressValue = gsl::narrow(state.progress); _tabStatus.ProgressValue(progressValue); } // Hide the tab icon (the progress ring is placed over it) From 2dccf0fade3f8a48b25503908da9ae4998c76ea0 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Wed, 14 Jul 2021 10:10:25 -0500 Subject: [PATCH 3/8] Not in love with this. --- src/cascadia/TerminalApp/Pane.cpp | 4 ++ src/cascadia/TerminalApp/Pane.h | 1 + src/cascadia/TerminalApp/TerminalPage.cpp | 8 +-- src/cascadia/TerminalApp/TerminalTab.cpp | 67 ++++++++++++----------- src/cascadia/TerminalApp/TerminalTab.h | 1 + 5 files changed, 45 insertions(+), 36 deletions(-) diff --git a/src/cascadia/TerminalApp/Pane.cpp b/src/cascadia/TerminalApp/Pane.cpp index 06fe62298c8..a834552f165 100644 --- a/src/cascadia/TerminalApp/Pane.cpp +++ b/src/cascadia/TerminalApp/Pane.cpp @@ -2133,6 +2133,10 @@ bool Pane::ContainsReadOnly() const return _IsLeaf() ? _control.ReadOnly() : (_firstChild->ContainsReadOnly() || _secondChild->ContainsReadOnly()); } +// Default to unset, 0%. +TaskbarState::TaskbarState() : + TaskbarState(0, 0){}; + TaskbarState::TaskbarState(const uint64_t dispatchTypesState, const uint64_t progressParam) : state{ dispatchTypesState }, progress{ progressParam } {} diff --git a/src/cascadia/TerminalApp/Pane.h b/src/cascadia/TerminalApp/Pane.h index 1f831f6d39b..bfb31cf51fc 100644 --- a/src/cascadia/TerminalApp/Pane.h +++ b/src/cascadia/TerminalApp/Pane.h @@ -35,6 +35,7 @@ DEFINE_ENUM_FLAG_OPERATORS(Borders); class TaskbarState { public: + TaskbarState(); TaskbarState(const uint64_t dispatchTypesState, const uint64_t progress); static int ComparePriority(const TaskbarState& lhs, const TaskbarState& rhs); diff --git a/src/cascadia/TerminalApp/TerminalPage.cpp b/src/cascadia/TerminalApp/TerminalPage.cpp index a5eb4c5ddf7..56ad3da7290 100644 --- a/src/cascadia/TerminalApp/TerminalPage.cpp +++ b/src/cascadia/TerminalApp/TerminalPage.cpp @@ -2022,9 +2022,9 @@ namespace winrt::TerminalApp::implementation // - The taskbar state of the last active control size_t TerminalPage::GetLastActiveControlTaskbarState() { - if (auto control{ _GetActiveControl() }) + if (auto tab{ _GetFocusedTabImpl() }) { - return gsl::narrow_cast(control.TaskbarState()); + return gsl::narrow_cast(tab->GetCombinedTaskbarState().state); } return {}; } @@ -2035,9 +2035,9 @@ namespace winrt::TerminalApp::implementation // - The taskbar progress of the last active control size_t TerminalPage::GetLastActiveControlTaskbarProgress() { - if (auto control{ _GetActiveControl() }) + if (auto tab{ _GetFocusedTabImpl() }) { - return gsl::narrow_cast(control.TaskbarProgress()); + return gsl::narrow_cast(tab->GetCombinedTaskbarState().progress); } return {}; } diff --git a/src/cascadia/TerminalApp/TerminalTab.cpp b/src/cascadia/TerminalApp/TerminalTab.cpp index 7e65aa41883..f19e334f1f7 100644 --- a/src/cascadia/TerminalApp/TerminalTab.cpp +++ b/src/cascadia/TerminalApp/TerminalTab.cpp @@ -177,10 +177,9 @@ namespace winrt::TerminalApp::implementation { lastFocusedControl.Focus(_focusState); - // Update our own progress state, and fire an event signaling + // Update our own progress state. This will fire an event signaling // that our taskbar progress changed. _UpdateProgressState(); - _TaskbarProgressChangedHandlers(lastFocusedControl, nullptr); } // When we gain focus, remove the bell indicator if it is active if (_tabStatus.BellIndicator()) @@ -630,6 +629,14 @@ namespace winrt::TerminalApp::implementation }); } + TaskbarState TerminalTab::GetCombinedTaskbarState() const + { + std::vector states; + _rootPane->CollectTaskbarStates(states); + std::sort(states.begin(), states.end(), TaskbarState::ComparePriority); + return states.empty() ? TaskbarState{} : states[0]; + } + // Method Description: // - This should be called on the UI thread. If you don't, then it might // silently do nothing. @@ -645,43 +652,39 @@ namespace winrt::TerminalApp::implementation // - void TerminalTab::_UpdateProgressState() { - std::vector states; - _rootPane->CollectTaskbarStates(states); - std::sort(states.begin(), states.end(), TaskbarState::ComparePriority); - if (!states.empty()) + const auto state{ GetCombinedTaskbarState() }; + + const auto taskbarState = state.state; + // The progress of the control changed, but not necessarily the progress of the tab. + // Set the tab's progress ring to the active pane's progress + if (taskbarState > 0) { - const auto& state{ states[0] }; - // if (const auto& activeControl{ GetActiveTerminalControl() }) - // { - const auto taskbarState = state.state; - // The progress of the control changed, but not necessarily the progress of the tab. - // Set the tab's progress ring to the active pane's progress - if (taskbarState > 0) + if (taskbarState == 3) { - if (taskbarState == 3) - { - // 3 is the indeterminate state, set the progress ring as such - _tabStatus.IsProgressRingIndeterminate(true); - } - else - { - // any non-indeterminate state has a value, set the progress ring as such - _tabStatus.IsProgressRingIndeterminate(false); - - const auto progressValue = gsl::narrow(state.progress); - _tabStatus.ProgressValue(progressValue); - } - // Hide the tab icon (the progress ring is placed over it) - HideIcon(true); - _tabStatus.IsProgressRingActive(true); + // 3 is the indeterminate state, set the progress ring as such + _tabStatus.IsProgressRingIndeterminate(true); } else { - // Show the tab icon - HideIcon(false); - _tabStatus.IsProgressRingActive(false); + // any non-indeterminate state has a value, set the progress ring as such + _tabStatus.IsProgressRingIndeterminate(false); + + const auto progressValue = gsl::narrow(state.progress); + _tabStatus.ProgressValue(progressValue); } + // Hide the tab icon (the progress ring is placed over it) + HideIcon(true); + _tabStatus.IsProgressRingActive(true); } + else + { + // Show the tab icon + HideIcon(false); + _tabStatus.IsProgressRingActive(false); + } + + // fire an event signaling that our taskbar progress changed. + _TaskbarProgressChangedHandlers(nullptr, nullptr); } // Method Description: diff --git a/src/cascadia/TerminalApp/TerminalTab.h b/src/cascadia/TerminalApp/TerminalTab.h index 7167f74a67c..eb83bac3e63 100644 --- a/src/cascadia/TerminalApp/TerminalTab.h +++ b/src/cascadia/TerminalApp/TerminalTab.h @@ -81,6 +81,7 @@ namespace winrt::TerminalApp::implementation void TogglePaneReadOnly(); std::shared_ptr GetActivePane() const; + TaskbarState GetCombinedTaskbarState() const; winrt::TerminalApp::TerminalTabStatus TabStatus() { From 8c0a7db88b42e704819cd01aa61ea7f35c84c44d Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Wed, 21 Jul 2021 14:04:21 -0500 Subject: [PATCH 4/8] Move TaskbarState to be a WinRT class. We'll need this for the next part... --- src/cascadia/TerminalApp/Pane.cpp | 41 ++------------ src/cascadia/TerminalApp/Pane.h | 17 +----- src/cascadia/TerminalApp/TaskbarState.cpp | 54 +++++++++++++++++++ src/cascadia/TerminalApp/TaskbarState.h | 34 ++++++++++++ src/cascadia/TerminalApp/TaskbarState.idl | 15 ++++++ .../TerminalApp/TerminalAppLib.vcxproj | 7 +++ src/cascadia/TerminalApp/TerminalPage.cpp | 4 +- src/cascadia/TerminalApp/TerminalTab.cpp | 12 ++--- src/cascadia/TerminalApp/TerminalTab.h | 2 +- 9 files changed, 125 insertions(+), 61 deletions(-) create mode 100644 src/cascadia/TerminalApp/TaskbarState.cpp create mode 100644 src/cascadia/TerminalApp/TaskbarState.h create mode 100644 src/cascadia/TerminalApp/TaskbarState.idl diff --git a/src/cascadia/TerminalApp/Pane.cpp b/src/cascadia/TerminalApp/Pane.cpp index 983adadef90..71c62339146 100644 --- a/src/cascadia/TerminalApp/Pane.cpp +++ b/src/cascadia/TerminalApp/Pane.cpp @@ -2132,46 +2132,13 @@ bool Pane::ContainsReadOnly() const return _IsLeaf() ? _control.ReadOnly() : (_firstChild->ContainsReadOnly() || _secondChild->ContainsReadOnly()); } -// Default to unset, 0%. -TaskbarState::TaskbarState() : - TaskbarState(0, 0){}; - -TaskbarState::TaskbarState(const uint64_t dispatchTypesState, const uint64_t progressParam) : - state{ dispatchTypesState }, - progress{ progressParam } {} - -uint64_t TaskbarState::_getPriority() const -{ - // This seemingly nonsensical ordering is from - // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist3-setprogressstate#how-the-taskbar-button-chooses-the-progress-indicator-for-a-group - switch (state) - { - case 0: // Clear = 0, - return 5; - case 1: // Set = 1, - return 3; - case 2: // Error = 2, - return 1; - case 3: // Indeterminate = 3, - return 4; - case 4: // Paused = 4 - return 2; - } - // Here, return 6, to definitely be greater than all the other valid values. - // This should never really happen. - return 6; -} - -int TaskbarState::ComparePriority(const TaskbarState& lhs, const TaskbarState& rhs) -{ - return lhs._getPriority() < rhs._getPriority(); -} - -void Pane::CollectTaskbarStates(std::vector& states) +void Pane::CollectTaskbarStates(std::vector& states) { if (_IsLeaf()) { - states.emplace_back(_control.TaskbarState(), _control.TaskbarProgress()); + auto tbState{ winrt::make(_control.TaskbarState(), + _control.TaskbarProgress()) }; + states.push_back(tbState); } else { diff --git a/src/cascadia/TerminalApp/Pane.h b/src/cascadia/TerminalApp/Pane.h index bfb31cf51fc..a38f0842de5 100644 --- a/src/cascadia/TerminalApp/Pane.h +++ b/src/cascadia/TerminalApp/Pane.h @@ -21,6 +21,7 @@ #pragma once #include "../../cascadia/inc/cppwinrt_utils.h" +#include "TaskbarState.h" enum class Borders : int { @@ -32,20 +33,6 @@ enum class Borders : int }; DEFINE_ENUM_FLAG_OPERATORS(Borders); -class TaskbarState -{ -public: - TaskbarState(); - TaskbarState(const uint64_t dispatchTypesState, const uint64_t progress); - static int ComparePriority(const TaskbarState& lhs, const TaskbarState& rhs); - - uint64_t state{ 0 }; - uint64_t progress{ 0 }; - -private: - uint64_t _getPriority() const; -}; - class Pane : public std::enable_shared_from_this { public: @@ -96,7 +83,7 @@ class Pane : public std::enable_shared_from_this bool ContainsReadOnly() const; - void CollectTaskbarStates(std::vector& states); + void CollectTaskbarStates(std::vector& states); WINRT_CALLBACK(Closed, winrt::Windows::Foundation::EventHandler); DECLARE_EVENT(GotFocus, _GotFocusHandlers, winrt::delegate>); diff --git a/src/cascadia/TerminalApp/TaskbarState.cpp b/src/cascadia/TerminalApp/TaskbarState.cpp new file mode 100644 index 00000000000..9402182de8a --- /dev/null +++ b/src/cascadia/TerminalApp/TaskbarState.cpp @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +#include "pch.h" +#include +#include "TaskbarState.h" +#include "TaskbarState.g.cpp" + +using namespace winrt; + +namespace winrt +{ + namespace MUX = Microsoft::UI::Xaml; + namespace WUX = Windows::UI::Xaml; +} + +namespace winrt::TerminalApp::implementation +{ + // Default to unset, 0%. + TaskbarState::TaskbarState() : + TaskbarState(0, 0){}; + + TaskbarState::TaskbarState(const uint64_t dispatchTypesState, const uint64_t progressParam) : + _State{ dispatchTypesState }, + _Progress{ progressParam } {} + + uint64_t TaskbarState::Priority() const + { + // This seemingly nonsensical ordering is from + // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist3-setprogressstate#how-the-taskbar-button-chooses-the-progress-indicator-for-a-group + switch (_State) + { + case 0: // Clear = 0, + return 5; + case 1: // Set = 1, + return 3; + case 2: // Error = 2, + return 1; + case 3: // Indeterminate = 3, + return 4; + case 4: // Paused = 4 + return 2; + } + // Here, return 6, to definitely be greater than all the other valid values. + // This should never really happen. + return 6; + } + + int TaskbarState::ComparePriority(const winrt::TerminalApp::TaskbarState& lhs, const winrt::TerminalApp::TaskbarState& rhs) + { + return lhs.Priority() < rhs.Priority(); + } + +} diff --git a/src/cascadia/TerminalApp/TaskbarState.h b/src/cascadia/TerminalApp/TaskbarState.h new file mode 100644 index 00000000000..e36b4440cc9 --- /dev/null +++ b/src/cascadia/TerminalApp/TaskbarState.h @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +#pragma once +#include "inc/cppwinrt_utils.h" +#include "TaskbarState.g.h" + +// fwdecl unittest classes +namespace TerminalAppLocalTests +{ + class TabTests; +}; + +namespace winrt::TerminalApp::implementation +{ + struct TaskbarState : TaskbarStateT + { + public: + TaskbarState(); + TaskbarState(const uint64_t dispatchTypesState, const uint64_t progress); + + static int ComparePriority(const winrt::TerminalApp::TaskbarState& lhs, const winrt::TerminalApp::TaskbarState& rhs); + + uint64_t Priority() const; + + WINRT_PROPERTY(uint64_t, State, 0); + WINRT_PROPERTY(uint64_t, Progress, 0); + }; +} + +namespace winrt::TerminalApp::factory_implementation +{ + BASIC_FACTORY(TaskbarState); +} diff --git a/src/cascadia/TerminalApp/TaskbarState.idl b/src/cascadia/TerminalApp/TaskbarState.idl new file mode 100644 index 00000000000..159242a17b2 --- /dev/null +++ b/src/cascadia/TerminalApp/TaskbarState.idl @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +namespace TerminalApp +{ + [default_interface] runtimeclass TaskbarState + { + TaskbarState(); + TaskbarState(UInt64 dispatchTypesState, UInt64 progress); + + UInt64 State{ get; }; + UInt64 Progress{ get; }; + UInt64 Priority { get; }; + } +} diff --git a/src/cascadia/TerminalApp/TerminalAppLib.vcxproj b/src/cascadia/TerminalApp/TerminalAppLib.vcxproj index 67317f4e482..95e49e2008b 100644 --- a/src/cascadia/TerminalApp/TerminalAppLib.vcxproj +++ b/src/cascadia/TerminalApp/TerminalAppLib.vcxproj @@ -89,6 +89,9 @@ TabBase.idl + + TaskbarState.idl + TerminalTab.idl @@ -164,6 +167,9 @@ TabBase.idl + + TaskbarState.idl + TerminalTab.idl @@ -256,6 +262,7 @@ + TerminalPage.xaml diff --git a/src/cascadia/TerminalApp/TerminalPage.cpp b/src/cascadia/TerminalApp/TerminalPage.cpp index ebca8a87954..ba723c26a47 100644 --- a/src/cascadia/TerminalApp/TerminalPage.cpp +++ b/src/cascadia/TerminalApp/TerminalPage.cpp @@ -2046,7 +2046,7 @@ namespace winrt::TerminalApp::implementation { if (auto tab{ _GetFocusedTabImpl() }) { - return tab->GetCombinedTaskbarState().state; + return tab->GetCombinedTaskbarState().State(); } return {}; } @@ -2059,7 +2059,7 @@ namespace winrt::TerminalApp::implementation { if (auto tab{ _GetFocusedTabImpl() }) { - return tab->GetCombinedTaskbarState().progress; + return tab->GetCombinedTaskbarState().Progress(); } return {}; } diff --git a/src/cascadia/TerminalApp/TerminalTab.cpp b/src/cascadia/TerminalApp/TerminalTab.cpp index f19e334f1f7..cc8058f50b0 100644 --- a/src/cascadia/TerminalApp/TerminalTab.cpp +++ b/src/cascadia/TerminalApp/TerminalTab.cpp @@ -629,12 +629,12 @@ namespace winrt::TerminalApp::implementation }); } - TaskbarState TerminalTab::GetCombinedTaskbarState() const + winrt::TerminalApp::TaskbarState TerminalTab::GetCombinedTaskbarState() const { - std::vector states; + std::vector states; _rootPane->CollectTaskbarStates(states); - std::sort(states.begin(), states.end(), TaskbarState::ComparePriority); - return states.empty() ? TaskbarState{} : states[0]; + std::sort(states.begin(), states.end(), TerminalApp::implementation::TaskbarState::ComparePriority); + return states.empty() ? winrt::make() : states[0]; } // Method Description: @@ -654,7 +654,7 @@ namespace winrt::TerminalApp::implementation { const auto state{ GetCombinedTaskbarState() }; - const auto taskbarState = state.state; + const auto taskbarState = state.State(); // The progress of the control changed, but not necessarily the progress of the tab. // Set the tab's progress ring to the active pane's progress if (taskbarState > 0) @@ -669,7 +669,7 @@ namespace winrt::TerminalApp::implementation // any non-indeterminate state has a value, set the progress ring as such _tabStatus.IsProgressRingIndeterminate(false); - const auto progressValue = gsl::narrow(state.progress); + const auto progressValue = gsl::narrow(state.Progress()); _tabStatus.ProgressValue(progressValue); } // Hide the tab icon (the progress ring is placed over it) diff --git a/src/cascadia/TerminalApp/TerminalTab.h b/src/cascadia/TerminalApp/TerminalTab.h index eb83bac3e63..4f135a327e9 100644 --- a/src/cascadia/TerminalApp/TerminalTab.h +++ b/src/cascadia/TerminalApp/TerminalTab.h @@ -81,7 +81,7 @@ namespace winrt::TerminalApp::implementation void TogglePaneReadOnly(); std::shared_ptr GetActivePane() const; - TaskbarState GetCombinedTaskbarState() const; + winrt::TerminalApp::TaskbarState GetCombinedTaskbarState() const; winrt::TerminalApp::TerminalTabStatus TabStatus() { From cbbdd385385e4b1f04632975c88d50a9080abb3e Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Wed, 21 Jul 2021 14:42:54 -0500 Subject: [PATCH 5/8] yay it works --- src/cascadia/TerminalApp/AppLogic.cpp | 32 ++++++------ src/cascadia/TerminalApp/AppLogic.h | 5 +- src/cascadia/TerminalApp/AppLogic.idl | 5 +- src/cascadia/TerminalApp/TerminalPage.cpp | 60 +++++++++++++++-------- src/cascadia/TerminalApp/TerminalPage.h | 5 +- src/cascadia/TerminalApp/TerminalPage.idl | 6 ++- src/cascadia/WindowsTerminal/AppHost.cpp | 11 +++-- 7 files changed, 73 insertions(+), 51 deletions(-) diff --git a/src/cascadia/TerminalApp/AppLogic.cpp b/src/cascadia/TerminalApp/AppLogic.cpp index 441fbd4deff..301aadc2ef0 100644 --- a/src/cascadia/TerminalApp/AppLogic.cpp +++ b/src/cascadia/TerminalApp/AppLogic.cpp @@ -1125,31 +1125,27 @@ namespace winrt::TerminalApp::implementation } } - // Method Description: - // - Gets the taskbar state value from the last active control - // Return Value: - // - The taskbar state of the last active control - uint64_t AppLogic::GetLastActiveControlTaskbarState() + winrt::TerminalApp::TaskbarState AppLogic::TaskbarState() { if (_root) { - return _root->GetLastActiveControlTaskbarState(); + return _root->TaskbarState(); } return {}; } - // Method Description: - // - Gets the taskbar progress value from the last active control - // Return Value: - // - The taskbar progress of the last active control - uint64_t AppLogic::GetLastActiveControlTaskbarProgress() - { - if (_root) - { - return _root->GetLastActiveControlTaskbarProgress(); - } - return {}; - } + // // Method Description: + // // - Gets the taskbar progress value from the last active control + // // Return Value: + // // - The taskbar progress of the last active control + // uint64_t AppLogic::GetLastActiveControlTaskbarProgress() + // { + // if (_root) + // { + // return _root->GetLastActiveControlTaskbarProgress(); + // } + // return {}; + // } // Method Description: // - Sets the initial commandline to process on startup, and attempts to diff --git a/src/cascadia/TerminalApp/AppLogic.h b/src/cascadia/TerminalApp/AppLogic.h index 3d778203921..5661134becb 100644 --- a/src/cascadia/TerminalApp/AppLogic.h +++ b/src/cascadia/TerminalApp/AppLogic.h @@ -89,8 +89,9 @@ namespace winrt::TerminalApp::implementation void WindowCloseButtonClicked(); - uint64_t GetLastActiveControlTaskbarState(); - uint64_t GetLastActiveControlTaskbarProgress(); + // uint64_t GetLastActiveControlTaskbarState(); + // uint64_t GetLastActiveControlTaskbarProgress(); + winrt::TerminalApp::TaskbarState TaskbarState(); winrt::Windows::Foundation::IAsyncOperation ShowDialog(winrt::Windows::UI::Xaml::Controls::ContentDialog dialog); diff --git a/src/cascadia/TerminalApp/AppLogic.idl b/src/cascadia/TerminalApp/AppLogic.idl index bb334d26f47..389dffe3579 100644 --- a/src/cascadia/TerminalApp/AppLogic.idl +++ b/src/cascadia/TerminalApp/AppLogic.idl @@ -68,8 +68,9 @@ namespace TerminalApp void TitlebarClicked(); void WindowCloseButtonClicked(); - UInt64 GetLastActiveControlTaskbarState(); - UInt64 GetLastActiveControlTaskbarProgress(); + // UInt64 GetLastActiveControlTaskbarState(); + // UInt64 GetLastActiveControlTaskbarProgress(); + TaskbarState TaskbarState{ get; }; FindTargetWindowResult FindTargetWindow(String[] args); diff --git a/src/cascadia/TerminalApp/TerminalPage.cpp b/src/cascadia/TerminalApp/TerminalPage.cpp index ba723c26a47..ecadb69b8b2 100644 --- a/src/cascadia/TerminalApp/TerminalPage.cpp +++ b/src/cascadia/TerminalApp/TerminalPage.cpp @@ -2038,31 +2038,49 @@ namespace winrt::TerminalApp::implementation _dialogPresenter = dialogPresenter; } - // Method Description: - // - Gets the taskbar state value from the last active control - // Return Value: - // - The taskbar state of the last active control - uint64_t TerminalPage::GetLastActiveControlTaskbarState() + winrt::TerminalApp::TaskbarState TerminalPage::TaskbarState() const { - if (auto tab{ _GetFocusedTabImpl() }) - { - return tab->GetCombinedTaskbarState().State(); - } - return {}; - } + std::vector states; - // Method Description: - // - Gets the taskbar progress value from the last active control - // Return Value: - // - The taskbar progress of the last active control - uint64_t TerminalPage::GetLastActiveControlTaskbarProgress() - { - if (auto tab{ _GetFocusedTabImpl() }) + for (const auto& tab : _tabs) { - return tab->GetCombinedTaskbarState().Progress(); + if (auto tabImpl{ _GetTerminalTabImpl(tab) }) + { + auto tabState{ tabImpl->GetCombinedTaskbarState() }; + states.push_back(tabState); + } } - return {}; - } + + std::sort(states.begin(), states.end(), TerminalApp::implementation::TaskbarState::ComparePriority); + + return states.empty() ? winrt::make() : states[0]; + } + + // // Method Description: + // // - Gets the taskbar state value from the last active control + // // Return Value: + // // - The taskbar state of the last active control + // uint64_t TerminalPage::GetLastActiveControlTaskbarState() + // { + // if (auto tab{ _GetFocusedTabImpl() }) + // { + // return tab->GetCombinedTaskbarState().State(); + // } + // return {}; + // } + + // // Method Description: + // // - Gets the taskbar progress value from the last active control + // // Return Value: + // // - The taskbar progress of the last active control + // uint64_t TerminalPage::GetLastActiveControlTaskbarProgress() + // { + // if (auto tab{ _GetFocusedTabImpl() }) + // { + // return tab->GetCombinedTaskbarState().Progress(); + // } + // return {}; + // } // Method Description: // - This is the method that App will call when the titlebar diff --git a/src/cascadia/TerminalApp/TerminalPage.h b/src/cascadia/TerminalApp/TerminalPage.h index 6d7370b9acd..1812be1652c 100644 --- a/src/cascadia/TerminalApp/TerminalPage.h +++ b/src/cascadia/TerminalApp/TerminalPage.h @@ -85,8 +85,9 @@ namespace winrt::TerminalApp::implementation winrt::TerminalApp::IDialogPresenter DialogPresenter() const; void DialogPresenter(winrt::TerminalApp::IDialogPresenter dialogPresenter); - uint64_t GetLastActiveControlTaskbarState(); - uint64_t GetLastActiveControlTaskbarProgress(); + // uint64_t GetLastActiveControlTaskbarState(); + // uint64_t GetLastActiveControlTaskbarProgress(); + winrt::TerminalApp::TaskbarState TaskbarState() const; void ShowKeyboardServiceWarning(); winrt::hstring KeyboardServiceDisabledText(); diff --git a/src/cascadia/TerminalApp/TerminalPage.idl b/src/cascadia/TerminalApp/TerminalPage.idl index 0d055782268..db93f02bfbf 100644 --- a/src/cascadia/TerminalApp/TerminalPage.idl +++ b/src/cascadia/TerminalApp/TerminalPage.idl @@ -1,5 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. +import "TaskbarState.idl"; namespace TerminalApp { @@ -42,8 +43,9 @@ namespace TerminalApp void ShowKeyboardServiceWarning(); String KeyboardServiceDisabledText { get; }; - UInt64 GetLastActiveControlTaskbarState(); - UInt64 GetLastActiveControlTaskbarProgress(); + // UInt64 GetLastActiveControlTaskbarState(); + // UInt64 GetLastActiveControlTaskbarProgress(); + TaskbarState TaskbarState{ get; }; event Windows.Foundation.TypedEventHandler TitleChanged; event Windows.Foundation.TypedEventHandler LastTabClosed; diff --git a/src/cascadia/WindowsTerminal/AppHost.cpp b/src/cascadia/WindowsTerminal/AppHost.cpp index 53e21ccdd38..070cb2c9be2 100644 --- a/src/cascadia/WindowsTerminal/AppHost.cpp +++ b/src/cascadia/WindowsTerminal/AppHost.cpp @@ -126,13 +126,16 @@ bool AppHost::OnDirectKeyEvent(const uint32_t vkey, const uint8_t scanCode, cons // Arguments: // - sender: not used // - args: not used -void AppHost::SetTaskbarProgress(const winrt::Windows::Foundation::IInspectable& /*sender*/, const winrt::Windows::Foundation::IInspectable& /*args*/) +void AppHost::SetTaskbarProgress(const winrt::Windows::Foundation::IInspectable& /*sender*/, + const winrt::Windows::Foundation::IInspectable& /*args*/) { if (_logic) { - const auto state = gsl::narrow_cast(_logic.GetLastActiveControlTaskbarState()); - const auto progress = gsl::narrow_cast(_logic.GetLastActiveControlTaskbarProgress()); - _window->SetTaskbarProgress(state, progress); + const auto state = _logic.TaskbarState(); + // const auto state = gsl::narrow_cast(_logic.GetLastActiveControlTaskbarState()); + // const auto progress = gsl::narrow_cast(_logic.GetLastActiveControlTaskbarProgress()); + _window->SetTaskbarProgress(gsl::narrow_cast(state.State()), + gsl::narrow_cast(state.Progress())); } } From 2703447e1c10deabeb6eebde93ae1ba333dab959 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Thu, 22 Jul 2021 08:55:53 -0500 Subject: [PATCH 6/8] cleanup --- src/cascadia/TerminalApp/AppLogic.cpp | 13 -------- src/cascadia/TerminalApp/AppLogic.h | 2 -- src/cascadia/TerminalApp/AppLogic.idl | 2 -- src/cascadia/TerminalApp/Pane.cpp | 8 +++++ src/cascadia/TerminalApp/TerminalPage.cpp | 38 +++++++---------------- src/cascadia/TerminalApp/TerminalPage.h | 2 -- src/cascadia/TerminalApp/TerminalPage.idl | 2 -- src/cascadia/TerminalApp/TerminalTab.cpp | 12 +++++++ src/cascadia/WindowsTerminal/AppHost.cpp | 2 -- 9 files changed, 32 insertions(+), 49 deletions(-) diff --git a/src/cascadia/TerminalApp/AppLogic.cpp b/src/cascadia/TerminalApp/AppLogic.cpp index 301aadc2ef0..4b029905d35 100644 --- a/src/cascadia/TerminalApp/AppLogic.cpp +++ b/src/cascadia/TerminalApp/AppLogic.cpp @@ -1134,19 +1134,6 @@ namespace winrt::TerminalApp::implementation return {}; } - // // Method Description: - // // - Gets the taskbar progress value from the last active control - // // Return Value: - // // - The taskbar progress of the last active control - // uint64_t AppLogic::GetLastActiveControlTaskbarProgress() - // { - // if (_root) - // { - // return _root->GetLastActiveControlTaskbarProgress(); - // } - // return {}; - // } - // Method Description: // - Sets the initial commandline to process on startup, and attempts to // parse it. Commands will be parsed into a list of ShortcutActions that diff --git a/src/cascadia/TerminalApp/AppLogic.h b/src/cascadia/TerminalApp/AppLogic.h index 5661134becb..0f97f47e58b 100644 --- a/src/cascadia/TerminalApp/AppLogic.h +++ b/src/cascadia/TerminalApp/AppLogic.h @@ -89,8 +89,6 @@ namespace winrt::TerminalApp::implementation void WindowCloseButtonClicked(); - // uint64_t GetLastActiveControlTaskbarState(); - // uint64_t GetLastActiveControlTaskbarProgress(); winrt::TerminalApp::TaskbarState TaskbarState(); winrt::Windows::Foundation::IAsyncOperation ShowDialog(winrt::Windows::UI::Xaml::Controls::ContentDialog dialog); diff --git a/src/cascadia/TerminalApp/AppLogic.idl b/src/cascadia/TerminalApp/AppLogic.idl index 389dffe3579..0b889103899 100644 --- a/src/cascadia/TerminalApp/AppLogic.idl +++ b/src/cascadia/TerminalApp/AppLogic.idl @@ -68,8 +68,6 @@ namespace TerminalApp void TitlebarClicked(); void WindowCloseButtonClicked(); - // UInt64 GetLastActiveControlTaskbarState(); - // UInt64 GetLastActiveControlTaskbarProgress(); TaskbarState TaskbarState{ get; }; FindTargetWindowResult FindTargetWindow(String[] args); diff --git a/src/cascadia/TerminalApp/Pane.cpp b/src/cascadia/TerminalApp/Pane.cpp index 71c62339146..e937fb31342 100644 --- a/src/cascadia/TerminalApp/Pane.cpp +++ b/src/cascadia/TerminalApp/Pane.cpp @@ -2132,6 +2132,14 @@ bool Pane::ContainsReadOnly() const return _IsLeaf() ? _control.ReadOnly() : (_firstChild->ContainsReadOnly() || _secondChild->ContainsReadOnly()); } +// Method Description: +// - If we're a parent, place the taskbar state for all our leaves into the +// provided vector. +// - If we're a leaf, place our own state into the vector. +// Arguments: +// - states: a vector that will receive all the states of all leaves in the tree +// Return Value: +// - void Pane::CollectTaskbarStates(std::vector& states) { if (_IsLeaf()) diff --git a/src/cascadia/TerminalApp/TerminalPage.cpp b/src/cascadia/TerminalApp/TerminalPage.cpp index ecadb69b8b2..8113b2b9614 100644 --- a/src/cascadia/TerminalApp/TerminalPage.cpp +++ b/src/cascadia/TerminalApp/TerminalPage.cpp @@ -2038,6 +2038,18 @@ namespace winrt::TerminalApp::implementation _dialogPresenter = dialogPresenter; } + // Method Description: + // - Get the combined taskbar state for the page. This is the combination of + // all the states of all the tabs, which are themselves a combination of + // all their panes. Taskbar states are given a priority based on the rules + // in: + // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist3-setprogressstate + // under "How the Taskbar Button Chooses the Progress Indicator for a Group" + // Arguments: + // - + // Return Value: + // - A TaskbarState object representing the combined taskbar state and + // progress precentage of all our tabs. winrt::TerminalApp::TaskbarState TerminalPage::TaskbarState() const { std::vector states; @@ -2056,32 +2068,6 @@ namespace winrt::TerminalApp::implementation return states.empty() ? winrt::make() : states[0]; } - // // Method Description: - // // - Gets the taskbar state value from the last active control - // // Return Value: - // // - The taskbar state of the last active control - // uint64_t TerminalPage::GetLastActiveControlTaskbarState() - // { - // if (auto tab{ _GetFocusedTabImpl() }) - // { - // return tab->GetCombinedTaskbarState().State(); - // } - // return {}; - // } - - // // Method Description: - // // - Gets the taskbar progress value from the last active control - // // Return Value: - // // - The taskbar progress of the last active control - // uint64_t TerminalPage::GetLastActiveControlTaskbarProgress() - // { - // if (auto tab{ _GetFocusedTabImpl() }) - // { - // return tab->GetCombinedTaskbarState().Progress(); - // } - // return {}; - // } - // Method Description: // - This is the method that App will call when the titlebar // has been clicked. It dismisses any open flyouts. diff --git a/src/cascadia/TerminalApp/TerminalPage.h b/src/cascadia/TerminalApp/TerminalPage.h index 1812be1652c..91178c92002 100644 --- a/src/cascadia/TerminalApp/TerminalPage.h +++ b/src/cascadia/TerminalApp/TerminalPage.h @@ -85,8 +85,6 @@ namespace winrt::TerminalApp::implementation winrt::TerminalApp::IDialogPresenter DialogPresenter() const; void DialogPresenter(winrt::TerminalApp::IDialogPresenter dialogPresenter); - // uint64_t GetLastActiveControlTaskbarState(); - // uint64_t GetLastActiveControlTaskbarProgress(); winrt::TerminalApp::TaskbarState TaskbarState() const; void ShowKeyboardServiceWarning(); diff --git a/src/cascadia/TerminalApp/TerminalPage.idl b/src/cascadia/TerminalApp/TerminalPage.idl index db93f02bfbf..7d4c580e9f3 100644 --- a/src/cascadia/TerminalApp/TerminalPage.idl +++ b/src/cascadia/TerminalApp/TerminalPage.idl @@ -43,8 +43,6 @@ namespace TerminalApp void ShowKeyboardServiceWarning(); String KeyboardServiceDisabledText { get; }; - // UInt64 GetLastActiveControlTaskbarState(); - // UInt64 GetLastActiveControlTaskbarProgress(); TaskbarState TaskbarState{ get; }; event Windows.Foundation.TypedEventHandler TitleChanged; diff --git a/src/cascadia/TerminalApp/TerminalTab.cpp b/src/cascadia/TerminalApp/TerminalTab.cpp index cc8058f50b0..4242fce2b6c 100644 --- a/src/cascadia/TerminalApp/TerminalTab.cpp +++ b/src/cascadia/TerminalApp/TerminalTab.cpp @@ -629,6 +629,18 @@ namespace winrt::TerminalApp::implementation }); } + // Method Description: + // - Get the combined taskbar state for the tab. This is the combination of + // all the states of all our panes. Taskbar states are given a priority + // based on the rules in: + // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist3-setprogressstate + // under "How the Taskbar Button Chooses the Progress Indicator for a + // Group" + // Arguments: + // - + // Return Value: + // - A TaskbarState object representing the combined taskbar state and + // progress precentage of all our panes. winrt::TerminalApp::TaskbarState TerminalTab::GetCombinedTaskbarState() const { std::vector states; diff --git a/src/cascadia/WindowsTerminal/AppHost.cpp b/src/cascadia/WindowsTerminal/AppHost.cpp index 070cb2c9be2..e59c3ec5f62 100644 --- a/src/cascadia/WindowsTerminal/AppHost.cpp +++ b/src/cascadia/WindowsTerminal/AppHost.cpp @@ -132,8 +132,6 @@ void AppHost::SetTaskbarProgress(const winrt::Windows::Foundation::IInspectable& if (_logic) { const auto state = _logic.TaskbarState(); - // const auto state = gsl::narrow_cast(_logic.GetLastActiveControlTaskbarState()); - // const auto progress = gsl::narrow_cast(_logic.GetLastActiveControlTaskbarProgress()); _window->SetTaskbarProgress(gsl::narrow_cast(state.State()), gsl::narrow_cast(state.Progress())); } From 15f03b34610b08912f7f90111833c719adac6b3a Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Thu, 22 Jul 2021 09:07:05 -0500 Subject: [PATCH 7/8] percentage --- src/cascadia/TerminalApp/TerminalPage.cpp | 2 +- src/cascadia/TerminalApp/TerminalTab.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cascadia/TerminalApp/TerminalPage.cpp b/src/cascadia/TerminalApp/TerminalPage.cpp index 8113b2b9614..446c184e9a2 100644 --- a/src/cascadia/TerminalApp/TerminalPage.cpp +++ b/src/cascadia/TerminalApp/TerminalPage.cpp @@ -2049,7 +2049,7 @@ namespace winrt::TerminalApp::implementation // - // Return Value: // - A TaskbarState object representing the combined taskbar state and - // progress precentage of all our tabs. + // progress percentage of all our tabs. winrt::TerminalApp::TaskbarState TerminalPage::TaskbarState() const { std::vector states; diff --git a/src/cascadia/TerminalApp/TerminalTab.cpp b/src/cascadia/TerminalApp/TerminalTab.cpp index 4242fce2b6c..0e3b369c399 100644 --- a/src/cascadia/TerminalApp/TerminalTab.cpp +++ b/src/cascadia/TerminalApp/TerminalTab.cpp @@ -640,7 +640,7 @@ namespace winrt::TerminalApp::implementation // - // Return Value: // - A TaskbarState object representing the combined taskbar state and - // progress precentage of all our panes. + // progress percentage of all our panes. winrt::TerminalApp::TaskbarState TerminalTab::GetCombinedTaskbarState() const { std::vector states; From 75f8ff2390dd1229ced5a2df1aebc5caa5e2a30b Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Mon, 9 Aug 2021 13:44:44 -0500 Subject: [PATCH 8/8] some really clever suggestions from carlos --- src/cascadia/TerminalApp/TaskbarState.cpp | 9 --------- src/cascadia/TerminalApp/TerminalPage.cpp | 12 +++++++----- src/cascadia/TerminalApp/TerminalTab.cpp | 4 ++-- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/cascadia/TerminalApp/TaskbarState.cpp b/src/cascadia/TerminalApp/TaskbarState.cpp index 9402182de8a..183460556cc 100644 --- a/src/cascadia/TerminalApp/TaskbarState.cpp +++ b/src/cascadia/TerminalApp/TaskbarState.cpp @@ -2,18 +2,9 @@ // Licensed under the MIT license. #include "pch.h" -#include #include "TaskbarState.h" #include "TaskbarState.g.cpp" -using namespace winrt; - -namespace winrt -{ - namespace MUX = Microsoft::UI::Xaml; - namespace WUX = Windows::UI::Xaml; -} - namespace winrt::TerminalApp::implementation { // Default to unset, 0%. diff --git a/src/cascadia/TerminalApp/TerminalPage.cpp b/src/cascadia/TerminalApp/TerminalPage.cpp index 9dbbff532da..4d49779ade9 100644 --- a/src/cascadia/TerminalApp/TerminalPage.cpp +++ b/src/cascadia/TerminalApp/TerminalPage.cpp @@ -2090,20 +2090,22 @@ namespace winrt::TerminalApp::implementation // progress percentage of all our tabs. winrt::TerminalApp::TaskbarState TerminalPage::TaskbarState() const { - std::vector states; + auto state{ winrt::make() }; for (const auto& tab : _tabs) { if (auto tabImpl{ _GetTerminalTabImpl(tab) }) { auto tabState{ tabImpl->GetCombinedTaskbarState() }; - states.push_back(tabState); + // lowest priority wins + if (tabState.Priority() < state.Priority()) + { + state = tabState; + } } } - std::sort(states.begin(), states.end(), TerminalApp::implementation::TaskbarState::ComparePriority); - - return states.empty() ? winrt::make() : states[0]; + return state; } // Method Description: diff --git a/src/cascadia/TerminalApp/TerminalTab.cpp b/src/cascadia/TerminalApp/TerminalTab.cpp index e3559c1556d..48cf05d3347 100644 --- a/src/cascadia/TerminalApp/TerminalTab.cpp +++ b/src/cascadia/TerminalApp/TerminalTab.cpp @@ -690,8 +690,8 @@ namespace winrt::TerminalApp::implementation { std::vector states; _rootPane->CollectTaskbarStates(states); - std::sort(states.begin(), states.end(), TerminalApp::implementation::TaskbarState::ComparePriority); - return states.empty() ? winrt::make() : states[0]; + return states.empty() ? winrt::make() : + *std::min_element(states.begin(), states.end(), TerminalApp::implementation::TaskbarState::ComparePriority); } // Method Description: