Remove IsUwp, RunAsUwp, defaults-universal and all fallout (#15222)

The ability to build and run Terminal as a UWP application was removed
in #12119. We left some of its vestiges around, but now there is no need
for them.

(cherry picked from commit 5ed3c76dcb)
Service-Card-Id: 89001993
Service-Version: 1.17
This commit is contained in:
Dustin L. Howett 2023-04-25 11:28:55 -05:00 committed by Dustin Howett
parent 526704b725
commit 752df35cf5
11 changed files with 42 additions and 361 deletions

View File

@ -35,7 +35,7 @@ namespace winrt::TerminalApp::implementation
}
else
{
_isUwp = true;
FAIL_FAST_MSG("Terminal is not intended to run as a Universal Windows Application");
}
}
@ -77,22 +77,6 @@ namespace winrt::TerminalApp::implementation
/// <param name="e">Details about the launch request and process.</param>
void App::OnLaunched(const LaunchActivatedEventArgs& /*e*/)
{
// if this is a UWP... it means its our problem to hook up the content to the window here.
if (_isUwp)
{
auto content = Window::Current().Content();
if (content == nullptr)
{
auto logic = Logic();
logic.RunAsUwp(); // Must set UWP status first, settings might change based on it.
logic.ReloadSettings();
logic.Create();
auto page = logic.GetRoot().as<TerminalPage>();
Window::Current().Content(page);
Window::Current().Activate();
}
}
// We used to support a pure UWP version of Terminal. We no longer do so.
}
}

View File

@ -26,7 +26,6 @@ namespace winrt::TerminalApp::implementation
}
private:
bool _isUwp = false;
winrt::Windows::UI::Xaml::Hosting::WindowsXamlManager _windowsXamlManager = nullptr;
winrt::Windows::Foundation::Collections::IVector<winrt::Windows::UI::Xaml::Markup::IXamlMetadataProvider> _providers = winrt::single_threaded_vector<Windows::UI::Xaml::Markup::IXamlMetadataProvider>();
bool _bIsClosed = false;

View File

@ -209,17 +209,6 @@ namespace winrt::TerminalApp::implementation
return _root->Initialize(hwnd);
}
// Method Description:
// - Called around the codebase to discover if this is a UWP where we need to turn off specific settings.
// Arguments:
// - <none> - reports internal state
// Return Value:
// - True if UWP, false otherwise.
bool AppLogic::IsUwp() const noexcept
{
return _isUwp;
}
// Method Description:
// - Called around the codebase to discover if Terminal is running elevated
// Arguments:
@ -235,18 +224,6 @@ namespace winrt::TerminalApp::implementation
return _canDragDrop;
}
// Method Description:
// - Called by UWP context invoker to let us know that we may have to change some of our behaviors
// for being a UWP
// Arguments:
// - <none> (sets to UWP = true, one way change)
// Return Value:
// - <none>
void AppLogic::RunAsUwp()
{
_isUwp = true;
}
// Method Description:
// - Build the UI for the terminal app. Before this method is called, it
// should not be assumed that the TerminalApp is usable. The Settings
@ -264,13 +241,6 @@ namespace winrt::TerminalApp::implementation
_root->DialogPresenter(*this);
// In UWP mode, we cannot handle taking over the title bar for tabs,
// so this setting is overridden to false no matter what the preference is.
if (_isUwp)
{
_settings.GlobalSettings().ShowTabsInTitlebar(false);
}
// Pay attention, that even if some command line arguments were parsed (like launch mode),
// we will not use the startup actions from settings.
// While this simplifies the logic, we might want to reconsider this behavior in the future.
@ -816,7 +786,7 @@ namespace winrt::TerminalApp::implementation
try
{
auto newSettings = _isUwp ? CascadiaSettings::LoadUniversal() : CascadiaSettings::LoadAll();
auto newSettings = CascadiaSettings::LoadAll();
if (newSettings.GetLoadingError())
{

View File

@ -59,8 +59,6 @@ namespace winrt::TerminalApp::implementation
STDMETHODIMP Initialize(HWND hwnd);
void Create();
bool IsUwp() const noexcept;
void RunAsUwp();
bool IsRunningElevated() const noexcept;
bool CanDragDrop() const noexcept;
void ReloadSettings();
@ -149,7 +147,6 @@ namespace winrt::TerminalApp::implementation
TYPED_EVENT(SystemMenuChangeRequested, winrt::Windows::Foundation::IInspectable, winrt::TerminalApp::SystemMenuChangeArgs);
private:
bool _isUwp{ false };
bool _isElevated{ false };
bool _canDragDrop{ false };

View File

@ -46,8 +46,6 @@ namespace TerminalApp
// registered?" when it definitely is.
void Create();
Boolean IsUwp();
void RunAsUwp();
Boolean IsRunningElevated();
Boolean CanDragDrop();

View File

@ -839,61 +839,48 @@ namespace winrt::TerminalApp::implementation
// add static items
{
// 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 isUwp = false;
try
// Create the settings button.
auto settingsItem = WUX::Controls::MenuFlyoutItem{};
settingsItem.Text(RS_(L"SettingsMenuItem"));
const auto settingsToolTip = RS_(L"SettingsToolTip");
WUX::Controls::ToolTipService::SetToolTip(settingsItem, box_value(settingsToolTip));
Automation::AutomationProperties::SetHelpText(settingsItem, settingsToolTip);
WUX::Controls::SymbolIcon ico{};
ico.Symbol(WUX::Controls::Symbol::Setting);
settingsItem.Icon(ico);
settingsItem.Click({ this, &TerminalPage::_SettingsButtonOnClick });
newTabFlyout.Items().Append(settingsItem);
auto actionMap = _settings.ActionMap();
const auto settingsKeyChord{ actionMap.GetKeyBindingForAction(ShortcutAction::OpenSettings, OpenSettingsArgs{ SettingsTarget::SettingsUI }) };
if (settingsKeyChord)
{
isUwp = ::winrt::Windows::UI::Xaml::Application::Current().as<::winrt::TerminalApp::App>().Logic().IsUwp();
_SetAcceleratorForMenuItem(settingsItem, settingsKeyChord);
}
CATCH_LOG();
if (!isUwp)
// Create the command palette button.
auto commandPaletteFlyout = WUX::Controls::MenuFlyoutItem{};
commandPaletteFlyout.Text(RS_(L"CommandPaletteMenuItem"));
const auto commandPaletteToolTip = RS_(L"CommandPaletteToolTip");
WUX::Controls::ToolTipService::SetToolTip(commandPaletteFlyout, box_value(commandPaletteToolTip));
Automation::AutomationProperties::SetHelpText(commandPaletteFlyout, commandPaletteToolTip);
WUX::Controls::FontIcon commandPaletteIcon{};
commandPaletteIcon.Glyph(L"\xE945");
commandPaletteIcon.FontFamily(Media::FontFamily{ L"Segoe Fluent Icons, Segoe MDL2 Assets" });
commandPaletteFlyout.Icon(commandPaletteIcon);
commandPaletteFlyout.Click({ this, &TerminalPage::_CommandPaletteButtonOnClick });
newTabFlyout.Items().Append(commandPaletteFlyout);
const auto commandPaletteKeyChord{ actionMap.GetKeyBindingForAction(ShortcutAction::ToggleCommandPalette) };
if (commandPaletteKeyChord)
{
// Create the settings button.
auto settingsItem = WUX::Controls::MenuFlyoutItem{};
settingsItem.Text(RS_(L"SettingsMenuItem"));
const auto settingsToolTip = RS_(L"SettingsToolTip");
WUX::Controls::ToolTipService::SetToolTip(settingsItem, box_value(settingsToolTip));
Automation::AutomationProperties::SetHelpText(settingsItem, settingsToolTip);
WUX::Controls::SymbolIcon ico{};
ico.Symbol(WUX::Controls::Symbol::Setting);
settingsItem.Icon(ico);
settingsItem.Click({ this, &TerminalPage::_SettingsButtonOnClick });
newTabFlyout.Items().Append(settingsItem);
auto actionMap = _settings.ActionMap();
const auto settingsKeyChord{ actionMap.GetKeyBindingForAction(ShortcutAction::OpenSettings, OpenSettingsArgs{ SettingsTarget::SettingsUI }) };
if (settingsKeyChord)
{
_SetAcceleratorForMenuItem(settingsItem, settingsKeyChord);
}
// Create the command palette button.
auto commandPaletteFlyout = WUX::Controls::MenuFlyoutItem{};
commandPaletteFlyout.Text(RS_(L"CommandPaletteMenuItem"));
const auto commandPaletteToolTip = RS_(L"CommandPaletteToolTip");
WUX::Controls::ToolTipService::SetToolTip(commandPaletteFlyout, box_value(commandPaletteToolTip));
Automation::AutomationProperties::SetHelpText(commandPaletteFlyout, commandPaletteToolTip);
WUX::Controls::FontIcon commandPaletteIcon{};
commandPaletteIcon.Glyph(L"\xE945");
commandPaletteIcon.FontFamily(Media::FontFamily{ L"Segoe Fluent Icons, Segoe MDL2 Assets" });
commandPaletteFlyout.Icon(commandPaletteIcon);
commandPaletteFlyout.Click({ this, &TerminalPage::_CommandPaletteButtonOnClick });
newTabFlyout.Items().Append(commandPaletteFlyout);
const auto commandPaletteKeyChord{ actionMap.GetKeyBindingForAction(ShortcutAction::ToggleCommandPalette) };
if (commandPaletteKeyChord)
{
_SetAcceleratorForMenuItem(commandPaletteFlyout, commandPaletteKeyChord);
}
_SetAcceleratorForMenuItem(commandPaletteFlyout, commandPaletteKeyChord);
}
// Create the about button.
@ -3717,18 +3704,6 @@ namespace winrt::TerminalApp::implementation
// - The OS-localized name for the TabletInputService
winrt::hstring _getTabletServiceName()
{
auto isUwp = false;
try
{
isUwp = ::winrt::Windows::UI::Xaml::Application::Current().as<::winrt::TerminalApp::App>().Logic().IsUwp();
}
CATCH_LOG();
if (isUwp)
{
return winrt::hstring{ TabletInputServiceKey };
}
wil::unique_schandle hManager{ OpenSCManagerW(nullptr, nullptr, 0) };
if (LOG_LAST_ERROR_IF(!hManager.is_valid()))

View File

@ -99,7 +99,6 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
public:
static Model::CascadiaSettings LoadDefaults();
static Model::CascadiaSettings LoadAll();
static Model::CascadiaSettings LoadUniversal();
static winrt::hstring SettingsPath();
static winrt::hstring DefaultSettingsPath();

View File

@ -11,7 +11,6 @@ namespace Microsoft.Terminal.Settings.Model
[default_interface] runtimeclass CascadiaSettings {
static CascadiaSettings LoadDefaults();
static CascadiaSettings LoadAll();
static CascadiaSettings LoadUniversal();
static String SettingsPath { get; };
static String DefaultSettingsPath { get; };

View File

@ -18,9 +18,8 @@
#endif
// The following files are generated at build time into the "Generated Files" directory.
// defaults(-universal).h is a file containing the default json settings in a std::string_view.
// defaults.h is a file containing the default json settings in a std::string_view.
#include "defaults.h"
#include "defaults-universal.h"
// userDefault.h is like the above, but with a default template for the user's settings.json.
#include <LegacyProfileGeneratorNamespaces.h>
@ -1020,17 +1019,6 @@ void CascadiaSettings::_researchOnLoad()
}
}
// Function Description:
// - Loads a batch of settings curated for the Universal variant of the terminal app
// Arguments:
// - <none>
// Return Value:
// - a unique_ptr to a CascadiaSettings with the connection types and settings for Universal terminal
Model::CascadiaSettings CascadiaSettings::LoadUniversal()
{
return *winrt::make_self<CascadiaSettings>(std::string_view{}, DefaultUniversalJson);
}
// Function Description:
// - Creates a new CascadiaSettings object initialized with settings from the
// hard-coded defaults.json.

View File

@ -333,10 +333,6 @@
<Target Name="_TerminalAppGenerateDefaultsH" Inputs="defaults.json" Outputs="Generated Files\defaults.h" BeforeTargets="BeforeClCompile">
<Exec Command="pwsh.exe -NoProfile -ExecutionPolicy Unrestricted &quot;$(OpenConsoleDir)\tools\GenerateHeaderForJson.ps1&quot; -JsonFile defaults.json -OutPath &quot;Generated Files\defaults.h&quot; -VariableName DefaultJson" />
</Target>
<!-- A different set of defaults for Universal variant -->
<Target Name="_TerminalAppGenerateDefaultsUniversalH" Inputs="defaults-universal.json" Outputs="Generated Files\defaults-universal.h" BeforeTargets="BeforeClCompile">
<Exec Command="pwsh.exe -NoProfile -ExecutionPolicy Unrestricted &quot;$(OpenConsoleDir)\tools\GenerateHeaderForJson.ps1&quot; -JsonFile defaults-universal.json -OutPath &quot;Generated Files\defaults-universal.h&quot; -VariableName DefaultUniversalJson" />
</Target>
<!-- Same as above, but for the default settings.json template -->
<Target Name="_TerminalAppGenerateUserSettingsH" Inputs="userDefaults.json" Outputs="Generated Files\userDefaults.h" BeforeTargets="BeforeClCompile">
<Exec Command="pwsh.exe -NoProfile -ExecutionPolicy Unrestricted &quot;$(OpenConsoleDir)\tools\GenerateHeaderForJson.ps1&quot; -JsonFile userDefaults.json -OutPath &quot;Generated Files\userDefaults.h&quot; -VariableName UserSettingsJson" />

View File

@ -1,224 +0,0 @@
// THIS IS AN AUTO-GENERATED FILE! Changes to this file will be ignored.
{
"defaultProfile": "{70bfecf4-bcbb-443b-a8fa-d7ac4f7ad201}",
// Launch Settings
"initialCols": 120,
"initialRows": 30,
"launchMode": "default",
"alwaysOnTop": false,
// Selection
"copyOnSelect": false,
"copyFormatting": true,
"wordDelimiters": " /\\()\"'-.,:;<>~!@#$%^&*|+=[]{}~?\u2502",
// Tab UI
"alwaysShowTabs": true,
"showTabsInTitlebar": true,
"showTerminalTitleInTitlebar": true,
"tabWidthMode": "equal",
"useTabSwitcher": true,
// Miscellaneous
"confirmCloseAllTabs": true,
"startOnUserLogin": false,
"theme": "system",
"snapToGridOnResize": true,
"profiles":
[
{
"guid": "{70bfecf4-bcbb-443b-a8fa-d7ac4f7ad201}",
"name": "PowerShell",
"commandline": "pwsh.exe",
"icon": "ms-appx:///ProfileIcons/pwsh.png",
"colorScheme": "Campbell",
"antialiasingMode": "grayscale",
"closeOnExit": "graceful",
"cursorShape": "bar",
"fontFace": "Cascadia Mono",
"fontSize": 12,
"hidden": false,
"historySize": 9001,
"padding": "8, 8, 8, 8",
"snapOnInput": true,
"altGrAliasing": true,
"startingDirectory": "%SystemRoot%",
"useAcrylic": false,
"backgroundImage": "ms-appx:///internal-background.png",
"backgroundImageAlignment": "bottomRight",
"backgroundImageOpacity": 0.4,
"backgroundImageStretchMode": "none"
},
{
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"name": "Command Prompt",
"commandline": "%SystemRoot%\\System32\\cmd.exe",
"icon": "ms-appx:///ProfileIcons/{0caa0dad-35be-5f56-a8ff-afceeeaa6101}.png",
"colorScheme": "Campbell",
"antialiasingMode": "grayscale",
"closeOnExit": "graceful",
"cursorShape": "bar",
"fontFace": "Cascadia Mono",
"fontSize": 12,
"hidden": false,
"historySize": 9001,
"padding": "8, 8, 8, 8",
"snapOnInput": true,
"altGrAliasing": true,
"startingDirectory": "%SystemRoot%",
"useAcrylic": false,
"backgroundImage": "ms-appx:///internal-background.png",
"backgroundImageAlignment": "bottomRight",
"backgroundImageOpacity": 0.4,
"backgroundImageStretchMode": "none"
}
],
"schemes":
[
{
"name": "Campbell",
"foreground": "#CCCCCC",
"background": "#0C0C0C",
"cursorColor": "#FFFFFF",
"black": "#0C0C0C",
"red": "#C50F1F",
"green": "#13A10E",
"yellow": "#C19C00",
"blue": "#0037DA",
"purple": "#881798",
"cyan": "#3A96DD",
"white": "#CCCCCC",
"brightBlack": "#767676",
"brightRed": "#E74856",
"brightGreen": "#16C60C",
"brightYellow": "#F9F1A5",
"brightBlue": "#3B78FF",
"brightPurple": "#B4009E",
"brightCyan": "#61D6D6",
"brightWhite": "#F2F2F2"
}
],
"actions":
[
// Application-level Keys
{ "command": "closeWindow", "keys": "alt+f4" },
{ "command": "toggleFullscreen", "keys": "alt+enter" },
{ "command": "toggleFullscreen", "keys": "f11" },
{ "command": "toggleFocusMode" },
{ "command": "toggleAlwaysOnTop" },
{ "command": "openNewTabDropdown", "keys": "ctrl+shift+space" },
{ "command": "openSettings", "keys": "ctrl+," },
{ "command": { "action": "openSettings", "target": "defaultsFile" }, "keys": "ctrl+alt+," },
{ "command": "find", "keys": "ctrl+shift+f" },
{ "command": "openTabColorPicker" },
{ "command": "commandPalette", "keys":"ctrl+shift+p" },
// Tab Management
// "command": "closeTab" is unbound by default.
// The closeTab command closes a tab without confirmation, even if it has multiple panes.
{ "command": "closeOtherTabs" },
{ "command": "closeTabsAfter" },
{ "command": "newTab", "keys": "ctrl+shift+t" },
{ "command": { "action": "newTab", "index": 0 }, "keys": "ctrl+shift+1" },
{ "command": { "action": "newTab", "index": 1 }, "keys": "ctrl+shift+2" },
{ "command": { "action": "newTab", "index": 2 }, "keys": "ctrl+shift+3" },
{ "command": { "action": "newTab", "index": 3 }, "keys": "ctrl+shift+4" },
{ "command": { "action": "newTab", "index": 4 }, "keys": "ctrl+shift+5" },
{ "command": { "action": "newTab", "index": 5 }, "keys": "ctrl+shift+6" },
{ "command": { "action": "newTab", "index": 6 }, "keys": "ctrl+shift+7" },
{ "command": { "action": "newTab", "index": 7 }, "keys": "ctrl+shift+8" },
{ "command": { "action": "newTab", "index": 8 }, "keys": "ctrl+shift+9" },
{ "command": "duplicateTab", "keys": "ctrl+shift+d" },
{ "command": "nextTab", "keys": "ctrl+tab" },
{ "command": "prevTab", "keys": "ctrl+shift+tab" },
{ "command": { "action": "switchToTab", "index": 0 }, "keys": "ctrl+alt+1" },
{ "command": { "action": "switchToTab", "index": 1 }, "keys": "ctrl+alt+2" },
{ "command": { "action": "switchToTab", "index": 2 }, "keys": "ctrl+alt+3" },
{ "command": { "action": "switchToTab", "index": 3 }, "keys": "ctrl+alt+4" },
{ "command": { "action": "switchToTab", "index": 4 }, "keys": "ctrl+alt+5" },
{ "command": { "action": "switchToTab", "index": 5 }, "keys": "ctrl+alt+6" },
{ "command": { "action": "switchToTab", "index": 6 }, "keys": "ctrl+alt+7" },
{ "command": { "action": "switchToTab", "index": 7 }, "keys": "ctrl+alt+8" },
{ "command": { "action": "switchToTab", "index": 8 }, "keys": "ctrl+alt+9" },
// Pane Management
{ "command": "closePane", "keys": "ctrl+shift+w" },
{ "command": { "action": "splitPane", "split": "horizontal" }, "keys": "alt+shift+-" },
{ "command": { "action": "splitPane", "split": "vertical" }, "keys": "alt+shift+plus" },
{ "command": { "action": "resizePane", "direction": "down" }, "keys": "alt+shift+down" },
{ "command": { "action": "resizePane", "direction": "left" }, "keys": "alt+shift+left" },
{ "command": { "action": "resizePane", "direction": "right" }, "keys": "alt+shift+right" },
{ "command": { "action": "resizePane", "direction": "up" }, "keys": "alt+shift+up" },
{ "command": { "action": "moveFocus", "direction": "down" }, "keys": "alt+down" },
{ "command": { "action": "moveFocus", "direction": "left" }, "keys": "alt+left" },
{ "command": { "action": "moveFocus", "direction": "right" }, "keys": "alt+right" },
{ "command": { "action": "moveFocus", "direction": "up" }, "keys": "alt+up" },
{ "command": "togglePaneZoom" },
// Clipboard Integration
{ "command": { "action": "copy", "singleLine": false }, "keys": "ctrl+shift+c" },
{ "command": { "action": "copy", "singleLine": false }, "keys": "ctrl+insert" },
{ "command": "paste", "keys": "ctrl+shift+v" },
{ "command": "paste", "keys": "shift+insert" },
// Scrollback
{ "command": "scrollDown", "keys": "ctrl+shift+down" },
{ "command": "scrollDownPage", "keys": "ctrl+shift+pgdn" },
{ "command": "scrollUp", "keys": "ctrl+shift+up" },
{ "command": "scrollUpPage", "keys": "ctrl+shift+pgup" },
// Visual Adjustments
{ "command": { "action": "adjustFontSize", "delta": 1 }, "keys": "ctrl+plus" },
{ "command": { "action": "adjustFontSize", "delta": -1 }, "keys": "ctrl+minus" },
{ "command": "resetFontSize", "keys": "ctrl+0" },
// Other commands
{
// Select color scheme...
"name": { "key": "SetColorSchemeParentCommandName" },
"commands": [
{
"iterateOn": "schemes",
"name": "${scheme.name}",
"command": { "action": "setColorScheme", "colorScheme": "${scheme.name}" }
}
]
},
{
// New tab...
"name": { "key": "NewTabParentCommandName" },
"commands": [
{
"iterateOn": "profiles",
"icon": "${profile.icon}",
"name": "${profile.name}",
"command": { "action": "newTab", "profile": "${profile.name}" }
}
]
},
{
// Split pane...
"name": { "key": "SplitPaneParentCommandName" },
"commands": [
{
"iterateOn": "profiles",
"icon": "${profile.icon}",
"name": "${profile.name}...",
"commands": [
{
"command": { "action": "splitPane", "profile": "${profile.name}", "split": "auto" }
},
{
"command": { "action": "splitPane", "profile": "${profile.name}", "split": "vertical" }
},
{
"command": { "action": "splitPane", "profile": "${profile.name}", "split": "horizontal" }
}
]
}
]
}
]
}