Skip to content

Commit 8d19aa2

Browse files
committed
fix: use dummy drag target on Wayland to prevent layout breakage
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. 验证右键菜单功能仍然正常工作 PMS: BUG-346739
1 parent b0c62f2 commit 8d19aa2

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

qml/windowed/AppListView.qml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,12 @@ FocusScope {
219219
MouseArea {
220220
id: mouseArea
221221
anchors.fill: parent
222+
223+
// Use a dummy Item as drag.target so Wayland dnd doesn't break the original ItemDelegate layout
224+
Item { id: dndTarget }
222225

223226
acceptedButtons: Qt.LeftButton | Qt.RightButton
224-
drag.target: itemDelegate
227+
drag.target: dndTarget
225228
// 当分类菜单打开时,禁用拖拽功能
226229
enabled: !(ddeCategoryMenu.visible || alphabetCategoryPopup.visible)
227230

qml/windowed/FreeSortListView.qml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,11 @@ Item {
329329
id: mouseArea
330330
anchors.fill: parent
331331

332+
// Use a dummy Item as drag.target so Wayland dnd doesn't break the original ItemDelegate layout
333+
Item { id: dndTarget }
334+
332335
acceptedButtons: Qt.LeftButton | Qt.RightButton
333-
drag.target: itemDelegate
336+
drag.target: dndTarget
334337

335338
onPressed: function (mouse) {
336339
if (mouse.button === Qt.LeftButton) {

0 commit comments

Comments
 (0)