fix: fix touchscreen long press and drag issues#741
fix: fix touchscreen long press and drag issues#741deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
Conversation
1. Changed visibility handling to opacity for dragged items to maintain layout stability 2. Replaced DragHandler with MouseArea for better touchscreen compatibility 3. Fixed drag state condition to use mouseArea.drag.active instead of dragHandler.active 4. Added proper touchscreen long press support via onPressAndHold handler 5. Implemented deferred drag start to prevent crashes during page/folder transitions 6. Restored click and right-click functionality within the MouseArea Log: Fixed touchscreen long press not triggering context menu and improved drag-and-drop reliability Influence: 1. Test long press on touchscreen to verify context menu appears 2. Test drag-and-drop operations on both mouse and touchscreen 3. Verify items disappear properly during drag (opacity becomes 0) 4. Test folder opening/closing during drag operations 5. Test right-click functionality still works correctly 6. Verify no crashes occur when switching pages during drag 7. Test drag threshold and hot spot positioning fix: 修复触摸屏长按和拖拽问题 1. 将拖拽项的可见性处理改为透明度控制,以保持布局稳定性 2. 用 MouseArea 替换 DragHandler 以获得更好的触摸屏兼容性 3. 修复拖拽状态条件,使用 mouseArea.drag.active 替代 dragHandler.active 4. 通过 onPressAndHold 处理器添加正确的触摸屏长按支持 5. 实现延迟拖拽启动,防止在页面/文件夹切换期间崩溃 6. 恢复 MouseArea 内的点击和右键点击功能 Log: 修复触摸屏长按无法触发上下文菜单的问题,并提高拖拽操作的可靠性 Influence: 1. 测试触摸屏长按,验证上下文菜单是否正常显示 2. 测试鼠标和触摸屏上的拖拽操作 3. 验证拖拽期间项目是否正确消失(透明度变为0) 4. 测试拖拽操作期间的文件夹打开/关闭 5. 测试右键点击功能是否仍然正常工作 6. 验证在拖拽期间切换页面不会导致崩溃 7. 测试拖拽阈值和热点定位
Reviewer's GuideRefactors drag-and-drop handling from DragHandler to MouseArea to improve touchscreen long-press support and drag reliability, switches dragged-item hiding from visibility to opacity, and defers drag start to avoid crashes when delegates are destroyed during page or folder transitions. Sequence diagram for deferred drag start with MouseAreasequenceDiagram
actor User
participant MouseArea
participant IconDelegateRoot as IconDelegateRoot
participant IconLoader as IconLoader
participant DndItem as DndItem
participant Qt as Qt
User->>MouseArea: press(left button)
MouseArea->>IconDelegateRoot: set Drag.hotSpot
MouseArea->>IconLoader: grabToImage(callback)
IconLoader-->>MouseArea: callback(result)
MouseArea->>IconDelegateRoot: set Drag.imageSource
User->>MouseArea: start_drag_move
MouseArea->>MouseArea: drag.active = true
MouseArea->>DndItem: set currentlyDraggedId
MouseArea->>DndItem: set currentlyDraggedIconName
MouseArea->>DndItem: copy Drag.hotSpot
MouseArea->>DndItem: copy Drag.mimeData
MouseArea->>DndItem: set mergeSize
MouseArea->>DndItem: copy Drag.imageSource
MouseArea->>DndItem: set Drag.dragType
MouseArea->>Qt: callLater(startDnd)
Qt-->>DndItem: startDnd()
DndItem->>DndItem: Drag.active = true
DndItem->>DndItem: Drag.startDrag()
note over IconDelegateRoot,DndItem: IconDelegateRoot may be destroyed during drag without crashing
Sequence diagram for touchscreen long press context menusequenceDiagram
actor TouchUser as TouchUser
participant MouseArea
participant IconDelegateRoot as IconDelegateRoot
TouchUser->>MouseArea: touch_and_hold
MouseArea->>MouseArea: onPressAndHold(mouse)
MouseArea->>IconDelegateRoot: menuTriggered()
Class diagram for updated icon drag and interaction handlingclassDiagram
class IconItemDelegate {
+bool dndEnabled
+string iconSource
+DragAttached Drag
+void folderClicked()
+void itemClicked()
+void menuTriggered()
}
class MouseAreaDelegate {
+bool hoverEnabled
+DragHandler drag
+void onPressed(mouse)
+void onClicked(mouse)
+void onPressAndHold(mouse)
}
class DndItem {
+string currentlyDraggedId
+string currentlyDraggedIconName
+int mergeSize
+DragAttached Drag
}
class FolderGridViewPopupDelegate {
+string desktopId
+string iconSource
+int opacity
+DragAttached Drag
}
class FullscreenFrameDelegate {
+string desktopId
+string iconSource
+int opacity
+DragAttached Drag
+bool dndEnabled
}
IconItemDelegate o-- MouseAreaDelegate : contains
IconItemDelegate ..> DndItem : configures_drag_state
FolderGridViewPopupDelegate ..> DndItem : hides_via_opacity
FullscreenFrameDelegate ..> DndItem : hides_via_opacity
DndItem <.. MouseAreaDelegate : receives_drag_parameters
class DragAttached {
+bool active
+int dragType
+point hotSpot
+map mimeData
+string imageSource
+void startDrag()
}
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 found 2 issues, and left some high level feedback:
- Switching from
visibletoopacitykeeps the delegate in the hit-test area; if the dragged icon should not accept input whilecurrentlyDraggedId === model.desktopId, consider also gatingenabled(oracceptedButtons) on that condition to avoid clicks/presses on an invisible item. - The MouseArea now combines
drag.thresholdwithonClicked; if very small drags should not result in a click action, you may want to track whether a drag was initiated/moved and suppress the click handler in that case.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Switching from `visible` to `opacity` keeps the delegate in the hit-test area; if the dragged icon should not accept input while `currentlyDraggedId === model.desktopId`, consider also gating `enabled` (or `acceptedButtons`) on that condition to avoid clicks/presses on an invisible item.
- The MouseArea now combines `drag.threshold` with `onClicked`; if very small drags should not result in a click action, you may want to track whether a drag was initiated/moved and suppress the click handler in that case.
## Individual Comments
### Comment 1
<location path="qml/IconItemDelegate.qml" line_range="123" />
<code_context>
+ drag.threshold: 1
+ onPressed: function (mouse) {
+ if (mouse.button === Qt.LeftButton && root.dndEnabled) {
+ root.Drag.hotSpot = mapToItem(iconLoader, Qt.point(mouse.x, mouse.y))
iconLoader.grabToImage(function(result) {
- dndItem.Drag.imageSource = result.url;
</code_context>
<issue_to_address>
**issue (bug_risk):** Hotspot mapping may use the wrong coordinate space
`Drag.hotSpot` is in `root`'s coordinate space, but `mapToItem(iconLoader, ...)` returns coordinates in `iconLoader` space. Unless these items overlap exactly, the hotspot will be offset from the cursor. Map directly to `root` (e.g., `mapToItem(root, ...)`) to keep the hotspot aligned.
</issue_to_address>
### Comment 2
<location path="qml/FullscreenFrame.qml" line_range="642" />
<code_context>
displayFont: isWindowedMode ? DTK.fontManager.t9 : DTK.fontManager.t6
Drag.mimeData: Helper.generateDragMimeData(model.desktopId)
- visible: dndItem.currentlyDraggedId !== model.desktopId
+ opacity: dndItem.currentlyDraggedId !== model.desktopId ? 1 : 0
iconSource: iconName
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Transparent dragged item may still accept input
Using `opacity` instead of `visible` keeps the dragged item interactive even when fully transparent. With a drag proxy above it, pointer events can still reach this delegate, changing behavior from the previous `visible`-based approach. If you want to preserve the old semantics, consider also toggling `visible` or `enabled` so the item ignores input while hidden.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, BLumia 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 |
|
/forcemerge |
|
This pr force merged! (status: blocked) |
layout stability
compatibility
dragHandler.active
handler
transitions
Log: Fixed touchscreen long press not triggering context menu and
improved drag-and-drop reliability
Influence:
fix: 修复触摸屏长按和拖拽问题
Log: 修复触摸屏长按无法触发上下文菜单的问题,并提高拖拽操作的可靠性
Influence:
Summary by Sourcery
Improve touch and mouse drag-and-drop handling for icon items to stabilize layout and prevent crashes during drag operations.
Bug Fixes:
Enhancements: