Skip to content

fix: use layer-shell for screen indicator on wayland#3288

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
caixr23:master
Jun 16, 2026
Merged

fix: use layer-shell for screen indicator on wayland#3288
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
caixr23:master

Conversation

@caixr23

@caixr23 caixr23 commented Jun 11, 2026

Copy link
Copy Markdown
Contributor
  1. Replace absolute x/y positioning with DLayerShellWindow anchors in ScreenIndicator.qml (both display and personalization)
  2. Use AnchorTop/Bottom/Left/Right for border indicator windows instead of virtualX/virtualY coordinates
  3. Migrate ScreenRecognize.qml to use AnchorBottom with margin for centered-bottom positioning
  4. Remove isX11 guard in DisplayMain.qml so indicators work on Wayland/Treeland
  5. Add DDEShell dependency in CMakeLists.txt

PMS: BUG-351883

Log: Fix screen indicator and recognition dialog not working on Treeland Wayland environment

Influence:

  1. Connect external monitor, open Display settings, click Identify
    • border indicators should correctly highlight each screen edge
  2. On Treeland, drag to change screen arrangement and click Identify
    • indicator borders should appear on the correct monitor

fix: 使用 layer-shell 实现屏幕指示器在 Wayland 下的正确定位

  1. 将 ScreenIndicator.qml 中的绝对 x/y 坐标定位替换为 DLayerShellWindow 锚定方式(display 和 personalization 模块)
  2. 使用 AnchorTop/Bottom/Left/Right 锚定边框指示窗口, 替代 virtualX/virtualY 坐标
  3. 将 ScreenRecognize.qml 迁移到使用 AnchorBottom + margin 实现底部居中定位
  4. 移除 DisplayMain.qml 中的 isX11 条件判断, 使指示器在 Wayland 下也能正常显示
  5. 在 CMakeLists.txt 中添加 DDEShell 依赖

PMS: BUG-351883

Log: 修复 Treeland Wayland 环境下屏幕指示器和识别弹框不生效的问题

Influence:

  1. 接入外接显示器,打开控制中心显示设置,点击识别 - 边框指示器应正确高亮各屏幕边缘
  2. 在 Treeland 环境下,拖动切换屏幕拼接位置后点击识别 - 指示器边框应出现在正确的显示器上

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry @caixr23, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@caixr23 caixr23 requested a review from mhduiy June 11, 2026 08:57
@caixr23 caixr23 force-pushed the master branch 3 times, most recently from 150519b to efa918b Compare June 11, 2026 09:05
Comment thread src/plugin-display/CMakeLists.txt Outdated
@deepin-bot

deepin-bot Bot commented Jun 11, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 6.1.92
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #3292

@deepin-bot

deepin-bot Bot commented Jun 12, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 6.1.93
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #3293

Comment thread src/plugin-display/qml/ScreenIndicator.qml
@caixr23 caixr23 force-pushed the master branch 3 times, most recently from fe78894 to 8ff31d5 Compare June 16, 2026 05:48
// 顶部边框:锚定顶部,左右拉伸
DS.DLayerShellWindow.anchors: DS.DLayerShellWindow.AnchorTop | DS.DLayerShellWindow.AnchorLeft | DS.DLayerShellWindow.AnchorRight
DS.DLayerShellWindow.layer: DS.DLayerShellWindow.LayerOverlay
DS.DLayerShellWindow.exclusionZone: -1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

默认就是-1,不用设置,

18202781743
18202781743 previously approved these changes Jun 16, 2026
1. Replace absolute x/y positioning with DLayerShellWindow anchors
   in ScreenIndicator.qml (both display and personalization)
2. Use AnchorTop/Bottom/Left/Right for border indicator windows
   instead of virtualX/virtualY coordinates
3. Migrate ScreenRecognize.qml to use AnchorBottom with margin
   for centered-bottom positioning
4. Remove isX11 guard in DisplayMain.qml so indicators work on
   Wayland/Treeland
5. Add DDEShell dependency in CMakeLists.txt

PMS: BUG-351883

Log: Fix screen indicator and recognition dialog not working on
Treeland Wayland environment

Influence:
1. Connect external monitor, open Display settings, click Identify
   - border indicators should correctly highlight each screen edge
2. On Treeland, drag to change screen arrangement and click Identify
   - indicator borders should appear on the correct monitor

fix: 使用 layer-shell 实现屏幕指示器在 Wayland 下的正确定位

1. 将 ScreenIndicator.qml 中的绝对 x/y 坐标定位替换为
   DLayerShellWindow 锚定方式(display 和 personalization 模块)
2. 使用 AnchorTop/Bottom/Left/Right 锚定边框指示窗口,
   替代 virtualX/virtualY 坐标
3. 将 ScreenRecognize.qml 迁移到使用 AnchorBottom + margin
   实现底部居中定位
4. 移除 DisplayMain.qml 中的 isX11 条件判断,
   使指示器在 Wayland 下也能正常显示
5. 在 CMakeLists.txt 中添加 DDEShell 依赖

PMS: BUG-351883

Log: 修复 Treeland Wayland 环境下屏幕指示器和识别弹框不生效的问题

Influence:
1. 接入外接显示器,打开控制中心显示设置,点击识别 -
   边框指示器应正确高亮各屏幕边缘
2. 在 Treeland 环境下,拖动切换屏幕拼接位置后点击识别 -
   指示器边框应出现在正确的显示器上
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:95分

■ 【总体评价】

代码成功将X11窗口定位重构为Wayland兼容的DLayerShellWindow锚点布局,消除了平台差异逻辑
逻辑正确且采用声明式重构大幅提升可维护性,无安全漏洞,符合优秀标准

■ 【详细分析】

  • 1.语法逻辑(正确)✓

QML属性绑定与组件生命周期管理完全正确。在DisplayMain.qml和WallpaperPage.qml中,采用先赋值null再赋值目标对象的方式触发属性改变,有效绕过了QML对于相同引用不触发变更信号的机制。ScreenIndicator.qml使用内联component定义IndicatorBorder并在Loader中按需加载,语法严谨。
潜在问题:ScreenRecognize.qml中bottomMargin依赖于height,在组件初始化瞬间height可能为0,导致margin计算为400并在布局后发生跳动。
建议:在ScreenRecognize.qml中使用Binding组件或增加visible状态控制,确保在height计算完成后再显示窗口。

  • 2.代码质量(良好)✓

彻底移除了冗余的Component动态创建逻辑和isX11条件分支,采用Repeater配合Loader的声明式范式统一了X11与Wayland的显示逻辑,代码结构清晰,可读性与可维护性显著提升。
潜在问题:plugin-display与plugin-personalization下的ScreenIndicator.qml代码存在完全相同的跨模块重复。
建议:考虑将ScreenIndicator.qml提取为公共组件供两个插件共享引用,消除代码冗余。

  • 3.代码性能(高效)✓

原实现在每次点击时通过createObject动态创建窗口对象,依赖手动调用close()和destroy()进行清理,容易因异常流程导致内存泄漏。重构后由QML引擎基于model数据自动管理Loader的实例化与销毁,资源回收更及时,性能开销更低。
潜在问题:无
建议:保持当前的声明式资源管理方式。

  • 4.代码安全(存在0个安全漏洞)✓

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
本次修改纯属于UI视图层的布局重构,将绝对坐标定位替换为DLayerShellWindow锚点布局。代码中未引入任何文件读写、网络请求、命令执行或动态代码求值,modelData.name仅作为纯文本渲染,不存在注入或越权风险。

  • 建议:维持当前的纯视图层隔离设计,避免在后续迭代中将业务逻辑混入QML视图文件。

■ 【改进建议代码示例】

// ScreenRecognize.qml:优化底部边距计算,避免初始化时因 height 为 0 导致的位置跳动
Window {
    id: root
    property string name: "screen"
    property real realBottomMargin: 400
    signal escPressed

    flags: Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint
    D.DWindow.enabled: true
    color: D.DTK.palette.window
    DS.DLayerShellWindow.anchors: DS.DLayerShellWindow.AnchorBottom
    DS.DLayerShellWindow.layer: DS.DLayerShellWindow.LayerOverlay
    
    // 使用 Binding 延迟绑定,确保在窗口真实尺寸计算完成后再更新 margin
    Binding {
        target: root
        property: "realBottomMargin"
        value: (root.screen && root.screen.height > 0 && root.height > 0) 
               ? Math.max(0, root.screen.height * 0.25 - root.height * 0.5) 
               : 400
    }
    DS.DLayerShellWindow.bottomMargin: root.realBottomMargin

    width: control.implicitWidth
    height: control.implicitHeight
    visible: root.height > 0 // 确保布局完成后再显示,消除视觉闪烁
    onClosing: destroy(10)
    
    Text {
        id: control
        leftPadding: 22
        topPadding: 12
        rightPadding: leftPadding
        bottomPadding: topPadding
        text: root.name
        font: D.DTK.fontManager.t4
        color: D.DTK.palette.brightText
    }
    Shortcut {
        sequence: "Esc"
        onActivated: root.escPressed()
    }
}

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, caixr23

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

@caixr23 caixr23 requested a review from 18202781743 June 16, 2026 07:23
@caixr23

caixr23 commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Jun 16, 2026

Copy link
Copy Markdown

This pr force merged! (status: blocked)

@deepin-bot deepin-bot Bot merged commit b14219e into linuxdeepin:master Jun 16, 2026
17 of 19 checks passed
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.

3 participants