From 40067fdf7f772bd20d8778b280f0bdc30c7a2429 Mon Sep 17 00:00:00 2001 From: Nate Graham Date: Wed, 30 Dec 2020 17:29:31 +0000 Subject: [PATCH] Only show "Force font DPI" feature on X11 Allowing users to manually change the font DPI independent of font sizes and the global scale is already of questionable value on X11, but on Wayland where Qt scaling is always used, it is an anachronism. So let's only show it on X11. On Wayland, people can use the global scaling feature in the KScreen KCM. See also https://phabricator.kde.org/T9500 --- kcms/fonts/fonts.cpp | 5 ++--- kcms/fonts/fontsaasettings.cpp | 15 ++++----------- kcms/fonts/fontsaasettingsbase.kcfg | 6 +----- kcms/fonts/package/contents/ui/main.qml | 17 +++-------------- kcms/krdb/krdb.cpp | 7 +------ startkde/startplasma-wayland.cpp | 8 -------- 6 files changed, 11 insertions(+), 47 deletions(-) diff --git a/kcms/fonts/fonts.cpp b/kcms/fonts/fonts.cpp index cf24db49f..c5c54919e 100644 --- a/kcms/fonts/fonts.cpp +++ b/kcms/fonts/fonts.cpp @@ -130,10 +130,9 @@ void KFonts::load() void KFonts::save() { auto dpiItem = fontsAASettings()->findItem("forceFontDPI"); - auto dpiWaylandItem = fontsAASettings()->findItem("forceFontDPIWayland"); auto antiAliasingItem = fontsAASettings()->findItem("antiAliasing"); - Q_ASSERT(dpiItem && dpiWaylandItem && antiAliasingItem); - if (dpiItem->isSaveNeeded() || dpiWaylandItem->isSaveNeeded() || antiAliasingItem->isSaveNeeded()) { + Q_ASSERT(dpiItem && antiAliasingItem); + if (dpiItem->isSaveNeeded() || antiAliasingItem->isSaveNeeded()) { emit aliasingChangeApplied(); } diff --git a/kcms/fonts/fontsaasettings.cpp b/kcms/fonts/fontsaasettings.cpp index 223cd19f3..e494b251b 100644 --- a/kcms/fonts/fontsaasettings.cpp +++ b/kcms/fonts/fontsaasettings.cpp @@ -265,7 +265,6 @@ FontsAASettings::FontsAASettings(QObject *parent) addItemInternal("subPixel", defaultSubPixel(), &FontsAASettings::subPixelChanged); addItemInternal("hinting", defaultHinting(), &FontsAASettings::hintingChanged); - connect(this, &FontsAASettings::forceFontDPIWaylandChanged, this, &FontsAASettings::dpiChanged); connect(this, &FontsAASettings::forceFontDPIChanged, this, &FontsAASettings::dpiChanged); } @@ -318,11 +317,7 @@ void FontsAASettings::setAntiAliasing(bool antiAliasing) int FontsAASettings::dpi() const { - if (KWindowSystem::isPlatformWayland()) { - return forceFontDPIWayland(); - } else { - return forceFontDPI(); - } + return forceFontDPI(); } void FontsAASettings::setDpi(int newDPI) @@ -330,11 +325,9 @@ void FontsAASettings::setDpi(int newDPI) if (dpi() == newDPI) { return; } - if (KWindowSystem::isPlatformWayland()) { - setForceFontDPIWayland(newDPI); - } else { - setForceFontDPI(newDPI); - } + + setForceFontDPI(newDPI); + emit dpiChanged(); } diff --git a/kcms/fonts/fontsaasettingsbase.kcfg b/kcms/fonts/fontsaasettingsbase.kcfg index d4b399850..22d80c0db 100644 --- a/kcms/fonts/fontsaasettingsbase.kcfg +++ b/kcms/fonts/fontsaasettingsbase.kcfg @@ -5,12 +5,8 @@ http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > - - - 0 - - + 0 diff --git a/kcms/fonts/package/contents/ui/main.qml b/kcms/fonts/package/contents/ui/main.qml index a63035bf4..64eca5001 100644 --- a/kcms/fonts/package/contents/ui/main.qml +++ b/kcms/fonts/package/contents/ui/main.qml @@ -362,6 +362,9 @@ KCM.SimpleKCM { RowLayout { Layout.preferredWidth: formLayout.maxImplicitWidth + // We don't want people messing with the font DPI on Wayland; + // they should always be using the global scaling system instead + visible: Qt.platform.pluginName === "xcb" QtControls.CheckBox { id: dpiCheckBox @@ -372,13 +375,6 @@ KCM.SimpleKCM { dpiTwiddledMessage.visible = checked } - // dpiSpinBox will set forceFontDPI or forceFontDPIWayland, - // so only one SettingStateBinding will be activated at a time. - KCM.SettingStateBinding { - configObject: kcm.fontsAASettings - settingName: "forceFontDPIWayland" - extraEnabledConditions: antiAliasingCheckBox.checked && !kcm.fontsAASettings.isAaImmutable - } KCM.SettingStateBinding { configObject: kcm.fontsAASettings settingName: "forceFontDPI" @@ -394,13 +390,6 @@ KCM.SimpleKCM { to: 999 from: 1 - // dpiSpinBox will set forceFontDPI or forceFontDPIWayland, - // so only one SettingStateBinding will be activated at a time. - KCM.SettingStateBinding { - configObject: kcm.fontsAASettings - settingName: "forceFontDPIWayland" - extraEnabledConditions: dpiCheckBox.enabled && dpiCheckBox.checked - } KCM.SettingStateBinding { configObject: kcm.fontsAASettings settingName: "forceFontDPI" diff --git a/kcms/krdb/krdb.cpp b/kcms/krdb/krdb.cpp index e004e08cb..1dc819aa3 100644 --- a/kcms/krdb/krdb.cpp +++ b/kcms/krdb/krdb.cpp @@ -457,13 +457,8 @@ void runRdb( uint flags ) int dpi; - //even though this sets up the X rdb, we want to use the value the - //user has set to use when under wayland - as X apps will be scaled by the compositor if (KWindowSystem::isPlatformWayland()) { - dpi = cfgfonts.readEntry( "forceFontDPIWayland", 0); - if (dpi == 0) { //with wayland we want xwayland to run at 96 dpi (unless set otherwise) as we have wayland scaling on top - dpi = 96; - } + dpi = 96; // Don't change the default DPI at all under wayland } else { dpi = cfgfonts.readEntry( "forceFontDPI", 0); } diff --git a/startkde/startplasma-wayland.cpp b/startkde/startplasma-wayland.cpp index 1c87b3734..9fbc8353b 100644 --- a/startkde/startplasma-wayland.cpp +++ b/startkde/startplasma-wayland.cpp @@ -29,14 +29,6 @@ int main(int argc, char** argv) createConfigDirectory(); setupCursor(true); - { - KConfig fonts(QStringLiteral("kcmfonts")); - KConfigGroup group = fonts.group("General"); - auto dpiSetting = group.readEntry("forceFontDPIWayland", 96); - auto dpi = dpiSetting == 0 ? 96 : dpiSetting; - qputenv("QT_WAYLAND_FORCE_DPI", QByteArray::number(dpi)); - } - // Query whether org.freedesktop.locale1 is available. If it is, try to // set XKB_DEFAULT_{MODEL,LAYOUT,VARIANT,OPTIONS} accordingly. {