-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
Add shield to tab row when elevated #11224
Changes from 7 commits
04dcd2b
009ef14
2acaedf
2899222
05679bc
b436935
5481e00
26aad5e
71e6d62
f29882c
134a4c3
06a081e
425ccaa
2bc4651
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,96 +11,112 @@ | |
xmlns:mux="using:Microsoft.UI.Xaml.Controls" | ||
mc:Ignorable="d"> | ||
|
||
<mux:TabView x:Name="TabView" | ||
VerticalAlignment="Bottom" | ||
HorizontalContentAlignment="Stretch" | ||
AllowDropTabs="True" | ||
CanDragTabs="True" | ||
CanReorderTabs="True" | ||
IsAddTabButtonVisible="false" | ||
TabWidthMode="Equal"> | ||
<StackPanel Orientation="Horizontal"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. protip: ignore whitespace for this file |
||
|
||
<mux:TabView.TabStripFooter> | ||
<mux:SplitButton x:Name="NewTabButton" | ||
x:Uid="NewTabSplitButton" | ||
HorizontalAlignment="Left" | ||
VerticalAlignment="Stretch" | ||
AllowDrop="True" | ||
AutomationProperties.AccessibilityView="Control" | ||
BorderThickness="0" | ||
Click="OnNewTabButtonClick" | ||
Content="" | ||
CornerRadius="{Binding Source={ThemeResource OverlayCornerRadius}, Converter={StaticResource TopCornerRadiusFilterConverter}}" | ||
DragOver="OnNewTabButtonDragOver" | ||
Drop="OnNewTabButtonDrop" | ||
FontFamily="Segoe MDL2 Assets" | ||
FontSize="12" | ||
FontWeight="SemiLight" | ||
UseLayoutRounding="true"> | ||
<ToolTipService.ToolTip> | ||
<ToolTip Placement="Mouse"> | ||
<TextBlock IsTextSelectionEnabled="False"> | ||
<Run x:Uid="NewTabRun" /> <LineBreak /> | ||
<Run x:Uid="NewPaneRun" | ||
FontStyle="Italic" /> <LineBreak /> | ||
<Run x:Uid="NewWindowRun" | ||
FontStyle="Italic" /> | ||
</TextBlock> | ||
</ToolTip> | ||
</ToolTipService.ToolTip> | ||
<!-- U+E710 is the fancy plus icon. --> | ||
<mux:SplitButton.Resources> | ||
<!-- Override the SplitButton* resources to match the tab view's button's styles. --> | ||
<ResourceDictionary> | ||
<ResourceDictionary.ThemeDictionaries> | ||
<ResourceDictionary x:Key="Light"> | ||
<StaticResource x:Key="SplitButtonBackground" | ||
ResourceKey="TabViewButtonBackground" /> | ||
<StaticResource x:Key="SplitButtonForeground" | ||
ResourceKey="TabViewButtonForeground" /> | ||
<StaticResource x:Key="SplitButtonBackgroundPressed" | ||
ResourceKey="TabViewItemHeaderBackgroundPressed" /> | ||
<StaticResource x:Key="SplitButtonForegroundPressed" | ||
ResourceKey="TabViewItemHeaderForegroundPressed" /> | ||
<StaticResource x:Key="SplitButtonBackgroundPointerOver" | ||
ResourceKey="TabViewItemHeaderBackgroundPointerOver" /> | ||
<StaticResource x:Key="SplitButtonForegroundPointerOver" | ||
ResourceKey="TabViewItemHeaderForegroundPointerOver" /> | ||
</ResourceDictionary> | ||
<ResourceDictionary x:Key="Dark"> | ||
<StaticResource x:Key="SplitButtonBackground" | ||
ResourceKey="TabViewButtonBackground" /> | ||
<StaticResource x:Key="SplitButtonForeground" | ||
ResourceKey="TabViewButtonForeground" /> | ||
<StaticResource x:Key="SplitButtonBackgroundPressed" | ||
ResourceKey="TabViewItemHeaderBackgroundPressed" /> | ||
<StaticResource x:Key="SplitButtonForegroundPressed" | ||
ResourceKey="TabViewItemHeaderForegroundPressed" /> | ||
<StaticResource x:Key="SplitButtonBackgroundPointerOver" | ||
ResourceKey="TabViewItemHeaderBackgroundPointerOver" /> | ||
<StaticResource x:Key="SplitButtonForegroundPointerOver" | ||
ResourceKey="TabViewItemHeaderForegroundPointerOver" /> | ||
</ResourceDictionary> | ||
<ResourceDictionary x:Key="HighContrast"> | ||
<StaticResource x:Key="SplitButtonBackground" | ||
ResourceKey="TabViewButtonBackground" /> | ||
<StaticResource x:Key="SplitButtonForeground" | ||
ResourceKey="TabViewButtonForeground" /> | ||
<StaticResource x:Key="SplitButtonBackgroundPressed" | ||
ResourceKey="TabViewItemHeaderBackgroundPressed" /> | ||
<StaticResource x:Key="SplitButtonForegroundPressed" | ||
ResourceKey="TabViewItemHeaderForegroundPressed" /> | ||
<StaticResource x:Key="SplitButtonBackgroundPointerOver" | ||
ResourceKey="TabViewItemHeaderBackgroundPointerOver" /> | ||
<StaticResource x:Key="SplitButtonForegroundPointerOver" | ||
ResourceKey="TabViewItemHeaderForegroundPointerOver" /> | ||
</ResourceDictionary> | ||
</ResourceDictionary.ThemeDictionaries> | ||
</ResourceDictionary> | ||
</mux:SplitButton.Resources> | ||
</mux:SplitButton> | ||
</mux:TabView.TabStripFooter> | ||
<ContentPresenter x:Name="ElevatedShield" | ||
Grid.Column="0"> | ||
|
||
</mux:TabView> | ||
<!-- EA18 is the "Shield" glyph --> | ||
<FontIcon x:Uid="ElevationShield" | ||
zadjii-msft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Margin="9,4,0,0" | ||
FontFamily="Segoe MDL2 Assets" | ||
FontSize="16" | ||
Glyph="" | ||
Visibility="{x:Bind ShowUacShield, Mode=OneWay}" /> | ||
lhecker marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
</ContentPresenter> | ||
|
||
<mux:TabView x:Name="TabView" | ||
VerticalAlignment="Bottom" | ||
HorizontalContentAlignment="Stretch" | ||
AllowDropTabs="True" | ||
CanDragTabs="True" | ||
CanReorderTabs="True" | ||
IsAddTabButtonVisible="false" | ||
TabWidthMode="Equal"> | ||
|
||
<mux:TabView.TabStripFooter> | ||
<mux:SplitButton x:Name="NewTabButton" | ||
x:Uid="NewTabSplitButton" | ||
HorizontalAlignment="Left" | ||
VerticalAlignment="Stretch" | ||
AllowDrop="True" | ||
AutomationProperties.AccessibilityView="Control" | ||
BorderThickness="0" | ||
Click="OnNewTabButtonClick" | ||
Content="" | ||
CornerRadius="{Binding Source={ThemeResource OverlayCornerRadius}, Converter={StaticResource TopCornerRadiusFilterConverter}}" | ||
DragOver="OnNewTabButtonDragOver" | ||
Drop="OnNewTabButtonDrop" | ||
FontFamily="Segoe MDL2 Assets" | ||
FontSize="12" | ||
FontWeight="SemiLight" | ||
UseLayoutRounding="true"> | ||
<ToolTipService.ToolTip> | ||
<ToolTip Placement="Mouse"> | ||
<TextBlock IsTextSelectionEnabled="False"> | ||
<Run x:Uid="NewTabRun" /> <LineBreak /> | ||
<Run x:Uid="NewPaneRun" | ||
FontStyle="Italic" /> <LineBreak /> | ||
<Run x:Uid="NewWindowRun" | ||
FontStyle="Italic" /> | ||
</TextBlock> | ||
</ToolTip> | ||
</ToolTipService.ToolTip> | ||
<!-- U+E710 is the fancy plus icon. --> | ||
<mux:SplitButton.Resources> | ||
<!-- Override the SplitButton* resources to match the tab view's button's styles. --> | ||
<ResourceDictionary> | ||
<ResourceDictionary.ThemeDictionaries> | ||
<ResourceDictionary x:Key="Light"> | ||
<StaticResource x:Key="SplitButtonBackground" | ||
ResourceKey="TabViewButtonBackground" /> | ||
<StaticResource x:Key="SplitButtonForeground" | ||
ResourceKey="TabViewButtonForeground" /> | ||
<StaticResource x:Key="SplitButtonBackgroundPressed" | ||
ResourceKey="TabViewItemHeaderBackgroundPressed" /> | ||
<StaticResource x:Key="SplitButtonForegroundPressed" | ||
ResourceKey="TabViewItemHeaderForegroundPressed" /> | ||
<StaticResource x:Key="SplitButtonBackgroundPointerOver" | ||
ResourceKey="TabViewItemHeaderBackgroundPointerOver" /> | ||
<StaticResource x:Key="SplitButtonForegroundPointerOver" | ||
ResourceKey="TabViewItemHeaderForegroundPointerOver" /> | ||
</ResourceDictionary> | ||
<ResourceDictionary x:Key="Dark"> | ||
<StaticResource x:Key="SplitButtonBackground" | ||
ResourceKey="TabViewButtonBackground" /> | ||
<StaticResource x:Key="SplitButtonForeground" | ||
ResourceKey="TabViewButtonForeground" /> | ||
<StaticResource x:Key="SplitButtonBackgroundPressed" | ||
ResourceKey="TabViewItemHeaderBackgroundPressed" /> | ||
<StaticResource x:Key="SplitButtonForegroundPressed" | ||
ResourceKey="TabViewItemHeaderForegroundPressed" /> | ||
<StaticResource x:Key="SplitButtonBackgroundPointerOver" | ||
ResourceKey="TabViewItemHeaderBackgroundPointerOver" /> | ||
<StaticResource x:Key="SplitButtonForegroundPointerOver" | ||
ResourceKey="TabViewItemHeaderForegroundPointerOver" /> | ||
</ResourceDictionary> | ||
<ResourceDictionary x:Key="HighContrast"> | ||
<StaticResource x:Key="SplitButtonBackground" | ||
ResourceKey="TabViewButtonBackground" /> | ||
<StaticResource x:Key="SplitButtonForeground" | ||
ResourceKey="TabViewButtonForeground" /> | ||
<StaticResource x:Key="SplitButtonBackgroundPressed" | ||
ResourceKey="TabViewItemHeaderBackgroundPressed" /> | ||
<StaticResource x:Key="SplitButtonForegroundPressed" | ||
ResourceKey="TabViewItemHeaderForegroundPressed" /> | ||
<StaticResource x:Key="SplitButtonBackgroundPointerOver" | ||
ResourceKey="TabViewItemHeaderBackgroundPointerOver" /> | ||
<StaticResource x:Key="SplitButtonForegroundPointerOver" | ||
ResourceKey="TabViewItemHeaderForegroundPointerOver" /> | ||
</ResourceDictionary> | ||
</ResourceDictionary.ThemeDictionaries> | ||
</ResourceDictionary> | ||
</mux:SplitButton.Resources> | ||
</mux:SplitButton> | ||
</mux:TabView.TabStripFooter> | ||
|
||
</mux:TabView> | ||
</StackPanel> | ||
|
||
</ContentPresenter> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,6 +118,29 @@ namespace winrt::TerminalApp::implementation | |
_systemRowsToScroll = _ReadSystemRowsToScroll(); | ||
} | ||
|
||
bool TerminalPage::IsElevated() const noexcept | ||
{ | ||
// use C++11 magic statics to make sure we only do this once. | ||
// This won't change over the lifetime of the application | ||
|
||
static const bool isElevated = []() { | ||
// *** THIS IS A SINGLETON *** | ||
auto result = false; | ||
lhecker marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// GH#2455 - Make sure to try/catch calls to Application::Current, | ||
// because that _won't_ be an instance of TerminalApp::App in the | ||
// LocalTests | ||
try | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How does this try-catch work with the magic static? If the try fails, is (Also, is this even a valid concern? Does Application::Current fail often?) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
literally only in the tests, because Application::Current isn't a TerminalApp::App in the tests. With the magic static, we catch the exception as it's getting initialized, return false, and then put false in the static member to store forever There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right now AppLogic just sets a member on itself already when it is created, but also the implementation of If that free function exists somewhere sufficiently up the stack, it could also be used for ApplicationState :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FWIW there's one of my many branches hanging around that does this. I think it's going to get looped in to #11222 when I bump that next (hopefully today, likely monday tho) |
||
{ | ||
result = ::winrt::Windows::UI::Xaml::Application::Current().as<::winrt::TerminalApp::App>().Logic().IsElevated(); | ||
} | ||
CATCH_LOG(); | ||
return result; | ||
}(); | ||
|
||
return isElevated; | ||
} | ||
|
||
void TerminalPage::Create() | ||
{ | ||
// Hookup the key bindings | ||
|
@@ -128,19 +151,7 @@ namespace winrt::TerminalApp::implementation | |
_tabView = _tabRow.TabView(); | ||
_rearranging = false; | ||
|
||
// GH#2455 - Make sure to try/catch calls to Application::Current, | ||
// because that _won't_ be an instance of TerminalApp::App in the | ||
// LocalTests | ||
auto isElevated = false; | ||
try | ||
{ | ||
// GH#3581 - There's a platform limitation that causes us to crash when we rearrange tabs. | ||
// Xaml tries to send a drag visual (to wit: a screenshot) to the drag hosting process, | ||
// but that process is running at a different IL than us. | ||
// For now, we're disabling elevated drag. | ||
isElevated = ::winrt::Windows::UI::Xaml::Application::Current().as<::winrt::TerminalApp::App>().Logic().IsElevated(); | ||
} | ||
CATCH_LOG(); | ||
const auto isElevated = IsElevated(); | ||
|
||
if (_settings.GlobalSettings().UseAcrylicInTabRow()) | ||
{ | ||
|
@@ -267,6 +278,8 @@ namespace winrt::TerminalApp::implementation | |
// Setup mouse vanish attributes | ||
SystemParametersInfoW(SPI_GETMOUSEVANISH, 0, &_shouldMouseVanish, false); | ||
|
||
_tabRow.ShowUacShield(IsElevated() && _settings.GlobalSettings().ShowAdminShield()); | ||
|
||
// Store cursor, so we can restore it, e.g., after mouse vanishing | ||
// (we'll need to adapt this logic once we make cursor context aware) | ||
try | ||
|
@@ -2256,6 +2269,8 @@ namespace winrt::TerminalApp::implementation | |
// enabled application-wide, so we don't need to check it each time we | ||
// want to create an animation. | ||
WUX::Media::Animation::Timeline::AllowDependentAnimations(!_settings.GlobalSettings().DisableAnimations()); | ||
|
||
_tabRow.ShowUacShield(IsElevated() && _settings.GlobalSettings().ShowAdminShield()); | ||
} | ||
|
||
// This is a helper to aid in sorting commands by their `Name`s, alphabetically. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ | |
<ColumnDefinition Width="Auto" /> | ||
</Grid.ColumnDefinitions> | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: you can undo changes to this file There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ^ This. 😄 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes plz |
||
<ContentPresenter x:Name="ContentRoot" | ||
Grid.Column="0" /> | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wording here feels off... but I cannot figure out why.,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fond of this one.