-
Notifications
You must be signed in to change notification settings - Fork 9k
Persist quake window size #19580
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
Open
metal-gabe
wants to merge
6
commits into
microsoft:main
Choose a base branch
from
metal-gabe:persist-quake-window-size
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Persist quake window size #19580
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e45d7ad
feat(persist-quake-window-size): add logic to track, store & retrieve…
metal-gabe 7bbd275
feat(persist-quake-window-size): fix window rect height issue;
metal-gabe 08e325a
feat(persist-quake-window-size): add logic to open quake window on cu…
metal-gabe d8a5768
feat(persist-quake-window-size): update var names to match convention;
metal-gabe 892963d
feat(persist-quake-window-size): update var names to match convention;
metal-gabe 7f5b40d
feat(persist-quake-window-size): add expected check-spelling keyword;
metal-gabe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -554,6 +554,7 @@ exemain | |
| EXETYPE | ||
| exeuwp | ||
| exewin | ||
| EXITSIZEMOVE | ||
| exitwin | ||
| EXPUNGECOMMANDHISTORY | ||
| EXSTYLE | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,6 +65,14 @@ AppHost::AppHost(WindowEmperor* manager, const winrt::TerminalApp::AppLogic& log | |
| // Update our own internal state tracking if we're in quake mode or not. | ||
| _IsQuakeWindowChanged(nullptr, nullptr); | ||
|
|
||
| const auto state = ApplicationState::SharedInstance(); | ||
| const auto savedPercent = static_cast<float>(state.QuakeWindowSizePercent()); | ||
| _window->SetQuakeWindowSizePercent(savedPercent); | ||
|
|
||
| #ifdef _DEBUG | ||
| OutputDebugStringW(wil::str_printf<std::wstring>(L"[IslandWindow] Loaded size percent from state: %.1f%%\n", savedPercent * 100.0f).c_str()); | ||
| #endif | ||
|
|
||
| _window->SetMinimizeToNotificationAreaBehavior(_windowLogic.GetMinimizeToNotificationArea()); | ||
|
|
||
| // Tell the window to callback to us when it's about to handle a WM_CREATE | ||
|
|
@@ -75,6 +83,7 @@ AppHost::AppHost(WindowEmperor* manager, const winrt::TerminalApp::AppLogic& log | |
| _windowCallbacks.WindowActivated = _window->WindowActivated({ this, &AppHost::_WindowActivated }); | ||
| _windowCallbacks.WindowMoved = _window->WindowMoved({ this, &AppHost::_WindowMoved }); | ||
| _windowCallbacks.ShouldExitFullscreen = _window->ShouldExitFullscreen({ &_windowLogic, &winrt::TerminalApp::TerminalWindow::RequestExitFullscreen }); | ||
| _windowCallbacks.QuakeWindowSizeChanged = _window->QuakeWindowSizeChanged({ this, &AppHost::_QuakeWindowSizeChanged }); | ||
|
|
||
| _window->MakeWindow(); | ||
|
|
||
|
|
@@ -391,6 +400,7 @@ void AppHost::_revokeWindowCallbacks() | |
| _window->DragRegionClicked(_windowCallbacks.DragRegionClicked); | ||
| _window->WindowVisibilityChanged(_windowCallbacks.WindowVisibilityChanged); | ||
| _window->MaximizeChanged(_windowCallbacks.MaximizeChanged); | ||
| _window->QuakeWindowSizeChanged(_windowCallbacks.QuakeWindowSizeChanged); | ||
| } | ||
|
|
||
| // Method Description: | ||
|
|
@@ -558,17 +568,32 @@ void AppHost::_initialResizeAndRepositionWindow(const HWND hwnd, til::rect propo | |
|
|
||
| if (_windowLogic.IsQuakeWindow()) | ||
| { | ||
| // 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 auto availableSpace = desktopDimensions + nonClientSize; | ||
| // Get cursor monitor for quake windows - the window should appear | ||
| // on the monitor where the cursor is, not the proposed window location | ||
| POINT cursorPos{}; | ||
| GetCursorPos(&cursorPos); | ||
| auto hmon = MonitorFromPoint(cursorPos, MONITOR_DEFAULTTONEAREST); | ||
|
|
||
| MONITORINFO cursorMonitorInfo{}; | ||
| cursorMonitorInfo.cbSize = sizeof(MONITORINFO); | ||
| GetMonitorInfo(hmon, &cursorMonitorInfo); | ||
|
|
||
| UINT dpiX = USER_DEFAULT_SCREEN_DPI; | ||
| UINT dpiY = USER_DEFAULT_SCREEN_DPI; | ||
| GetDpiForMonitor(hmon, MDT_EFFECTIVE_DPI, &dpiX, &dpiY); | ||
|
|
||
| const til::rect workArea{ cursorMonitorInfo.rcWork }; | ||
| const auto nonClientSize = _window->GetTotalNonClientExclusiveSize(dpiX); | ||
| const auto availableSpace = til::size{ workArea.width(), workArea.height() } + nonClientSize; | ||
| const auto savedPercent = ApplicationState::SharedInstance().QuakeWindowSizePercent(); | ||
|
|
||
| origin = { | ||
| (nearestMonitorInfo.rcWork.left - (nonClientSize.width / 2)), | ||
| (nearestMonitorInfo.rcWork.top) | ||
| (cursorMonitorInfo.rcWork.left - (nonClientSize.width / 2)) + 1, | ||
| cursorMonitorInfo.rcWork.top | ||
| }; | ||
| dimensions = { | ||
| availableSpace.width, | ||
| availableSpace.height / 2 | ||
| availableSpace.width - 2, | ||
| static_cast<til::CoordType>(availableSpace.height * savedPercent) | ||
| }; | ||
| launchMode = LaunchMode::FocusMode; | ||
| } | ||
|
|
@@ -1030,6 +1055,16 @@ void AppHost::_IsQuakeWindowChanged(const winrt::Windows::Foundation::IInspectab | |
| _window->IsQuakeWindow(_windowLogic.IsQuakeWindow()); | ||
| } | ||
|
|
||
| void AppHost::_QuakeWindowSizeChanged(float sizePercent) | ||
| { | ||
| // Persist the new quake window size to ApplicationState | ||
| ApplicationState::SharedInstance().QuakeWindowSizePercent(static_cast<double>(sizePercent)); | ||
|
|
||
| #ifdef _DEBUG | ||
|
Author
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. All debug logs that were added can be removed once this PR is ready for final review. |
||
| OutputDebugStringW(wil::str_printf<std::wstring>(L"[IslandWindow] Persisting size percent to state: %.1f%%\n", sizePercent * 100.0f).c_str()); | ||
| #endif | ||
| } | ||
|
|
||
| // Raised from TerminalWindow. We handle by bubbling the request to the window manager. | ||
| void AppHost::_RequestQuitAll(const winrt::Windows::Foundation::IInspectable&, | ||
| const winrt::Windows::Foundation::IInspectable&) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
The logic below was updated due to an issue where, after compiling/building, the very first activation would open on the main monitor (i.e. not on the current monitor that the cursor was on, which does not align with the behavior of the current release) at 50% (it wasn't using the stored size).