fix: use dummy drag target on Wayland to prevent layout breakage#756
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR updates drag-and-drop handling in AppListView and FreeSortListView by introducing a dummy QML Item as the MouseArea.drag.target instead of the ItemDelegate itself, preventing layout breakage under Wayland while preserving existing behavior elsewhere. Sequence diagram for the new drag-and-drop dummy target on WaylandsequenceDiagram
actor User
participant MouseArea
participant dndTarget
participant ItemDelegate
participant WaylandCompositor
User->>MouseArea: press(Qt.LeftButton)
MouseArea->>MouseArea: set drag.target to dndTarget
User->>MouseArea: move mouse with button pressed
MouseArea->>dndTarget: update position during drag
MouseArea->>WaylandCompositor: initiate drag using dndTarget
WaylandCompositor-->>MouseArea: drag events bound to dndTarget
ItemDelegate-->>ItemDelegate: layout and position remain unchanged
User->>MouseArea: release button
MouseArea->>WaylandCompositor: finish drag operation
dndTarget-->>MouseArea: final position used for drop handling
ItemDelegate-->>User: visual layout stable after drag
Flow diagram for MouseArea drag.target wiring with dummy Itemgraph TD
subgraph AppListView
ALV_ItemDelegate[ItemDelegate]
ALV_MouseArea[MouseArea]
ALV_dndTarget[dndTarget Item]
ALV_MouseArea --> ALV_dndTarget
ALV_MouseArea --> ALV_ItemDelegate
ALV_MouseArea -- drag.target --> ALV_dndTarget
ALV_ItemDelegate -- visual layout --> ALV_ItemDelegate
end
subgraph FreeSortListView
FSLV_ItemDelegate[ItemDelegate]
FSLV_MouseArea[MouseArea]
FSLV_dndTarget[dndTarget Item]
FSLV_MouseArea --> FSLV_dndTarget
FSLV_MouseArea --> FSLV_ItemDelegate
FSLV_MouseArea -- drag.target --> FSLV_dndTarget
FSLV_ItemDelegate -- visual layout --> FSLV_ItemDelegate
end
ALV_MouseArea -. same pattern .- FSLV_MouseArea
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The new
dndTargetItems have no size or position bindings; consider anchoring them to theitemDelegate(e.g.,anchors.fill: parentor explicitx/y/width/heightbindings) to ensure the drag hotspot and geometry match the visual item consistently across platforms.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new `dndTarget` Items have no size or position bindings; consider anchoring them to the `itemDelegate` (e.g., `anchors.fill: parent` or explicit `x/y/width/height` bindings) to ensure the drag hotspot and geometry match the visual item consistently across platforms.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
BLumia
left a comment
There was a problem hiding this comment.
总觉得这个改法怪怪的,按理说这个问题本身不应该和显示协议相关。目前改动不大,能接受,不过有条件的话可以写最小复现例子丢给 Qt 那边。
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, BLumia, wjyrich 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 |
Add a dummy Item as drag.target instead of directly using the ItemDelegate to avoid layout issues in Wayland drag-and-drop. The original implementation caused the ItemDelegate's layout to break when used as a drag target under Wayland compositors, leading to visual glitches and incorrect positioning. Log: Fix layout breakage during drag-and-drop on Wayland Influence: 1. Test drag-and-drop functionality in both AppListView and FreeSortListView 2. Verify that item layout remains stable during and after drag operations on Wayland 3. Ensure no regression on X11 sessions 4. Test drag-and-drop behavior with multiple items and across different view sections 5. Verify that right-click context menu still works correctly fix: 在 Wayland 上使用虚拟拖拽目标以防止布局损坏 添加一个虚拟的 Item 作为 drag.target,而不是直接使用 ItemDelegate,以 避免 Wayland 拖放操作中的布局问题。原实现方式在 Wayland 合成器下直接使 用 ItemDelegate 作为拖拽目标会导致其布局损坏,出现视觉错乱和位置不正确的 问题。 Log: 修复 Wayland 下拖拽时布局损坏问题 Influence: 1. 测试 AppListView 和 FreeSortListView 中的拖拽功能 2. 验证 Wayland 下拖拽操作期间和之后项目布局保持稳定 3. 确保在 X11 会话中没有回归问题 4. 测试多个项目和不同视图区间的拖拽行为 5. 验证右键菜单功能仍然正常工作 此问题修复,自由排序时, 交换应用位置会出现的图标重叠问题.
deepin pr auto review这段代码的修改主要涉及QML中拖拽功能的实现,特别是在Wayland显示服务器协议下的兼容性处理。以下是对这段diff的详细审查意见: 1. 语法逻辑
2. 代码质量
3. 代码性能
4. 代码安全
5. 潜在改进建议虽然这段修改解决了 Wayland 下的布局破坏问题,但引入了一个"哑"(dummy)目标后,通常需要配合其他逻辑来实现视觉上的拖拽反馈(即用户看到东西在动)。 建议检查以下逻辑是否存在或需要补充:
总结: |
Add a dummy Item as drag.target instead of directly using the ItemDelegate to avoid layout issues in Wayland drag-and-drop. The original implementation caused the ItemDelegate's layout to break when used as a drag target under Wayland compositors, leading to visual glitches and incorrect positioning.
Log: Fix layout breakage during drag-and-drop on Wayland
Influence:
fix: 在 Wayland 上使用虚拟拖拽目标以防止布局损坏
添加一个虚拟的 Item 作为 drag.target,而不是直接使用 ItemDelegate,以 避免 Wayland 拖放操作中的布局问题。原实现方式在 Wayland 合成器下直接使
用 ItemDelegate 作为拖拽目标会导致其布局损坏,出现视觉错乱和位置不正确的
问题。
Log: 修复 Wayland 下拖拽时布局损坏问题
Influence:
此问题修复,自由排序时, 交换应用位置会出现的图标重叠问题.
Summary by Sourcery
Prevent Wayland drag-and-drop from breaking item layouts by decoupling drag targets from visual delegates in app list views.
Bug Fixes:
Enhancements: