fix: add delay for x11 window preview to prevent accidental shows - #1714
fix: add delay for x11 window preview to prevent accidental shows#1714wjyrich wants to merge 1 commit into
Conversation
1. Add a 300ms delay timer before showing X11 window previews 2. Store the pending preview window ID and only trigger preview if mouse remains on the item 3. Cancel pending previews on hover leave, mouse click, and container hide events 4. Prevent flickering when users quickly move across taskbar items Log: X11窗口预view display now has a 300ms delay to reduce accidental previews Influence: 1. Hover over a taskbar item and verify preview appears after ~300ms 2. Quickly move across multiple taskbar items and verify no preview flickering 3. Hover and move away before the delay expires, verify preview does not appear 4. Click a taskbar item while preview is pending, verify it is cancelled 5. Hide the preview container while a preview is pending, verify timers are cleaned up 6. Verify preview behavior in both compositing and non-compositing environments fix: 为 X11 窗口预览添加延迟显示功能 1. 添加300ms的延迟定时器,用于X11窗口预览显示 2. 记录待预览的窗口ID,仅当鼠标仍停留在项目上时才触发预览 3. 在鼠标悬停离开、鼠标点击和容器隐藏事件时取消待处理的预览 4. 防止用户快速滑动任务栏项目时出现预览闪烁 Log: X11窗口预览新增300ms延迟,减少误触发现象 Influence: 1. 悬停在任务栏项目上,验证约300ms后显示预览 2. 快速滑动多个任务栏项目,验证无预览闪烁 3. 在延迟时间内移开鼠标,验证预览不显示 4. 在预览等待期间点击任务栏项目,验证取消操作 5. 预览等待期间隐藏容器,验证定时器正确清理 6. 在非合成和合成环境下验证预览行为 PMS: TASK-394749
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: wjyrich 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 |
Reviewer's GuideAdds a 300 ms single-shot delay before X11 window previews are shown, tracks the hovered window to suppress accidental previews during rapid movement, and cancels pending work on hover leave, clicks, and container hiding while preserving compositor-specific behavior. Sequence diagram for delayed X11 window previewsequenceDiagram
participant User
participant PreviewContainer
participant PreviewDelayTimer
participant X11WindowMonitor
participant WM_HELPER
User->>PreviewContainer: entered(index)
PreviewContainer->>PreviewContainer: m_pendingPreviewWinId = WinIdRole
PreviewContainer->>PreviewDelayTimer: start()
PreviewDelayTimer-->>PreviewContainer: timeout after 300ms
PreviewContainer->>WM_HELPER: hasComposite()
alt compositor available
PreviewContainer->>X11WindowMonitor: previewWindow(m_pendingPreviewWinId)
end
State diagram for pending X11 preview cancellationstateDiagram-v2
[*] --> NoPendingPreview
NoPendingPreview --> PreviewPending: entered(index) / start()
PreviewPending --> PreviewShown: timeout / previewWindow(m_pendingPreviewWinId)
PreviewPending --> NoPendingPreview: HoverLeave / stop()
PreviewPending --> NoPendingPreview: LeftClick / stop()
PreviewPending --> NoPendingPreview: hideEvent / stop()
PreviewShown --> NoPendingPreview: HoverLeave / cancelPreviewWindow()
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="panels/dock/taskmanager/x11preview.cpp" line_range="393-398" />
<code_context>
+ m_previewDelayTimer = new QTimer(this);
+ m_previewDelayTimer->setSingleShot(true);
+ m_previewDelayTimer->setInterval(PREVIEW_WINDOW_DELAY);
+ connect(m_previewDelayTimer, &QTimer::timeout, this, [this]() {
+ if (m_pendingPreviewWinId == 0 || m_monitor.isNull())
+ return;
+ if (WM_HELPER->hasComposite())
+ m_monitor->previewWindow(m_pendingPreviewWinId);
+ });
+
setWindowFlags(Qt::ToolTip | Qt::WindowStaysOnTopHint | Qt::WindowDoesNotAcceptFocus | Qt::FramelessWindowHint);
</code_context>
<issue_to_address>
**issue (bug_risk):** The timeout callback previews `m_pendingPreviewWinId` without verifying that the cursor is still over that item. Moving from an item into empty space in the viewport does not necessarily emit the viewport's `HoverLeave`, so the pending window ID remains set and its preview appears after 300 ms even though the mouse has already left the item.
**Triggers:** When the preview viewport contains empty space, such as below the final row or between items.
**Suggested fix:** On timeout, validate the cursor position with `m_view->indexAt(...)` and only preview when it resolves to the same index/window ID; otherwise stop the timer and clear `m_pendingPreviewWinId`. Alternatively, cancel the timer on item-level hover leave.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| connect(m_previewDelayTimer, &QTimer::timeout, this, [this]() { | ||
| if (m_pendingPreviewWinId == 0 || m_monitor.isNull()) | ||
| return; | ||
| if (WM_HELPER->hasComposite()) | ||
| m_monitor->previewWindow(m_pendingPreviewWinId); | ||
| }); |
There was a problem hiding this comment.
issue (bug_risk): The timeout callback previews m_pendingPreviewWinId without verifying that the cursor is still over that item. Moving from an item into empty space in the viewport does not necessarily emit the viewport's HoverLeave, so the pending window ID remains set and its preview appears after 300 ms even though the mouse has already left the item.
Triggers: When the preview viewport contains empty space, such as below the final row or between items.
Suggested fix: On timeout, validate the cursor position with m_view->indexAt(...) and only preview when it resolves to the same index/window ID; otherwise stop the timer and clear m_pendingPreviewWinId. Alternatively, cancel the timer on item-level hover leave.
Log: X11窗口预view display now has a 300ms delay to reduce accidental previews
Influence:
fix: 为 X11 窗口预览添加延迟显示功能
Log: X11窗口预览新增300ms延迟,减少误触发现象
Influence:
PMS: TASK-394749
Summary by Sourcery
Delay X11 taskbar window previews and cancel them when hover context changes to provide more stable preview behavior.
New Features:
Bug Fixes:
Enhancements: