fix(session): wait for KWin before starting GUI processes

main
Reion Wong 3 weeks ago
parent 530f73431b
commit 779765e599

@ -18,4 +18,4 @@ export DESKTOP_SESSION=Cutefish
# spice-vdagent. The agent uses X11 selections and cannot connect to the
# native Wayland display directly; KWin bridges the Xwayland clipboard into
# the Wayland session.
exec /usr/bin/kwin_wayland --xwayland --exit-with-session /usr/bin/cutefish-kwin-wayland-session "$@"
exec /usr/bin/kwin_wayland_wrapper --xwayland --exit-with-session /usr/bin/cutefish-kwin-wayland-session "$@"

@ -2,7 +2,7 @@
Name=Cutefish (KWin Wayland)
Comment=Cutefish desktop session on KWin Wayland
Exec=/usr/bin/cutefish-wayland-session
TryExec=/usr/bin/kwin_wayland
TryExec=/usr/bin/kwin_wayland_wrapper
Type=Application
DesktopNames=Cutefish;KDE;
X-GDM-SessionRegisters=true

@ -30,8 +30,11 @@
#include <QTimer>
#include <QThread>
#include <QDir>
#include <QDBusConnectionInterface>
#include <QDBusInterface>
#include <QDBusPendingCall>
#include <QDBusReply>
#include <QDBusServiceWatcher>
ProcessManager::ProcessManager(Application *app, QObject *parent)
: QObject(parent)
@ -52,6 +55,37 @@ ProcessManager::~ProcessManager()
void ProcessManager::start()
{
if (m_kwinReady)
return;
const QString serviceName = QStringLiteral("org.kde.KWinWrapper");
m_kwinWatcher = new QDBusServiceWatcher(serviceName,
QDBusConnection::sessionBus(),
QDBusServiceWatcher::WatchForRegistration,
this);
connect(m_kwinWatcher, &QDBusServiceWatcher::serviceRegistered,
this, [this](const QString &) {
startAfterKWinReady();
});
if (QDBusConnectionInterface *interface = QDBusConnection::sessionBus().interface()) {
const QDBusReply<bool> reply = interface->isServiceRegistered(serviceName);
if (reply.isValid() && reply.value())
startAfterKWinReady();
}
}
void ProcessManager::startAfterKWinReady()
{
if (m_kwinReady)
return;
m_kwinReady = true;
if (m_kwinWatcher) {
m_kwinWatcher->deleteLater();
m_kwinWatcher = nullptr;
}
// The settings daemon owns the Cutefish settings D-Bus service and
// starts the desktop components after that service is ready.
startDaemonProcess();
@ -89,6 +123,16 @@ void ProcessManager::stopProcesses(QMap<QString, QProcess *> &processes)
void ProcessManager::startDesktopProcess()
{
if (!m_kwinReady) {
qWarning() << "Ignoring desktop startup before KWin is ready";
return;
}
if (m_desktopStarted)
return;
m_desktopStarted = true;
// When the cutefish-settings-daemon theme module is loaded, start the desktop.
// In the way, there will be no problem that desktop and launcher can't get wallpaper.

@ -26,6 +26,7 @@
#include <QMap>
class Application;
class QDBusServiceWatcher;
class ProcessManager : public QObject
{
Q_OBJECT
@ -42,10 +43,14 @@ public:
void loadAutoStartProcess();
private:
void startAfterKWinReady();
void stopProcesses(QMap<QString, QProcess *> &processes);
private:
Application *m_app;
QDBusServiceWatcher *m_kwinWatcher = nullptr;
bool m_kwinReady = false;
bool m_desktopStarted = false;
QMap<QString, QProcess *> m_systemProcess;
QMap<QString, QProcess *> m_autoStartProcess;

Loading…
Cancel
Save