Enforced an absolute maximum when calculating minimum size for Insight window.

The absolute maximum takes the user's screen size into account.
This commit is contained in:
Nav
2022-04-04 21:35:58 +01:00
parent e05084ebda
commit 2e47f53e47

View File

@@ -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())
);
}