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 1 commit
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
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
21 changes: 17 additions & 4 deletions 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 @@ -2277,15 +2279,17 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
}

// Method Description:
// - Sends an event (which will be caught by TerminalPage and forwarded to AppHost after)
// - 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)
{
auto setTaskbarProgressArgs = winrt::make_self<SetTaskbarProgressEventArgs>(state, progress);
_setTaskbarProgressHandlers(*this, *setTaskbarProgressArgs);
_taskbarState = state;
_taskbarProgress = progress;
SendTaskbarProgressEvent();
}

hstring TermControl::Title()
Expand Down Expand Up @@ -3034,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 Down
5 changes: 5 additions & 0 deletions src/cascadia/TerminalControl/TermControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,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 Down Expand Up @@ -232,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
2 changes: 2 additions & 0 deletions src/cascadia/TerminalControl/TermControl.idl
Original file line number Diff line number Diff line change
Expand Up @@ -97,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
3 changes: 3 additions & 0 deletions src/cascadia/WindowsTerminal/IslandWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,18 +530,21 @@ void IslandWindow::SetTaskbarProgress(const size_t state, const size_t progress)
break;
case 1:
// sets the progress value to value given by the 'progress' parameter
_taskbar->SetProgressState(_window.get(), TBPF_NORMAL);
_taskbar->SetProgressValue(_window.get(), progress, 100);
break;
case 2:
PankajBhojwani marked this conversation as resolved.
Show resolved Hide resolved
// sets the progress indicator to an error state
_taskbar->SetProgressState(_window.get(), TBPF_ERROR);
_taskbar->SetProgressValue(_window.get(), progress, 100);
break;
case 3:
// sets the progress indicator to an indeterminate state
_taskbar->SetProgressState(_window.get(), TBPF_INDETERMINATE);
case 4:
// sets the progress indicator to a pause state
_taskbar->SetProgressState(_window.get(), TBPF_PAUSED);
_taskbar->SetProgressValue(_window.get(), progress, 100);
default:
break;
}
Expand Down