Skip to content

fix: separate touchscreen and mouse context menu triggers in notifica…#1554

Merged
Ivy233 merged 1 commit into
linuxdeepin:masterfrom
Ivy233:fix/touchscreen-notify-context-menu
Apr 15, 2026
Merged

fix: separate touchscreen and mouse context menu triggers in notifica…#1554
Ivy233 merged 1 commit into
linuxdeepin:masterfrom
Ivy233:fix/touchscreen-notify-context-menu

Conversation

@Ivy233

@Ivy233 Ivy233 commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

…tion center

Split the context menu TapHandler into two separate handlers with device filtering to prevent touchscreen tap from incorrectly triggering the context menu when expanding collapsed notifications:

  1. Mouse/Touchpad handler: accepts right-button click from Keyboard, Mouse, and TouchPad devices
  2. Touchscreen handler: only accepts long-press gesture from TouchScreen device

This ensures that a single-finger tap on a collapsed notification only expands it without showing the context menu, while long-press still triggers the menu as expected.

Log: fix touchscreen tap incorrectly triggering context menu when expanding collapsed notifications

fix: 通知中心分离触摸屏和鼠标右键菜单触发方式

将右键菜单的 TapHandler 拆分为两个独立的处理器,并添加设备过滤,
防止触摸屏点击展开折叠通知时错误地触发右键菜单:

  1. 鼠标/触控板处理器:接受来自键盘、鼠标和触控板设备的右键点击
  2. 触摸屏处理器:仅接受来自触摸屏设备的长按手势

这确保了在折叠通知上单指点击只会展开通知而不会显示右键菜单,
同时长按仍然可以按预期触发菜单。

Log: 修复触摸屏点击展开折叠通知时错误触发右键菜单的问题

PMS: BUG-355017

Summary by Sourcery

Separate mouse and touchscreen context menu triggers in the notification center to avoid accidental context menu activation when expanding notifications.

Bug Fixes:

  • Prevent single-finger taps on collapsed notifications from triggering the context menu on touchscreens.

Enhancements:

  • Introduce distinct TapHandlers for mouse/touchpad right-clicks and touchscreen long-press gestures with appropriate device filtering.

@sourcery-ai

sourcery-ai Bot commented Apr 14, 2026

Copy link
Copy Markdown

Reviewer's Guide

Splits the notification center context-menu TapHandler into separate mouse/touchpad and touchscreen handlers with device filtering so that mouse right-click still opens the context menu while a single-finger tap on touchscreens only expands notifications, reserving long-press for the context menu.

Sequence diagram for separated context menu TapHandlers in notification center

sequenceDiagram
    actor User
    participant PointerDevice as PointerDevice_event
    participant MouseTapHandler as Mouse_TapHandler
    participant TouchTapHandler as Touchscreen_TapHandler
    participant NotifyViewDelegate as NotifyViewDelegate
    participant ContextMenu as ContextMenu

    rect rgb(230,230,250)
        User->>PointerDevice: right_click
        PointerDevice->>MouseTapHandler: tap_event(Qt.RightButton, device=Mouse)
        MouseTapHandler-->>TouchTapHandler: no_event
        MouseTapHandler->>MouseTapHandler: onPressedChanged(pressed=true)
        MouseTapHandler->>NotifyViewDelegate: setting(pos)
        NotifyViewDelegate->>ContextMenu: open_at(pos)
    end

    rect rgb(230,255,230)
        User->>PointerDevice: single_finger_tap
        PointerDevice->>TouchTapHandler: tap_event(device=TouchScreen)
        TouchTapHandler-->>MouseTapHandler: no_event
        TouchTapHandler->>NotifyViewDelegate: expand_notification
        NotifyViewDelegate->>ContextMenu: no_action
    end

    rect rgb(255,250,230)
        User->>PointerDevice: long_press
        PointerDevice->>TouchTapHandler: long_press_event(device=TouchScreen)
        TouchTapHandler->>TouchTapHandler: onLongPressed()
        TouchTapHandler->>NotifyViewDelegate: setting(pos)
        NotifyViewDelegate->>ContextMenu: open_at(pos)
    end
Loading

Flow diagram for device-filtered TapHandler routing

flowchart TD
    A[Pointer event in NotifyViewDelegate] --> B{PointerDevice type}

    B -->|Keyboard| C[Mouse_TapHandler]
    B -->|Mouse| C
    B -->|TouchPad| C
    B -->|TouchScreen| D[Touchscreen_TapHandler]

    C --> E{Button == Qt.RightButton and pressed}
    E -->|yes| F[call setting pos then open context menu]
    E -->|no| G[no context menu from Mouse_TapHandler]

    D --> H{Gesture type}
    H -->|long_press| F
    H -->|tap| I[expand or select notification only]
    H -->|other| J[ignore for context menu]
Loading

File-Level Changes

Change Details Files
Separate context-menu event handling between mouse/touchpad and touchscreen in the notification center delegate, with explicit device filtering and long-press handling.
  • Restrict the existing right-button TapHandler to keyboard, mouse, and touchpad pointer devices using acceptedDevices.
  • Add a new TapHandler that targets touchscreen devices only and invokes the same context-menu logic on long press instead of on press.
  • Apply the same mouse/touchscreen TapHandler separation to both main and grouped notification delegates so behavior is consistent across notification types.
panels/notification/center/NotifyViewDelegate.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

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

Hey - I've left some high level feedback:

  • The mouse and touchscreen TapHandler blocks are duplicated in two places; consider extracting them into a shared component or helper to avoid repetition and keep behavior consistent between sections.
  • If pen/stylus or other pointing devices are expected in this UI, consider whether they should be treated like mouse/touchpad or touchscreen and update the acceptedDevices masks accordingly.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The mouse and touchscreen TapHandler blocks are duplicated in two places; consider extracting them into a shared component or helper to avoid repetition and keep behavior consistent between sections.
- If pen/stylus or other pointing devices are expected in this UI, consider whether they should be treated like mouse/touchpad or touchscreen and update the acceptedDevices masks accordingly.

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.

Comment thread panels/notification/center/NotifyViewDelegate.qml Outdated
…tion center

Split the context menu TapHandler into two separate handlers with device
filtering to prevent touchscreen tap from incorrectly triggering the
context menu when expanding collapsed notifications:

1. Mouse/other devices handler: uses acceptedDevices with
   PointerDevice.AllDevices & ~PointerDevice.TouchScreen to exclude
   touchscreen, as touchscreen events bypass acceptedButtons check in Qt
2. Touchscreen handler: only accepts long-press gesture from TouchScreen
   device

This ensures that a single-finger tap on a collapsed notification only
expands it without showing the context menu, while long-press still
triggers the menu as expected.

Log: fix touchscreen tap incorrectly triggering context menu when expanding
collapsed notifications

fix: 通知中心分离触摸屏和鼠标右键菜单触发方式

将右键菜单的 TapHandler 拆分为两个独立的处理器,并添加设备过滤,
防止触摸屏点击展开折叠通知时错误地触发右键菜单:

1. 鼠标/其他设备处理器:使用 acceptedDevices 设置为
   PointerDevice.AllDevices & ~PointerDevice.TouchScreen 排除触摸屏,
   因为 Qt 中触摸屏事件会绕过 acceptedButtons 检查
2. 触摸屏处理器:仅接受来自触摸屏设备的长按手势

这确保了在折叠通知上单指点击只会展开通知而不会显示右键菜单,
同时长按仍然可以按预期触发菜单。

Log: 修复触摸屏点击展开折叠通知时错误触发右键菜单的问题

PMS: BUG-355017
@Ivy233 Ivy233 force-pushed the fix/touchscreen-notify-context-menu branch from 5acc8af to 2da197f Compare April 15, 2026 03:27
@Ivy233 Ivy233 requested a review from 18202781743 April 15, 2026 03:29
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, Ivy233

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

@Ivy233 Ivy233 merged commit 1bdec03 into linuxdeepin:master Apr 15, 2026
10 of 12 checks passed
@Ivy233 Ivy233 deleted the fix/touchscreen-notify-context-menu branch April 15, 2026 03:36
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.

3 participants