further excise IsQuakeWindow

This commit is contained in:
Mike Griese
2023-09-14 13:28:21 -05:00
parent c4d31fd51e
commit a9531ab1df
6 changed files with 85 additions and 26 deletions

View File

@@ -75,6 +75,7 @@ namespace SettingsModelLocalTests
TEST_METHOD(DefaultQuakeWindowSettings);
TEST_METHOD(LayeredWindowSettings);
TEST_METHOD(LayeredOnDefaultWindowSettings);
TEST_METHOD(LayeredQuakeWindowSettings);
TEST_METHOD(TestGeneratedQuakeWindowSettings);
TEST_METHOD(LoadFragmentsWithMultipleUpdates);
@@ -2136,6 +2137,9 @@ namespace SettingsModelLocalTests
void DeserializationTests::TestGeneratedQuakeWindowSettings()
{
Log::Comment(L"This test ensures that the defaultProfile for the _quake "
L"window is resolved, even if it's unset by the user");
static constexpr std::string_view settingsJson{ R"(
{
"defaultProfile": "{6239a42c-0000-49a3-80bd-e8fdd045185c}",
@@ -2219,6 +2223,73 @@ namespace SettingsModelLocalTests
}
}
void DeserializationTests::LayeredQuakeWindowSettings()
{
static constexpr std::string_view settingsJson{ R"(
{
"defaultProfile": "{6239a42c-0000-49a3-80bd-e8fdd045185c}",
"initialRows": 5,
"initialCols": 15,
"launchMode": "default",
"windows": [
{
"name": "_quake",
"defaultProfile": "{6239a42c-1111-49a3-80bd-e8fdd045185c}",
"dockWindow": {
"side": "bottom",
"height": 0.3
},
// launchMode intentionally omitted
"minimizeToNotificationArea": false
}
],
"profiles": [
{
"name": "profile0",
"guid": "{6239a42c-0000-49a3-80bd-e8fdd045185c}",
"historySize": 1,
"commandline": "cmd.exe"
},
{
"name": "profile1",
"guid": "{6239a42c-1111-49a3-80bd-e8fdd045185c}",
"historySize": 2,
"commandline": "cmd.exe"
}
]
})" };
const auto settings{ winrt::make_self<implementation::CascadiaSettings>(settingsJson, DefaultJson) };
VERIFY_ARE_EQUAL(1u, settings->AllWindowSettings().Size());
{
const auto& windowSettings{ settings->WindowSettingsDefaults() };
VERIFY_IS_NOT_NULL(windowSettings);
VERIFY_ARE_EQUAL(5, windowSettings.InitialRows());
VERIFY_ARE_EQUAL(15, windowSettings.InitialCols());
VERIFY_ARE_EQUAL(LaunchMode::DefaultMode, windowSettings.LaunchMode());
}
{
const auto& windowSettings{ settings->WindowSettings(L"_quake") };
VERIFY_IS_NOT_NULL(windowSettings);
VERIFY_ARE_NOT_EQUAL(settings->WindowSettingsDefaults(), windowSettings);
VERIFY_ARE_EQUAL(5, windowSettings.InitialRows());
VERIFY_ARE_EQUAL(15, windowSettings.InitialCols());
// Even thought we didn't specify the launch mode in our JSON, we're
// sneakily pre-initializing the blob for the _quake window with
// FocusMode
VERIFY_ARE_EQUAL(LaunchMode::FocusMode, windowSettings.LaunchMode());
// They did, however, ask for custom docking positioning:
VERIFY_ARE_EQUAL(DockPosition::Bottom, windowSettings.DockWindow().Side());
VERIFY_ARE_EQUAL(0.3, windowSettings.DockWindow().Height());
}
}
// This test ensures GH#11597, GH#12520 don't regress.
void DeserializationTests::LoadFragmentsWithMultipleUpdates()
{

View File

@@ -52,8 +52,6 @@ namespace TerminalApp
String WindowIdForDisplay { get; };
String VirtualWorkingDirectory { get; set; };
Boolean IsQuakeWindow();
};
[default_interface] runtimeclass TerminalPage : Windows.UI.Xaml.Controls.Page, Windows.UI.Xaml.Data.INotifyPropertyChanged, IDirectKeyListener

View File

@@ -218,7 +218,7 @@ namespace winrt::TerminalApp::implementation
// that the window size is _first_ set up as something sensible, so
// leaving fullscreen returns to a reasonable size.
const auto launchMode = this->GetLaunchMode();
if (_WindowProperties->IsQuakeWindow() || WI_IsFlagSet(launchMode, LaunchMode::FocusMode))
if (WI_IsFlagSet(launchMode, LaunchMode::FocusMode))
{
_root->SetFocusMode(true);
}
@@ -230,7 +230,7 @@ namespace winrt::TerminalApp::implementation
_root->Maximized(true);
}
if (WI_IsFlagSet(launchMode, LaunchMode::FullscreenMode) && !_WindowProperties->IsQuakeWindow())
if (WI_IsFlagSet(launchMode, LaunchMode::FullscreenMode))
{
_root->SetFullscreen(true);
}
@@ -1221,19 +1221,17 @@ namespace winrt::TerminalApp::implementation
void TerminalWindow::WindowName(const winrt::hstring& name)
{
const auto oldIsQuakeMode = _WindowProperties->IsQuakeWindow();
const auto oldName = _WindowProperties->WindowName();
_WindowProperties->WindowName(name);
if (!_root)
{
return;
}
const auto newIsQuakeMode = _WindowProperties->IsQuakeWindow();
if (newIsQuakeMode != oldIsQuakeMode)
if (oldName != name)
{
// If we're entering Quake Mode from ~Focus Mode, then this will enter Focus Mode
// If we're entering Quake Mode from Focus Mode, then this will do nothing
// If we're leaving Quake Mode (we're already in Focus Mode), then this will do nothing
_root->SetFocusMode(true);
// TODO! reload settings
_IsQuakeWindowChangedHandlers(*this, nullptr);
}
}
@@ -1397,9 +1395,4 @@ namespace winrt::TerminalApp::implementation
_WindowName;
}
bool WindowProperties::IsQuakeWindow() const noexcept
{
return _WindowName == QuakeWindowName;
}
};

View File

@@ -46,7 +46,6 @@ namespace winrt::TerminalApp::implementation
void WindowId(const uint64_t& value);
winrt::hstring WindowIdForDisplay() const noexcept;
winrt::hstring WindowNameForDisplay() const noexcept;
bool IsQuakeWindow() const noexcept;
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, VirtualWorkingDirectory, _PropertyChangedHandlers, L"");
@@ -146,7 +145,6 @@ namespace winrt::TerminalApp::implementation
void WindowName(const winrt::hstring& value);
void WindowId(const uint64_t& value);
bool IsQuakeWindow() const noexcept { return _WindowProperties->IsQuakeWindow(); }
TerminalApp::WindowProperties WindowProperties() { return *_WindowProperties; }
void AttachContent(winrt::hstring content, uint32_t tabIndex);

View File

@@ -111,7 +111,6 @@ namespace TerminalApp
WindowProperties WindowProperties { get; };
void WindowName(String name);
void WindowId(UInt64 id);
Boolean IsQuakeWindow();
// See IDialogPresenter and TerminalPage's DialogPresenter for more
// information.

View File

@@ -827,13 +827,13 @@ void WindowEmperor::_checkWindowsForNotificationIcon()
// RequestsTrayIcon setting value, and combine that with the result of each
// window (which won't change during a settings reload).
bool needsIcon = _app.Logic().RequestsTrayIcon();
{
auto windows{ _windows.lock_shared() };
for (const auto& _windowThread : *windows)
{
needsIcon |= _windowThread->Logic().IsQuakeWindow();
}
}
//{
// auto windows{ _windows.lock_shared() };
// for (const auto& _windowThread : *windows)
// {
// needsIcon |= _windowThread->Logic().IsQuakeWindow();
// }
//}
if (needsIcon)
{