Skip to content

fix: add delay for x11 window preview to prevent accidental shows - #1714

Open
wjyrich wants to merge 1 commit into
linuxdeepin:masterfrom
wjyrich:task-394749
Open

fix: add delay for x11 window preview to prevent accidental shows#1714
wjyrich wants to merge 1 commit into
linuxdeepin:masterfrom
wjyrich:task-394749

Conversation

@wjyrich

@wjyrich wjyrich commented Aug 26, 2026

Copy link
Copy Markdown
Contributor
  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

Summary by Sourcery

Delay X11 taskbar window previews and cancel them when hover context changes to provide more stable preview behavior.

New Features:

  • Add a short delay before displaying X11 window previews to reduce accidental activations.

Bug Fixes:

  • Prevent preview flickering when moving quickly across taskbar items by cancelling previews that are no longer relevant.

Enhancements:

  • Cancel pending previews when the pointer leaves an item, the user clicks, or the preview container is hidden.

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
@deepin-ci-robot

Copy link
Copy Markdown

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

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 Aug 26, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds 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 preview

sequenceDiagram
    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
Loading

State diagram for pending X11 preview cancellation

stateDiagram-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()
Loading

File-Level Changes

Change Details Files
Introduces deferred X11 preview activation with hover-state tracking.
  • Adds a single-shot 300 ms timer and stores the pending window ID.
  • Starts or restarts delayed preview handling when a taskbar item is entered.
  • Shows the preview only after the timer expires and only in compositing environments.
panels/dock/taskmanager/x11preview.cpp
panels/dock/taskmanager/x11preview.h
Cancels pending preview work across lifecycle and user interaction paths.
  • Stops the delay timer and clears the pending window on hover leave, left-click, and container hide.
  • Retains existing compositor checks and preview cancellation behavior.
panels/dock/taskmanager/x11preview.cpp
Updates the preview container state and ownership declarations for the new timer.
  • Adds timer and pending-window members initialized for the container.
  • Parents the timer to the container for automatic cleanup.
panels/dock/taskmanager/x11preview.cpp
panels/dock/taskmanager/x11preview.h

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

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 on lines +393 to +398
connect(m_previewDelayTimer, &QTimer::timeout, this, [this]() {
if (m_pendingPreviewWinId == 0 || m_monitor.isNull())
return;
if (WM_HELPER->hasComposite())
m_monitor->previewWindow(m_pendingPreviewWinId);
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

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