From c9ca203390bb479ca16ffa55ef7abee80fb51dd9 Mon Sep 17 00:00:00 2001 From: ComixHe Date: Fri, 8 Mar 2024 11:36:04 +0800 Subject: [PATCH] fix: incorrect scale factor has been set in qt application which load dxcb platform plugin issue: https://github.com/linuxdeepin/developer-center/issues/7431 Signed-off-by: ComixHe --- src/dbus/applicationservice.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/dbus/applicationservice.cpp b/src/dbus/applicationservice.cpp index a7671cb..2dfefa5 100644 --- a/src/dbus/applicationservice.cpp +++ b/src/dbus/applicationservice.cpp @@ -53,7 +53,8 @@ void ApplicationService::appendExtraEnvironments(QVariantMap &runtimeOptions) co { QString oldEnv; // scale factor - static QStringList scaleEnvs{"DEEPIN_WINE_SCALE=%1;", "GDK_DPI_SCALE=%1;", "QT_SCALE_FACTOR=%1;", "GDK_SCALE=%1;"}; + // NOTE: Use QT_SCREEN_SCALE_FACTOR in multi-monitor situations, as this feature may be added in the future + static QStringList scaleEnvs{"DEEPIN_WINE_SCALE=%1;", "GDK_DPI_SCALE=%1;", "QT_SCREEN_SCALE_FACTOR=%1;", "GDK_SCALE=%1;"}; auto factor = scaleFactor(); if (auto it = runtimeOptions.find("env"); it != runtimeOptions.cend()) { oldEnv = it->value(); @@ -66,6 +67,9 @@ void ApplicationService::appendExtraEnvironments(QVariantMap &runtimeOptions) co // GIO oldEnv.append(QString{"GIO_LAUNCHED_DESKTOP_FILE=%1;"}.arg(m_desktopSource.sourcePath())); + // set for dxcb platform plugin, which should use scale factor directly instead of processing double times. + oldEnv.append(QString{"D_DXCB_FORCE_OVERRIDE_HIDPI=1"}); + runtimeOptions.insert("env", oldEnv); }