Skip to content

Conversation

@calsys456
Copy link
Contributor

@calsys456 calsys456 commented Dec 24, 2025

移除不再需要的功能和依赖项,精简项目结构:

  • 将 Seat 类并入 SeatManager 和 Display
  • 删除无用的配置项
  • 移除 elogind 支持,统一使用 systemd
  • 移除对 XCB 和 XKB 的依赖
  • 清理未使用的类:ThemeConfig、ThemeMetadata、SafeDataStream
  • 删除不需要的资源文件:国旗图片、默认头像
  • 维护手册
  • 移除测试代码和相关构建配置
  • 清理旧的 PAM 配置文件和 systemd 服务文件
  • 增加注释和文档

这些更改简化了构建系统,减少了维护负担,使代码易于上手维护

Summary by Sourcery

Simplify the daemon’s seat/display and authentication handling while removing unused features, dependencies, and test-only paths.

New Features:

  • Add retry logic for starting display servers and automatically recreate displays when they stop.
  • Introduce per-display session tracking to drive Treeland VT switching based on active sessions.

Bug Fixes:

  • Ensure Treeland activation checks for valid XDG session IDs and distinguish between greeter and user sessions when switching.
  • Fix VT/user resolution for Treeland so switching behavior correctly handles both greeter and non-greeter terminals.

Enhancements:

  • Replace the Seat abstraction with SeatManager-anchored Display instances and centralize seat lifecycle management.
  • Refactor Auth to own its PAM/session objects, track display server type, and provide clearer session and process control APIs.
  • Streamline Display’s login/unlock flow, maintaining active Auth instances explicitly and emitting clearer success/failure signals.
  • Always use the system D-Bus for display manager, seat, and session registration instead of a test-mode-dependent choice.
  • Remove test-mode code paths and related conditionals from daemon and power management behavior.
  • Trim configuration options related to themes, avatars, numlock, autologin, input methods, and various desktop/session tweaks that are no longer used.

Build:

  • Drop support for elogind in favor of systemd-only integration and simplify related CMake options and feature reporting.
  • Remove XCB and XKB from the build, along with their custom Find modules and include usage.
  • Stop building tests and the test subtree, and drop the data/systemd CMake subtree from the build.
  • Remove installation of greeter-specific PAM files, extra PAM variants, flags and face icon assets, and the ddm-greeter man page.

Documentation:

  • Add template man pages for ddm, ddm.conf, and ddm-state.conf, and stop shipping the ddm-greeter man page.

Tests:

  • Remove the entire test suite and its CMake configuration from the project.

Chores:

  • Update REUSE metadata to reflect removed common and daemon sources and headers tied to them, such as SafeDataStream and theme configuration types.
  • Delete unused helper classes and resources, including SafeDataStream, ThemeConfig, ThemeMetadata, Seat, test-only assets, and related headers and sources.

@deepin-ci-robot
Copy link

Hi @calsys456. Thanks for your PR.

I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@sourcery-ai
Copy link

sourcery-ai bot commented Dec 24, 2025

Reviewer's Guide

Refactor the display/login daemon by removing the Seat abstraction and unused configuration/theme/test code, consolidating seat management into SeatManager/Display/Auth, and simplifying the build and packaging to rely only on systemd (no elogind/XCB/XKB, no greeter PAM or avatar assets).

Sequence diagram for updated login flow via Display

sequenceDiagram
    actor User
    participant Treeland as TreelandGreeter
    participant Socket as QLocalSocket
    participant Display
    participant Auth
    participant Logind as systemd_logind
    participant Xorg as XorgDisplayServer

    User->>Treeland: Enter credentials
    Treeland->>Socket: Send login(user, password, session)
    Socket->>Display: login(socket, user, password, session)

    alt user is dde
        Display-->>Socket: loginFailed(socket, user)
        Display->>Display: return
    end

    rect rgb(235,235,235)
        note over Display,Auth: Reuse or create Auth for this user
    end
    Display->>Display: Find existing Auth in auths
    alt found
        Display->>Auth: use existing instance
    else not found
        Display->>Auth: new Auth(Display, user)
    end

    Display->>Auth: authenticate(password)
    alt auth fails
        Auth-->>Display: false
        Display-->>Socket: loginFailed(socket, user)
        Display->>Display: return
    else auth ok
        Auth-->>Display: true
    end

    Display->>Display: Prepare session env (XDG_*, etc.)
    Display->>Logind: openSession(env)
    Logind-->>Auth: XDG_SESSION_ID
    Auth->>Auth: xdgSessionId set

    alt session.isSingleMode
        Display->>Auth: set type = Treeland, tty = new VT
        Display->>Treeland: onLoginSucceeded(user)
        Display->>Display: activateSession(user, xdgSessionId)
    else session.xdgSessionType == x11
        Display->>Auth: set type = X11
        Display->>Treeland: stop()
        Display->>Xorg: start(tty)
        Xorg-->>Display: display, cookie
    else Wayland session
        Display->>Auth: set type = Wayland
        Display->>Treeland: stop()
    end

    Display->>Auth: startUserProcess(session.exec(), cookie)
    Auth-->>Display: userProcessStarted
    Display->>Display: auths << auth
    Display-->>Socket: loginSucceeded(socket, user)
Loading

Sequence diagram for updated unlock (re-login) flow

sequenceDiagram
    actor User
    participant Treeland as TreelandGreeter
    participant Socket as QLocalSocket
    participant Display
    participant TempAuth as Auth(temp)
    participant AuthList as ExistingAuth
    participant VT as VirtualTerminal

    User->>Treeland: Enter password on lock screen
    Treeland->>Socket: Send unlock(user, password)
    Socket->>Display: unlock(socket, user, password)

    alt user is dde
        Display-->>Socket: loginFailed(socket, user)
        Socket->>Socket: return
    end

    Display->>TempAuth: Auth(Display, user)
    Display->>TempAuth: authenticate(password)
    alt auth fails
        TempAuth-->>Display: false
        Display-->>Socket: loginFailed(socket, user)
        Socket->>Socket: return
    else auth ok
        TempAuth-->>Display: true
    end

    Display->>Display: Update last activated user in config

    loop search matching session
        Display->>AuthList: iterate over auths
    end

    alt found Treeland session
        Display-->>Socket: loginSucceeded(socket, user)
        Display->>Display: activateSession(user, xdgSessionId)
    else found X11/Wayland session
        Display->>VT: jumpToVt(AuthList.tty, false)
    else no matching session
        Display-->>Socket: loginFailed(socket, user)
    end
Loading

Class diagram for updated seat/display/auth architecture

classDiagram
    class SeatManager {
        +QList~Display*~ displays
        +QHash~QString, LogindSeat*~ systemSeats
        +void initialize()
        +void createSeat(QString name)
        +void removeSeat(QString name)
        +void switchToGreeter(QString seat)
        +void logindSeatAdded(QString name, QDBusObjectPath objectPath)
        +void logindSeatRemoved(QString name, QDBusObjectPath objectPath)
        +void displayStopped()
        -void startDisplay(Display* display, int tryNr)
    }

    class Display {
        <<QObject>>
        +QString name
        +int terminalId
        +QList~Auth*~ auths
        -bool m_started
        -TreelandDisplayServer* m_treeland
        -XorgDisplayServer* m_x11Server
        -SocketServer* m_socketServer
        +Display(SeatManager* parent, QString name)
        +~Display()
        +bool start()
        +void stop()
        +void activateSession(QString user, int xdgSessionId)
        +void connected(QLocalSocket* socket)
        +void login(QLocalSocket* socket, QString user, QString password, Session session)
        +void logout(QLocalSocket* socket, int id)
        +void unlock(QLocalSocket* socket, QString user, QString password)
        +void userProcessFinished(int status)
        +signal void stopped()
        +signal void loginFailed(QLocalSocket* socket, QString user)
        +signal void loginSucceeded(QLocalSocket* socket, QString user)
    }

    class Auth {
        <<QObject>>
        +bool active
        +QString user
        +Display::DisplayServerType type
        +QString sessionId
        +QString display
        +int tty
        +int xdgSessionId
        -Pam* m_pam
        -UserSession* m_session
        -QProcessEnvironment m_env
        +Auth(QObject* parent, QString user)
        +~Auth()
        +bool authenticate(QByteArray secret)
        +int openSession(QProcessEnvironment env)
        +void startUserProcess(QString command, QByteArray cookie)
        +void stop()
        +signal void userProcessFinished(int status)
    }

    class TreelandDisplayServer {
        +bool start(int tty)
        +void stop()
        +void activateUser(QString user, int xdgSessionId)
    }

    class XorgDisplayServer {
        +QString display
        +QByteArray cookie()
        +bool start(int vt)
        +signal void stopped()
    }

    class SeatManagerLogindSeatNote {
        <<LogindSeat>>
        +QString name
        +QDBusObjectPath objectPath
        +bool canGraphical()
    }

    SeatManager "1" o-- "*" Display : manages
    SeatManager "*" o-- "*" SeatManagerLogindSeatNote : systemSeats

    Display "1" o-- "*" Auth : owns auths
    Display "1" o-- "1" TreelandDisplayServer : uses
    Display "0..1" o-- "1" XorgDisplayServer : optional X11

    Auth "1" --> "1" Pam : uses
    Auth "1" --> "1" UserSession : runs process

    class Pam {
        +QString user
        +bool sessionOpened
        +bool start()
        +bool authenticate(QByteArray secret)
        +std::optional~QProcessEnvironment~ openSession(QProcessEnvironment env)
        +void closeSession()
    }

    class UserSession {
        +void setProcessEnvironment(QProcessEnvironment env)
        +void start(QString command, Display::DisplayServerType type, QByteArray cookie)
        +void stop()
        +qint64 processId()
        +QProcessEnvironment processEnvironment()
        +signal void finished(int exitCode, QProcess::ExitStatus status)
    }
Loading

File-Level Changes

Change Details Files
Inline Seat into SeatManager/Display and rework display lifecycle and session activation
  • Change Display to be owned by SeatManager with an explicit seat name instead of Seat, exposing name, terminalId and auths
  • Introduce SeatManager::displays/systemSeats collections and new helpers startDisplay(), displayStopped(), switchToGreeter() that manage Display instances with retry logic
  • Update XorgDisplayServer to take the seat name from Display instead of Seat, and adjust TreelandConnector to reason about Treeland sessions based on Display/auth state
src/daemon/Display.cpp
src/daemon/Display.h
src/daemon/SeatManager.cpp
src/daemon/SeatManager.h
src/daemon/XorgDisplayServer.cpp
src/daemon/TreelandConnector.cpp
src/daemon/DaemonApp.cpp
Simplify Auth API and move utmp helpers to internal statics
  • Refactor Auth to accept username in constructor, drop id/skipAuth/singleMode and expose Display::DisplayServerType type field
  • Turn utmpLogin/utmpLogout into file-local static helpers and adjust authenticate(), openSession(), startUserProcess(), stop() accordingly
  • Update Display to use the new Auth API, track active auths in QList<Auth*> auths, and handle login/unlock/session switching via activateSession()
src/daemon/Auth.cpp
src/daemon/Auth.h
src/daemon/Display.cpp
src/daemon/Display.h
Remove testing mode and elogind/ConsoleKit-specific branches, standardizing on systemd and always using system bus
  • Drop DaemonApp::testing flag and the --test-mode CLI option and remove test-mode guards in PowerManager and DisplayManager DBus registration
  • Remove elogind-specific CMake options and pkg-config checks; treat lack of SYSTEMD_FOUND as the only fallback
  • Simplify CK2PowerManager and PowerManager to always call backend methods without test-mode short-circuiting
src/daemon/DaemonApp.cpp
src/daemon/DaemonApp.h
src/daemon/PowerManager.cpp
src/daemon/DisplayManager.cpp
CMakeLists.txt
Prune unused configuration options, theme/avatar handling, and related tests
  • Remove several MainConfig entries (display server selection, numlock, theme and user listing knobs, autologin, input method, compositor commands, HiDPI) and their NumState enum and operators
  • Delete ThemeConfig/ThemeMetadata/SafeDataStream and their references from the common library and REUSE metadata
  • Remove tests and QML theme test assets that depended on the deleted configuration and theme code
src/common/Configuration.h
src/common/CMakeLists.txt
src/common/SafeDataStream.cpp
src/common/SafeDataStream.h
src/common/ThemeConfig.cpp
src/common/ThemeConfig.h
src/common/ThemeMetadata.cpp
src/common/ThemeMetadata.h
REUSE.toml
test/CMakeLists.txt
test/ConfigurationTest.cpp
test/ConfigurationTest.h
test/QMLThemeConfigTest.cpp
test/QMLThemeConfigTest.qml
test/SessionTest.cpp
test/plasmawayland-dev.desktop
test/theme.conf
Simplify data and services installation by dropping avatars, flags, some systemd and PAM artifacts, and man page for the greeter
  • Stop installing flags directory and face icon resources from data/, and delete faces/README
  • Remove data/systemd subdirectory and associated CMakeLists, as well as ddm-greeter man page generation
  • Drop greeter/autologin PAM configs and templating; only install a single ddm PAM file (plus Debian variant)
  • Adjust REUSE.toml paths to match the removed files
data/CMakeLists.txt
data/systemd/CMakeLists.txt
data/faces/README
data/man/CMakeLists.txt
services/CMakeLists.txt
services/ddm-autologin-tally2.pam
services/ddm-autologin.pam
services/ddm-greeter.pam.in
services/debian.ddm-autologin.pam
services/debian.ddm-greeter.pam
REUSE.toml
Clean up build dependencies by removing XCB/XKB and tests
  • Drop FindXCB.cmake and FindXKB.cmake modules and their usage; stop including/linking XCB in the daemon target
  • Remove add_subdirectory(test) and commented enable_testing() stub from the top-level CMakeLists
  • Tighten daemon include directories to only LibXau and Wayland where needed
CMakeLists.txt
src/daemon/CMakeLists.txt
src/daemon/XorgDisplayServer.cpp
cmake/FindXCB.cmake
cmake/FindXKB.cmake
test/CMakeLists.txt

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 2 issues, and left some high level feedback:

  • In SeatManager::createSeat(), the new Display is added to the displays list twice (using both 'displays << display;' and 'displays.append(display);'); one of these should be removed to avoid duplicate entries.
  • SeatManager now exposes 'displays' and 'systemSeats' as public mutable members; consider making these private with accessor methods to prevent unintended external modification and keep ownership/lifecycle centralized in SeatManager.
  • The new SeatManager::startDisplay() retry logic uses synchronous QThread::msleep(500) in Display::startAuth paths and hard-coded retry counts/delays; consider making these constants/configurable and avoiding blocking sleeps in the main thread if this runs in the GUI/event thread.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In SeatManager::createSeat(), the new Display is added to the displays list twice (using both 'displays << display;' and 'displays.append(display);'); one of these should be removed to avoid duplicate entries.
- SeatManager now exposes 'displays' and 'systemSeats' as public mutable members; consider making these private with accessor methods to prevent unintended external modification and keep ownership/lifecycle centralized in SeatManager.
- The new SeatManager::startDisplay() retry logic uses synchronous QThread::msleep(500) in Display::startAuth paths and hard-coded retry counts/delays; consider making these constants/configurable and avoiding blocking sleeps in the main thread if this runs in the GUI/event thread.

## Individual Comments

### Comment 1
<location> `src/daemon/SeatManager.cpp:127-136` </location>
<code_context>
-            return;
-        }
-
-        // create a new display
-        qDebug() << "Adding new display...";
-        Display *display = new Display(this);
</code_context>

<issue_to_address>
**issue (bug_risk):** Display is inserted into `displays` twice in `createSeat`, which can cause duplicate entries and confusing behavior.

In `createSeat`, `display` is pushed into `displays` twice (`<<` and `append`), leaving duplicate pointers to the same instance. This can cause double-iteration side effects and unexpected behavior with removal operations. Please keep only one insertion (e.g., drop the first one before `startDisplay(display)`).
</issue_to_address>

### Comment 2
<location> `CMakeLists.txt:129-130` </location>
<code_context>
+if (NOT SYSTEMD_FOUND)
     # Set the VT on which ddm will normally appear, and the
     # commands for shutdown and reboot. On FreeBSD, there are
     # normally more getty's running than on Linux.
</code_context>

<issue_to_address>
**nitpick (typo):** Consider correcting the plural form of "getty's" in this comment.

Since "getty's" is used as a plural here, the apostrophe is incorrect. Please change it to a plural form like "gettys" or "getties" to avoid confusion.

```suggestion
    # commands for shutdown and reboot. On FreeBSD, there are
    # normally more gettys running than on Linux.
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

zccrs
zccrs previously approved these changes Dec 24, 2025
移除不再需要的功能和依赖项,精简项目结构:

- 将 Seat 类并入 SeatManager 和 Display
- 删除无用的配置项
- 移除 elogind 支持,统一使用 systemd
- 移除对 XCB 和 XKB 的依赖
- 清理未使用的类:ThemeConfig、ThemeMetadata、SafeDataStream
- 删除不需要的资源文件:国旗图片、默认头像
- 维护手册
- 移除测试代码和相关构建配置
- 清理旧的 PAM 配置文件和 systemd 服务文件
- 增加注释和文档

这些更改简化了构建系统,减少了维护负担,使代码易于上手维护
@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: calsys456, zccrs

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@zccrs zccrs merged commit 7ae129c into linuxdeepin:master Dec 24, 2025
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants