From d4cea1f024afc180d8e6e7dd2fbed451fb4d75b0 Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Wed, 19 Apr 2023 19:48:36 +0200 Subject: [PATCH] cabana: enable Hi-DPI support on MacOS (#27965) old-commit-hash: 475903e24486be0a5be2bb935db221832c9cd239 --- selfdrive/ui/qt/util.cc | 6 +++--- selfdrive/ui/qt/util.h | 2 +- tools/cabana/cabana.cc | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/selfdrive/ui/qt/util.cc b/selfdrive/ui/qt/util.cc index 4f52310649..2e222f5956 100644 --- a/selfdrive/ui/qt/util.cc +++ b/selfdrive/ui/qt/util.cc @@ -110,7 +110,7 @@ void sigTermHandler(int s) { qApp->quit(); } -void initApp(int argc, char *argv[]) { +void initApp(int argc, char *argv[], bool disable_hidpi) { Hardware::set_display_power(true); Hardware::set_brightness(65); @@ -118,13 +118,13 @@ void initApp(int argc, char *argv[]) { std::signal(SIGINT, sigTermHandler); std::signal(SIGTERM, sigTermHandler); + if (disable_hidpi) { #ifdef __APPLE__ - { // Get the devicePixelRatio, and scale accordingly to maintain 1:1 rendering QApplication tmp(argc, argv); qputenv("QT_SCALE_FACTOR", QString::number(1.0 / tmp.devicePixelRatio() ).toLocal8Bit()); - } #endif + } setQtSurfaceFormat(); } diff --git a/selfdrive/ui/qt/util.h b/selfdrive/ui/qt/util.h index 3188f3f9b9..5b66ec9fa4 100644 --- a/selfdrive/ui/qt/util.h +++ b/selfdrive/ui/qt/util.h @@ -19,7 +19,7 @@ void clearLayout(QLayout* layout); void setQtSurfaceFormat(); QString timeAgo(const QDateTime &date); void swagLogMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg); -void initApp(int argc, char *argv[]); +void initApp(int argc, char *argv[], bool disable_hidpi = true); QWidget* topWidget (QWidget* widget); QPixmap loadPixmap(const QString &fileName, const QSize &size = {}, Qt::AspectRatioMode aspectRatioMode = Qt::KeepAspectRatio); QPixmap bootstrapPixmap(const QString &id); diff --git a/tools/cabana/cabana.cc b/tools/cabana/cabana.cc index 2f7a560600..3556321286 100644 --- a/tools/cabana/cabana.cc +++ b/tools/cabana/cabana.cc @@ -12,7 +12,7 @@ int main(int argc, char *argv[]) { QCoreApplication::setApplicationName("Cabana"); QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts); - initApp(argc, argv); + initApp(argc, argv, false); QApplication app(argc, argv); app.setApplicationDisplayName("Cabana"); app.setWindowIcon(QIcon(":cabana-icon.png"));