Skip to content

Commit

Permalink
Don't draw the tab strip when maximized
Browse files Browse the repository at this point in the history
  • Loading branch information
zadjii-msft committed Nov 1, 2019
1 parent 8e56bfe commit bac4be7
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 15 deletions.
9 changes: 9 additions & 0 deletions src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1329,6 +1329,15 @@ namespace winrt::TerminalApp::implementation
void TerminalPage::_ToggleFullscreen()
{
_toggleFullscreenHandlers(*this, nullptr);

_isFullscreen = !_isFullscreen;

// collapse/show the tabs themselves
_tabView.Visibility(!_isFullscreen ? Visibility::Visible : Visibility::Collapsed);

// collapse/show the row that the tabs are in.
// NaN is the special value XAML uses for "Auto" sizing.
_tabRow.Height(!_isFullscreen ? NAN : 0);
}

// -------------------------------- WinRT Events ---------------------------------
Expand Down
2 changes: 2 additions & 0 deletions src/cascadia/TerminalApp/TerminalPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ namespace winrt::TerminalApp::implementation

std::shared_ptr<ScopedResourceLoader> _resourceLoader{ nullptr };

bool _isFullscreen{ false };

void _ShowAboutDialog();
void _ShowCloseWarningDialog();

Expand Down
4 changes: 1 addition & 3 deletions src/cascadia/WindowsTerminal/IslandWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ class IslandWindow :
RECT _rcFullscreenWindowSize;
RECT _rcNonFullscreenWindowSize;

void SetIsFullscreen(const bool fFullscreenEnabled);

virtual void SetIsFullscreen(const bool fFullscreenEnabled);
void _BackupWindowSizes(const bool fCurrentIsInFullscreen);

void _ApplyWindowSize();
};
46 changes: 34 additions & 12 deletions src/cascadia/WindowsTerminal/NonClientIslandWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ void NonClientIslandWindow::OnSize(const UINT width, const UINT height)
// - <none>
void NonClientIslandWindow::_UpdateDragRegion()
{
if (_dragBar)
if (_dragBar && !_fullscreen)
{
// TODO:GH#1897 This is largely duplicated from OnSize, and we should do
// better than that.
Expand Down Expand Up @@ -248,6 +248,15 @@ void NonClientIslandWindow::_UpdateDragRegion()
winrt::check_bool(CombineRgn(_dragBarRegion.get(), nonClientRegion.get(), clientRegion.get(), RGN_OR));
winrt::check_bool(SetWindowRgn(_interopWindowHandle, _dragBarRegion.get(), true));
}
else if (_fullscreen)
{
const auto windowRect = GetWindowRect();
const auto width = windowRect.right - windowRect.left;
const auto height = windowRect.bottom - windowRect.top;

auto windowRegion = wil::unique_hrgn(CreateRectRgn(0, 0, width, height));
winrt::check_bool(SetWindowRgn(_interopWindowHandle, windowRegion.get(), true));
}
}

// Method Description:
Expand Down Expand Up @@ -551,17 +560,24 @@ RECT NonClientIslandWindow::GetMaxWindowRectInPixels(const RECT* const prcSugges
const auto cx = windowRect.right - windowRect.left;
const auto cy = windowRect.bottom - windowRect.top;

// Fill in ONLY the titlebar area. If we paint the _entirety_ of the
// window rect here, the single pixel of the bottom border (set in
// _UpdateFrameMargins) will be drawn, and blend with whatever the
// border color is.
RECT dragBarRect = GetDragAreaRect();
const auto dragHeight = RECT_HEIGHT(&dragBarRect);
dragBarRect.left = 0;
dragBarRect.right = cx;
dragBarRect.top = 0;
dragBarRect.bottom = dragHeight + yPos;
::FillRect(hdc.get(), &dragBarRect, _backgroundBrush.get());
// Don't fill in the drag region when we're fullscreen. This is
// maybe a hack - we should probably actually just be extending all
// the way to the borders of the monitor, but that's not working
// currently.
if (!_fullscreen)
{
// Fill in ONLY the titlebar area. If we paint the _entirety_ of the
// window rect here, the single pixel of the bottom border (set in
// _UpdateFrameMargins) will be drawn, and blend with whatever the
// border color is.
RECT dragBarRect = GetDragAreaRect();
const auto dragHeight = RECT_HEIGHT(&dragBarRect);
dragBarRect.left = 0;
dragBarRect.right = cx;
dragBarRect.top = 0;
dragBarRect.bottom = dragHeight + yPos;
::FillRect(hdc.get(), &dragBarRect, _backgroundBrush.get());
}

// Draw the top window border
RECT clientRect = { 0, 0, cx, yPos };
Expand Down Expand Up @@ -800,3 +816,9 @@ bool NonClientIslandWindow::_HandleWindowPosChanging(WINDOWPOS* const windowPos)
}
return true;
}

void NonClientIslandWindow::SetIsFullscreen(const bool fFullscreenEnabled)
{
IslandWindow::SetIsFullscreen(fFullscreenEnabled);
_titlebar.Visibility(!fFullscreenEnabled ? Visibility::Visible : Visibility::Collapsed);
}
2 changes: 2 additions & 0 deletions src/cascadia/WindowsTerminal/NonClientIslandWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class NonClientIslandWindow : public IslandWindow
bool _HandleWindowPosChanging(WINDOWPOS* const windowPos);
void _UpdateDragRegion();

void SetIsFullscreen(const bool fFullscreenEnabled) override;

void OnDragBarSizeChanged(winrt::Windows::Foundation::IInspectable sender, winrt::Windows::UI::Xaml::SizeChangedEventArgs eventArgs);

RECT GetMaxWindowRectInPixels(const RECT* const prcSuggested, _Out_opt_ UINT* pDpiSuggested);
Expand Down

0 comments on commit bac4be7

Please sign in to comment.