-
Notifications
You must be signed in to change notification settings - Fork 42
fix: fix touchscreen double-tap and long-press handling #561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideSeparates 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 barsequenceDiagram
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
Flow diagram for TapHandler device filtering on the title barflowchart 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
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this 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.Mousebehaves 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.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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 pr auto review这段代码修改的目的是为了区分鼠标操作和触摸屏操作,为不同输入设备提供不同的交互逻辑。以下是对这段代码的详细审查和改进建议: 1. 语法逻辑审查优点:
潜在问题与改进建议:
2. 代码质量审查优点:
改进建议:
3. 代码性能审查
4. 代码安全审查
总结与最终代码建议这段代码的修改逻辑是正确的,能够很好地解决混合输入设备场景下的交互问题。为了提高代码的健壮性和一致性,建议微调参数签名并添加注释。 改进后的代码片段: // 鼠标/触控板事件处理
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()
}
} |
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
adding a separate TapHandler for non-mouse devices
handling it in the non-mouse TapHandler
touchscreen events
acceptedDevices: PointerDevice.Mouse
stylus, etc.) and handles their gestures
Log: Fixed touchscreen double-tap to maximize/restore windows and long-
press to show system menu
Influence:
correctly
ensure proper device filtering
fix: 修复触摸屏双击和长按处理问题
的问题
问题
PointerDevice.Mouse)
Log: 修复触摸屏双击最大化/还原窗口和长按显示系统菜单功能
Influence:
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: