Skip to content
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

Add and enforce minimum width #5599

Merged
4 commits merged into from
Apr 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/cascadia/WindowsTerminal/IslandWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,14 @@ LRESULT IslandWindow::_OnSizing(const WPARAM wParam, const LPARAM lParam)
// If this fails, we'll use the default of 96.
GetDpiForMonitor(hmon, MDT_EFFECTIVE_DPI, &dpix, &dpiy);

const auto widthScale = base::ClampedNumeric<float>(dpix) / USER_DEFAULT_SCREEN_DPI;
const long minWidthScaled = minimumWidth * widthScale;

const auto nonClientSize = GetTotalNonClientExclusiveSize(dpix);

auto clientWidth = winRect->right - winRect->left - nonClientSize.cx;
clientWidth = std::max(minWidthScaled, clientWidth);

auto clientHeight = winRect->bottom - winRect->top - nonClientSize.cy;

if (wParam != WMSZ_TOP && wParam != WMSZ_BOTTOM)
Expand Down
4 changes: 4 additions & 0 deletions src/cascadia/WindowsTerminal/IslandWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,8 @@ class IslandWindow :
virtual void _SetIsFullscreen(const bool fullscreenEnabled);
void _BackupWindowSizes(const bool currentIsInFullscreen);
void _ApplyWindowSize();

private:
// This minimum width allows for width the tabs fit
static constexpr long minimumWidth = 460L;
};