Skip to content

Commit cfd4ade

Browse files
author
Console Service Bot
committed
Merge remote-tracking branch 'origin/main' into feature/llm
2 parents 6b44d8c + 297703d commit cfd4ade

32 files changed

+3170
-644
lines changed

src/cascadia/TerminalControl/ControlCore.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,27 @@ namespace winrt::Microsoft::Terminal::Control::implementation
152152

153153
_renderer->SetBackgroundColorChangedCallback([this]() { _rendererBackgroundColorChanged(); });
154154
_renderer->SetFrameColorChangedCallback([this]() { _rendererTabColorChanged(); });
155-
_renderer->SetRendererEnteredErrorStateCallback([this]() { RendererEnteredErrorState.raise(nullptr, nullptr); });
155+
_renderer->SetRendererEnteredErrorStateCallback([this]() { _rendererEnteredErrorState(); });
156156
}
157157

158158
UpdateSettings(settings, unfocusedAppearance);
159159
}
160160

161+
void ControlCore::_rendererEnteredErrorState()
162+
{
163+
// The first time the renderer fails out (after all of its own retries), switch it to D2D and WARP
164+
// and force it to try again. If it _still_ fails, we can let it halt.
165+
if (_renderFailures++ == 0)
166+
{
167+
const auto lock = _terminal->LockForWriting();
168+
_renderEngine->SetGraphicsAPI(parseGraphicsAPI(GraphicsAPI::Direct2D));
169+
_renderEngine->SetSoftwareRendering(true);
170+
_renderer->EnablePainting();
171+
return;
172+
}
173+
RendererEnteredErrorState.raise(nullptr, nullptr);
174+
}
175+
161176
void ControlCore::_setupDispatcherAndCallbacks()
162177
{
163178
// Get our dispatcher. If we're hosted in-proc with XAML, this will get
@@ -917,6 +932,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
917932
_renderEngine->SetSoftwareRendering(_settings.SoftwareRendering());
918933
// Inform the renderer of our opacity
919934
_renderEngine->EnableTransparentBackground(_isBackgroundTransparent());
935+
_renderFailures = 0; // We may have changed the engine; reset the failure counter.
920936

921937
// Trigger a redraw to repaint the window background and tab colors.
922938
_renderer->TriggerRedrawAll(true, true);
@@ -1983,6 +1999,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
19831999
{
19842000
// The lock must be held, because it calls into IRenderData which is shared state.
19852001
const auto lock = _terminal->LockForWriting();
2002+
_renderFailures = 0;
19862003
_renderer->EnablePainting();
19872004
}
19882005

src/cascadia/TerminalControl/ControlCore.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
344344
safe_void_coroutine _renderEngineSwapChainChanged(const HANDLE handle);
345345
void _rendererBackgroundColorChanged();
346346
void _rendererTabColorChanged();
347+
void _rendererEnteredErrorState();
347348
#pragma endregion
348349

349350
void _raiseReadOnlyWarning();
@@ -398,6 +399,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
398399
float _panelWidth{ 0 };
399400
float _panelHeight{ 0 };
400401
float _compositionScale{ 0 };
402+
uint8_t _renderFailures{ 0 };
401403
bool _forceCursorVisible = false;
402404

403405
// Audio stuff.

src/cascadia/TerminalSettingsEditor/Actions.cpp

Lines changed: 8 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -18,52 +18,17 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
1818
Automation::AutomationProperties::SetName(AddNewButton(), RS_(L"Actions_AddNewTextBlock/Text"));
1919
}
2020

21-
Automation::Peers::AutomationPeer Actions::OnCreateAutomationPeer()
22-
{
23-
_ViewModel.OnAutomationPeerAttached();
24-
return nullptr;
25-
}
26-
2721
void Actions::OnNavigatedTo(const NavigationEventArgs& e)
2822
{
2923
_ViewModel = e.Parameter().as<Editor::ActionsViewModel>();
30-
31-
// Subscribe to the view model's FocusContainer event.
32-
// Use the KeyBindingViewModel or index provided in the event to focus the corresponding container
33-
_ViewModel.FocusContainer([this](const auto& /*sender*/, const auto& args) {
34-
if (auto kbdVM{ args.try_as<KeyBindingViewModel>() })
35-
{
36-
if (const auto& container = KeyBindingsListView().ContainerFromItem(*kbdVM))
37-
{
38-
container.as<Controls::ListViewItem>().Focus(FocusState::Programmatic);
39-
}
40-
}
41-
else if (const auto& index = args.try_as<uint32_t>())
42-
{
43-
if (const auto& container = KeyBindingsListView().ContainerFromIndex(*index))
44-
{
45-
container.as<Controls::ListViewItem>().Focus(FocusState::Programmatic);
46-
}
47-
}
48-
});
49-
50-
// Subscribe to the view model's UpdateBackground event.
51-
// The view model does not have access to the page resources, so it asks us
52-
// to update the key binding's container background
53-
_ViewModel.UpdateBackground([this](const auto& /*sender*/, const auto& args) {
54-
if (auto kbdVM{ args.try_as<KeyBindingViewModel>() })
55-
{
56-
if (kbdVM->IsInEditMode())
57-
{
58-
const auto& containerBackground{ Resources().Lookup(box_value(L"ActionContainerBackgroundEditing")).as<Windows::UI::Xaml::Media::Brush>() };
59-
kbdVM->ContainerBackground(containerBackground);
60-
}
61-
else
62-
{
63-
const auto& containerBackground{ Resources().Lookup(box_value(L"ActionContainerBackground")).as<Windows::UI::Xaml::Media::Brush>() };
64-
kbdVM->ContainerBackground(containerBackground);
65-
}
66-
}
24+
_ViewModel.CurrentPage(ActionsSubPage::Base);
25+
auto vmImpl = get_self<ActionsViewModel>(_ViewModel);
26+
vmImpl->MarkAsVisited();
27+
_layoutUpdatedRevoker = LayoutUpdated(winrt::auto_revoke, [this](auto /*s*/, auto /*e*/) {
28+
// Only let this succeed once.
29+
_layoutUpdatedRevoker.revoke();
30+
31+
AddNewButton().Focus(FocusState::Programmatic);
6732
});
6833

6934
TraceLoggingWrite(
@@ -74,9 +39,4 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
7439
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
7540
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage));
7641
}
77-
78-
void Actions::AddNew_Click(const IInspectable& /*sender*/, const RoutedEventArgs& /*eventArgs*/)
79-
{
80-
_ViewModel.AddNewKeybinding();
81-
}
8242
}

src/cascadia/TerminalSettingsEditor/Actions.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
1616
Actions();
1717

1818
void OnNavigatedTo(const winrt::Windows::UI::Xaml::Navigation::NavigationEventArgs& e);
19-
Windows::UI::Xaml::Automation::Peers::AutomationPeer OnCreateAutomationPeer();
20-
21-
void AddNew_Click(const IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& eventArgs);
2219

2320
til::property_changed_event PropertyChanged;
2421
WINRT_OBSERVABLE_PROPERTY(Editor::ActionsViewModel, ViewModel, PropertyChanged.raise, nullptr);
22+
23+
private:
24+
winrt::Windows::UI::Xaml::FrameworkElement::LayoutUpdated_revoker _layoutUpdatedRevoker;
2525
};
2626
}
2727

0 commit comments

Comments
 (0)