Skip to content

fix(lockscreen): fix login view disappearing after TTY switch and hotplug - #1401

Draft
deepin-wm wants to merge 1 commit into
linuxdeepin:masterfrom
deepin-wm:agent/git-commit/8029004fc070
Draft

deepin-wm wants to merge 1 commit into
linuxdeepin:masterfrom
deepin-wm:agent/git-commit/8029004fc070

Conversation

@deepin-wm

@deepin-wm deepin-wm commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

修复:TTY 切回后登录界面消失 & 副屏拔插后登录/电源界面不跟随鼠标

问题

  • 场景 A:扩展模式下,切换到其他 TTY 再切回 treeland,登录界面(m_loginView)消失且不再出现。
  • 场景 B:扩展模式下拔插副屏后,登录/电源界面不再跟随鼠标显示到副屏。

根因

  • Bug A:切换 TTY 时 DRM 输出被禁用再重新启用,QML 场景图可能销毁 m_loginView,但裸指针 QQuickItem* m_loginView 变成悬空指针。
  • Bug BaddOutput() 未连接 WOutput::enabledChanged 信号,且未在输出添加后调用 repositionLoginView(),导致热插拔副屏后登录/电源界面不会跟随鼠标。

改动

  • m_loginViewQQuickItem* 改为 QPointer<QQuickItem>,QML 销毁后自动置 null
  • addOutput() 连接 WOutput::enabledChangedonOutputEnabledChanged(使用 Qt::UniqueConnection),末尾调用 repositionLoginView()
  • removeOutput() 断开 enabledChanged 连接
  • 新增 onOutputEnabledChanged():检查 isEnabled() 后,若 m_loginView 为空且可见则重建,否则重新定位
  • onCursorPositionChanged()m_loginView 为空且可见时触发 createLoginView() 重建

Multica Issue

WM-465

Summary by Sourcery

Restore lock-screen login and power interface visibility and mouse-following behavior after TTY switches and display hotplug events.

Bug Fixes:

  • Prevent the lock-screen login view from disappearing after TTY switches by safely handling QML view destruction and recreating it when needed.
  • Keep login and power interfaces positioned correctly across display hotplug and output enable/disable events.

Enhancements:

  • Improve lock-screen output lifecycle handling by updating view positioning whenever outputs are added, enabled, or the cursor moves.

…plug

Use QPointer<QQuickItem> for m_loginView so it is automatically
nulled when QML destroys the item, preventing dangling pointer
access after TTY switches that disable and re-enable DRM outputs.

Connect WOutput::enabledChanged in addOutput() to rebuild or
reposition the login view when an output is re-enabled, and call
repositionLoginView() so newly added outputs can be followed.

Add rebuild logic in onCursorPositionChanged() and the new
onOutputEnabledChanged() to recreate the login view when it has
been destroyed by QML but the lock screen is still visible.

将 m_loginView 从裸指针改为 QPointer<QQuickItem>,QML 销毁后
自动置 null,避免 TTY 切换导致 DRM 输出禁用/启用时产生悬空指针。
addOutput 中连接 enabledChanged 信号并调用 repositionLoginView,
使热插拔副屏后登录界面可跟随鼠标。onCursorPositionChanged 和新增
的 onOutputEnabledChanged 在 m_loginView 为空且界面可见时重建。

Log: 修复TTY切回后登录界面消失及副屏热插拔后不跟随鼠标
Issue: Fixes WM-465
Influence: TTY切换回来后登录界面不再消失,副屏热插拔后登录/电源
界面正常跟随鼠标显示在对应屏幕上。
@sourcery-ai

sourcery-ai Bot commented Sep 14, 2026

Copy link
Copy Markdown

Reviewer's Guide

Fixes lock-screen login view loss after TTY switching by making its pointer resilient to QML destruction and adding recovery logic, while updating output lifecycle handling so login and power views are repositioned or recreated after display hotplug and re-enablement.

Sequence diagram for lock-screen recovery after output re-enablement

sequenceDiagram
    participant WOutput
    participant LockScreen
    participant QML

    WOutput->>LockScreen: onOutputEnabledChanged()
    alt output disabled
        LockScreen-->>WOutput: return
    else output enabled and login view missing
        LockScreen->>LockScreen: isVisible()
        LockScreen->>QML: createLoginView()
    else output enabled and login view exists
        LockScreen->>LockScreen: repositionLoginView()
    end
Loading

Sequence diagram for login view recovery after cursor movement

sequenceDiagram
    participant Cursor
    participant LockScreen
    participant QML

    Cursor->>LockScreen: onCursorPositionChanged()
    alt login view missing and lock screen visible
        LockScreen->>QML: createLoginView()
    else login view exists
        LockScreen->>LockScreen: repositionLoginView()
    end
Loading

File-Level Changes

Change Details Files
Make login-view lifetime safe across QML scene teardown and recreate it when needed.
  • Replace the raw login-view pointer with QPointer so destruction automatically clears the reference.
  • Recreate the view when cursor movement or output re-enablement occurs while the lock screen is visible and no view exists.
  • Continue repositioning an existing view in response to cursor changes and output state changes.
src/core/lockscreen.cpp
src/core/lockscreen.h
Track output hotplug and enablement changes so lock-screen surfaces follow the active display.
  • Connect each output’s enabledChanged signal with a unique connection.
  • Reposition the login view after adding an output and disconnect the signal when removing one.
  • Ignore disabled or invalid output notifications.
src/core/lockscreen.cpp

Possibly linked issues

  • #WM-465: PR replaces the dangling login-view pointer with QPointer, addressing the likely stale QML item behind the rendering crash.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants