Skip to content

feat: Support TTY switching with DDM#489

Merged
zccrs merged 2 commits intolinuxdeepin:masterfrom
calsys456:master
Aug 20, 2025
Merged

feat: Support TTY switching with DDM#489
zccrs merged 2 commits intolinuxdeepin:masterfrom
calsys456:master

Conversation

@calsys456
Copy link
Copy Markdown
Collaborator

@calsys456 calsys456 commented Aug 4, 2025

  1. Remove dependence of seatd-dde.service, use system provided seatd service;
  2. Add onCreated signal for WBackend and acquire VT control immediately after backend created;
  3. Call DDM to switch VT when Ctrl+Alt+Fx is pressed, if available;
  4. Expose D-Bus interface for re-activate session to DDM;

#417

Summary by Sourcery

Enable TTY switching through the Deepin Display Manager by acquiring VT control at startup, handling Ctrl+Alt+Fx switches via DDM, and adding a D-Bus interface for session reactivation.

New Features:

  • Support VT control acquisition via DDM upon backend creation using a new WBackend::onCreated signal
  • Expose an ActivateSession D-Bus method in the compositor interface for session reactivation

Enhancements:

  • Delegate Ctrl+Alt+Fx VT switching to DDM with VTUser query and fallback to direct VT change if DDM is unavailable
  • Implement activateSession and deactivateSession in Helper to toggle Wayland session active state

Chores:

  • Remove dependency on seatd-dde.service and switch to the system-provided seatd service

@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: apr3vau

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

@deepin-ci-robot
Copy link
Copy Markdown

Hi @apr3vau. 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
Copy Markdown

sourcery-ai Bot commented Aug 4, 2025

Reviewer's Guide

Refactor TTY switching to use Deepin Display Manager (DDM) via D-Bus, introduce a WBackend onCreated hook for immediate VT control, implement DDM-driven VT transitions on Ctrl+Alt+Fx with session activation/deactivation signaling, and expose session activation over D-Bus.

Sequence diagram for VT switching with DDM on Ctrl+Alt+Fx

sequenceDiagram
    actor User
    participant Helper
    participant DDM as "DDM (D-Bus)"
    participant Backend
    User->>Helper: Press Ctrl+Alt+Fx
    Helper->>DDM: Call VTUser(vtnr)
    DDM-->>Helper: Return user (may be empty)
    alt user is empty
        Helper->>DDM: Call SwitchToVT(vtnr)
        Helper->>Helper: deactivateSession()
    else user is not empty
        alt user != "ddm"
            Helper->>Helper: m_userModel->setCurrentUserName(user)
        end
        Helper->>DDM: Call SwitchToVT(vtnr)
    end
Loading

Sequence diagram for WBackend creation and VT acquisition

sequenceDiagram
    participant Server
    participant Backend as WBackend
    participant Helper
    participant DDM as "DDM (D-Bus)"
    Server->>Backend: create()
    Backend-->>Helper: onCreated signal
    Helper->>DDM: AcquireVT(0)
Loading

ER diagram for D-Bus interface changes (org.deepin.compositor1)

erDiagram
    COMPOSITOR1 {
        string XWaylandName
        void ActivateSession
    }
Loading

Updated class diagram for Helper and WBackend

classDiagram
    class Helper {
        +void activateSession()
        +void deactivateSession()
    }
    class WBackend {
        +void onCreated()
    }
    Helper o-- WBackend : m_backend
    WBackend --|> QObject
    WBackend --|> WObject
    WBackend --|> WServerObject
Loading

Updated class diagram for Treeland

classDiagram
    class Treeland {
        +void ActivateSession()
    }
    Treeland o-- Helper : d->helper
Loading

File-Level Changes

Change Details Files
Introduce WBackend::onCreated signal and acquire VT control via DDM on backend startup
  • Declare onCreated signal in WBackend header
  • Emit onCreated in WBackend::create() implementation
  • Connect onCreated in Helper::init() to call DDM AcquireVT over system D-Bus
waylib/src/server/kernel/wbackend.h
waylib/src/server/kernel/wbackend.cpp
src/seat/helper.cpp
Route Ctrl+Alt+Fx VT switches through DDM with user context handling
  • Import QDBusReply to capture DDM VTUser response
  • Validate DDM service availability and fallback to session change_vt
  • Call DDM VTUser, SwitchToVT and update current user model
  • Retain legacy change_vt fallback when DDM is unavailable
src/seat/helper.cpp
Expose session activation/deactivation and emit wlr_session active events
  • Add activateSession() and deactivateSession() methods in Helper
  • Emit wl_signal events on session activation state changes
  • Declare and implement Treeland::ActivateSession(), update D-Bus XML
src/seat/helper.h
src/seat/helper.cpp
src/core/treeland.h
src/core/treeland.cpp
misc/dbus/org.deepin.compositor1.xml
Remove dependency on seatd-dde.service in favor of system-provided seatd
  • Update treeland.service.in to drop seatd-dde.service requirement
misc/systemd/treeland.service.in

Possibly linked issues

  • Supports TTY switch #417: PR implements TTY switching per issue: seatd integration, VT control, DDM communication for Ctrl+Alt+Fx and session activation.

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
Copy Markdown

@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 @apr3vau - I've reviewed your changes - here's some feedback:

  • Extract the DDM D-Bus interaction (creating QDBusInterface and calling VT methods) into a shared helper to avoid duplicating inline calls and make future maintenance easier.
  • Add explicit error checking on QDBusReply (e.g. isValid()/error()) so that D-Bus failures when acquiring or switching VTs are handled rather than ignored.
  • Standardize your naming (e.g. ActivateSession vs activateSession, onCreated vs created) to match the rest of the codebase’s signal/slot conventions for consistency.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Extract the DDM D-Bus interaction (creating QDBusInterface and calling VT methods) into a shared helper to avoid duplicating inline calls and make future maintenance easier.
- Add explicit error checking on QDBusReply (e.g. isValid()/error()) so that D-Bus failures when acquiring or switching VTs are handled rather than ignored.
- Standardize your naming (e.g. ActivateSession vs activateSession, onCreated vs created) to match the rest of the codebase’s signal/slot conventions for consistency.

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.

Comment thread src/seat/helper.cpp
Comment thread src/seat/helper.cpp Outdated
Comment thread waylib/src/server/kernel/wbackend.cpp Outdated
Comment thread waylib/src/server/kernel/wbackend.h Outdated
Comment thread src/seat/helper.cpp Outdated
Comment thread src/seat/helper.cpp Outdated
Comment thread src/seat/helper.cpp Outdated
Comment thread src/seat/helper.cpp Outdated
Comment thread misc/systemd/treeland.service.in
Comment thread src/core/treeland.h Outdated
Comment thread src/seat/helper.cpp Outdated
@calsys456
Copy link
Copy Markdown
Collaborator Author

ddm PR 快速链接 linuxdeepin/ddm#34

@calsys456 calsys456 force-pushed the master branch 2 times, most recently from 8d34bd1 to c511bd2 Compare August 12, 2025 04:07
Comment thread src/core/treeland-private-protocol.c Outdated
Comment thread src/core/treeland-private-protocol.h Outdated
Comment thread src/core/privateprotocol.h Outdated
Comment thread src/core/treeland-private-protocol.xml Outdated
Comment thread src/greeter/greeterproxy.cpp Outdated
Comment thread src/seat/helper.cpp Outdated
Comment thread waylib/src/server/kernel/wbackend.cpp Outdated
Comment thread waylib/src/server/kernel/wbackend.cpp Outdated
Comment thread waylib/src/server/kernel/wbackend.cpp Outdated
Comment thread waylib/src/server/kernel/wbackend.cpp Outdated
Comment thread src/greeter/greeterproxy.cpp Outdated
Comment thread src/modules/ddm/ddminterfacev1.cpp Outdated
Comment thread src/modules/ddm/ddminterfacev1.cpp Outdated
Comment thread src/modules/ddm/ddminterfacev1.cpp Outdated
Comment thread src/modules/ddm/ddminterfacev1.h Outdated
Comment thread src/seat/helper.h Outdated
Comment thread src/seat/helper.h Outdated
Comment thread src/seat/helper.h Outdated
Comment thread waylib/src/server/kernel/wbackend.h Outdated
@calsys456 calsys456 force-pushed the master branch 6 times, most recently from e014a85 to 115014d Compare August 19, 2025 05:04
Comment thread src/modules/ddm/ddminterfacev1.cpp Outdated
1. Remove dependence of seatd-dde.service, use system provided seatd
service;
2. Add private wayland protocol treeland-private-protocol.xml for IPC
3. Acquire VT control immediately after first rendering complete;
4. Call DDM to switch VT when Ctrl+Alt+Fx is pressed, if available;
5. Expose wayland request for deactivate and re-activate session to DDM;
…uck for switching too quickly

Treeland will failed to deactivate session when the animation is still
playing, and get the whole VT stuck. Disable all animation to prevent it
as mostly as possible.
@zccrs zccrs merged commit 547da09 into linuxdeepin:master Aug 20, 2025
11 of 14 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.

4 participants