Move font DPI syncing to kcminit

StartPlasma's fontDPI syncs the current font DPI to xrdb, which affects
font DPI for X applications (inc apps run in xwayland)

This is seldom used on wayland as with framebuffer scaling you don't
want to adjust your font DPI, but it is used by some users. As it's
xrdb, it needs to come after Xwayland is started for the wayland case.

The goal of this patch is to move towards killing the
startplasma-waylandsession binary as well as just being better design to
have these things comparmentalised.

kcminit is very early in the boot process before all GUI apps with the
exception of ksplash. I don't think this will make a big difference as
that's just a picture anyway?
wilder-5.24
David Edmundson 5 years ago
parent 4e7892ee66
commit d53fd656e8
  1. 1
      kcms/fonts/CMakeLists.txt
  2. 34
      kcms/fonts/fontinit.cpp
  3. 5
      kcms/fonts/kcm_fonts.desktop
  4. 1
      startkde/startplasma-waylandsession.cpp
  5. 1
      startkde/startplasma-x11.cpp
  6. 19
      startkde/startplasma.cpp

@ -9,6 +9,7 @@ set(kcm_fonts_PART_SRCS
fonts.cpp
fontsaasettings.cpp
kxftconfig.cpp
fontinit.cpp
../kfontinst/lib/FcEngine.cpp
../kcms-common.cpp
)

@ -0,0 +1,34 @@
/*
This file is part of the KDE project.
SPDX-FileCopyrightText: 2021 David Edmundson <davidedmundson@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <KConfig>
#include <KConfigGroup>
#include <KWindowSystem>
#include <QProcess>
extern "C" {
Q_DECL_EXPORT void kcminit_fonts()
{
KConfig cfg(QStringLiteral("kcmfonts"));
KConfigGroup fontsCfg(&cfg, "General");
QString fontDpiKey = KWindowSystem::isPlatformWayland() ? QStringLiteral("forceFontDPIWayland") : QStringLiteral("forceFontDPI");
if (!fontsCfg.hasKey(fontDpiKey)) {
return;
}
const QByteArray input = "Xft.dpi: " + QByteArray::number(fontsCfg.readEntry(fontDpiKey, 0));
QProcess p;
p.start(QStringLiteral("xrdb"), {QStringLiteral("-quiet"), QStringLiteral("-merge"), QStringLiteral("-nocpp")});
p.setProcessChannelMode(QProcess::ForwardedChannels);
p.write(input);
p.closeWriteChannel();
p.waitForFinished(-1);
}
}

@ -1,7 +1,7 @@
[Desktop Entry]
Icon=preferences-desktop-font
Type=Service
X-KDE-ServiceTypes=KCModule
X-KDE-ServiceTypes=KCModule,KCModuleInit
X-DocPath=kcontrol/fonts/index.html
X-KDE-Library=kcm_fonts
@ -10,6 +10,9 @@ X-KDE-ParentApp=kcontrol
X-KDE-System-Settings-Parent-Category=appearance
X-KDE-Weight=50
X-KDE-Init-Symbol=kcminit_fonts
X-KDE-Init-Phase=0
Name=Fonts
Name[ar]=الخطوط
Name[az]=Şriftlər

@ -10,7 +10,6 @@ int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
setupFontDpi();
QScopedPointer<QProcess, KillBeforeDeleter> ksplash;
if (!qEnvironmentVariableIsSet("KWIN_RESTART_COUNT")) {

@ -58,7 +58,6 @@ int main(int argc, char **argv)
}
setupCursor(false);
setupFontDpi();
QScopedPointer<QProcess, KillBeforeDeleter> ksplash(setupKSplash());
runEnvironmentScripts();

@ -391,25 +391,6 @@ bool syncDBusEnvironment()
return job->exec();
}
void setupFontDpi()
{
KConfig cfg(QStringLiteral("kcmfonts"));
KConfigGroup fontsCfg(&cfg, "General");
if (!fontsCfg.hasKey("forceFontDPI")) {
return;
}
// TODO port to c++?
const QByteArray input = "Xft.dpi: " + QByteArray::number(fontsCfg.readEntry("forceFontDPI", 0));
QProcess p;
p.start(QStringLiteral("xrdb"), {QStringLiteral("-quiet"), QStringLiteral("-merge"), QStringLiteral("-nocpp")});
p.setProcessChannelMode(QProcess::ForwardedChannels);
p.write(input);
p.closeWriteChannel();
p.waitForFinished(-1);
}
static bool desktopLockedAtStart = false;
QProcess *setupKSplash()

Loading…
Cancel
Save