Skip to content

fix: filter touch events in windowed icon delegate - #810

Open
mhduiy wants to merge 1 commit into
masterfrom
agent/pms-bug-bot/36b775dc6012
Open

mhduiy wants to merge 1 commit into
masterfrom
agent/pms-bug-bot/36b775dc6012

Conversation

@mhduiy

@mhduiy mhduiy commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Root Cause Analysis

IconItemDelegate.qml MouseArea.onPressed lacks mouse.source touch-synthesized event filtering. When a touchscreen finger press is synthesized as a mouse event, the MouseArea's drag.target consumes it, triggering app drag instead of letting the parent GridView/Flickable scroll. This is the same defect class as BUG-362161 (commit f86bd7a), which fixed AppListView.qml and FreeSortListView.qml but missed IconItemDelegate.qml.

Key evidence:

  • qml/windowed/IconItemDelegate.qml:58drag.target: root.dndEnabled ? root : null enables drag
  • qml/windowed/IconItemDelegate.qml:62-68 — onPressed has no mouse.source check
  • qml/windowed/AppListView.qml:253-258 — already fixed with source check guard (f86bd7a)

Fix

Add mouse.source check in onPressed to reject touch-synthesized events (same pattern as f86bd7a), and add TapHandler { acceptedDevices: PointerDevice.TouchScreen } for touch tap activation and long-press context menu support.

Change Safety Assessment

Code Safety

Risk: Low. The mouse.source guard only rejects synthesized events (source != Qt.MouseEventNotSynthesized); real mouse events pass through unaffected. The TapHandler is restricted to PointerDevice.TouchScreen and does not interfere with mouse event delivery. The same pattern is validated in AppListView.qml.

Historical note: commit 2c2921f (BUG-358827) removed a previous TapHandler due to event conflicts with MouseArea. However, that conflict involved TapHandlers accepting mouse buttons — this fix's TapHandler only accepts touch screen devices, and the current code already handles right-click via onClicked. AppListView uses the identical pattern successfully.

Business Impact

  • Touchscreen single-finger scroll in windowed launcher app grid now works (previously triggered app drag)
  • Touchscreen tap to open apps and long-press for context menu remain functional via TapHandler
  • Mouse left-click, right-click context menu, and drag-and-drop are unaffected

Verification Suggestions

  1. Touchscreen: single-finger scroll up/down in app grid — should scroll, not drag
  2. Touchscreen: tap an icon — should open the app
  3. Touchscreen: long-press an icon — should show context menu
  4. Mouse: left-click, right-click, and drag — all should work as before

根因分析

IconItemDelegate.qml 的 MouseArea.onPressed 缺少 mouse.source 触摸合成事件过滤。触摸屏单指按下被 Qt 合成为鼠标事件后,MouseArea 的 drag.target 消费该事件触发应用拖拽,阻止父级 GridView/Flickable 滚动。与 BUG-362161(commit f86bd7a)同一类缺陷,上次修复覆盖了 AppListView.qmlFreeSortListView.qml,遗漏了 IconItemDelegate.qml

修复方案

onPressed 中添加 mouse.source 检查守卫拒绝触摸合成事件(与 f86bd7a 模式一致),添加 TapHandler { acceptedDevices: PointerDevice.TouchScreen } 支持触摸点击激活和长按右键菜单。

改动安全评估

代码安全

风险:低。 mouse.source 守卫仅拒绝合成事件,真实鼠标事件不受影响。TapHandler 限定 PointerDevice.TouchScreen,不干扰鼠标事件分发。AppListView.qml 已验证相同模式可行。

业务影响

  • 触控屏单指滑动应用网格区域现在可正常滚动(之前触发应用拖拽)
  • 触控屏点击打开应用、长按弹出右键菜单通过 TapHandler 保持可用
  • 鼠标左键点击、右键菜单、拖拽功能不受影响

验证建议

  1. 触控屏:单指在应用网格上下滑动 — 应滚动而非拖拽
  2. 触控屏:点击图标 — 应打开应用
  3. 触控屏:长按图标 — 应弹出右键菜单
  4. 鼠标:左键点击、右键菜单、拖拽 — 均应正常工作

Summary by Sourcery

Fix touchscreen interaction handling in the windowed icon delegate so scrolling, activation, and context menus work correctly without affecting mouse controls.

New Features:

  • Add touch-specific tap and long-press interactions for windowed app icons.

Bug Fixes:

  • Prevent synthesized touchscreen mouse events from starting icon drags so the app grid can scroll normally.

1. Root cause: IconItemDelegate.qml MouseArea.onPressed lacks
   mouse.source check, touch-synthesized events consumed by drag
   mechanism, blocking parent Flickable scrolling
2. Fix: add mouse.source guard to reject synthesized events, add
   TapHandler for touch tap and long-press menu support
3. Impact: only IconItemDelegate.qml changed, real mouse interaction
   unaffected, follows same pattern as AppListView (f86bd7a)

Log: fix touch scroll triggering app drag in windowed launcher

Influence:
1. Test touchscreen single-finger scroll in app grid area
2. Test touchscreen tap to open app and long-press for context menu
3. Test mouse left-click, right-click, and drag remain functional

fix: 过滤窗口模式图标代理的触摸事件

1. 根因:IconItemDelegate.qml 的 MouseArea.onPressed 缺少
   mouse.source 检查,触摸合成事件被 drag 机制消费,阻止父级
   Flickable 滚动
2. 方案:添加 mouse.source 守卫拒绝合成事件,添加 TapHandler
   支持触摸点击和长按菜单
3. 影响:仅修改 IconItemDelegate.qml,真实鼠标交互不受影响,
   与 AppListView(f86bd7a)修复模式一致

Log: 修复窗口模式启动器触摸滑动触发应用拖拽的问题

Influence:
1. 测试触控屏单指在应用网格区域滑动滚动
2. 测试触控屏点击打开应用和长按弹出右键菜单
3. 测试鼠标左键点击、右键菜单、拖拽功能正常

PMS: BUG-309193

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

Sorry @mhduiy, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 5 hours and 23 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mhduiy

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

@sourcery-ai

sourcery-ai Bot commented Sep 14, 2026

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

Reviewer's Guide

Updates the windowed icon delegate to prevent synthesized touchscreen presses from starting app drags, allowing the parent grid to scroll, while adding TouchScreen-specific tap and long-press handling so touch activation and context menus remain functional without changing mouse interactions.

Sequence diagram for touch input in the windowed icon delegate

sequenceDiagram
    actor User
    participant Touchscreen
    participant IconItemDelegate
    participant GridView
    participant App
    participant ContextMenu

    User->>Touchscreen: Touch and drag
    Touchscreen->>IconItemDelegate: onPressed(mouse)
    alt synthesized mouse event
        IconItemDelegate-->>GridView: mouse.accepted = false
        GridView->>GridView: Scroll content
    else touch tap
        Touchscreen->>IconItemDelegate: TapHandler.onTapped()
        IconItemDelegate->>App: itemClicked()
    else touch long press
        Touchscreen->>IconItemDelegate: TapHandler.onLongPressed()
        IconItemDelegate->>ContextMenu: menuTriggered()
    end
Loading

File-Level Changes

Change Details Files
Filter touch-synthesized mouse presses so parent scrolling is not intercepted by icon drag handling.
  • Reject synthesized touch mouse events in the existing press handler by clearing acceptance.
  • Preserve native mouse behavior and existing drag-and-drop handling.
qml/windowed/IconItemDelegate.qml
Handle touchscreen activation and long-press actions through a touch-specific pointer handler.
  • Add a TouchScreen-only TapHandler with drag-threshold gesture policy.
  • Trigger icon activation on touch taps and the context menu on long presses.
qml/windowed/IconItemDelegate.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

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 100 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 未发现安全漏洞,代码修改遵循已有模式,语法逻辑正确,代码质量良好,性能无瓶颈。修复了触屏合成事件未过滤导致的拖拽冲突问题,与 AppListView.qml 和 FreeSortListView.qml 的修复模式完全一致。

📋 提交信息

项目 内容
PR #810
标题 fix: filter touch events in windowed icon delegate
作者 mhduiy
修改文件 qml/windowed/IconItemDelegate.qml (+17, -0)
分析模式 全量分析(GitHub PR)

🔍 详细分析

1. 语法逻辑 ✓ (25/25分)

评价词: 语法正确,逻辑清晰

分析:

  • QML 语法正确,TapHandler 块正确嵌套在 MouseArea 内部
  • onPressed 函数正确检查 mouse.source 属性后再处理事件
  • mouse.accepted = false; return 是 QML 中拒绝事件的标准方式,设置后 MouseArea 不会继续跟踪该按下事件,因此 onPressAndHoldonClickeddrag 均不会被触屏合成事件触发
  • mouse.source !== undefined 是良好的防御性编程,兼容不同 Qt 版本中 mouse.source 属性可能不存在的情况
  • TapHandler 的 acceptedDevices: PointerDevice.TouchScreen 限定仅处理触摸屏设备,避免与 MouseArea 的鼠标事件处理冲突
  • gesturePolicy: TapHandler.DragThreshold 正确区分点击和滑动操作

潜在问题:
✅ 未发现明显问题


2. 代码质量 ✓ (25/25分)

评价词: 代码结构清晰,注释完整

分析:

  • 添加了清晰的中文注释:"触屏合成的鼠标事件不接受,交给 Flickable 处理滚动",解释了过滤逻辑的目的
  • TapHandler 的属性设置语义清晰:acceptedDevices 限定设备类型,gesturePolicy 设定手势策略
  • 代码遵循与 AppListView.qml(第242-251行)和 FreeSortListView.qml(第351-363行)完全一致的修复模式,保持代码库一致性
  • onTapped: function(eventPoint, buttons) 使用了正确的 Qt TapHandler API 签名
  • onLongPressed 调用 root.menuTriggered() 与 MouseArea 的 onPressAndHoldonClicked 中的右键处理保持一致
  • 无重复代码,无调试残留,无敏感信息

潜在问题:
✅ 未发现明显问题


3. 代码性能 ✓ (20/20分)

评价词: 性能良好,资源使用合理

分析:

  • mouse.source 属性检查是轻量级的属性读取操作,仅在 onPressed 时执行一次,开销可忽略
  • TapHandler 仅在触摸屏设备事件时激活,不影响鼠标事件的性能
  • 无不必要的内存分配或计算
  • grabToImage 调用现在被正确地限定在非合成鼠标事件中,避免触屏事件触发不必要的图像抓取

潜在问题:
✅ 未发现明显问题


4. 代码安全 ✓ (30/30分)

评价词: 存在0个安全漏洞

分析:

  • 本次代码变更仅为 UI 事件处理逻辑调整,不涉及用户输入校验、网络访问、文件系统操作或敏感信息处理
  • 无命令注入、SQL 注入、路径遍历等安全风险
  • 无硬编码密钥或敏感信息泄露
  • 无缓冲区溢出或内存安全问题
  • 安全扫描工具确认:0 个安全漏洞

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个

安全漏洞详情:
✅ 未发现安全漏洞


📝 审查总结

本次 PR 修复了 IconItemDelegate.qml 中触屏合成鼠标事件未过滤的问题。该问题与 BUG-362161 同类,之前的修复(commit f86bd7a)覆盖了 AppListView.qmlFreeSortListView.qml,但遗漏了 IconItemDelegate.qml

修复方案正确且一致:

  1. onPressed 中添加 mouse.source 检查,拒绝触屏合成的鼠标事件,使 Flickable 能正常处理滚动
  2. 添加 TapHandler 限定 PointerDevice.TouchScreen,恢复触屏点击打开应用和长按弹出菜单功能
  3. 修复模式与已验证的 AppListView.qmlFreeSortListView.qml 完全一致

代码变更风险评估为低风险,不影响现有鼠标交互功能。


本报告由 AI 代码审查工具自动生成

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.

2 participants