From a239d0e636b36591e212920a95344de1a6dccc6a Mon Sep 17 00:00:00 2001 From: fuleyi Date: Thu, 21 May 2026 17:40:28 +0800 Subject: [PATCH] fix: enable touch scrolling in launcher MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Update the icon press handling in AppListView.qml and FreeSortListView.qml. 2. Detect synthesized mouse events generated from touch input by checking mouse.source. 3. When the event comes from touch rather than a real mouse, mark it as not accepted and return early so the parent Flickable can handle vertical scrolling. 4. Keep the existing left-click image grab and subsequent interaction logic unchanged for real mouse input. 5. This change is necessary because launcher icons were consuming touch-generated press events, which blocked swipe up/down gestures and prevented smooth scrolling in the app list. Log: Enabled vertical touch scrolling on launcher app icons Influence: 1. Verify that swiping up and down directly on launcher icons scrolls the app list smoothly. 2. Verify that mouse left-click behavior on icons is unchanged, including image grab related interactions. 3. Test long-press behavior on touch devices to ensure it does not regress unexpectedly. 4. Verify scrolling behavior in both AppListView and FreeSortListView. 5. Test with real mouse input and touch input separately to confirm correct event routing. 6. Check that icon click, drag, and reorder related interactions still work as expected after the event acceptance change. fix: 启动器支持图标区域触控滑动 1. 更新了 AppListView.qml 和 FreeSortListView.qml 中的图标按下事件处理 逻辑。 2. 通过检查 mouse.source 来识别由触摸输入合成的鼠标事件。 3. 当事件来源于触摸而不是真实鼠标时,将事件设置为不接受并提前返回,让父 级 Flickable 接管上下滑动处理。 4. 对真实鼠标输入,保留原有的左键截图抓取及后续交互逻辑不变。 5. 之所以需要此修改,是因为启动器图标此前会消费触摸生成的按下事件,导致 用户在图标区域上下滑动时手势被拦截,应用列表无法顺畅滚动。 Log: 已支持在启动器应用图标区域进行上下触控滑动 Influence: 1. 验证在启动器图标区域直接上下滑动时,应用列表能够平滑滚动。 2. 验证鼠标左键点击图标的行为保持不变,包括相关的图像抓取交互。 3. 在触屏设备上测试长按行为,确认没有引入异常回归。 4. 分别验证 AppListView 和 FreeSortListView 中的滚动表现。 5. 使用真实鼠标输入和触摸输入分别测试,确认事件分发符合预期。 6. 检查图标点击、拖拽、自由排序等相关交互在事件接受逻辑调整后仍然正常。 PMS: BUG-362161 Change-Id: I54e01447f677a2275ab285c576dabbf84799f5f5 --- qml/windowed/AppListView.qml | 18 ++++++++---------- qml/windowed/FreeSortListView.qml | 19 ++++++++----------- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/qml/windowed/AppListView.qml b/qml/windowed/AppListView.qml index 86dd48b9..67c0436f 100644 --- a/qml/windowed/AppListView.qml +++ b/qml/windowed/AppListView.qml @@ -225,20 +225,23 @@ FocusScope { // 当分类菜单打开时,禁用拖拽功能 enabled: !(ddeCategoryMenu.visible || alphabetCategoryPopup.visible) - // 记录是否是触摸长按导致的,防止在 onClicked 中重复处理 - property bool isTouchLongPressed: false - TapHandler { acceptedDevices: PointerDevice.TouchScreen gesturePolicy: TapHandler.DragThreshold + onTapped: function(eventPoint, buttons) { + launchApp(desktopId) + } onLongPressed: { - mouseArea.isTouchLongPressed = true showContextMenu(itemDelegate, model) } } onPressed: function (mouse) { - isTouchLongPressed = false + // 触屏合成的鼠标事件不接受,交给 Flickable 处理滚动 + if (mouse.source !== undefined && mouse.source !== Qt.MouseEventNotSynthesized) { + mouse.accepted = false + return + } if (mouse.button === Qt.LeftButton) { itemDelegate.contentItem.grabToImage(function(result) { itemDelegate.Drag.imageSource = result.url @@ -246,11 +249,6 @@ FocusScope { } } onClicked: function (mouse) { - if (isTouchLongPressed) { - isTouchLongPressed = false - return - } - if (mouse.button === Qt.RightButton) { showContextMenu(itemDelegate, model) baseLayer.focus = true diff --git a/qml/windowed/FreeSortListView.qml b/qml/windowed/FreeSortListView.qml index 2697f52a..e03c7c64 100644 --- a/qml/windowed/FreeSortListView.qml +++ b/qml/windowed/FreeSortListView.qml @@ -335,14 +335,13 @@ Item { acceptedButtons: Qt.LeftButton | Qt.RightButton drag.target: dndTarget - // 记录是否是触摸长按导致的,防止在 onClicked 中重复处理 - property bool isTouchLongPressed: false - TapHandler { acceptedDevices: PointerDevice.TouchScreen gesturePolicy: TapHandler.DragThreshold + onTapped: function(eventPoint, buttons) { + launchItem() + } onLongPressed: { - mouseArea.isTouchLongPressed = true showContextMenu(itemDelegate, model, { hideMoveToTopMenu: index === 0 }) @@ -351,20 +350,18 @@ Item { } onPressed: function (mouse) { - isTouchLongPressed = false + // 触屏合成的鼠标事件不接受,交给 Flickable 处理滚动 + if (mouse.source !== undefined && mouse.source !== Qt.MouseEventNotSynthesized) { + mouse.accepted = false + return + } if (mouse.button === Qt.LeftButton) { itemDelegate.contentItem.grabToImage(function(result) { itemDelegate.Drag.imageSource = result.url }) } } - onClicked: function (mouse) { - if (isTouchLongPressed) { - isTouchLongPressed = false - return - } - if (mouse.button === Qt.RightButton) { showContextMenu(itemDelegate, model, { hideMoveToTopMenu: index === 0