Skip to content

perf: optimize dock network plugin panel height resizing frequency#531

Open
yixinshark wants to merge 1 commit intolinuxdeepin:masterfrom
yixinshark:fix-updateSize
Open

perf: optimize dock network plugin panel height resizing frequency#531
yixinshark wants to merge 1 commit intolinuxdeepin:masterfrom
yixinshark:fix-updateSize

Conversation

@yixinshark
Copy link
Copy Markdown
Contributor

@yixinshark yixinshark commented Mar 26, 2026

Introduced a QTimer to debounce the updateSize calls within the DockContentWidget. This heavily reduces the number of layout and geometry calculation events fired to the compositor (max 1 per 150ms) when rapidly scanning and appending Wi-Fi hotspots, thereby fixing visual flickering issues in Wayland without leaving dead space.

性能:优化任务栏网络插件面板高度调整频率

在 DockContentWidget 内部引入了 QTimer 对 updateSize 调用进行节流 (防抖)处理。扫描并连续追加 Wi-Fi 热点时,大幅减少发往合成器的
布局与几何计算事件(受限于最多 150ms 一次),从而修复了 Wayland 下
因窗口频繁变尺寸而引发的闪烁问题,同时也完整保留了正常的自适应包
裹尺寸机制。

Log: optimize dock network plugin panel height resizing frequency

Summary by Sourcery

Enhancements:

  • Limit dock network panel height recalculation frequency via a timer-driven size update to avoid excessive geometry updates while preserving adaptive sizing behavior.

Introduced a QTimer to debounce the updateSize calls within the
DockContentWidget. This heavily reduces the number of layout and
geometry calculation events fired to the compositor (max 1 per
150ms) when rapidly scanning and appending Wi-Fi hotspots, thereby
fixing visual flickering issues in Wayland without leaving dead space.

性能:优化任务栏网络插件面板高度调整频率

在 DockContentWidget 内部引入了 QTimer 对 updateSize 调用进行节流
(防抖)处理。扫描并连续追加 Wi-Fi 热点时,大幅减少发往合成器的
布局与几何计算事件(受限于最多 150ms 一次),从而修复了 Wayland 下
因窗口频繁变尺寸而引发的闪烁问题,同时也完整保留了正常的自适应包
裹尺寸机制。

Log: optimize dock network plugin panel height resizing frequency
@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: yixinshark

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

sourcery-ai bot commented Mar 26, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Introduces a debounced height recalculation mechanism for the dock network plugin panel using a QTimer, reducing frequent resize/layout events while preserving correct adaptive sizing behavior, especially to fix Wayland flicker when Wi-Fi hotspots list changes rapidly.

Sequence diagram for debounced DockContentWidget height updates

sequenceDiagram
    participant NetView
    participant DockContentWidget
    participant QTimer

    NetView->>DockContentWidget: updateSize()
    alt widget not visible
        DockContentWidget->>DockContentWidget: doUpdateSize()
        DockContentWidget->>NetView: setMaxHeight(h)
    else widget visible
        DockContentWidget->>QTimer: start(150ms)
        QTimer-->>DockContentWidget: timeout()
        DockContentWidget->>DockContentWidget: doUpdateSize()
        DockContentWidget->>NetView: setMaxHeight(h)
    end

    DockContentWidget->>DockContentWidget: showEvent(event)
    DockContentWidget->>DockContentWidget: doUpdateSize()
    DockContentWidget->>DockContentWidget: queued doUpdateSize()
    DockContentWidget->>DockContentWidget: resize(size())
Loading

Class diagram for DockContentWidget debounce changes

classDiagram
    class DockContentWidget {
        QVBoxLayout* m_mainLayout
        NetView* m_netView
        int m_minHeight
        JumpSettingButton* m_netSetBtn
        JumpSettingButton* m_netCheckBtn
        QTimer* m_updateTimer

        DockContentWidget(NetView* netView)
        void updateSize()
        void doUpdateSize()
        void showEvent(QShowEvent* event)
    }

    class NetView {
        void setMaxHeight(int h)
        int height()
        void updateSize()
    }

    class JumpSettingButton {
        int height()
        bool isVisible()
    }

    class QTimer {
        void setSingleShot(bool singleShot)
        void setInterval(int msec)
        void start()
        signal timeout()
    }

    class QVBoxLayout {
        QMargins contentsMargins()
    }

    class QMargins {
        int top()
    }

    DockContentWidget --> NetView : uses
    DockContentWidget --> JumpSettingButton : uses
    DockContentWidget --> QTimer : debounces_updateSize
    DockContentWidget --> QVBoxLayout : layout
    QVBoxLayout --> QMargins : returns
Loading

File-Level Changes

Change Details Files
Debounce dock content size recalculation to limit resize/layout events to at most once every 150ms while maintaining correct sizing on show and when hidden.
  • Add a QTimer member to DockContentWidget, configure it as single-shot with a 150ms interval, and connect its timeout to a new doUpdateSize slot.
  • Refactor the existing updateSize slot to either call doUpdateSize immediately when the widget is not visible or start the QTimer when it is visible, effectively debouncing resize operations.
  • Move the original size computation and NetView max-height adjustment logic into doUpdateSize so it is shared by both the timer and direct callers.
  • Adjust showEvent to invoke doUpdateSize synchronously and via a queued connection instead of the debounced updateSize, ensuring correct initial layout without delay.
  • Extend the DockContentWidget member list to include the QTimer pointer for managing debounced updates.
dock-network-plugin/dockcontentwidget.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

Copy link
Copy Markdown

@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 replacing the hard-coded 150 ms debounce interval with a named constant or configuration value to make the intent clearer and simplify future tuning.
  • If doUpdateSize is not meant to be called from outside this class, you could move it to the private section (or use a private slot) to avoid expanding the public API surface unnecessarily.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider replacing the hard-coded `150` ms debounce interval with a named constant or configuration value to make the intent clearer and simplify future tuning.
- If `doUpdateSize` is not meant to be called from outside this class, you could move it to the private section (or use a private slot) to avoid expanding the public API surface unnecessarily.

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.

@yixinshark yixinshark requested a review from caixr23 March 27, 2026 01:39
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