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 7 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.SendTaskbarProgressEvent();
}
}

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(*this, 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;
}
}
31 changes: 30 additions & 1 deletion src/cascadia/TerminalControl/TermControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
_lastMouseClickTimestamp{},
_lastMouseClickPos{},
_selectionNeedsToBeCopied{ false },
_searchBox{ nullptr }
_searchBox{ nullptr },
_taskbarState{ 0 },
_taskbarProgress{ 0 }
{
_EnsureStaticInitialization();
InitializeComponent();
Expand Down Expand Up @@ -104,6 +106,9 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
auto pfnCopyToClipboard = std::bind(&TermControl::_CopyToClipboard, this, std::placeholders::_1);
_terminal->SetCopyToClipboardCallback(pfnCopyToClipboard);

auto pfnSetTaskbarProgress = std::bind(&TermControl::_SetTaskbarProgress, this, std::placeholders::_1, std::placeholders::_2);
_terminal->SetTaskbarProgressCallback(pfnSetTaskbarProgress);

// 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 @@ -2273,6 +2278,20 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
_tsfTryRedrawCanvas->Run();
}

// Method Description:
// - Sets our internal knowledge of the taskbar's state and progress, then
// sends an event (which will be caught by TerminalPage and forwarded to AppHost after)
// to set the progress indicator on the taskbar
// Arguments:
// - state: the state with which to set the progress indicator
// - progress: the progress with which to set the progress indicator (only used if state is 1)
void TermControl::_SetTaskbarProgress(const size_t state, const size_t progress)
{
_taskbarState = state;
_taskbarProgress = progress;
SendTaskbarProgressEvent();
}

hstring TermControl::Title()
{
hstring hstr{ _terminal->GetConsoleTitle() };
Expand Down Expand Up @@ -3019,6 +3038,15 @@ 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::SendTaskbarProgressEvent()
{
auto setTaskbarProgressArgs = winrt::make_self<SetTaskbarProgressEventArgs>(_taskbarState, _taskbarProgress);
_setTaskbarProgressHandlers(*this, *setTaskbarProgressArgs);
}

// -------------------------------- 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 +3057,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
}
25 changes: 25 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,8 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation

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

void SendTaskbarProgressEvent();

// clang-format off
// -------------------------------- WinRT Events ---------------------------------
DECLARE_EVENT(TitleChanged, _titleChangedHandlers, TerminalControl::TitleChangedEventArgs);
Expand All @@ -148,6 +167,8 @@ 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 Expand Up @@ -213,6 +234,9 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
// Track the last hyperlink ID we hovered over
uint16_t _lastHoveredId;

size_t _taskbarState;
size_t _taskbarProgress;
PankajBhojwani marked this conversation as resolved.
Show resolved Hide resolved

using Timestamp = uint64_t;

// imported from WinUser
Expand Down Expand Up @@ -268,6 +292,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
void _CopyToClipboard(const std::wstring_view& wstr);
void _TerminalScrollPositionChanged(const int viewTop, const int viewHeight, const int bufferSize);
void _TerminalCursorPositionChanged();
void _SetTaskbarProgress(const size_t state, const size_t progress);

void _MouseScrollHandler(const double mouseDelta, const Windows::Foundation::Point point, const bool isLeftButtonPressed);
void _MouseZoomHandler(const double delta);
Expand Down
9 changes: 9 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,8 @@ namespace Microsoft.Terminal.TerminalControl
void SendInput(String input);
void ToggleRetroEffect();

void SendTaskbarProgressEvent();

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
10 changes: 10 additions & 0 deletions src/cascadia/TerminalCore/Terminal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,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::SetTaskbarProgressCallback(std::function<void(const size_t, const size_t)> pfn) noexcept
{
_pfnSetTaskbarProgress.swap(pfn);
}

void Terminal::_InitializeColorTable()
try
{
Expand Down
4 changes: 4 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 SetTaskbarProgressCallback(std::function<void(const size_t, const size_t)> pfn) noexcept;

void SetCursorOn(const bool isOn);
bool IsCursorBlinkingAllowed() const noexcept;
Expand Down Expand Up @@ -216,6 +219,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(const size_t, const size_t)> _pfnSetTaskbarProgress;

std::unique_ptr<::Microsoft::Console::VirtualTerminal::StateMachine> _stateMachine;
std::unique_ptr<::Microsoft::Console::VirtualTerminal::TerminalInput> _terminalInput;
Expand Down
13 changes: 13 additions & 0 deletions src/cascadia/TerminalCore/TerminalApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,3 +600,16 @@ 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
{
_pfnSetTaskbarProgress(state, progress);
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
11 changes: 11 additions & 0 deletions src/cascadia/WindowsTerminal/AppHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ 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)
{
_window->SetTaskbarProgress(gsl::narrow<size_t>(args.State()), gsl::narrow<size_t>(args.Progress()));
}

// 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 +181,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
1 change: 1 addition & 0 deletions src/cascadia/WindowsTerminal/AppHost.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class AppHost
void LastTabClosed(const winrt::Windows::Foundation::IInspectable& sender, const winrt::TerminalApp::LastTabClosedEventArgs& args);
void Initialize();
bool OnDirectKeyEvent(const uint32_t vkey, const uint8_t scanCode, const bool down);
void SetTaskbarProgress(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Microsoft::Terminal::TerminalControl::SetTaskbarProgressEventArgs& args);

private:
bool _useNonClientArea;
Expand Down
Loading