Warning, file /plasma/plasma-workspace/startkde/startplasma-wayland.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002     SPDX-FileCopyrightText: 2019 Aleix Pol Gonzalez <aleixpol@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "debug.h"
0008 #include "startplasma.h"
0009 #include <KConfig>
0010 #include <KConfigGroup>
0011 #include <QDBusConnection>
0012 #include <QDBusInterface>
0013 #include <signal.h>
0014 
0015 int main(int argc, char **argv)
0016 {
0017     QCoreApplication app(argc, argv);
0018 
0019     createConfigDirectory();
0020     setupCursor(true);
0021     signal(SIGTERM, sigtermHandler);
0022 
0023     {
0024         KConfig fonts(QStringLiteral("kcmfonts"));
0025         KConfigGroup group = fonts.group("General");
0026         auto dpiSetting = group.readEntry("forceFontDPIWayland", 96);
0027         auto dpi = dpiSetting == 0 ? 96 : dpiSetting;
0028         qputenv("QT_WAYLAND_FORCE_DPI", QByteArray::number(dpi));
0029     }
0030 
0031     // Query whether org.freedesktop.locale1 is available. If it is, try to
0032     // set XKB_DEFAULT_{MODEL,LAYOUT,VARIANT,OPTIONS} accordingly.
0033     {
0034         const QString locale1Service = QStringLiteral("org.freedesktop.locale1");
0035         const QString locale1Path = QStringLiteral("/org/freedesktop/locale1");
0036         QDBusMessage message =
0037             QDBusMessage::createMethodCall(locale1Service, locale1Path, QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("GetAll"));
0038         message << locale1Service;
0039         QDBusMessage resultMessage = QDBusConnection::systemBus().call(message);
0040         if (resultMessage.type() == QDBusMessage::ReplyMessage) {
0041             QVariantMap result;
0042             QDBusArgument dbusArgument = resultMessage.arguments().at(0).value<QDBusArgument>();
0043             while (!dbusArgument.atEnd()) {
0044                 dbusArgument >> result;
0045             }
0046 
0047             auto queryAndSet = [&](const QByteArray &var, const QString &value) {
0048                 const auto r = result.value(value).toString();
0049                 if (!r.isEmpty())
0050                     qputenv(var, r.toUtf8());
0051             };
0052 
0053             queryAndSet("XKB_DEFAULT_MODEL", QStringLiteral("X11Model"));
0054             queryAndSet("XKB_DEFAULT_LAYOUT", QStringLiteral("X11Layout"));
0055             queryAndSet("XKB_DEFAULT_VARIANT", QStringLiteral("X11Variant"));
0056             queryAndSet("XKB_DEFAULT_OPTIONS", QStringLiteral("X11Options"));
0057         } else {
0058             qCWarning(PLASMA_STARTUP) << "not a reply org.freedesktop.locale1" << resultMessage;
0059         }
0060     }
0061     runEnvironmentScripts();
0062 
0063     if (!qEnvironmentVariableIsSet("DBUS_SESSION_BUS_ADDRESS")) {
0064         out << "startplasmacompositor: Could not start D-Bus. Can you call qdbus?\n";
0065         return 1;
0066     }
0067     setupPlasmaEnvironment();
0068     runStartupConfig();
0069     qputenv("PLASMA_USE_QT_SCALING", "1");
0070     qputenv("XDG_SESSION_TYPE", "wayland");
0071 
0072     auto oldSystemdEnvironment = getSystemdEnvironment();
0073     if (!syncDBusEnvironment()) {
0074         out << "Could not sync environment to dbus.\n";
0075         return 1;
0076     }
0077 
0078     // We import systemd environment after we sync the dbus environment here.
0079     // Otherwise it may leads to some unwanted order of applying environment
0080     // variables (e.g. LANG and LC_*)
0081     importSystemdEnvrionment();
0082 
0083     if (!startPlasmaSession(true))
0084         return 4;
0085 
0086     // Anything after here is logout
0087     // It is not called after shutdown/restart
0088     waitForKonqi();
0089     out << "startplasma-wayland: Shutting down...\n";
0090 
0091     // Keep for KF5; remove in KF6 (KInit will be gone then)
0092     runSync(QStringLiteral("kdeinit5_shutdown"), {});
0093 
0094     out << "startplasmacompositor: Shutting down...\n";
0095     cleanupPlasmaEnvironment(oldSystemdEnvironment);
0096     out << "startplasmacompositor: Done.\n";
0097 
0098     return 0;
0099 }