Skip to content
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

Implement ConEmu's OSC 9;4 to set the taskbar progress indicator #8055

Merged
merged 25 commits into from
Nov 18, 2020
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
af9e4d5
osc 9;4 implementation
PankajBhojwani Oct 27, 2020
606490f
spelling
PankajBhojwani Oct 27, 2020
0decbea
Merge branch 'main' of https://github.com/microsoft/terminal into dev…
PankajBhojwani Oct 27, 2020
4e6f6fe
address comments
PankajBhojwani Oct 27, 2020
da83748
add paused state
PankajBhojwani Oct 27, 2020
3d0ed84
use last focused tab's progress and state
PankajBhojwani Oct 27, 2020
f08c962
use split string
PankajBhojwani Oct 28, 2020
5f83dfd
use sender instead of args, some name changes
PankajBhojwani Oct 28, 2020
ab99ed5
remove all references to SetTaskbarProgressEventArgs, validation for …
PankajBhojwani Oct 29, 2020
4125052
tests
PankajBhojwani Oct 29, 2020
a900678
conflict with main
PankajBhojwani Oct 29, 2020
0aa5667
get the taskbar state and progress from the last active control
PankajBhojwani Oct 29, 2020
e69d0af
addressing comments, cleanups
PankajBhojwani Oct 30, 2020
57d8e07
com ptr
PankajBhojwani Oct 30, 2020
5d724bc
merging main, fixing conflicts
PankajBhojwani Nov 4, 2020
4ab32ec
send event when tab changes
PankajBhojwani Nov 4, 2020
5aff81a
check if control exists before using it
PankajBhojwani Nov 4, 2020
9fc16c8
conflict with main
PankajBhojwani Nov 6, 2020
f19b818
con emu action
PankajBhojwani Nov 6, 2020
f931acc
spel
PankajBhojwani Nov 6, 2020
c694192
_GetTaskbarProgress no longer needed
PankajBhojwani Nov 9, 2020
2476802
conflicts
PankajBhojwani Nov 16, 2020
fc9fedf
com_ptr, nits
PankajBhojwani Nov 18, 2020
bf2051b
narrow cast
PankajBhojwani Nov 18, 2020
378dd7f
narrow 2
PankajBhojwani Nov 18, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/actions/spell-check/dictionary/apis.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ IExplorer
IMap
IObject
IStorage
ITaskbar
llabs
LCID
lround
Expand All @@ -32,6 +33,7 @@ NCHITTEST
NCLBUTTONDBLCLK
NCRBUTTONDBLCLK
NOAGGREGATION
NOPROGRESS
NOREDIRECTIONBITMAP
oaidl
ocidl
Expand All @@ -51,6 +53,7 @@ spsc
STDCPP
strchr
syscall
TBPF
tmp
tx
userenv
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalApp/AppLogic.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ namespace winrt::TerminalApp::implementation
FORWARDED_TYPED_EVENT(FocusModeChanged, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable, _root, FocusModeChanged);
FORWARDED_TYPED_EVENT(FullscreenChanged, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable, _root, FullscreenChanged);
FORWARDED_TYPED_EVENT(AlwaysOnTopChanged, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable, _root, AlwaysOnTopChanged);
FORWARDED_TYPED_EVENT(SetTaskbarProgress, winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::TerminalControl::SetTaskbarProgressEventArgs, _root, SetTaskbarProgress);
};
}

Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalApp/AppLogic.idl
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,6 @@ namespace TerminalApp
event Windows.Foundation.TypedEventHandler<Object, Object> FocusModeChanged;
event Windows.Foundation.TypedEventHandler<Object, Object> FullscreenChanged;
event Windows.Foundation.TypedEventHandler<Object, Object> AlwaysOnTopChanged;
event Windows.Foundation.TypedEventHandler<Object, Microsoft.Terminal.TerminalControl.SetTaskbarProgressEventArgs> SetTaskbarProgress;
PankajBhojwani marked this conversation as resolved.
Show resolved Hide resolved
}
}
1 change: 1 addition & 0 deletions src/cascadia/TerminalApp/Tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ namespace winrt::TerminalApp::implementation
if (lastFocusedControl)
{
lastFocusedControl.Focus(FocusState::Programmatic);
lastFocusedControl.TaskbarProgressChanged();
}
}

Expand Down
14 changes: 14 additions & 0 deletions src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1129,6 +1129,9 @@ namespace winrt::TerminalApp::implementation

term.OpenHyperlink({ this, &TerminalPage::_OpenHyperlinkHandler });

// Add an event handler for when the terminal wants to set a progress indicator on the taskbar
term.SetTaskbarProgress({ this, &TerminalPage::_SetTaskbarProgressHandler });

// Bind Tab events to the TermControl and the Tab's Pane
hostingTab.Initialize(term);

Expand Down Expand Up @@ -1869,6 +1872,16 @@ namespace winrt::TerminalApp::implementation
return control.CopySelectionToClipboard(singleLine, formats);
}

// Method Description:
// - Send an event (which will be caught by AppHost) to set the progress indicator on the taskbar
// Arguments:
// - sender (not used)
// - eventArgs: the arguments specifying how to set the progress indicator
void TerminalPage::_SetTaskbarProgressHandler(const IInspectable sender, const Microsoft::Terminal::TerminalControl::SetTaskbarProgressEventArgs eventArgs)
{
_setTaskbarProgressHandlers(sender, eventArgs);
}

// Method Description:
// - Paste text from the Windows Clipboard to the focused terminal
void TerminalPage::_PasteText()
Expand Down Expand Up @@ -2639,4 +2652,5 @@ namespace winrt::TerminalApp::implementation
DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(TerminalPage, FocusModeChanged, _focusModeChangedHandlers, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(TerminalPage, FullscreenChanged, _fullscreenChangedHandlers, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(TerminalPage, AlwaysOnTopChanged, _alwaysOnTopChangedHandlers, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(TerminalPage, SetTaskbarProgress, _setTaskbarProgressHandlers, winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::TerminalControl::SetTaskbarProgressEventArgs);
}
3 changes: 3 additions & 0 deletions src/cascadia/TerminalApp/TerminalPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ namespace winrt::TerminalApp::implementation
DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(FocusModeChanged, _focusModeChangedHandlers, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(FullscreenChanged, _fullscreenChangedHandlers, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(AlwaysOnTopChanged, _alwaysOnTopChangedHandlers, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(SetTaskbarProgress, _setTaskbarProgressHandlers, winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::TerminalControl::SetTaskbarProgressEventArgs);
TYPED_EVENT(Initialized, winrt::Windows::Foundation::IInspectable, winrt::Windows::UI::Xaml::RoutedEventArgs);

private:
Expand Down Expand Up @@ -189,6 +190,8 @@ namespace winrt::TerminalApp::implementation
void _ShowCouldNotOpenDialog(winrt::hstring reason, winrt::hstring uri);
bool _CopyText(const bool singleLine, const Windows::Foundation::IReference<Microsoft::Terminal::TerminalControl::CopyFormat>& formats);

void _SetTaskbarProgressHandler(const IInspectable sender, const Microsoft::Terminal::TerminalControl::SetTaskbarProgressEventArgs eventArgs);

void _PasteText();

fire_and_forget _LaunchSettings(const Microsoft::Terminal::Settings::Model::SettingsTarget target);
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalApp/TerminalPage.idl
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ namespace TerminalApp
event Windows.Foundation.TypedEventHandler<Object, Object> FullscreenChanged;
event Windows.Foundation.TypedEventHandler<Object, Object> AlwaysOnTopChanged;
event Windows.Foundation.TypedEventHandler<Object, Windows.UI.Xaml.RoutedEventArgs> Initialized;
event Windows.Foundation.TypedEventHandler<Object, Microsoft.Terminal.TerminalControl.SetTaskbarProgressEventArgs> SetTaskbarProgress;
}
}
23 changes: 23 additions & 0 deletions src/cascadia/TerminalControl/TermControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
auto pfnCopyToClipboard = std::bind(&TermControl::_CopyToClipboard, this, std::placeholders::_1);
_terminal->SetCopyToClipboardCallback(pfnCopyToClipboard);

auto pfnTaskbarProgressChanged = std::bind(&TermControl::TaskbarProgressChanged, this);
_terminal->TaskbarProgressChangedCallback(pfnTaskbarProgressChanged);

// This event is explicitly revoked in the destructor: does not need weak_ref
auto onReceiveOutputFn = [this](const hstring str) {
_terminal->Write(str);
Expand Down Expand Up @@ -3019,6 +3022,25 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
return coreColor.has_value() ? Windows::Foundation::IReference<winrt::Windows::UI::Color>(coreColor.value()) : nullptr;
}

// Method Description:
// - Sends an event (which will be caught by TerminalPage and forwarded to AppHost after)
// to set the progress indicator on the taskbar
void TermControl::TaskbarProgressChanged()
{
auto setTaskbarProgressArgs = winrt::make_self<SetTaskbarProgressEventArgs>(_terminal->GetTaskbarState(), _terminal->GetTaskbarProgress());
_setTaskbarProgressHandlers(*this, *setTaskbarProgressArgs);
}

const size_t TermControl::GetTaskbarState() const noexcept
{
return _terminal->GetTaskbarState();
}

const size_t TermControl::GetTaskbarProgress() const noexcept
{
return _terminal->GetTaskbarProgress();
}

// -------------------------------- WinRT Events ---------------------------------
// Winrt events need a method for adding a callback to the event and removing the callback.
// These macros will define them both for you.
Expand All @@ -3029,5 +3051,6 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(TermControl, PasteFromClipboard, _clipboardPasteHandlers, TerminalControl::TermControl, TerminalControl::PasteFromClipboardEventArgs);
DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(TermControl, CopyToClipboard, _clipboardCopyHandlers, TerminalControl::TermControl, TerminalControl::CopyToClipboardEventArgs);
DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(TermControl, OpenHyperlink, _openHyperlinkHandlers, TerminalControl::TermControl, TerminalControl::OpenHyperlinkEventArgs);
DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(TermControl, SetTaskbarProgress, _setTaskbarProgressHandlers, TerminalControl::TermControl, TerminalControl::SetTaskbarProgressEventArgs);
// clang-format on
}
22 changes: 22 additions & 0 deletions src/cascadia/TerminalControl/TermControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "CopyToClipboardEventArgs.g.h"
#include "PasteFromClipboardEventArgs.g.h"
#include "OpenHyperlinkEventArgs.g.h"
#include "SetTaskbarProgressEventArgs.g.h"
#include <winrt/Microsoft.Terminal.TerminalConnection.h>
#include "../../renderer/base/Renderer.hpp"
#include "../../renderer/dx/DxRenderer.hpp"
Expand Down Expand Up @@ -81,6 +82,22 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
hstring _uri;
};

struct SetTaskbarProgressEventArgs :
public SetTaskbarProgressEventArgsT<SetTaskbarProgressEventArgs>
{
public:
SetTaskbarProgressEventArgs(size_t state, size_t progress) :
_state(state),
_progress(progress) {}

size_t State() { return _state; };
size_t Progress() { return _progress; };

private:
size_t _state;
size_t _progress;
};

struct TermControl : TermControlT<TermControl>
{
TermControl(IControlSettings settings, TerminalConnection::ITerminalConnection connection);
Expand Down Expand Up @@ -139,6 +156,10 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation

Windows::Foundation::IReference<winrt::Windows::UI::Color> TabColor() noexcept;

void TaskbarProgressChanged();
const size_t GetTaskbarState() const noexcept;
const size_t GetTaskbarProgress() const noexcept;

// clang-format off
// -------------------------------- WinRT Events ---------------------------------
DECLARE_EVENT(TitleChanged, _titleChangedHandlers, TerminalControl::TitleChangedEventArgs);
Expand All @@ -148,6 +169,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(PasteFromClipboard, _clipboardPasteHandlers, TerminalControl::TermControl, TerminalControl::PasteFromClipboardEventArgs);
DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(CopyToClipboard, _clipboardCopyHandlers, TerminalControl::TermControl, TerminalControl::CopyToClipboardEventArgs);
DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(OpenHyperlink, _openHyperlinkHandlers, TerminalControl::TermControl, TerminalControl::OpenHyperlinkEventArgs);
DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(SetTaskbarProgress, _setTaskbarProgressHandlers, TerminalControl::TermControl, TerminalControl::SetTaskbarProgressEventArgs);

TYPED_EVENT(WarningBell, IInspectable, IInspectable);
TYPED_EVENT(ConnectionStateChanged, TerminalControl::TermControl, IInspectable);
Expand Down
11 changes: 11 additions & 0 deletions src/cascadia/TerminalControl/TermControl.idl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ namespace Microsoft.Terminal.TerminalControl
String Uri { get; };
}

runtimeclass SetTaskbarProgressEventArgs
{
UInt64 State { get; };
UInt64 Progress { get; };
}

[default_interface] runtimeclass TermControl : Windows.UI.Xaml.Controls.UserControl, IDirectKeyListener, IMouseWheelListener
{
TermControl(Microsoft.Terminal.TerminalControl.IControlSettings settings, Microsoft.Terminal.TerminalConnection.ITerminalConnection connection);
Expand All @@ -60,6 +66,7 @@ namespace Microsoft.Terminal.TerminalControl
event Windows.Foundation.TypedEventHandler<TermControl, CopyToClipboardEventArgs> CopyToClipboard;
event Windows.Foundation.TypedEventHandler<TermControl, PasteFromClipboardEventArgs> PasteFromClipboard;
event Windows.Foundation.TypedEventHandler<TermControl, OpenHyperlinkEventArgs> OpenHyperlink;
event Windows.Foundation.TypedEventHandler<TermControl, SetTaskbarProgressEventArgs> SetTaskbarProgress;
event Windows.Foundation.TypedEventHandler<Object, Object> WarningBell;

event Windows.Foundation.TypedEventHandler<TermControl, Windows.UI.Xaml.RoutedEventArgs> Initialized;
Expand Down Expand Up @@ -90,6 +97,10 @@ namespace Microsoft.Terminal.TerminalControl
void SendInput(String input);
void ToggleRetroEffect();

void TaskbarProgressChanged();
UInt64 GetTaskbarState();
UInt64 GetTaskbarProgress();
PankajBhojwani marked this conversation as resolved.
Show resolved Hide resolved

Windows.Foundation.IReference<Windows.UI.Color> TabColor { get; };
event Windows.Foundation.TypedEventHandler<Object, Object> TabColorChanged;
}
Expand Down
2 changes: 2 additions & 0 deletions src/cascadia/TerminalCore/ITerminalApi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ namespace Microsoft::Terminal::Core
virtual bool AddHyperlink(std::wstring_view uri, std::wstring_view params) noexcept = 0;
virtual bool EndHyperlink() noexcept = 0;

virtual bool SetTaskbarProgress(const size_t state, const size_t progress) noexcept = 0;

protected:
ITerminalApi() = default;
};
Expand Down
24 changes: 23 additions & 1 deletion src/cascadia/TerminalCore/Terminal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ Terminal::Terminal() :
_snapOnInput{ true },
_altGrAliasing{ true },
_blockSelection{ false },
_selection{ std::nullopt }
_selection{ std::nullopt },
_taskbarState{ 0 },
_taskbarProgress{ 0 }
{
auto dispatch = std::make_unique<TerminalDispatch>(*this);
auto engine = std::make_unique<OutputStateMachineEngine>(std::move(dispatch));
Expand Down Expand Up @@ -1005,6 +1007,16 @@ void Terminal::SetBackgroundCallback(std::function<void(const COLORREF)> pfn) no
_pfnBackgroundColorChanged.swap(pfn);
}

// Method Description:
// - Allows settings a callback for settings the taskbar progress indicator
// Arguments:
// - pfn: a function callback that takes 2 size_t parameters, one indicating the progress state
// and the other indicating the progress value
void Microsoft::Terminal::Core::Terminal::TaskbarProgressChangedCallback(std::function<void()> pfn) noexcept
{
_pfnTaskbarProgressChanged.swap(pfn);
}

void Terminal::_InitializeColorTable()
try
{
Expand Down Expand Up @@ -1047,3 +1059,13 @@ BlinkingState& Terminal::GetBlinkingState() const noexcept
{
return _blinkingState;
}

const size_t Microsoft::Terminal::Core::Terminal::GetTaskbarState() const noexcept
{
return _taskbarState;
}

const size_t Microsoft::Terminal::Core::Terminal::GetTaskbarProgress() const noexcept
{
return _taskbarProgress;
}
10 changes: 10 additions & 0 deletions src/cascadia/TerminalCore/Terminal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ class Microsoft::Terminal::Core::Terminal final :

bool AddHyperlink(std::wstring_view uri, std::wstring_view params) noexcept override;
bool EndHyperlink() noexcept override;

bool SetTaskbarProgress(const size_t state, const size_t progress) noexcept override;
#pragma endregion

#pragma region ITerminalInput
Expand Down Expand Up @@ -183,6 +185,7 @@ class Microsoft::Terminal::Core::Terminal final :
void SetScrollPositionChangedCallback(std::function<void(const int, const int, const int)> pfn) noexcept;
void SetCursorPositionChangedCallback(std::function<void()> pfn) noexcept;
void SetBackgroundCallback(std::function<void(const COLORREF)> pfn) noexcept;
void TaskbarProgressChangedCallback(std::function<void()> pfn) noexcept;

void SetCursorOn(const bool isOn);
bool IsCursorBlinkingAllowed() const noexcept;
Expand All @@ -191,6 +194,9 @@ class Microsoft::Terminal::Core::Terminal final :

Microsoft::Console::Render::BlinkingState& GetBlinkingState() const noexcept;

const size_t GetTaskbarState() const noexcept;
const size_t GetTaskbarProgress() const noexcept;

#pragma region TextSelection
// These methods are defined in TerminalSelection.cpp
enum class SelectionExpansionMode
Expand All @@ -216,6 +222,7 @@ class Microsoft::Terminal::Core::Terminal final :
std::function<void(const COLORREF)> _pfnBackgroundColorChanged;
std::function<void()> _pfnCursorPositionChanged;
std::function<void(const std::optional<til::color>)> _pfnTabColorChanged;
std::function<void()> _pfnTaskbarProgressChanged;

std::unique_ptr<::Microsoft::Console::VirtualTerminal::StateMachine> _stateMachine;
std::unique_ptr<::Microsoft::Console::VirtualTerminal::TerminalInput> _terminalInput;
Expand All @@ -235,6 +242,9 @@ class Microsoft::Terminal::Core::Terminal final :
bool _altGrAliasing;
bool _suppressApplicationTitle;

size_t _taskbarState;
size_t _taskbarProgress;

#pragma region Text Selection
// a selection is represented as a range between two COORDs (start and end)
// the pivot is the COORD that remains selected when you extend a selection in any direction
Expand Down
15 changes: 15 additions & 0 deletions src/cascadia/TerminalCore/TerminalApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,3 +600,18 @@ bool Terminal::EndHyperlink() noexcept
_buffer->SetCurrentAttributes(attr);
return true;
}

// Method Description:
// - Updates the taskbar progress indicator
// Arguments:
// - state: indicates the progress state
// - progress: indicates the progress value
// Return Value:
// - true
bool Terminal::SetTaskbarProgress(const size_t state, const size_t progress) noexcept
{
_taskbarState = state;
_taskbarProgress = progress;
_pfnTaskbarProgressChanged();
PankajBhojwani marked this conversation as resolved.
Show resolved Hide resolved
return true;
}
12 changes: 12 additions & 0 deletions src/cascadia/TerminalCore/TerminalDispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,18 @@ bool TerminalDispatch::EndHyperlink() noexcept
return _terminalApi.EndHyperlink();
}

// Method Description:
// - Updates the taskbar progress indicator
// Arguments:
// - state: indicates the progress state
// - progress: indicates the progress value
// Return Value:
// - true
bool TerminalDispatch::SetTaskbarProgress(const size_t state, const size_t progress) noexcept
{
return _terminalApi.SetTaskbarProgress(state, progress);
}

// Routine Description:
// - Support routine for routing private mode parameters to be set/reset as flags
// Arguments:
Expand Down
2 changes: 2 additions & 0 deletions src/cascadia/TerminalCore/TerminalDispatch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class TerminalDispatch : public Microsoft::Console::VirtualTerminal::TermDispatc
bool AddHyperlink(const std::wstring_view uri, const std::wstring_view params) noexcept override;
bool EndHyperlink() noexcept override;

bool SetTaskbarProgress(const size_t state, const size_t progress) noexcept override;

private:
::Microsoft::Terminal::Core::ITerminalApi& _terminalApi;

Expand Down
12 changes: 12 additions & 0 deletions src/cascadia/WindowsTerminal/AppHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,17 @@ bool AppHost::OnDirectKeyEvent(const uint32_t vkey, const uint8_t scanCode, cons
return false;
}

// Method Description:
// - Event handler to update the taskbar progress indicator
// Arguments:
// - sender: not used
// - args: contains the progress state/value needed to set the taskbar progress
void AppHost::SetTaskbarProgress(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Microsoft::Terminal::TerminalControl::SetTaskbarProgressEventArgs& /*args*/)
{
auto control = sender.try_as<winrt::Microsoft::Terminal::TerminalControl::TermControl>();
_window->SetTaskbarProgress(gsl::narrow<size_t>(control.GetTaskbarState()), gsl::narrow<size_t>(control.GetTaskbarProgress()));
}

// Method Description:
// - Retrieve any commandline args passed on the commandline, and pass them to
// the app logic for processing.
Expand Down Expand Up @@ -171,6 +182,7 @@ void AppHost::Initialize()

_logic.TitleChanged({ this, &AppHost::AppTitleChanged });
_logic.LastTabClosed({ this, &AppHost::LastTabClosed });
_logic.SetTaskbarProgress({ this, &AppHost::SetTaskbarProgress });

_window->UpdateTitle(_logic.Title());

Expand Down
Loading