Skip to content

Commit

Permalink
cleanup code for review
Browse files Browse the repository at this point in the history
  • Loading branch information
zadjii-msft committed Jul 7, 2020
1 parent a6b7f03 commit 8fb257a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
6 changes: 6 additions & 0 deletions doc/cascadia/profiles.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"switchToTab",
"toggleBorderless",
"toggleFullscreen",
"toggleAlwaysOnTop",
"find",
"setTabColor",
"openTabColorPicker",
Expand Down Expand Up @@ -321,6 +322,11 @@
"additionalProperties": true,
"description": "Properties that affect the entire window, regardless of the profile settings.",
"properties": {
"alwaysOnTop": {
"default": false,
"description": "When set to true, the window is created on top of all other windows. If multiple windows are all \"always on top\", the most recently focused one will be the topmost",
"type": "boolean"
},
"alwaysShowTabs": {
"default": true,
"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.",
Expand Down
18 changes: 18 additions & 0 deletions src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1907,6 +1907,9 @@ namespace winrt::TerminalApp::implementation
_CreateNewTabFlyout();
}

// Reload the current value of alwaysOnTop from the settings file. This
// will let the user hot-reload this setting, but any runtime changes to
// the alwaysOnTop setting will be lost.
_isAlwayOnTop = _settings->GlobalSettings().AlwaysOnTop();
_alwaysOnTopChangedHandlers(*this, nullptr);
}
Expand Down Expand Up @@ -1991,6 +1994,12 @@ namespace winrt::TerminalApp::implementation
_UpdateTabView();
}

// Method Description:
// - Toggles always on top mode. Raises our AlwaysOnTopChanged event.
// Arguments:
// - <none>
// Return Value:
// - <none>
void TerminalPage::ToggleAlwaysOnTop()
{
_isAlwayOnTop = !_isAlwayOnTop;
Expand Down Expand Up @@ -2185,6 +2194,15 @@ namespace winrt::TerminalApp::implementation
}
}

// Method Description:
// - Returns true if we're currently in "Always on top" mode. When we're in
// always on top mode, the window should be on top of all other windows.
// If multiple windows are all "always on top", they'll maintain their own
// z-order, with all the windows on top of all other non-topmost windows.
// Arguments:
// - <none>
// Return Value:
// - true if we should be in "always on top" mode
bool TerminalPage::AlwaysOnTop() const
{
return _isAlwayOnTop;
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalApp/defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"initialCols": 120,
"initialRows": 30,
"launchMode": "default",
"alwaysOnTop": false,

// Selection
"copyOnSelect": false,
Expand Down
11 changes: 10 additions & 1 deletion src/cascadia/WindowsTerminal/IslandWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,15 @@ void IslandWindow::ToggleFullscreen()
_SetIsFullscreen(!_fullscreen);
}

// Method Description:
// - Enter or exit the "always on top" state. Before the window is created, this
// value will later be used when we create the window to create the window on
// top of all others. After the window is created, it will either enter the
// group of topmost windows, or exit the group of topmost windows.
// Arguments:
// - alwaysOnTop: whether we should be entering or exiting always on top mode.
// Return Value:
// - <none>
void IslandWindow::SetAlwaysOnTop(const bool alwaysOnTop)
{
_alwaysOnTop = alwaysOnTop;
Expand All @@ -472,7 +481,7 @@ void IslandWindow::SetAlwaysOnTop(const bool alwaysOnTop)
if (hwnd)
{
const til::rectangle windowPos{ GetWindowRect() };
SetWindowPos(GetHandle(),
SetWindowPos(hwnd,
_alwaysOnTop ? HWND_TOPMOST : HWND_NOTOPMOST,
windowPos.left<int>(),
windowPos.top<int>(),
Expand Down

1 comment on commit 8fb257a

@github-actions

This comment was marked as resolved.

Please sign in to comment.