From d8ca6bc08a7d505877d6af320c75ba7d77cfa897 Mon Sep 17 00:00:00 2001 From: nogunumo Date: Fri, 27 Nov 2020 15:27:00 +0900 Subject: [PATCH 1/6] Add CentreOnLaunch property --- src/cascadia/TerminalApp/AppLogic.cpp | 39 +++++++++++++++++-- src/cascadia/TerminalApp/AppLogic.h | 3 +- .../GlobalAppSettings.cpp | 5 +++ .../TerminalSettingsModel/GlobalAppSettings.h | 1 + .../GlobalAppSettings.idl | 4 ++ 5 files changed, 47 insertions(+), 5 deletions(-) diff --git a/src/cascadia/TerminalApp/AppLogic.cpp b/src/cascadia/TerminalApp/AppLogic.cpp index a6f15bea939..db5fe6f3bcd 100644 --- a/src/cascadia/TerminalApp/AppLogic.cpp +++ b/src/cascadia/TerminalApp/AppLogic.cpp @@ -4,6 +4,8 @@ #include "pch.h" #include "AppLogic.h" #include "AppLogic.g.cpp" +#include "wtypes.h" +#include "TerminalPage.h" #include #include @@ -630,17 +632,46 @@ namespace winrt::TerminalApp::implementation // - a point containing the requested initial position in pixels. TerminalApp::InitialPosition AppLogic::GetInitialPosition(int64_t defaultInitialX, int64_t defaultInitialY) { + if (!_loadedInitialSettings) { // Load settings if we haven't already LoadSettings(); } + UINT dpi = USER_DEFAULT_SCREEN_DPI; + int _width = 0; + int _height = 0; + GetDesktopResolution(_width, _height); const auto initialPosition{ _settings.GlobalSettings().InitialPosition() }; - return { - initialPosition.X ? initialPosition.X.Value() : defaultInitialX, - initialPosition.Y ? initialPosition.Y.Value() : defaultInitialY - }; + const auto CentreOnLaunch{ _settings.GlobalSettings().CentreOnLaunch() }; + const auto dimentions = GetLaunchDimensions(dpi); + const auto appWidth = dimentions.Width; + const auto appHeight = dimentions.Height; + + if (CentreOnLaunch) + { + return { + (_width / 2) - (static_cast(appWidth) / 2), + (_height / 2) - (static_cast(appHeight) / 2) + }; + } + else + { + return { + initialPosition.X ? initialPosition.X.Value() : defaultInitialX, + initialPosition.Y ? initialPosition.Y.Value() : defaultInitialY + }; + } + } + + void AppLogic::GetDesktopResolution(int& width, int& height) + { + RECT desktop; + const HWND hDesktop = GetDesktopWindow(); + GetWindowRect(hDesktop, &desktop); + width = desktop.right; + height= desktop.bottom; } winrt::Windows::UI::Xaml::ElementTheme AppLogic::GetRequestedTheme() diff --git a/src/cascadia/TerminalApp/AppLogic.h b/src/cascadia/TerminalApp/AppLogic.h index c11c1a5fc24..52cc51d148f 100644 --- a/src/cascadia/TerminalApp/AppLogic.h +++ b/src/cascadia/TerminalApp/AppLogic.h @@ -34,6 +34,7 @@ namespace winrt::TerminalApp::implementation bool Fullscreen() const; bool AlwaysOnTop() const; + void GetDesktopResolution(int& horizontal, int& vertical); Windows::Foundation::Size GetLaunchDimensions(uint32_t dpi); TerminalApp::InitialPosition GetInitialPosition(int64_t defaultInitialX, int64_t defaultInitialY); winrt::Windows::UI::Xaml::ElementTheme GetRequestedTheme(); @@ -70,7 +71,7 @@ namespace winrt::TerminalApp::implementation winrt::com_ptr _root{ nullptr }; Microsoft::Terminal::Settings::Model::CascadiaSettings _settings{ nullptr }; - + HRESULT _settingsLoadedResult; winrt::hstring _settingsLoadExceptionText{}; diff --git a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp index 28a1f1aa529..e1168e090d5 100644 --- a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp +++ b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp @@ -23,6 +23,7 @@ static constexpr std::string_view AlwaysShowTabsKey{ "alwaysShowTabs" }; static constexpr std::string_view InitialRowsKey{ "initialRows" }; static constexpr std::string_view InitialColsKey{ "initialCols" }; static constexpr std::string_view InitialPositionKey{ "initialPosition" }; +static constexpr std::string_view CentreOnLaunchKey{ "centreOnLaunch" }; static constexpr std::string_view ShowTitleInTitlebarKey{ "showTerminalTitleInTitlebar" }; static constexpr std::string_view ThemeKey{ "theme" }; static constexpr std::string_view TabWidthModeKey{ "tabWidthMode" }; @@ -104,6 +105,7 @@ winrt::com_ptr GlobalAppSettings::Copy() const globals->_WarnAboutLargePaste = _WarnAboutLargePaste; globals->_WarnAboutMultiLinePaste = _WarnAboutMultiLinePaste; globals->_InitialPosition = _InitialPosition; + globals->_CentreOnLaunch = _CentreOnLaunch; globals->_LaunchMode = _LaunchMode; globals->_SnapToGridOnResize = _SnapToGridOnResize; globals->_ForceFullRepaintRendering = _ForceFullRepaintRendering; @@ -257,6 +259,8 @@ void GlobalAppSettings::LayerJson(const Json::Value& json) JsonUtils::GetValueForKey(json, InitialPositionKey, _InitialPosition); + JsonUtils::GetValueForKey(json, CentreOnLaunchKey, _CentreOnLaunch); + JsonUtils::GetValueForKey(json, ShowTitleInTitlebarKey, _ShowTitleInTitlebar); JsonUtils::GetValueForKey(json, ShowTabsInTitlebarKey, _ShowTabsInTitlebar); @@ -369,6 +373,7 @@ Json::Value GlobalAppSettings::ToJson() const JsonUtils::SetValueForKey(json, InitialRowsKey, _InitialRows); JsonUtils::SetValueForKey(json, InitialColsKey, _InitialCols); JsonUtils::SetValueForKey(json, InitialPositionKey, _InitialPosition); + JsonUtils::SetValueForKey(json, CentreOnLaunchKey, _CentreOnLaunch); JsonUtils::SetValueForKey(json, ShowTitleInTitlebarKey, _ShowTitleInTitlebar); JsonUtils::SetValueForKey(json, ShowTabsInTitlebarKey, _ShowTabsInTitlebar); JsonUtils::SetValueForKey(json, WordDelimitersKey, _WordDelimiters); diff --git a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.h b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.h index 29c4fbda7e0..8c4c9d150b1 100644 --- a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.h +++ b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.h @@ -75,6 +75,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation GETSET_SETTING(bool, WarnAboutLargePaste, true); GETSET_SETTING(bool, WarnAboutMultiLinePaste, true); GETSET_SETTING(Model::LaunchPosition, InitialPosition, nullptr, nullptr); + GETSET_SETTING(bool, CentreOnLaunch, false); GETSET_SETTING(Model::LaunchMode, LaunchMode, LaunchMode::DefaultMode); GETSET_SETTING(bool, SnapToGridOnResize, true); GETSET_SETTING(bool, ForceFullRepaintRendering, false); diff --git a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.idl b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.idl index 6d427b4ec5b..ef99022bfef 100644 --- a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.idl +++ b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.idl @@ -95,6 +95,10 @@ namespace Microsoft.Terminal.Settings.Model void ClearInitialPosition(); LaunchPosition InitialPosition; + Boolean HasCentreOnLaunch(); + void ClearCentreOnLaunch(); + Boolean CentreOnLaunch; + Boolean HasLaunchMode(); void ClearLaunchMode(); LaunchMode LaunchMode; From 5f27ad5491f55126a1854a5f3f3e44aafdd51b68 Mon Sep 17 00:00:00 2001 From: nogunumo Date: Fri, 27 Nov 2020 23:20:52 +0900 Subject: [PATCH 2/6] code format --- src/cascadia/TerminalApp/AppLogic.cpp | 4 +--- src/cascadia/TerminalApp/AppLogic.h | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/cascadia/TerminalApp/AppLogic.cpp b/src/cascadia/TerminalApp/AppLogic.cpp index db5fe6f3bcd..66c2ed8929a 100644 --- a/src/cascadia/TerminalApp/AppLogic.cpp +++ b/src/cascadia/TerminalApp/AppLogic.cpp @@ -5,7 +5,6 @@ #include "AppLogic.h" #include "AppLogic.g.cpp" #include "wtypes.h" -#include "TerminalPage.h" #include #include @@ -632,7 +631,6 @@ namespace winrt::TerminalApp::implementation // - a point containing the requested initial position in pixels. TerminalApp::InitialPosition AppLogic::GetInitialPosition(int64_t defaultInitialX, int64_t defaultInitialY) { - if (!_loadedInitialSettings) { // Load settings if we haven't already @@ -671,7 +669,7 @@ namespace winrt::TerminalApp::implementation const HWND hDesktop = GetDesktopWindow(); GetWindowRect(hDesktop, &desktop); width = desktop.right; - height= desktop.bottom; + height = desktop.bottom; } winrt::Windows::UI::Xaml::ElementTheme AppLogic::GetRequestedTheme() diff --git a/src/cascadia/TerminalApp/AppLogic.h b/src/cascadia/TerminalApp/AppLogic.h index 52cc51d148f..bd81659d5a2 100644 --- a/src/cascadia/TerminalApp/AppLogic.h +++ b/src/cascadia/TerminalApp/AppLogic.h @@ -71,7 +71,7 @@ namespace winrt::TerminalApp::implementation winrt::com_ptr _root{ nullptr }; Microsoft::Terminal::Settings::Model::CascadiaSettings _settings{ nullptr }; - + HRESULT _settingsLoadedResult; winrt::hstring _settingsLoadExceptionText{}; From 6a3a852e8c937da5ae3dfc2e10455bece9f24104 Mon Sep 17 00:00:00 2001 From: nogunumo Date: Sun, 29 Nov 2020 17:16:52 +0900 Subject: [PATCH 3/6] correct spelling --- src/cascadia/TerminalApp/AppLogic.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cascadia/TerminalApp/AppLogic.cpp b/src/cascadia/TerminalApp/AppLogic.cpp index 66c2ed8929a..30a1733a0c6 100644 --- a/src/cascadia/TerminalApp/AppLogic.cpp +++ b/src/cascadia/TerminalApp/AppLogic.cpp @@ -643,9 +643,9 @@ namespace winrt::TerminalApp::implementation GetDesktopResolution(_width, _height); const auto initialPosition{ _settings.GlobalSettings().InitialPosition() }; const auto CentreOnLaunch{ _settings.GlobalSettings().CentreOnLaunch() }; - const auto dimentions = GetLaunchDimensions(dpi); - const auto appWidth = dimentions.Width; - const auto appHeight = dimentions.Height; + const auto dimensions = GetLaunchDimensions(dpi); + const auto appWidth = dimensions.Width; + const auto appHeight = dimensions.Height; if (CentreOnLaunch) { From c79b4c8d0570579691352e91a3776df666caba76 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Thu, 4 Feb 2021 07:10:21 -0600 Subject: [PATCH 4/6] this seems to work --- src/cascadia/TerminalApp/AppLogic.cpp | 45 +++++++++---------- src/cascadia/TerminalApp/AppLogic.h | 2 +- src/cascadia/TerminalApp/AppLogic.idl | 1 + .../GlobalAppSettings.cpp | 8 ++-- .../TerminalSettingsModel/GlobalAppSettings.h | 2 +- .../GlobalAppSettings.idl | 6 +-- src/cascadia/WindowsTerminal/AppHost.cpp | 22 ++++++++- 7 files changed, 51 insertions(+), 35 deletions(-) diff --git a/src/cascadia/TerminalApp/AppLogic.cpp b/src/cascadia/TerminalApp/AppLogic.cpp index 63ecbad0156..4b0c55e8fa4 100644 --- a/src/cascadia/TerminalApp/AppLogic.cpp +++ b/src/cascadia/TerminalApp/AppLogic.cpp @@ -655,40 +655,37 @@ namespace winrt::TerminalApp::implementation } UINT dpi = USER_DEFAULT_SCREEN_DPI; - int _width = 0; - int _height = 0; - GetDesktopResolution(_width, _height); const auto initialPosition{ _settings.GlobalSettings().InitialPosition() }; - const auto CentreOnLaunch{ _settings.GlobalSettings().CentreOnLaunch() }; const auto dimensions = GetLaunchDimensions(dpi); const auto appWidth = dimensions.Width; const auto appHeight = dimensions.Height; - if (CentreOnLaunch) - { - return { - (_width / 2) - (static_cast(appWidth) / 2), - (_height / 2) - (static_cast(appHeight) / 2) - }; - } - else - { - return { - initialPosition.X ? initialPosition.X.Value() : defaultInitialX, - initialPosition.Y ? initialPosition.Y.Value() : defaultInitialY - }; - } + return { + initialPosition.X ? initialPosition.X.Value() : defaultInitialX, + initialPosition.Y ? initialPosition.Y.Value() : defaultInitialY + }; } - void AppLogic::GetDesktopResolution(int& width, int& height) + bool AppLogic::CenterOnLaunch() { - RECT desktop; - const HWND hDesktop = GetDesktopWindow(); - GetWindowRect(hDesktop, &desktop); - width = desktop.right; - height = desktop.bottom; + if (!_loadedInitialSettings) + { + // Load settings if we haven't already + LoadSettings(); + } + return _settings.GlobalSettings().CenterOnLaunch(); } + // Windows::Foundation::Size AppLogic::_GetDesktopSize() + // { + // RECT desktop; + // const HWND hDesktop = GetDesktopWindow(); + // GetWindowRect(hDesktop, &desktop); + // width = desktop.right; + // height = desktop.bottom; + // return { desktop.right - desktop.left, desktop.bottom - desktop.top }; + // } + winrt::Windows::UI::Xaml::ElementTheme AppLogic::GetRequestedTheme() { if (!_loadedInitialSettings) diff --git a/src/cascadia/TerminalApp/AppLogic.h b/src/cascadia/TerminalApp/AppLogic.h index 6269fc04f89..c0832136006 100644 --- a/src/cascadia/TerminalApp/AppLogic.h +++ b/src/cascadia/TerminalApp/AppLogic.h @@ -37,8 +37,8 @@ namespace winrt::TerminalApp::implementation bool Fullscreen() const; bool AlwaysOnTop() const; - void GetDesktopResolution(int& horizontal, int& vertical); Windows::Foundation::Size GetLaunchDimensions(uint32_t dpi); + bool CenterOnLaunch(); TerminalApp::InitialPosition GetInitialPosition(int64_t defaultInitialX, int64_t defaultInitialY); winrt::Windows::UI::Xaml::ElementTheme GetRequestedTheme(); Microsoft::Terminal::Settings::Model::LaunchMode GetLaunchMode(); diff --git a/src/cascadia/TerminalApp/AppLogic.idl b/src/cascadia/TerminalApp/AppLogic.idl index 3abf62eb12a..5422efce20c 100644 --- a/src/cascadia/TerminalApp/AppLogic.idl +++ b/src/cascadia/TerminalApp/AppLogic.idl @@ -43,6 +43,7 @@ namespace TerminalApp Boolean AlwaysOnTop { get; }; Windows.Foundation.Size GetLaunchDimensions(UInt32 dpi); + Boolean CenterOnLaunch { get; }; InitialPosition GetInitialPosition(Int64 defaultInitialX, Int64 defaultInitialY); Windows.UI.Xaml.ElementTheme GetRequestedTheme(); diff --git a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp index 70bdf7650fc..91aec00f43f 100644 --- a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp +++ b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp @@ -23,7 +23,7 @@ static constexpr std::string_view AlwaysShowTabsKey{ "alwaysShowTabs" }; static constexpr std::string_view InitialRowsKey{ "initialRows" }; static constexpr std::string_view InitialColsKey{ "initialCols" }; static constexpr std::string_view InitialPositionKey{ "initialPosition" }; -static constexpr std::string_view CentreOnLaunchKey{ "centreOnLaunch" }; +static constexpr std::string_view CenterOnLaunchKey{ "centerOnLaunch" }; static constexpr std::string_view ShowTitleInTitlebarKey{ "showTerminalTitleInTitlebar" }; static constexpr std::string_view ThemeKey{ "theme" }; static constexpr std::string_view TabWidthModeKey{ "tabWidthMode" }; @@ -106,7 +106,7 @@ winrt::com_ptr GlobalAppSettings::Copy() const globals->_WarnAboutLargePaste = _WarnAboutLargePaste; globals->_WarnAboutMultiLinePaste = _WarnAboutMultiLinePaste; globals->_InitialPosition = _InitialPosition; - globals->_CentreOnLaunch = _CentreOnLaunch; + globals->_CenterOnLaunch = _CenterOnLaunch; globals->_LaunchMode = _LaunchMode; globals->_SnapToGridOnResize = _SnapToGridOnResize; globals->_ForceFullRepaintRendering = _ForceFullRepaintRendering; @@ -262,7 +262,7 @@ void GlobalAppSettings::LayerJson(const Json::Value& json) JsonUtils::GetValueForKey(json, InitialPositionKey, _InitialPosition); - JsonUtils::GetValueForKey(json, CentreOnLaunchKey, _CentreOnLaunch); + JsonUtils::GetValueForKey(json, CenterOnLaunchKey, _CenterOnLaunch); JsonUtils::GetValueForKey(json, ShowTitleInTitlebarKey, _ShowTitleInTitlebar); @@ -383,7 +383,7 @@ Json::Value GlobalAppSettings::ToJson() const JsonUtils::SetValueForKey(json, InitialRowsKey, _InitialRows); JsonUtils::SetValueForKey(json, InitialColsKey, _InitialCols); JsonUtils::SetValueForKey(json, InitialPositionKey, _InitialPosition); - JsonUtils::SetValueForKey(json, CentreOnLaunchKey, _CentreOnLaunch); + JsonUtils::SetValueForKey(json, CenterOnLaunchKey, _CenterOnLaunch); JsonUtils::SetValueForKey(json, ShowTitleInTitlebarKey, _ShowTitleInTitlebar); JsonUtils::SetValueForKey(json, ShowTabsInTitlebarKey, _ShowTabsInTitlebar); JsonUtils::SetValueForKey(json, WordDelimitersKey, _WordDelimiters); diff --git a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.h b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.h index 258ae77dcb0..fa7530d30d7 100644 --- a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.h +++ b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.h @@ -76,7 +76,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation GETSET_SETTING(bool, WarnAboutLargePaste, true); GETSET_SETTING(bool, WarnAboutMultiLinePaste, true); GETSET_SETTING(Model::LaunchPosition, InitialPosition, nullptr, nullptr); - GETSET_SETTING(bool, CentreOnLaunch, false); + GETSET_SETTING(bool, CenterOnLaunch, false); GETSET_SETTING(Model::LaunchMode, LaunchMode, LaunchMode::DefaultMode); GETSET_SETTING(bool, SnapToGridOnResize, true); GETSET_SETTING(bool, ForceFullRepaintRendering, false); diff --git a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.idl b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.idl index 65e66408748..d7b72d3b116 100644 --- a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.idl +++ b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.idl @@ -95,9 +95,9 @@ namespace Microsoft.Terminal.Settings.Model void ClearInitialPosition(); LaunchPosition InitialPosition; - Boolean HasCentreOnLaunch(); - void ClearCentreOnLaunch(); - Boolean CentreOnLaunch; + Boolean HasCenterOnLaunch(); + void ClearCenterOnLaunch(); + Boolean CenterOnLaunch; Boolean HasLaunchMode(); void ClearLaunchMode(); diff --git a/src/cascadia/WindowsTerminal/AppHost.cpp b/src/cascadia/WindowsTerminal/AppHost.cpp index 57043b0ed13..62d73287bc8 100644 --- a/src/cascadia/WindowsTerminal/AppHost.cpp +++ b/src/cascadia/WindowsTerminal/AppHost.cpp @@ -315,6 +315,7 @@ void AppHost::_HandleCreateWindow(const HWND hwnd, RECT proposedRect, LaunchMode // Acquire the actual initial position auto initialPos = _logic.GetInitialPosition(proposedRect.left, proposedRect.top); + const auto centerOnLaunch = _logic.CenterOnLaunch(); proposedRect.left = static_cast(initialPos.X); proposedRect.top = static_cast(initialPos.Y); @@ -374,11 +375,28 @@ void AppHost::_HandleCreateWindow(const HWND hwnd, RECT proposedRect, LaunchMode adjustedWidth = islandWidth + nonClientSize.cx; adjustedHeight = islandHeight + nonClientSize.cy; - const COORD origin{ gsl::narrow(proposedRect.left), - gsl::narrow(proposedRect.top) }; const COORD dimensions{ Utils::ClampToShortMax(adjustedWidth, 1), Utils::ClampToShortMax(adjustedHeight, 1) }; + if (centerOnLaunch) + { + // Find nearest monitor for the position that we've actually settled on + HMONITOR hMonNearest = MonitorFromRect(&proposedRect, MONITOR_DEFAULTTONEAREST); + MONITORINFO nearestMonitorInfo; + nearestMonitorInfo.cbSize = sizeof(MONITORINFO); + // Get monitor dimensions: + GetMonitorInfo(hMonNearest, &nearestMonitorInfo); + const COORD desktopDimensions{ gsl::narrow(nearestMonitorInfo.rcWork.right - nearestMonitorInfo.rcWork.left), + gsl::narrow(nearestMonitorInfo.rcWork.bottom - nearestMonitorInfo.rcWork.top) }; + // Move our proposed location into the center of that specific monitor. + proposedRect.left = nearestMonitorInfo.rcWork.left + + ((desktopDimensions.X / 2) - (dimensions.X / 2)); + proposedRect.top = nearestMonitorInfo.rcWork.top + + ((desktopDimensions.Y / 2) - (dimensions.Y / 2)); + } + const COORD origin{ gsl::narrow(proposedRect.left), + gsl::narrow(proposedRect.top) }; + const auto newPos = Viewport::FromDimensions(origin, dimensions); bool succeeded = SetWindowPos(hwnd, nullptr, From 7c0042da3e5ebd88c33c628f1c066f6179c34378 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Thu, 4 Feb 2021 07:11:35 -0600 Subject: [PATCH 5/6] some cleanup --- src/cascadia/TerminalApp/AppLogic.cpp | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/cascadia/TerminalApp/AppLogic.cpp b/src/cascadia/TerminalApp/AppLogic.cpp index 4b0c55e8fa4..9fb44f0a30c 100644 --- a/src/cascadia/TerminalApp/AppLogic.cpp +++ b/src/cascadia/TerminalApp/AppLogic.cpp @@ -4,7 +4,6 @@ #include "pch.h" #include "AppLogic.h" #include "AppLogic.g.cpp" -#include "wtypes.h" #include #include @@ -654,12 +653,7 @@ namespace winrt::TerminalApp::implementation LoadSettings(); } - UINT dpi = USER_DEFAULT_SCREEN_DPI; const auto initialPosition{ _settings.GlobalSettings().InitialPosition() }; - const auto dimensions = GetLaunchDimensions(dpi); - const auto appWidth = dimensions.Width; - const auto appHeight = dimensions.Height; - return { initialPosition.X ? initialPosition.X.Value() : defaultInitialX, initialPosition.Y ? initialPosition.Y.Value() : defaultInitialY @@ -676,16 +670,6 @@ namespace winrt::TerminalApp::implementation return _settings.GlobalSettings().CenterOnLaunch(); } - // Windows::Foundation::Size AppLogic::_GetDesktopSize() - // { - // RECT desktop; - // const HWND hDesktop = GetDesktopWindow(); - // GetWindowRect(hDesktop, &desktop); - // width = desktop.right; - // height = desktop.bottom; - // return { desktop.right - desktop.left, desktop.bottom - desktop.top }; - // } - winrt::Windows::UI::Xaml::ElementTheme AppLogic::GetRequestedTheme() { if (!_loadedInitialSettings) From c3b10e71be9ea63af6b451300b1dee6ce98451e3 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Mon, 8 Feb 2021 12:42:47 -0600 Subject: [PATCH 6/6] update schema --- doc/cascadia/profiles.schema.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/cascadia/profiles.schema.json b/doc/cascadia/profiles.schema.json index bf1bad790fb..7d544f946bd 100644 --- a/doc/cascadia/profiles.schema.json +++ b/doc/cascadia/profiles.schema.json @@ -629,6 +629,11 @@ "description": "When set to true, tabs are always displayed. When set to false and \"showTabsInTitlebar\" is set to false, tabs only appear after opening a new tab.", "type": "boolean" }, + "centerOnLaunch": { + "default": false, + "description": "When set to `true`, the terminal window will auto-center itself on the display it opens on. The terminal will use the \"initialPosition\" to determine which display to open on.", + "type": "boolean" + }, "copyOnSelect": { "default": false, "description": "When set to true, a selection is immediately copied to your clipboard upon creation. When set to false, the selection persists and awaits further action.",