From 021decb43375ac1fdfd14cc5d5e6efaa81e11848 Mon Sep 17 00:00:00 2001 From: reionwong Date: Sun, 8 Aug 2021 20:45:55 +0800 Subject: [PATCH] Fix HiDPI --- session/application.cpp | 9 +----- settings-daemon/theme/thememanager.cpp | 45 +++++++------------------- 2 files changed, 12 insertions(+), 42 deletions(-) diff --git a/session/application.cpp b/session/application.cpp index af5d074..7324d0d 100644 --- a/session/application.cpp +++ b/session/application.cpp @@ -138,14 +138,7 @@ void Application::initEnvironments() qputenv("QT_QPA_PLATFORMTHEME", "cutefish"); qputenv("QT_PLATFORM_PLUGIN", "cutefish"); - qunsetenv("QT_SCALE_FACTOR"); - qunsetenv("QT_SCREEN_SCALE_FACTORS"); - qunsetenv("QT_ENABLE_HIGHDPI_SCALING"); - qunsetenv("QT_USE_PHYSICAL_DPI"); - qunsetenv("QT_FONT_DPI"); - qputenv("QT_SCALE_FACTOR_ROUNDING_POLICY", "PassThrough"); - - qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "1"); + qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "0"); // IM Config qputenv("GTK_IM_MODULE", "fcitx5"); diff --git a/settings-daemon/theme/thememanager.cpp b/settings-daemon/theme/thememanager.cpp index 6b9ec0f..b56a199 100644 --- a/settings-daemon/theme/thememanager.cpp +++ b/settings-daemon/theme/thememanager.cpp @@ -158,41 +158,18 @@ qreal ThemeManager::devicePixelRatio() void ThemeManager::setDevicePixelRatio(qreal ratio) { - m_settings->setValue(s_devicePixelRatio, ratio); - - // Set font dpi - // ref kscreen. - if (qFuzzyCompare(ratio, 1.0)) { - const int scaleDpi = qRound(ratio * 96.0); - QProcess proc; - proc.start(QStringLiteral("xrdb"), {QStringLiteral("-quiet"), QStringLiteral("-merge"), QStringLiteral("-nocpp")}); - if (proc.waitForStarted()) { - proc.write(QByteArray("Xft.dpi: " + QString::number(scaleDpi).toLatin1())); - proc.closeWriteChannel(); - proc.waitForFinished(); - } - - // if dpi is the default (96) remove the entry rather than setting it -// QProcess proc; -// proc.start(QStringLiteral("xrdb"), {QStringLiteral("-quiet"), QStringLiteral("-remove"), QStringLiteral("-nocpp")}); -// if (proc.waitForStarted()) { -// proc.write(QByteArray("Xft.dpi\n")); -// proc.closeWriteChannel(); -// proc.waitForFinished(); -// } - - m_settings->setValue("forceFontDPI", 96); - } else { - const int scaleDpi = qRound(ratio * 96.0); - QProcess proc; - proc.start(QStringLiteral("xrdb"), {QStringLiteral("-quiet"), QStringLiteral("-merge"), QStringLiteral("-nocpp")}); - if (proc.waitForStarted()) { - proc.write(QByteArray("Xft.dpi: " + QString::number(scaleDpi).toLatin1())); - proc.closeWriteChannel(); - proc.waitForFinished(); - } - m_settings->setValue("forceFontDPI", scaleDpi); + int scaleDpi = qRound(ratio * 96.0); + QProcess process; + process.start(QStringLiteral("xrdb"), {QStringLiteral("-quiet"), QStringLiteral("-merge"), QStringLiteral("-nocpp")}); + + if (process.waitForStarted()) { + process.write(QByteArray("Xft.dpi: " + QString::number(scaleDpi).toLatin1())); + process.closeWriteChannel(); + process.waitForFinished(); } + + m_settings->setValue(s_devicePixelRatio, ratio); + m_settings->setValue("forceFontDPI", scaleDpi); } QString ThemeManager::wallpaper()