fix: launch autostart application after scaleFactor has been set

Signed-off-by: ComixHe <heyuming@deepin.org>
This commit is contained in:
ComixHe
2023-09-15 17:14:58 +08:00
committed by black-desk
parent 7d94a8b71d
commit bbe0551ffb
2 changed files with 34 additions and 1 deletions

View File

@ -97,7 +97,37 @@ void ApplicationManager1Service::initService(QDBusConnection &connection) noexce
flag.write(sessionId, sessionId.size());
}
scanAutoStart();
constexpr auto XSettings = "org.deepin.dde.XSettings1";
auto *watcher =
new QDBusServiceWatcher{XSettings, QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForRegistration, this};
auto *sigCon = new QMetaObject::Connection{};
auto singleSlot = [this, watcher, sigCon]() {
QObject::disconnect(*sigCon);
delete sigCon;
qDebug() << XSettings << "is registered.";
scanAutoStart();
watcher->deleteLater();
};
*sigCon = connect(watcher, &QDBusServiceWatcher::serviceRegistered, std::move(singleSlot));
auto msg =
QDBusMessage::createMethodCall("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "NameHasOwner");
msg << XSettings;
auto reply = QDBusConnection::sessionBus().call(msg);
if (reply.type() != QDBusMessage::ReplyMessage) {
qWarning() << "call org.freedesktop.DBus::NameHasOwner failed, skip autostart:" << reply.errorMessage();
// ...
return;
}
if (reply.arguments().first().toBool()) {
singleSlot();
}
}
void ApplicationManager1Service::addInstanceToApplication(const QString &unitName, const QDBusObjectPath &systemdUnitPath)