fix(core): restore session-owned desktop startup

main
Reion Wong 3 weeks ago
parent efa5af4f22
commit 1da7c89496

@ -14,8 +14,8 @@ declared in `cutefish-services/CMakeLists.txt`.
For the Wayland session, install KWin Wayland and select `Cutefish (KWin
Wayland)` from the display manager. The session entry launches KWin with
Wayland enabled and starts `cutefish-session` inside the
compositor. The session starts the retained services daemon, which in turn
starts the desktop components after its D-Bus service is ready.
compositor. The session starts the retained services daemon, waits for its
D-Bus service to register, and then starts the desktop components.
## Build

@ -19,15 +19,10 @@
#include "application.h"
#include "poweradaptor.h"
#include <QStandardPaths>
#include <QProcess>
#include <QTimer>
#include <QFile>
#include <QDebug>
#include <QDir>
#include <QTranslator>
#include <QLocale>
#include <QTimer>
#include <sys/stat.h>
#include <sys/types.h>
@ -49,8 +44,7 @@ Application::Application(int &argc, char **argv)
{
initTrash();
// connect to D-Bus and register as an object:
QDBusConnection::sessionBus().registerService(QStringLiteral("com.cutefish.Services"));
// Register all service objects before publishing the well-known name.
new PowerAdaptor(m_powerManager);
QDBusConnection::sessionBus().registerObject(QStringLiteral("/com/cutefish/Services/Power"), m_powerManager);
@ -66,18 +60,7 @@ Application::Application(int &argc, char **argv)
}
}
QTimer::singleShot(10, this, &Application::invokeDesktopProcess);
}
void Application::invokeDesktopProcess()
{
// Start desktop UI component.
QDBusInterface sessionInterface("com.cutefish.Session", "/Session", "com.cutefish.Session",
QDBusConnection::sessionBus());
if (sessionInterface.isValid()) {
sessionInterface.call("startDesktopProcess");
}
QDBusConnection::sessionBus().registerService(QStringLiteral("com.cutefish.Services"));
}
void Application::initTrash()

@ -30,8 +30,6 @@
#include "power/powermanager.h"
#include "power/cpumanagement.h"
#include <QTimer>
class Application : public QApplication
{
Q_OBJECT
@ -39,7 +37,6 @@ class Application : public QApplication
public:
explicit Application(int &argc, char **argv);
void invokeDesktopProcess();
void initTrash();
private:

@ -22,17 +22,12 @@
#include <QCoreApplication>
#include <QStandardPaths>
#include <QFileInfoList>
#include <QFileInfo>
#include <QSettings>
#include <QDebug>
#include <QProcessEnvironment>
#include <QTimer>
#include <QThread>
#include <QDir>
#include <QDBusConnectionInterface>
#include <QDBusInterface>
#include <QDBusPendingCall>
#include <QDBusReply>
#include <QDBusServiceWatcher>
@ -86,9 +81,33 @@ void ProcessManager::startAfterKWinReady()
m_kwinWatcher = nullptr;
}
// The services daemon owns the Cutefish settings D-Bus service and
// starts the desktop components after that service is ready.
// Start the desktop after the services daemon has registered its D-Bus
// service so its theme and input backends are available to the shell.
const QString serviceName = QStringLiteral("com.cutefish.Services");
const auto servicesReady = [this]() {
if (m_servicesWatcher) {
m_servicesWatcher->deleteLater();
m_servicesWatcher = nullptr;
}
startDesktopProcess();
};
m_servicesWatcher = new QDBusServiceWatcher(serviceName,
QDBusConnection::sessionBus(),
QDBusServiceWatcher::WatchForRegistration,
this);
connect(m_servicesWatcher, &QDBusServiceWatcher::serviceRegistered,
this, [servicesReady](const QString &) {
servicesReady();
});
startDaemonProcess();
if (QDBusConnectionInterface *interface = QDBusConnection::sessionBus().interface()) {
const QDBusReply<bool> reply = interface->isServiceRegistered(serviceName);
if (reply.isValid() && reply.value())
servicesReady();
}
}
void ProcessManager::logout()
@ -133,9 +152,6 @@ void ProcessManager::startDesktopProcess()
m_desktopStarted = true;
// Start the desktop after the services daemon has initialized its theme module.
// In the way, there will be no problem that desktop and launcher can't get wallpaper.
QList<QPair<QString, QStringList>> list;
// Desktop components
// The status bar, dock, launcher, desktop and notifications are one process now.
@ -184,8 +200,7 @@ void ProcessManager::startDesktopProcess()
void ProcessManager::startDaemonProcess()
{
QList<QPair<QString, QStringList>> list;
// This daemon registers com.cutefish.Services and triggers startup of
// the desktop components once the service is available.
// This daemon provides the services used by the desktop components.
list << qMakePair(QString("cutefish-services"), QStringList());
for (QPair<QString, QStringList> pair : list) {

@ -49,6 +49,7 @@ private:
private:
Application *m_app;
QDBusServiceWatcher *m_kwinWatcher = nullptr;
QDBusServiceWatcher *m_servicesWatcher = nullptr;
bool m_kwinReady = false;
bool m_desktopStarted = false;
QMap<QString, QProcess *> m_systemProcess;

Loading…
Cancel
Save