mirror of
https://github.com/microsoft/terminal.git
synced 2026-05-20 13:57:43 +00:00
account for centering too
This commit is contained in:
@@ -724,14 +724,18 @@ void AppHost::_initialResizeAndRepositionWindow(const HWND hwnd, til::rect propo
|
||||
width,
|
||||
height };
|
||||
|
||||
// TODO! account for centerOnLaunch too
|
||||
// Account for centerOnLaunch too
|
||||
const til::size fromSide = centerOnLaunch ? (til::size{ til::math::rounding,
|
||||
(availableSpace.width - width) / 2.0,
|
||||
(availableSpace.height - height) / 2.0 }) :
|
||||
(til::size{ 0, 0 });
|
||||
|
||||
switch (dockingSettings.Side())
|
||||
{
|
||||
case winrt::Microsoft::Terminal::Settings::Model::DockPosition::Top:
|
||||
{
|
||||
origin = {
|
||||
(nearestMonitorInfo.rcWork.left - (singleBorderWidth)),
|
||||
(nearestMonitorInfo.rcWork.left - (singleBorderWidth) + fromSide.width),
|
||||
(nearestMonitorInfo.rcWork.top)
|
||||
};
|
||||
break;
|
||||
@@ -739,7 +743,7 @@ void AppHost::_initialResizeAndRepositionWindow(const HWND hwnd, til::rect propo
|
||||
case winrt::Microsoft::Terminal::Settings::Model::DockPosition::Bottom:
|
||||
{
|
||||
origin = {
|
||||
(nearestMonitorInfo.rcWork.left - (singleBorderWidth)),
|
||||
(nearestMonitorInfo.rcWork.left - (singleBorderWidth) + fromSide.width),
|
||||
(nearestMonitorInfo.rcWork.bottom - singleBorderHeight - (dimensions.height))
|
||||
};
|
||||
break;
|
||||
@@ -748,7 +752,7 @@ void AppHost::_initialResizeAndRepositionWindow(const HWND hwnd, til::rect propo
|
||||
{
|
||||
origin = {
|
||||
(nearestMonitorInfo.rcWork.left - (singleBorderWidth)),
|
||||
(nearestMonitorInfo.rcWork.top)
|
||||
(nearestMonitorInfo.rcWork.top) + fromSide.height
|
||||
};
|
||||
break;
|
||||
}
|
||||
@@ -756,7 +760,7 @@ void AppHost::_initialResizeAndRepositionWindow(const HWND hwnd, til::rect propo
|
||||
{
|
||||
origin = {
|
||||
(nearestMonitorInfo.rcWork.right - (singleBorderWidth) - (dimensions.width)),
|
||||
(nearestMonitorInfo.rcWork.top)
|
||||
(nearestMonitorInfo.rcWork.top) + fromSide.height
|
||||
};
|
||||
break;
|
||||
}
|
||||
@@ -1272,7 +1276,7 @@ void AppHost::_IsQuakeWindowChanged(const winrt::Windows::Foundation::IInspectab
|
||||
const winrt::Windows::Foundation::IInspectable&)
|
||||
{
|
||||
// _window->IsQuakeWindow(_windowLogic.IsQuakeWindow());
|
||||
_window->DockSettings(_windowLogic.Docking());
|
||||
_window->DockSettings(_windowLogic.Docking(), _windowLogic.CenterOnLaunch());
|
||||
}
|
||||
|
||||
// Raised from our Peasant. We handle by propagating the call to our terminal window.
|
||||
|
||||
@@ -719,14 +719,14 @@ long IslandWindow::_calculateTotalSize(const bool isWidth, const long clientSize
|
||||
{
|
||||
const auto newWindowRect{ _getDockedSize(proposed) };
|
||||
|
||||
// Inform User32 that we want to be placed at the position
|
||||
// and dimensions that _getQuakeModeSize returned. When we
|
||||
// snap across monitor boundaries, this will re-evaluate our
|
||||
// size for the new monitor.
|
||||
lpwpos->x = newWindowRect.left;
|
||||
lpwpos->y = newWindowRect.top;
|
||||
lpwpos->cx = newWindowRect.width();
|
||||
lpwpos->cy = newWindowRect.height();
|
||||
// Inform User32 that we want to be placed at the position
|
||||
// and dimensions that _getQuakeModeSize returned. When we
|
||||
// snap across monitor boundaries, this will re-evaluate our
|
||||
// size for the new monitor.
|
||||
lpwpos->x = newWindowRect.left;
|
||||
lpwpos->y = newWindowRect.top;
|
||||
lpwpos->cx = newWindowRect.width();
|
||||
lpwpos->cy = newWindowRect.height();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1724,8 +1724,9 @@ Docking IslandWindow::DockSettings() const noexcept
|
||||
return _dockingSettings;
|
||||
}
|
||||
|
||||
void IslandWindow::DockSettings(Docking settings) noexcept
|
||||
void IslandWindow::DockSettings(Docking settings, const bool centered) noexcept
|
||||
{
|
||||
_centered = centered;
|
||||
if (_dockingSettings != settings)
|
||||
{
|
||||
_dockingSettings = settings;
|
||||
@@ -1835,14 +1836,18 @@ til::rect IslandWindow::_getDockedSize(HMONITOR hmon)
|
||||
width,
|
||||
height };
|
||||
|
||||
// TODO! account for centerOnLaunch too
|
||||
// Account for centerOnLaunch too
|
||||
const til::size fromSide = _centered ? (til::size{ til::math::rounding,
|
||||
(availableSpace.width - width) / 2.0,
|
||||
(availableSpace.height - height) / 2.0 }) :
|
||||
(til::size{ 0, 0 });
|
||||
til::point origin;
|
||||
switch (_dockingSettings.Side())
|
||||
{
|
||||
case winrt::Microsoft::Terminal::Settings::Model::DockPosition::Top:
|
||||
{
|
||||
origin = {
|
||||
(nearestMonitorInfo.rcWork.left - (singleBorderWidth)),
|
||||
(nearestMonitorInfo.rcWork.left - (singleBorderWidth) + fromSide.width),
|
||||
(nearestMonitorInfo.rcWork.top)
|
||||
};
|
||||
break;
|
||||
@@ -1850,7 +1855,7 @@ til::rect IslandWindow::_getDockedSize(HMONITOR hmon)
|
||||
case winrt::Microsoft::Terminal::Settings::Model::DockPosition::Bottom:
|
||||
{
|
||||
origin = {
|
||||
(nearestMonitorInfo.rcWork.left - (singleBorderWidth)),
|
||||
(nearestMonitorInfo.rcWork.left - (singleBorderWidth) + fromSide.width),
|
||||
(nearestMonitorInfo.rcWork.bottom - singleBorderHeight - (dimensions.height))
|
||||
};
|
||||
break;
|
||||
@@ -1859,7 +1864,7 @@ til::rect IslandWindow::_getDockedSize(HMONITOR hmon)
|
||||
{
|
||||
origin = {
|
||||
(nearestMonitorInfo.rcWork.left - (singleBorderWidth)),
|
||||
(nearestMonitorInfo.rcWork.top)
|
||||
(nearestMonitorInfo.rcWork.top) + fromSide.height
|
||||
};
|
||||
break;
|
||||
}
|
||||
@@ -1867,7 +1872,7 @@ til::rect IslandWindow::_getDockedSize(HMONITOR hmon)
|
||||
{
|
||||
origin = {
|
||||
(nearestMonitorInfo.rcWork.right - (singleBorderWidth) - (dimensions.width)),
|
||||
(nearestMonitorInfo.rcWork.top)
|
||||
(nearestMonitorInfo.rcWork.top) + fromSide.height
|
||||
};
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
winrt::fire_and_forget SummonWindow(winrt::Microsoft::Terminal::Remoting::SummonWindowBehavior args);
|
||||
|
||||
winrt::Microsoft::Terminal::Settings::Model::Docking DockSettings() const noexcept;
|
||||
void DockSettings(winrt::Microsoft::Terminal::Settings::Model::Docking settings) noexcept;
|
||||
void DockSettings(winrt::Microsoft::Terminal::Settings::Model::Docking settings, const bool centered) noexcept;
|
||||
void SetAutoHideWindow(bool autoHideWindow) noexcept;
|
||||
|
||||
void HideWindow();
|
||||
@@ -147,6 +147,7 @@ protected:
|
||||
void _moveToMonitor(const MONITORINFO activeMonitor);
|
||||
|
||||
winrt::Microsoft::Terminal::Settings::Model::Docking _dockingSettings{ nullptr };
|
||||
bool _centered{ false };
|
||||
bool _autoHideWindow{ false };
|
||||
|
||||
void _applyDocking();
|
||||
|
||||
Reference in New Issue
Block a user