Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Build-Depends: cmake (>= 3.4~),
debhelper-compat (= 13),
ninja-build,
extra-cmake-modules (>= 1.4.0~),
libddm-dev,
libddm-dev (> 0.2.2),
libdtk6core-bin,
libdtk6core-dev,
libdtk6declarative-dev,
Expand Down Expand Up @@ -53,7 +53,7 @@ Depends: qml6-module-qtquick-layouts,
${shlibs:Depends},
Conflicts: libwaylib, qwlroots
Replaces: libwaylib, qwlroots
Recommends: ddm,
Recommends: ddm (> 0.2.2),
Description: a Wayland compositor based on wlroots and QML, designed with an attractive and elegant appearance.

Package: treeland-dev
Expand Down
2 changes: 2 additions & 0 deletions misc/dbus/org.deepin.compositor1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
<method name="XWaylandName">
<arg type="s" direction="out" name="result"/>
</method>
<signal name="SessionChanged">
</signal>
</interface>
</node>
5 changes: 4 additions & 1 deletion src/core/shellhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ WXWayland *ShellHandler::createXWayland(WServer *server,
void ShellHandler::removeXWayland(WXWayland *xwayland)
{
m_xwaylands.removeOne(xwayland);
xwayland->safeDeleteLater();
// Ensure xwayland is removed from interfaceList
if (auto server = WServer::from(xwayland))
server->detach(xwayland);
delete xwayland;
}

void ShellHandler::initInputMethodHelper(WServer *server, WSeat *seat)
Expand Down
2 changes: 1 addition & 1 deletion src/core/treeland.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class TreelandPrivate : public QObject
connect(qmlEngine, &QQmlEngine::quit, q, &Treeland::quit, Qt::QueuedConnection);
helper = qmlEngine->singletonInstance<Helper *>("Treeland", "Helper");
connect(helper, &Helper::requestQuit, q, &Treeland::quit, Qt::QueuedConnection);
helper->init();
helper->init(q);

#ifndef DISABLE_DDM
auto userModel = qmlEngine->singletonInstance<UserModel *>("Treeland", "UserModel");
Expand Down
1 change: 1 addition & 0 deletions src/core/treeland.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@

Q_SIGNALS:
void socketDisconnected();
void SessionChanged();

public Q_SLOTS:

Check warning on line 48 in src/core/treeland.h

View workflow job for this annotation

GitHub Actions / cppcheck

There is an unknown macro here somewhere. Configuration is required. If Q_SLOTS is a macro then please configure it.
bool ActivateWayland(QDBusUnixFileDescriptor fd);
QString XWaylandName();

Expand Down
81 changes: 8 additions & 73 deletions src/greeter/greeterproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,82 +293,14 @@ void GreeterProxy::unlock(const QString &user, const QString &password)
}
}

static QString getSessionPathByUser(UserPtr userInfo);

void GreeterProxy::logout()
{
qCDebug(treelandGreeter) << "Logout.";
d->isLoggedIn = false;
Q_EMIT isLoggedInChanged();
auto user = userModel()->currentUser();
QThreadPool::globalInstance()->start([user]() {
const auto path = getSessionPathByUser(user);
if (path.isEmpty()) {
qCWarning(treelandGreeter, "No session logged in.");
return;
}
qCDebug(treelandGreeter) << "Terminate the session" << path;
auto reply = DDBusSender::system()
.service("org.freedesktop.login1")
.path(path)
.interface("org.freedesktop.login1.Session")
.method("Terminate")
.call();
if (reply.isError()) {
qCWarning(treelandGreeter) << "Failed to logout, error:" << reply.error().message();
}
});
}

QString getSessionPathByUser(UserPtr userInfo)
{
if (!userInfo) {
qCWarning(treelandGreeter) << "No user logged in.";
return {};
}

QDBusPendingReply<QList<SessionInfo>> sessionsRelpy =
DDBusSender::system()
.service("org.freedesktop.login1")
.path("/org/freedesktop/login1")
.interface("org.freedesktop.login1.Manager")
.method("ListSessions")
.call();
if (sessionsRelpy.isError()) {
qCWarning(treelandGreeter) << "Failed to logout, error:" << sessionsRelpy.error().message();
return {};
}

QStringList userSessions;
const auto sessions = sessionsRelpy.value();
for (auto item : sessions) {
if (item.uid != userInfo->UID())
continue;
// TODO multiple seats.
if (item.seat.isEmpty())
continue;
userSessions << item.path.path();
}
std::sort(userSessions.begin(), userSessions.end(), [](const QString &s1, const QString &s2) {
return s1.localeAwareCompare(s2) > 0;
});
for (auto item : userSessions) {
QDBusPendingReply<QVariant> relpy = DDBusSender::system()
.service("org.freedesktop.login1")
.path(item)
.interface("org.freedesktop.login1.Session")
.property("Active")
.get();
if (relpy.value().toBool())
return item;
}
return {};
}

void GreeterProxy::activateUser(const QString &user)
{
auto userInfo = userModel()->get(user);
SocketWriter(d->socket) << quint32(GreeterMessages::ActivateUser) << user;
auto session = Helper::instance()->activeSession().lock();
SocketWriter(d->socket) << quint32(GreeterMessages::Logout) << session->id;
Helper::instance()->removeSession(session);
}

void GreeterProxy::connected()
Expand Down Expand Up @@ -483,7 +415,8 @@ void GreeterProxy::readyRead()
} break;
case DaemonMessages::UserActivateMessage: {
QString user;
input >> user;
int sessionId;
input >> user >> sessionId;

// NOTE: maybe DDM will active dde user.
if (!d->userModel->getUser(user)) {
Expand All @@ -494,8 +427,10 @@ void GreeterProxy::readyRead()
}

d->userModel->setCurrentUserName(user);
// userLoggedIn signal is connected with Helper::updateActiveUserSession
Q_EMIT d->userModel->userLoggedIn(user, sessionId);

qCInfo(treelandGreeter) << "activate successfully: " << user;
qCInfo(treelandGreeter) << "activate successfully: " << user << ", XDG_SESSION_ID: " << sessionId;
} break;
case DaemonMessages::UserLoggedIn: {
QString user;
Expand Down
1 change: 0 additions & 1 deletion src/greeter/greeterproxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ public Q_SLOTS:
void init();

void login(const QString &user, const QString &password, int sessionIndex);
void activateUser(const QString &user);
void unlock(const QString &user, const QString &password);
void logout();

Expand Down
1 change: 1 addition & 0 deletions src/greeter/usermodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class UserModel : public QAbstractListModel
void currentUserNameChanged();
void updateTranslations(const QLocale &locale);
void countChanged();
void userLoggedIn(const QString &username, int sessionId);

private Q_SLOTS:
void onUserAdded(quint64 uid);
Expand Down
1 change: 0 additions & 1 deletion src/plugins/lockscreen/qml/UserList.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ D.Popup {
function selectCurrentUser(userName, index) {
UserModel.currentUserName = userName
users.lastCheckedIndex = index
GreeterModel.proxy.activateUser(userName)
userList.close()
}

Expand Down
Loading
Loading