Skip to content

Conversation

@18202781743
Copy link
Contributor

@18202781743 18202781743 commented Jan 26, 2026

  1. Fixed touchscreen double-tap not maximizing/restoring windows by
    adding a separate TapHandler for non-mouse devices
  2. Fixed touchscreen long-press not showing system window menu by
    handling it in the non-mouse TapHandler
  3. Added device filtering to prevent conflicts between mouse and
    touchscreen events
  4. The original TapHandler now only accepts mouse events with
    acceptedDevices: PointerDevice.Mouse
  5. The new TapHandler accepts all non-mouse devices (touchscreen,
    stylus, etc.) and handles their gestures

Log: Fixed touchscreen double-tap to maximize/restore windows and long-
press to show system menu

Influence:

  1. Test double-tap on touchscreen to maximize and restore windows
  2. Test long-press on touchscreen to show system window menu
  3. Verify mouse right-click and left-click double-tap still work
    correctly
  4. Test with different input devices (touchscreen, mouse, stylus) to
    ensure proper device filtering
  5. Verify no conflicts between mouse and touchscreen event handling

fix: 修复触摸屏双击和长按处理问题

  1. 通过为非鼠标设备添加单独的TapHandler修复触摸屏双击无法最大化/还原窗口
    的问题
  2. 通过在非鼠标TapHandler中处理长按修复触摸屏长按无法显示系统窗口菜单的
    问题
  3. 添加设备过滤以防止鼠标和触摸屏事件冲突
  4. 原TapHandler现在只接受鼠标事件(acceptedDevices:
    PointerDevice.Mouse)
  5. 新的TapHandler接受所有非鼠标设备(触摸屏、手写笔等)并处理其手势

Log: 修复触摸屏双击最大化/还原窗口和长按显示系统菜单功能

Influence:

  1. 测试触摸屏双击以最大化和还原窗口
  2. 测试触摸屏长按以显示系统窗口菜单
  3. 验证鼠标右键和左键双击功能是否正常工作
  4. 测试不同输入设备(触摸屏、鼠标、手写笔)以确保正确的设备过滤
  5. 验证鼠标和触摸屏事件处理之间没有冲突

PMS: BUG-348313

Summary by Sourcery

Fix pointer event handling on the title bar so touchscreen and other non-mouse devices correctly trigger window state and system menu actions without conflicting with mouse input.

Bug Fixes:

  • Restore touchscreen double-tap on the title bar to maximize and restore windows.
  • Restore touchscreen long-press on the title bar to open the system window menu.
  • Prevent conflicts between mouse and non-mouse pointer events on the title bar by separating their handlers.

@18202781743 18202781743 requested review from BLumia and mhduiy January 26, 2026 09:09
@sourcery-ai
Copy link

sourcery-ai bot commented Jan 26, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Separates mouse and non-mouse input handling on the title bar by device type so that touchscreen double-tap and long-press gestures work correctly without impacting mouse behavior.

Sequence diagram for separated mouse and touchscreen tap handling on the title bar

sequenceDiagram
    actor User
    participant PointerDevice
    participant TitleBar
    participant MouseTapHandler
    participant TouchTapHandler
    participant Control
    participant DWindow

    %% Mouse double-click to maximize/restore
    User->>PointerDevice: mouse_double_click
    PointerDevice->>TitleBar: pointer_event(device_mouse)
    TitleBar->>MouseTapHandler: route_event
    MouseTapHandler->>MouseTapHandler: filter(acceptedDevices_mouse)
    MouseTapHandler-->>TitleBar: accepted
    MouseTapHandler->>Control: onDoubleTapped_leftButton
    Control->>Control: toggleWindowState

    %% Touchscreen double-tap to maximize/restore
    User->>PointerDevice: touch_double_tap
    PointerDevice->>TitleBar: pointer_event(device_touch)
    TitleBar->>MouseTapHandler: route_event
    MouseTapHandler->>MouseTapHandler: filter(acceptedDevices_mouse)
    MouseTapHandler-->>TitleBar: rejected
    TitleBar->>TouchTapHandler: route_event
    TouchTapHandler->>TouchTapHandler: filter(non_mouse_devices)
    TouchTapHandler-->>TitleBar: accepted
    TouchTapHandler->>Control: onDoubleTapped
    Control->>Control: toggleWindowState

    %% Touchscreen long-press to open system menu
    User->>PointerDevice: touch_long_press
    PointerDevice->>TitleBar: pointer_event(device_touch)
    TitleBar->>TouchTapHandler: route_event
    TouchTapHandler->>TouchTapHandler: filter(non_mouse_devices)
    TouchTapHandler-->>TitleBar: accepted
    TouchTapHandler->>DWindow: onLongPressed
    DWindow->>DWindow: popupSystemWindowMenu
Loading

Flow diagram for TapHandler device filtering on the title bar

flowchart TD
    A[Pointer event on TitleBar] --> B{Device is mouse?}
    B -->|Yes| C[MouseTapHandler]
    B -->|No - touch, stylus, etc.| D[TouchTapHandler]

    C --> E{Button type?}
    E -->|LeftButton double_tap| F[Control.toggleWindowState]
    E -->|RightButton single_click| G[DWindow.popupSystemWindowMenu]

    D --> H{Gesture type?}
    H -->|double_tap| F
    H -->|long_press| G
Loading

File-Level Changes

Change Details Files
Constrain the existing title-bar TapHandler to mouse-only input and keep mouse behaviors intact.
  • Add an acceptedDevices filter restricting the existing TapHandler to PointerDevice.Mouse.
  • Ensure double-tap with the left mouse button still toggles window maximize/restore.
  • Preserve right-click behavior that shows the system window menu for mouse input.
qt6/src/qml/TitleBar.qml
Introduce a dedicated TapHandler for non-mouse pointer devices to handle touchscreen and stylus gestures.
  • Add a second TapHandler configured with acceptedDevices set to all non-mouse devices (PointerDevice.AllDevices & ~PointerDevice.Mouse).
  • Handle onDoubleTapped for non-mouse devices by toggling the window maximize/restore state.
  • Handle onLongPressed for non-mouse devices by invoking __dwindow.popupSystemWindowMenu() so the system window menu appears on long-press.
  • Avoid conflicts between mouse and touchscreen input by separating handlers by device type.
qt6/src/qml/TitleBar.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

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • Consider extracting the shared double-tap behavior into a helper or single handler where feasible to avoid duplicating control.toggleWindowState() logic across mouse and non-mouse handlers.
  • Double-check that PointerDevice.AllDevices & ~PointerDevice.Mouse behaves consistently across platforms and Qt versions; if certain device types (e.g., touchpad vs. touchscreen) must be handled differently, it may be clearer to enumerate the intended non-mouse devices explicitly.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider extracting the shared double-tap behavior into a helper or single handler where feasible to avoid duplicating `control.toggleWindowState()` logic across mouse and non-mouse handlers.
- Double-check that `PointerDevice.AllDevices & ~PointerDevice.Mouse` behaves consistently across platforms and Qt versions; if certain device types (e.g., touchpad vs. touchscreen) must be handled differently, it may be clearer to enumerate the intended non-mouse devices explicitly.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

mhduiy
mhduiy previously approved these changes Jan 26, 2026
1. Fixed touchscreen double-tap not maximizing/restoring windows by
adding a separate TapHandler for non-mouse devices
2. Fixed touchscreen long-press not showing system window menu by
handling it in the non-mouse TapHandler
3. Added device filtering to prevent conflicts between mouse and
touchscreen events
4. The original TapHandler now only accepts mouse events with
acceptedDevices: PointerDevice.Mouse
5. The new TapHandler accepts all non-mouse devices (touchscreen,
stylus, etc.) and handles their gestures

Log: Fixed touchscreen double-tap to maximize/restore windows and long-
press to show system menu

Influence:
1. Test double-tap on touchscreen to maximize and restore windows
2. Test long-press on touchscreen to show system window menu
3. Verify mouse right-click and left-click double-tap still work
correctly
4. Test with different input devices (touchscreen, mouse, stylus) to
ensure proper device filtering
5. Verify no conflicts between mouse and touchscreen event handling

fix: 修复触摸屏双击和长按处理问题

1. 通过为非鼠标设备添加单独的TapHandler修复触摸屏双击无法最大化/还原窗口
的问题
2. 通过在非鼠标TapHandler中处理长按修复触摸屏长按无法显示系统窗口菜单的
问题
3. 添加设备过滤以防止鼠标和触摸屏事件冲突
4. 原TapHandler现在只接受鼠标事件(acceptedDevices:
PointerDevice.Mouse)
5. 新的TapHandler接受所有非鼠标设备(触摸屏、手写笔等)并处理其手势

Log: 修复触摸屏双击最大化/还原窗口和长按显示系统菜单功能

Influence:
1. 测试触摸屏双击以最大化和还原窗口
2. 测试触摸屏长按以显示系统窗口菜单
3. 验证鼠标右键和左键双击功能是否正常工作
4. 测试不同输入设备(触摸屏、鼠标、手写笔)以确保正确的设备过滤
5. 验证鼠标和触摸屏事件处理之间没有冲突

PMS: BUG-348313
@deepin-ci-robot
Copy link
Contributor

deepin pr auto review

这段代码修改的目的是为了区分鼠标操作和触摸屏操作,为不同输入设备提供不同的交互逻辑。以下是对这段代码的详细审查和改进建议:

1. 语法逻辑审查

优点:

  • 设备分离逻辑清晰:通过使用 PointerDevice.AllDevices & ~PointerDevice.TouchScreenPointerDevice.TouchScreen,成功地将鼠标/触控板操作与触摸屏操作分离开来。
  • 交互语义符合直觉
    • 鼠标:左键双击切换窗口状态,右键长按弹出菜单。
    • 触摸屏:双击切换窗口状态,长按弹出菜单。
    • 这符合各自平台的常规操作习惯。

潜在问题与改进建议:

  • TapHandleronDoubleTapped 参数

    • 在第一个 TapHandler 中,onDoubleTapped 定义了参数 (eventPoint, button),但在新添加的第二个 TapHandler(针对触摸屏)中,onDoubleTapped 定义为 function (),没有参数。
    • 建议:虽然触摸屏通常没有"右键"概念,不需要判断 button,但为了代码的一致性和健壮性,建议保留参数签名,例如 onDoubleTapped: function(eventPoint) { ... }。这样如果未来需要获取触摸点的坐标,可以直接使用。
  • 事件处理冲突

    • TapHandler 默认会捕获点击事件。虽然这里通过 acceptedDevices 进行了物理隔离,但在某些混合设备上(如支持触摸的笔记本),如果逻辑处理不当可能会有微妙的冲突。不过目前的写法使用了互斥的设备过滤,逻辑上是安全的。

2. 代码质量审查

优点:

  • 可读性:代码结构清晰,意图明确。

改进建议:

  • 代码复用

    • control.toggleWindowState()__dwindow.popupSystemWindowMenu() 在两个 Handler 中被重复调用。
    • 建议:可以将这些操作封装为 Item 级别的函数(如果是私有逻辑),或者直接保留现状。鉴于目前逻辑非常简单,重复调用反而更直观,无需过度封装。
  • 注释

    • 建议添加注释说明为什么要分离这两个 Handler,例如:// 分离鼠标和触摸屏事件处理,以适应不同设备的交互习惯

3. 代码性能审查

  • 评估:此修改对性能影响极小。
  • 分析:添加了一个额外的 TapHandler。虽然增加了一个对象,但 QML 引擎对输入事件的处理非常高效。通过明确的 acceptedDevices 过滤,事件分发会非常迅速,不会造成明显的性能损耗。

4. 代码安全审查

  • 评估:无安全风险。
  • 分析:这段代码仅涉及 UI 交互逻辑,不涉及数据处理、网络请求或文件系统访问,因此不存在常规的安全漏洞(如注入攻击、权限泄露等)。

总结与最终代码建议

这段代码的修改逻辑是正确的,能够很好地解决混合输入设备场景下的交互问题。为了提高代码的健壮性和一致性,建议微调参数签名并添加注释。

改进后的代码片段:

    // 鼠标/触控板事件处理
    TapHandler {
        acceptedButtons: Qt.RightButton | Qt.LeftButton
        // 排除触摸屏,仅处理鼠标类设备
        acceptedDevices: PointerDevice.AllDevices & ~PointerDevice.TouchScreen
        
        onDoubleTapped: function (eventPoint, button) {
            if (button === Qt.LeftButton) {
                control.toggleWindowState()
            }
        }
        onLongPressed: function (eventPoint, button) {
            if (button === Qt.RightButton) {
                __dwindow.popupSystemWindowMenu()
            }
        }
    }
    
    // 触摸屏事件处理
    TapHandler {
        acceptedDevices: PointerDevice.TouchScreen
        
        onDoubleTapped: function (eventPoint) { // 建议保留 eventPoint 参数
            control.toggleWindowState()
        }
        onLongPressed: function (eventPoint) { // 建议保留 eventPoint 参数
            __dwindow.popupSystemWindowMenu()
        }
    }

@deepin-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, BLumia, 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

@18202781743 18202781743 merged commit b7c1e92 into linuxdeepin:master Jan 27, 2026
19 of 20 checks passed
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.

4 participants