fix(xwayland): refresh user Xauthority after Xwayland restart - #1448
Conversation
Xwayland regenerates /tmp/.xauth_<display> on every start, but treeland-sd only fetched it at startup, on compositor re-registration, or after a failed activation. An in-place restart inside a running compositor triggers none of those, so the user's XAUTHORITY kept stale MIT-MAGIC-COOKIE-1 data and X11 clients failed with "Invalid MIT-MAGIC-COOKIE-1 key". Add XWaylandAuthChanged instead of reusing SessionChanged: an in-place restart re-generates the auth data without switching the active session, so reusing SessionChanged would also wake the wayland helper into re-running ActivateWayland. Xwayland now subscribes to the new signal, which requires dropping the per-type early return in tryStart(). Xwayland 每次(重)启动都会重新生成 /tmp/.xauth_<display>,但 treeland-sd 只在 进程启动、compositor 重新注册或上次激活失败时才重新获取。compositor 运行期间 的 Xwayland 原地重启不会触发上述任何一条,导致用户 XAUTHORITY 文件保留过期的 MIT-MAGIC-COOKIE-1,X11 客户端报 Invalid MIT-MAGIC-COOKIE-1 key。 新增 XWaylandAuthChanged 而不复用 SessionChanged:原地重启只重新生成认证数据, 并未切换活动会话,复用 SessionChanged 会连带唤醒 wayland helper 重复执行 ActivateWayland。Xwayland 改为订阅新信号,因此需要去掉 tryStart() 中按类型提前 返回的分支。 Log: 修复 Xwayland 重启后用户 XAUTHORITY 未刷新 PMS: BUG-378331 Influence: treeland-sd(xwayland 类型)改订 XWaylandAuthChanged,Xwayland 重启 后用户侧 XAUTHORITY 自动刷新,X11 应用不再报 Invalid MIT-MAGIC-COOKIE-1 key。 新增 D-Bus 信号,旧客户端不受影响。
Reviewer's GuideAdds a dedicated XWaylandAuthChanged D-Bus signal emitted when Xwayland becomes ready, allowing treeland-sd to refresh user XAUTHORITY after in-place restarts. Xwayland activation now listens only for this authentication event, avoiding unnecessary ActivateWayland runs while preserving existing session-change behavior for other types. Sequence diagram for Xwayland authentication refresh after restartsequenceDiagram
participant Xwayland
participant SessionManager
participant TreelandDBus as Treeland_DBus
participant TreelandSD as treeland_sd
participant X11Client as X11_Client
Xwayland->>SessionManager: ready
SessionManager->>TreelandDBus: XWaylandAuthChanged()
TreelandDBus-->>TreelandSD: XWaylandAuthChanged
treeland_sd->>Xwayland: activate()
Xwayland-->>X11Client: refreshed XAUTHORITY
X11Client->>Xwayland: X11 connection
Xwayland-->>X11Client: authentication succeeds
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
No unresolved blocking issues were identified.
Review effort: Lite
Findings: None
What changed in this PR
Refreshes XWayland authentication after in-place restarts without reactivating Wayland sessions.
Changes:
- Adds and propagates
XWaylandAuthChanged. - Updates XWayland socket activation to refresh authentication.
- Removes the XWayland-specific activation bypass.
- Updates the D-Bus interface definition.
| File | Description |
|---|---|
src/systemd-socket.cpp |
Subscribes XWayland helpers to authentication changes. |
src/session/session.h |
Declares the authentication signal. |
src/session/session.cpp |
Emits the signal when XWayland is ready. |
src/seat/helper.cpp |
Forwards the signal to Treeland. |
src/core/treeland.h |
Declares the compositor signal. |
src/core/treeland.cpp |
Exposes the signal through D-Bus. |
misc/dbus/org.deepin.compositor1.xml |
Documents the new D-Bus signal. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: gugullll, wineee The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Xwayland regenerates /tmp/.xauth_ on every start, but treeland-sd only fetched it at startup, on compositor re-registration, or after a failed activation. An in-place restart inside a running compositor triggers none of those, so the user's XAUTHORITY kept stale MIT-MAGIC-COOKIE-1 data and X11 clients failed with "Invalid MIT-MAGIC-COOKIE-1 key".
Add XWaylandAuthChanged instead of reusing SessionChanged: an in-place restart re-generates the auth data without switching the active session, so reusing SessionChanged would also wake the wayland helper into re-running ActivateWayland. Xwayland now subscribes to the new signal, which requires dropping the per-type early return in tryStart().
Xwayland 每次(重)启动都会重新生成 /tmp/.xauth_,但 treeland-sd 只在 进程启动、compositor 重新注册或上次激活失败时才重新获取。compositor 运行期间
的 Xwayland 原地重启不会触发上述任何一条,导致用户 XAUTHORITY 文件保留过期的
MIT-MAGIC-COOKIE-1,X11 客户端报 Invalid MIT-MAGIC-COOKIE-1 key。
新增 XWaylandAuthChanged 而不复用 SessionChanged:原地重启只重新生成认证数据, 并未切换活动会话,复用 SessionChanged 会连带唤醒 wayland helper 重复执行 ActivateWayland。Xwayland 改为订阅新信号,因此需要去掉 tryStart() 中按类型提前 返回的分支。
Log: 修复 Xwayland 重启后用户 XAUTHORITY 未刷新
PMS: BUG-378331
Influence: treeland-sd(xwayland 类型)改订 XWaylandAuthChanged,Xwayland 重启 后用户侧 XAUTHORITY 自动刷新,X11 应用不再报 Invalid MIT-MAGIC-COOKIE-1 key。 新增 D-Bus 信号,旧客户端不受影响。
Summary by Sourcery
Refresh XWayland authentication state after restarts without changing the active session.
New Features:
Bug Fixes:
Enhancements: