Repository navigation
feat: Support VT switching - #34
Conversation
|
Hi @apr3vau. Thanks for your PR. 😃 |
|
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 Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
Reviewer's GuideThis PR adds full VT switching support by removing the bundled seatd service, tracking VT numbers in user sessions, exposing new VT-related D-Bus methods, and implementing VT acquisition and switching logic in the VirtualTerminal module. Sequence diagram for VT acquire and treeland activation via D-BussequenceDiagram
participant Kernel
participant VirtualTerminal
participant DisplayManager as D-Bus:org.deepin.DisplayManager
participant Treeland as D-Bus:org.deepin.Compositor1
Kernel->>VirtualTerminal: VT acquire display signal
VirtualTerminal->>DisplayManager: VTUser(vt) (D-Bus call)
DisplayManager-->>VirtualTerminal: username or empty
alt user found
VirtualTerminal->>Treeland: ActivateSession (D-Bus call)
end
ER diagram for session VT number trackingerDiagram
SESSION {
string name
string seat
string user
uint vtnr
}
SESSION ||--o{ USER : "belongs to"
SESSION ||--o{ SEAT : "assigned to"
Class diagram for updated DisplayManagerSession and DisplayManager classesclassDiagram
class DisplayManager {
+QString VTUser(uint vtnr)
+void AcquireVT(uint vtnr)
+void SwitchToVT(uint vtnr)
+void AddSession(const QString &name, const QString &seat, const QString &user, const uint &vtnr)
}
class DisplayManagerSession {
+DisplayManagerSession(const QString &name, const QString &seat, const QString &user, const uint &vtnr, QObject *parent = 0)
+const uint &VTNr() const
-uint m_vtnr
}
DisplayManager "1" -- "*" DisplayManagerSession : manages
Class diagram for new VirtualTerminal VT methodsclassDiagram
class VirtualTerminal {
+void acquireVt(int vt)
+void switchToVt(int vt)
}
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey @apr3vau - I've reviewed your changes - here's some feedback:
- Add proper error handling for open() failures in VirtualTerminal::acquireVt and switchToVt to avoid invoking handleVtSwitches or ioctl on invalid file descriptors.
- Return and pass VT numbers by value instead of const uint& for these small built-in types to simplify method signatures and avoid unintended references.
- The synchronous D-Bus calls in onAcquireDisplay could block the signal handler—consider moving them to an asynchronous context or ensuring they won’t introduce deadlocks.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Add proper error handling for open() failures in VirtualTerminal::acquireVt and switchToVt to avoid invoking handleVtSwitches or ioctl on invalid file descriptors.
- Return and pass VT numbers by value instead of const uint& for these small built-in types to simplify method signatures and avoid unintended references.
- The synchronous D-Bus calls in onAcquireDisplay could block the signal handler—consider moving them to an asynchronous context or ensuring they won’t introduce deadlocks.
## Individual Comments
### Comment 1
<location> `src/common/VirtualTerminal.cpp:286` </location>
<code_context>
close(vtFd);
}
+
+ void acquireVt(int vt) {
+ int vtFd = open(qPrintable(path(vt)), O_RDWR | O_NOCTTY);
+ handleVtSwitches(vtFd);
+ close(vtFd);
+ }
+
</code_context>
<issue_to_address>
No error handling for open() failure in acquireVt.
Passing -1 to handleVtSwitches and close may cause undefined behavior. Please check if vtFd is -1 and handle the error before proceeding.
</issue_to_address>
### Comment 2
<location> `src/common/VirtualTerminal.cpp:292` </location>
<code_context>
+ close(vtFd);
+ }
+
+ void switchToVt(int vt) {
+ int activeVtFd = open(defaultVtPath, O_RDWR | O_NOCTTY);
+ handleVtSwitches(activeVtFd);
+ close(activeVtFd);
+ int fd = open(qPrintable(path(vt)), O_RDWR | O_NOCTTY);
+ if (ioctl(fd, VT_ACTIVATE, vt) < 0) {
+ qWarning("Failed to switch to VT %d: %s", vt, strerror(errno));
+ return;
+ }
+ close(fd);
+ }
}
</code_context>
<issue_to_address>
No error handling for open() failures in switchToVt.
Check the return value of each open() call and handle errors appropriately to prevent issues in subsequent operations.
</issue_to_address>
### Comment 3
<location> `src/daemon/Display.cpp:147` </location>
<code_context>
qDebug("Using VT %d", m_terminalId);
+ // Record current VT as ddm user session
+ DaemonApp::instance()->displayManager()->AddSession("", seat()->name(), "ddm", static_cast<uint>(VirtualTerminal::currentVt()));
+
// restart display after display server ended
</code_context>
<issue_to_address>
Empty session name may cause issues if uniqueness is expected.
Verify that passing an empty session name is intentional and properly handled to avoid conflicts or unexpected behavior.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
75b783f to
2e87664
Compare
1. Remove seatd-dde.service, use system provided seatd service; 2. Record VT number per session; 3. Add private wayland protocol treeland-private-protocol.xml for IPC, implement wayland event for acquiring VT control and switching VT; 4. Listen to VT acquire & release display signal and activate & deactivate treeland correspondingly.
|
因为依赖新的 treeland-protocols,所以构建流程失败。先行合入。 |
Summary by Sourcery
Enable virtual terminal (VT) support in the display manager by tracking session VTs, exposing VT control over D-Bus, and handling VT switch events.
New Features:
Enhancements:
Build:
Documentation: