From 2e47f53e47cdf8bba752ef6fd0a82486c5ec448a Mon Sep 17 00:00:00 2001 From: Nav Date: Mon, 4 Apr 2022 21:35:58 +0100 Subject: [PATCH] Enforced an absolute maximum when calculating minimum size for Insight window. The absolute maximum takes the user's screen size into account. --- .../InsightWindow/InsightWindow.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp index 1ba55f87..1bdaf8da 100644 --- a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp @@ -666,6 +666,18 @@ namespace Bloom void InsightWindow::adjustMinimumSize() { static const auto absoluteMinimum = QSize(900, 400); + + /* + * On X11, the QScreen::availableGeometry() function may return the full geometry of the screen, without + * accounting for reserved areas for window managers and other decorations. + * + * Because of this, we always use QScreen::geometry() and account for reserved areas ourselves. It's near + * impossible to do this accurately, so we just subtract 200 from the width and height, and hope that it's + * enough. + */ + const auto screenSize = this->screen()->availableGeometry().size(); + const auto absoluteMaximum = QSize(screenSize.width() - 200, screenSize.height() - 200); + auto minSize = QSize(); if (this->targetPackageWidget != nullptr) { @@ -682,8 +694,8 @@ namespace Bloom } this->setMinimumSize( - std::max(minSize.width(), absoluteMinimum.width()), - std::max(minSize.height(), absoluteMinimum.height()) + std::min(std::max(minSize.width(), absoluteMinimum.width()), absoluteMaximum.width()), + std::min(std::max(minSize.height(), absoluteMinimum.height()), absoluteMaximum.height()) ); }