-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
Make the window name _quake
special
#9785
Changes from 8 commits
7560ee3
8d9c1f1
2db7fd5
04a4249
87c6c2d
34f0dfd
2a1b468
1e43eef
beb96e3
d3861c5
02e4ef7
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 |
---|---|---|
|
@@ -57,6 +57,9 @@ AppHost::AppHost() noexcept : | |
_window = std::make_unique<IslandWindow>(); | ||
} | ||
|
||
// Update our own internal state tracking if we're in quake mode or not. | ||
_IsQuakeWindowChanged(nullptr, nullptr); | ||
|
||
// Tell the window to callback to us when it's about to handle a WM_CREATE | ||
auto pfn = std::bind(&AppHost::_HandleCreateWindow, | ||
this, | ||
|
@@ -251,6 +254,7 @@ void AppHost::Initialize() | |
_logic.SetTaskbarProgress({ this, &AppHost::SetTaskbarProgress }); | ||
_logic.IdentifyWindowsRequested({ this, &AppHost::_IdentifyWindowsRequested }); | ||
_logic.RenameWindowRequested({ this, &AppHost::_RenameWindowRequested }); | ||
_logic.IsQuakeWindowChanged({ this, &AppHost::_IsQuakeWindowChanged }); | ||
|
||
_window->UpdateTitle(_logic.Title()); | ||
|
||
|
@@ -379,39 +383,58 @@ void AppHost::_HandleCreateWindow(const HWND hwnd, RECT proposedRect, LaunchMode | |
|
||
// Get the size of a window we'd need to host that client rect. This will | ||
// add the titlebar space. | ||
const auto nonClientSize = _window->GetTotalNonClientExclusiveSize(dpix); | ||
adjustedWidth = islandWidth + nonClientSize.cx; | ||
adjustedHeight = islandHeight + nonClientSize.cy; | ||
const til::size nonClientSize = _window->GetTotalNonClientExclusiveSize(dpix); | ||
adjustedWidth = islandWidth + nonClientSize.width<long>(); | ||
adjustedHeight = islandHeight + nonClientSize.height<long>(); | ||
|
||
til::size dimensions{ Utils::ClampToShortMax(adjustedWidth, 1), | ||
Utils::ClampToShortMax(adjustedHeight, 1) }; | ||
|
||
// 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 til::size desktopDimensions{ gsl::narrow<short>(nearestMonitorInfo.rcWork.right - nearestMonitorInfo.rcWork.left), | ||
gsl::narrow<short>(nearestMonitorInfo.rcWork.bottom - nearestMonitorInfo.rcWork.top) }; | ||
|
||
const COORD dimensions{ Utils::ClampToShortMax(adjustedWidth, 1), | ||
Utils::ClampToShortMax(adjustedHeight, 1) }; | ||
til::point origin{ ::base::saturated_cast<ptrdiff_t>(proposedRect.left), | ||
::base::saturated_cast<ptrdiff_t>(proposedRect.top) }; | ||
|
||
if (centerOnLaunch) | ||
if (_logic.IsQuakeWindow()) | ||
zadjii-msft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
// If we just use rcWork by itself, we'll fail to account for the invisible | ||
// space reserved for the resize handles. So retrieve that size here. | ||
const til::size ncSize{ _window->GetTotalNonClientExclusiveSize(dpix) }; | ||
const til::size availableSpace = desktopDimensions + nonClientSize; | ||
|
||
origin = til::point{ | ||
::base::saturated_cast<ptrdiff_t>(nearestMonitorInfo.rcWork.left - (nonClientSize.width() / 2)), | ||
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. I feel like this is weird. We're doing the math unprotected from over/underflow first then casting the result into Shouldn't we be doing a saturated operation on these things or casting them into the math wrappers first and then let it do the saturated subtract? The same goes for some of the other saturated casts below. Though I'm not totally clear on what the source types are here that requires us to do the cast to begin with. 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. Yea you know, I felt weird writing that. I thinkthe types are LONGs originally. Maybe lemme back that out and spend more than 30 seconds on it |
||
::base::saturated_cast<ptrdiff_t>(nearestMonitorInfo.rcWork.top) | ||
}; | ||
dimensions = til::size{ | ||
availableSpace.width(), | ||
availableSpace.height() / 2 | ||
}; | ||
launchMode = LaunchMode::FocusMode; | ||
} | ||
else 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<short>(nearestMonitorInfo.rcWork.right - nearestMonitorInfo.rcWork.left), | ||
gsl::narrow<short>(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)); | ||
origin = til::point{ | ||
::base::saturated_cast<ptrdiff_t>(nearestMonitorInfo.rcWork.left + ((desktopDimensions.width() / 2) - (dimensions.width() / 2))), | ||
::base::saturated_cast<ptrdiff_t>(nearestMonitorInfo.rcWork.top + ((desktopDimensions.height() / 2) - (dimensions.height() / 2))) | ||
}; | ||
} | ||
const COORD origin{ gsl::narrow<short>(proposedRect.left), | ||
gsl::narrow<short>(proposedRect.top) }; | ||
|
||
const auto newPos = Viewport::FromDimensions(origin, dimensions); | ||
const til::rectangle newRect{ origin, dimensions }; | ||
bool succeeded = SetWindowPos(hwnd, | ||
nullptr, | ||
newPos.Left(), | ||
newPos.Top(), | ||
newPos.Width(), | ||
newPos.Height(), | ||
newRect.left<int>(), | ||
newRect.top<int>(), | ||
newRect.width<int>(), | ||
newRect.height<int>(), | ||
SWP_NOACTIVATE | SWP_NOZORDER); | ||
|
||
// Refresh the dpi of HWND because the dpi where the window will launch may be different | ||
|
@@ -674,3 +697,9 @@ winrt::fire_and_forget AppHost::_RenameWindowRequested(const winrt::Windows::Fou | |
} | ||
} | ||
} | ||
|
||
void AppHost::_IsQuakeWindowChanged(const winrt::Windows::Foundation::IInspectable&, | ||
const winrt::Windows::Foundation::IInspectable&) | ||
{ | ||
_window->IsQuakeWindow(_logic.IsQuakeWindow()); | ||
} |
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.
Why
ToggleFocusMode
and not something likeEnableFocusMode
orSetFocusMode(true)
? QM will always be in focus mode right?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.
Frankly, I hadn't written
_SetFocusMode
yet when I added this line 😋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.
Ah, but that's a private member on TerminalPage... meh, I just didn't feel like adding another method that'll only have one usage right here