Skip to content

fix: prevent app list item overlap after drag on Wayland#775

Merged
yixinshark merged 1 commit into
linuxdeepin:masterfrom
yixinshark:fix-wayland-app-list-drag-target
Jun 17, 2026
Merged

fix: prevent app list item overlap after drag on Wayland#775
yixinshark merged 1 commit into
linuxdeepin:masterfrom
yixinshark:fix-wayland-app-list-drag-target

Conversation

@yixinshark

@yixinshark yixinshark commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Use an invisible dummy item as the drag target in the categorized app list.
  • Keep the visible ItemDelegate under ListView layout control during Wayland drag operations.
  • Preserve dock drag-and-drop MIME data for pinning apps to Dock.

Test plan

  • Built successfully with cmake --build /tmp/dde-launchpad-build.
  • Verified on Wayland/Treeland that dragging items in sort-by-name and sort-by-category modes no longer leaves list items overlapped after release.

Pms: BUG-295171

Summary by Sourcery

Bug Fixes:

  • Resolve item overlap in the categorized app list after drag-and-drop on Wayland by using a separate dummy drag target instead of the visible item delegate.

@sourcery-ai

sourcery-ai Bot commented Jun 15, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts the Wayland drag behavior in the windowed app list so that drag operations use an invisible dummy item as the drag target, preserving the layout of the visible ItemDelegate and preventing item overlap after drag.

Sequence diagram for Wayland drag using dummy Item target

sequenceDiagram
    actor User
    participant MouseArea
    participant dndTarget
    participant ItemDelegate
    participant WaylandCompositor

    User->>MouseArea: pressAndHold
    MouseArea->>MouseArea: startDrag
    MouseArea->>dndTarget: set drag.target
    MouseArea->>WaylandCompositor: initiateDrag(dndTarget)
    Note over ItemDelegate,WaylandCompositor: ItemDelegate remains under ListView layout control
    User->>MouseArea: release
    WaylandCompositor-->>MouseArea: drop
    MouseArea->>ItemDelegate: updateModelOrder
    Note over ItemDelegate: No visual overlap after drag on Wayland
Loading

File-Level Changes

Change Details Files
Use an invisible dummy Item as the drag target instead of the ItemDelegate to keep ListView layout intact during Wayland drag operations.
  • Add a dummy Item inside the MouseArea to serve as the drag.target during drag-and-drop
  • Update the MouseArea drag.target binding from the ItemDelegate to the new dummy Item
  • Keep existing drag enablement logic that disables dragging while category menus are open
qml/windowed/AppListView.qml

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

@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.

Hey - I've reviewed your changes and they look great!


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.

In category and name sorting modes, the windowed app list should not reorder
items when an item is dragged. On Wayland/Treeland, using the visible
ItemDelegate itself as the MouseArea drag target can leave the delegate at a
dragged offset after release, causing it to overlap with other list items.

Use a dummy invisible Item as the drag target in AppListView so the platform
drag operation can still start for dock pinning, while the real delegate
remains under ListView layout control.

在按分类和按名称排序模式下,窗口模式左侧应用列表不应通过拖拽改变位置。
在 Wayland/Treeland 环境中,如果直接把可见的 ItemDelegate 作为 MouseArea
的拖拽目标,释放后 delegate 可能停留在拖拽偏移位置,导致与其他列表项重叠。

在 AppListView 中改用不可见的 dummy Item 作为拖拽目标,保留拖到 Dock 的
平台拖拽能力,同时让真实 delegate 继续由 ListView 布局管理。

Log: prevent app list item overlap after drag on Wayland
Pms: BUG-295171
Change-Id: Ie8df5b75712b552d755a164c59053f518e5a8313
@yixinshark yixinshark force-pushed the fix-wayland-app-list-drag-target branch from 7c33e1b to 6728854 Compare June 17, 2026 02:36
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:100分

■ 【总体评价】

代码通过引入虚拟拖拽目标完美解决了Wayland环境下的布局破坏问题,质量极高
逻辑正确、注释清晰且无任何安全风险,无需扣分

■ 【详细分析】

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

在 AppListView.qml 的 MouseArea 组件中,新增了一个空 Item 作为 drag.target,成功将拖拽行为与实际的 itemDelegate 视图解耦。此方式有效规避了 Wayland 协议下 DnD 操作直接移动原组件导致的布局错乱,逻辑严密且符合 QML 语法规范。
建议:保持当前的实现方式,无需额外修改

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

代码新增了详细的英文注释,准确解释了使用 dummy Item 的原因,极大提升了可读性和可维护性。变量命名 dndTarget 符合驼峰命名规范且语义明确,代码结构简洁。
建议:在 UOS 系统的组件中,建议将注释统一为中文以保持代码库风格一致

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

新增的 Item 是一个没有任何子对象、无绑定属性、无渲染内容的轻量级空节点,其在 Qt Scenegraph 中的内存占用和渲染开销几乎为零,对整体列表滑动和交互性能无任何负面影响。
建议:保持现状,无需优化

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

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
本次代码修改仅涉及 QML 前端 UI 视图的拖拽目标重定向,完全隔离于后端业务逻辑、文件系统、网络通信及命令执行环境,不存在任何攻击面。

  • 建议:继续保持这种纯视图层修改的安全隔离意识

■ 【改进建议代码示例】

                MouseArea {
                    id: mouseArea
                    anchors.fill: parent

                    // 使用虚拟 Item 作为 drag.target,防止 Wayland 拖拽破坏原始 ItemDelegate 布局
                    Item { id: dndTarget }
                    
                    acceptedButtons: Qt.LeftButton | Qt.RightButton
                    drag.target: dndTarget
                    // 当分类菜单打开时,禁用拖拽功能
                    enabled: !(ddeCategoryMenu.visible || alphabetCategoryPopup.visible)

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: robertkill, yixinshark

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

@yixinshark yixinshark merged commit 6335bf8 into linuxdeepin:master Jun 17, 2026
11 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