From 983cc14174bb11df095e7621bd61fe42fb1ed0d8 Mon Sep 17 00:00:00 2001 From: kernyan Date: Thu, 11 Nov 2021 07:25:12 -0500 Subject: [PATCH] ui: auto scaling on resolution below 1920 x 1080 (#22842) * ui: resizable on PC by mouse drag * Revert "ui: resizable on PC by mouse drag" This reverts commit 56aa8254a2ae3f3b8a4b1f5957a51b2258780e97. * ui: auto scaling on resolution below 1920 x 1080 special case when on PC and screen resolution is exactly 1920 x 1080, we don't use fixed-sized window to account for taskbar/menubar area * Update qt_window.cc set maximum window size * keep SCALE Co-authored-by: Willem Melching --- selfdrive/ui/qt/qt_window.cc | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/selfdrive/ui/qt/qt_window.cc b/selfdrive/ui/qt/qt_window.cc index aad21e6c06..d630b560bb 100644 --- a/selfdrive/ui/qt/qt_window.cc +++ b/selfdrive/ui/qt/qt_window.cc @@ -1,11 +1,16 @@ #include "selfdrive/ui/qt/qt_window.h" void setMainWindow(QWidget *w) { - const bool wide = (QGuiApplication::primaryScreen()->size().width() >= WIDE_WIDTH) ^ - (getenv("INVERT_WIDTH") != NULL); - const float scale = util::getenv("SCALE", 1.0f); - - w->setFixedSize(QSize(wide ? WIDE_WIDTH : 1920, 1080) * scale); + const QSize sz = QGuiApplication::primaryScreen()->size(); + if (Hardware::PC() && sz.width() <= 1920 && sz.height() <= 1080 && getenv("SCALE") == nullptr) { + w->setMinimumSize(QSize(640, 480)); // allow resize smaller than fullscreen + w->setMaximumSize(QSize(2160, 1080)); + w->resize(sz); + } else { + const float scale = util::getenv("SCALE", 1.0f); + const bool wide = (sz.width() >= WIDE_WIDTH) ^ (getenv("INVERT_WIDTH") != NULL); + w->setFixedSize(QSize(wide ? WIDE_WIDTH : 1920, 1080) * scale); + } w->show(); #ifdef QCOM2