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
wilder-5.22
Nate Graham 5 years ago
parent 736218793a
commit 40067fdf7f
  1. 5
      kcms/fonts/fonts.cpp
  2. 15
      kcms/fonts/fontsaasettings.cpp
  3. 6
      kcms/fonts/fontsaasettingsbase.kcfg
  4. 17
      kcms/fonts/package/contents/ui/main.qml
  5. 7
      kcms/krdb/krdb.cpp
  6. 8
      startkde/startplasma-wayland.cpp

@ -130,10 +130,9 @@ void KFonts::load()
void KFonts::save() void KFonts::save()
{ {
auto dpiItem = fontsAASettings()->findItem("forceFontDPI"); auto dpiItem = fontsAASettings()->findItem("forceFontDPI");
auto dpiWaylandItem = fontsAASettings()->findItem("forceFontDPIWayland");
auto antiAliasingItem = fontsAASettings()->findItem("antiAliasing"); auto antiAliasingItem = fontsAASettings()->findItem("antiAliasing");
Q_ASSERT(dpiItem && dpiWaylandItem && antiAliasingItem); Q_ASSERT(dpiItem && antiAliasingItem);
if (dpiItem->isSaveNeeded() || dpiWaylandItem->isSaveNeeded() || antiAliasingItem->isSaveNeeded()) { if (dpiItem->isSaveNeeded() || antiAliasingItem->isSaveNeeded()) {
emit aliasingChangeApplied(); emit aliasingChangeApplied();
} }

@ -265,7 +265,6 @@ FontsAASettings::FontsAASettings(QObject *parent)
addItemInternal("subPixel", defaultSubPixel(), &FontsAASettings::subPixelChanged); addItemInternal("subPixel", defaultSubPixel(), &FontsAASettings::subPixelChanged);
addItemInternal("hinting", defaultHinting(), &FontsAASettings::hintingChanged); addItemInternal("hinting", defaultHinting(), &FontsAASettings::hintingChanged);
connect(this, &FontsAASettings::forceFontDPIWaylandChanged, this, &FontsAASettings::dpiChanged);
connect(this, &FontsAASettings::forceFontDPIChanged, this, &FontsAASettings::dpiChanged); connect(this, &FontsAASettings::forceFontDPIChanged, this, &FontsAASettings::dpiChanged);
} }
@ -318,11 +317,7 @@ void FontsAASettings::setAntiAliasing(bool antiAliasing)
int FontsAASettings::dpi() const int FontsAASettings::dpi() const
{ {
if (KWindowSystem::isPlatformWayland()) { return forceFontDPI();
return forceFontDPIWayland();
} else {
return forceFontDPI();
}
} }
void FontsAASettings::setDpi(int newDPI) void FontsAASettings::setDpi(int newDPI)
@ -330,11 +325,9 @@ void FontsAASettings::setDpi(int newDPI)
if (dpi() == newDPI) { if (dpi() == newDPI) {
return; return;
} }
if (KWindowSystem::isPlatformWayland()) {
setForceFontDPIWayland(newDPI); setForceFontDPI(newDPI);
} else {
setForceFontDPI(newDPI);
}
emit dpiChanged(); emit dpiChanged();
} }

@ -5,12 +5,8 @@
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile name="kcmfonts" /> <kcfgfile name="kcmfonts" />
<group name="General"> <group name="General">
<entry name="forceFontDPIWayland" type="UInt">
<label>Force font DPI Wayland</label>
<default>0</default>
</entry>
<entry name="forceFontDPI" type="UInt"> <entry name="forceFontDPI" type="UInt">
<label>Force font DPI X11</label> <label>Force font DPI on X11</label>
<default>0</default> <default>0</default>
</entry> </entry>
</group> </group>

@ -362,6 +362,9 @@ KCM.SimpleKCM {
RowLayout { RowLayout {
Layout.preferredWidth: formLayout.maxImplicitWidth 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 { QtControls.CheckBox {
id: dpiCheckBox id: dpiCheckBox
@ -372,13 +375,6 @@ KCM.SimpleKCM {
dpiTwiddledMessage.visible = checked 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 { KCM.SettingStateBinding {
configObject: kcm.fontsAASettings configObject: kcm.fontsAASettings
settingName: "forceFontDPI" settingName: "forceFontDPI"
@ -394,13 +390,6 @@ KCM.SimpleKCM {
to: 999 to: 999
from: 1 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 { KCM.SettingStateBinding {
configObject: kcm.fontsAASettings configObject: kcm.fontsAASettings
settingName: "forceFontDPI" settingName: "forceFontDPI"

@ -457,13 +457,8 @@ void runRdb( uint flags )
int dpi; 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()) { if (KWindowSystem::isPlatformWayland()) {
dpi = cfgfonts.readEntry( "forceFontDPIWayland", 0); dpi = 96; // Don't change the default DPI at all under wayland
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;
}
} else { } else {
dpi = cfgfonts.readEntry( "forceFontDPI", 0); dpi = cfgfonts.readEntry( "forceFontDPI", 0);
} }

@ -29,14 +29,6 @@ int main(int argc, char** argv)
createConfigDirectory(); createConfigDirectory();
setupCursor(true); 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 // Query whether org.freedesktop.locale1 is available. If it is, try to
// set XKB_DEFAULT_{MODEL,LAYOUT,VARIANT,OPTIONS} accordingly. // set XKB_DEFAULT_{MODEL,LAYOUT,VARIANT,OPTIONS} accordingly.
{ {

Loading…
Cancel
Save