Skip to content

Conversation

@mhduiy
Copy link
Contributor

@mhduiy mhduiy commented Jan 26, 2026

  1. Added m_isResizing property to DockPanel class to track dock resizing state
  2. Modified resizeDock method in DockDBusProxy to set resizing flag before and after size changes
  3. Updated QML animations to be disabled during both dragging AND resizing operations
  4. Added Q_PROPERTY for isResizing with proper getter/setter and signal emission

The fix prevents animation conflicts when the dock is being resized through D-Bus calls. Previously, animations would interfere with smooth resizing operations, causing visual glitches or delayed updates. By disabling animations during resize operations (similar to how they're disabled during dragging), we ensure smooth and immediate visual feedback when the dock size changes programmatically.

Log: Fixed dock animation interference during resize operations

Influence:

  1. Test dock resizing through configuration settings or D-Bus calls
  2. Verify animations work normally when not resizing or dragging
  3. Check that animations are properly disabled during resize operations
  4. Test edge cases where resizing and dragging might overlap
  5. Verify dock positioning and layout updates correctly during resize

fix: 修复停靠栏调整大小时动画干扰问题

  1. 在 DockPanel 类中添加 m_isResizing 属性以跟踪停靠栏调整大小状态
  2. 修改 DockDBusProxy 中的 resizeDock 方法,在大小更改前后设置调整大小 标志
  3. 更新 QML 动画,使其在拖动和调整大小操作期间均被禁用
  4. 为 isResizing 添加 Q_PROPERTY,包含适当的 getter/setter 和信号发射

此修复防止了通过 D-Bus 调用调整停靠栏大小时动画冲突的问题。之前,动画会
干扰平滑的调整大小操作,导致视觉故障或更新延迟。通过在调整大小操作期间禁
用动画(类似于拖动期间的禁用方式),我们确保当停靠栏大小以编程方式更改时
能够获得平滑且即时的视觉反馈。

Log: 修复了调整停靠栏大小时动画干扰的问题

Influence:

  1. 通过配置设置或 D-Bus 调用测试停靠栏调整大小功能
  2. 验证在未调整大小或拖动时动画正常工作
  3. 检查动画在调整大小操作期间是否被正确禁用
  4. 测试调整大小和拖动可能重叠的边缘情况
  5. 验证停靠栏在调整大小期间的位置和布局是否正确更新

PMS: BUG-339381

Summary by Sourcery

Disable dock layout animations while the dock is being resized programmatically via D-Bus to avoid visual interference and ensure smooth size changes.

Bug Fixes:

  • Prevent dock animations from conflicting with dock resizing operations triggered through D-Bus.

Enhancements:

  • Expose a new isResizing Q_PROPERTY on DockPanel and propagate its state to QML so layout behaviors can react to resize operations.

1. Added m_isResizing property to DockPanel class to track dock resizing
state
2. Modified resizeDock method in DockDBusProxy to set resizing flag
before and after size changes
3. Updated QML animations to be disabled during both dragging AND
resizing operations
4. Added Q_PROPERTY for isResizing with proper getter/setter and signal
emission

The fix prevents animation conflicts when the dock is being resized
through D-Bus calls. Previously, animations would interfere with smooth
resizing operations, causing visual glitches or delayed updates. By
disabling animations during resize operations (similar to how they're
disabled during dragging), we ensure smooth and immediate visual
feedback when the dock size changes programmatically.

Log: Fixed dock animation interference during resize operations

Influence:
1. Test dock resizing through configuration settings or D-Bus calls
2. Verify animations work normally when not resizing or dragging
3. Check that animations are properly disabled during resize operations
4. Test edge cases where resizing and dragging might overlap
5. Verify dock positioning and layout updates correctly during resize

fix: 修复停靠栏调整大小时动画干扰问题

1. 在 DockPanel 类中添加 m_isResizing 属性以跟踪停靠栏调整大小状态
2. 修改 DockDBusProxy 中的 resizeDock 方法,在大小更改前后设置调整大小
标志
3. 更新 QML 动画,使其在拖动和调整大小操作期间均被禁用
4. 为 isResizing 添加 Q_PROPERTY,包含适当的 getter/setter 和信号发射

此修复防止了通过 D-Bus 调用调整停靠栏大小时动画冲突的问题。之前,动画会
干扰平滑的调整大小操作,导致视觉故障或更新延迟。通过在调整大小操作期间禁
用动画(类似于拖动期间的禁用方式),我们确保当停靠栏大小以编程方式更改时
能够获得平滑且即时的视觉反馈。

Log: 修复了调整停靠栏大小时动画干扰的问题

Influence:
1. 通过配置设置或 D-Bus 调用测试停靠栏调整大小功能
2. 验证在未调整大小或拖动时动画正常工作
3. 检查动画在调整大小操作期间是否被正确禁用
4. 测试调整大小和拖动可能重叠的边缘情况
5. 验证停靠栏在调整大小期间的位置和布局是否正确更新

PMS: BUG-339381
@sourcery-ai
Copy link

sourcery-ai bot commented Jan 26, 2026

Reviewer's Guide

Adds a resize-state flag to DockPanel, exposes it to QML, and uses it to temporarily disable dock layout animations while the dock is being programmatically resized over D-Bus, preventing animation glitches during resize operations.

Sequence diagram for dock resize over D-Bus with animations disabled

sequenceDiagram
    actor User
    participant SettingsApp
    participant DockDBusProxy
    participant DockPanel
    participant QML_DockView

    User ->> SettingsApp: Change dock size in settings
    SettingsApp ->> DockDBusProxy: resizeDock(offset, dragging=false)
    DockDBusProxy ->> DockPanel: setIsResizing(true)
    DockPanel ->> QML_DockView: isResizingChanged(true)
    QML_DockView ->> QML_DockView: disable layout animations
    DockDBusProxy ->> DockPanel: setDockSize(offset)
    DockPanel ->> QML_DockView: layout update
    DockDBusProxy ->> DockPanel: setIsResizing(false)
    DockPanel ->> QML_DockView: isResizingChanged(false)
    QML_DockView ->> QML_DockView: reenable layout animations
Loading

Class diagram for updated DockPanel resize state handling

classDiagram
    class DockPanel {
        +DockPanel(QObject *parent)
        +bool showInPrimary
        +QString screenName
        +bool locked
        +qreal devicePixelRatio
        +bool contextDragging
        +void setContextDragging(bool newContextDragging)
        +bool isResizing() const
        +void setIsResizing(bool resizing)
        void lockedChanged(bool locked)
        void contextDraggingChanged()
        void isResizingChanged(bool isResizing)
        -ColorTheme m_theme
        -bool m_compositorReady
        -bool m_launcherShown
        -bool m_contextDragging
        -bool m_isResizing
    }

    class DockDBusProxy {
        +QString getPluginKey(QString pluginName)
        +void resizeDock(int offset, bool dragging)
    }

    DockDBusProxy --> DockPanel : parent()
Loading

File-Level Changes

Change Details Files
Track dock resize state on DockPanel and expose it as a Q_PROPERTY for QML/DBus use.
  • Initialize a new m_isResizing member in the DockPanel constructor
  • Add isResizing getter and setIsResizing setter methods with change detection
  • Declare isResizing as a Q_PROPERTY with READ/WRITE and NOTIFY bindings
  • Declare an isResizingChanged signal and store the resize state in a private member
panels/dock/dockpanel.cpp
panels/dock/dockpanel.h
Disable QML margin animations when the dock is resizing to avoid conflicts with programmatic size changes.
  • Update Behavior on Layout.leftMargin to be enabled only when the dock is neither dragging nor resizing
  • Update Behavior on Layout.topMargin to be enabled only when the dock is neither dragging nor resizing
panels/dock/package/main.qml
Toggle the DockPanel resizing flag around D-Bus-driven dock resize operations.
  • Update DockDBusProxy::resizeDock to set the parent panel into resizing state before changing the dock size
  • Reset the resizing state on the parent panel immediately after setDockSize completes
panels/dock/dockdbusproxy.cpp

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

@deepin-ci-robot
Copy link

deepin pr auto review

这段代码的目的是为 Dock 面板添加一个调整大小(resizing)的状态标识,并在调整大小时禁用某些布局动画,以避免动画干扰或性能问题。总体来说,代码逻辑清晰,能够实现预期功能。

以下是从语法逻辑、代码质量、代码性能和代码安全四个方面的详细审查与改进建议:

1. 语法逻辑

  • 审查结果:通过。
  • 分析
    • C++ 部分的属性绑定、信号槽声明以及成员变量初始化符合 Qt/QML 规范。
    • DockDBusProxy::resizeDock 中的逻辑顺序(设置状态 -> 调整大小 -> 恢复状态)是正确的,能够确保在 setDockSize 执行期间 isResizing 为真。
    • QML 部分的逻辑判断 !dock.isDragging && !Applet.isResizing 准确表达了"既不在拖拽也不在调整大小时才启用动画"的意图。

2. 代码质量

  • 审查结果:良好,有微小的改进空间。
  • 分析
    • 格式问题:在 dockpanel.cpp 中,isResizing() 函数的实现存在多余的空行:
      bool DockPanel::isResizing() const
      {
          return m_isResizing;
      
      }
      建议删除多余的空行,保持代码整洁。
    • 异常安全性:在 DockDBusProxy::resizeDock 中,虽然逻辑简单,但如果 setDockSize 内部抛出异常(尽管 Qt 通常不鼓励异常),setIsResizing(false) 可能不会被执行。虽然在此场景下风险极低,但在更复杂的系统中,建议使用 RAII(资源获取即初始化)模式来确保状态重置。例如,可以使用一个简单的辅助类在析构时自动重置状态。

3. 代码性能

  • 审查结果:良好,改进有效。
  • 分析
    • 动画优化:在 QML 中,Behaviorenabled 属性绑定到 !Applet.isResizing。这是一个很好的性能优化实践。在调整大小时禁用布局动画(Layout.leftMarginLayout.topMargin 的动画)可以显著减少 CPU/GPU 的开销,避免在频繁的大小计算中穿插昂贵的动画插值计算,使拖拽/调整大小更加跟手流畅。
    • 属性通知setIsResizing 中实现了 if (m_isResizing == resizing) return;,这避免了不必要的信号发射和 QML 属性绑定求值,是正确的性能优化手段。

4. 代码安全

  • 审查结果:通过。
  • 分析
    • 线程安全:代码主要在 UI 线程(主线程)运行,通过 DBus 代理调用。Qt 的信号槽机制在连接到同一线程时是直接调用的,因此不存在多线程竞争条件导致的数据竞争问题。
    • 状态一致性:通过布尔标志位 m_isResizing 来控制 UI 行为,状态切换清晰,能够保证 UI 状态与内部逻辑的一致性。

改进建议代码示例

针对代码质量中的格式问题异常安全性,提供以下修改建议:

1. 修正 dockpanel.cpp 中的格式

bool DockPanel::isResizing() const
{
    return m_isResizing;
}

2. 增强 DockDBusProxy::resizeDock 的安全性(使用 RAII 模式)

如果项目中有类似的辅助类,或者为了代码的健壮性,可以定义一个简单的 Scope Guard:

// 在 dockdbusproxy.cpp 中
class ScopeGuard {
public:
    explicit ScopeGuard(std::function<void()> f) : m_func(std::move(f)) {}
    ~ScopeGuard() { if(m_func) m_func(); }
    // 禁止拷贝
    ScopeGuard(const ScopeGuard&) = delete;
    ScopeGuard& operator=(const ScopeGuard&) = delete;
private:
    std::function<void()> m_func;
};

void DockDBusProxy::resizeDock(int offset, bool dragging)
{
    Q_UNUSED(dragging)
    parent()->setIsResizing(true);
    // 使用 ScopeGuard 确保 setDockSize 无论是否抛出异常,都能执行 setIsResizing(false)
    ScopeGuard onExit([this]() { parent()->setIsResizing(false); });
    
    parent()->setDockSize(offset);
}

注:如果项目编码规范不使用 C++ 异常,或者 setDockSize 极其简单,当前的写法也是完全可接受的。

总结

该代码改动有效地解决了调整 Dock 大小时可能产生的动画卡顿问题,逻辑正确,性能优化到位。建议修复微小的格式瑕疵,并考虑在更复杂的场景下使用 RAII 机制保证状态复位。

Copy link

@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 found 1 issue, and left some high level feedback:

  • The isResizingChanged method is declared under private Q_SLOTS but used as the NOTIFY signal for the isResizing Q_PROPERTY; this should be declared in the signals section so it is treated as a proper Qt signal rather than just a slot.
  • In DockDBusProxy::resizeDock, setIsResizing(true) is set immediately before setDockSize(offset) and reset right after; if setDockSize triggers asynchronous or deferred layout/animation work, consider moving the flag handling closer to the real resize lifecycle so that animations stay disabled for the full duration of the operation.
  • The QML changes gate animations on !Applet.isResizing, but the new C++ property is DockPanel::isResizing; double-check that Applet.isResizing is correctly bound to this new property (or switch the QML condition to use the dock’s property directly) to avoid the flag never actually affecting animations.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `isResizingChanged` method is declared under `private Q_SLOTS` but used as the `NOTIFY` signal for the `isResizing` Q_PROPERTY; this should be declared in the `signals` section so it is treated as a proper Qt signal rather than just a slot.
- In `DockDBusProxy::resizeDock`, `setIsResizing(true)` is set immediately before `setDockSize(offset)` and reset right after; if `setDockSize` triggers asynchronous or deferred layout/animation work, consider moving the flag handling closer to the real resize lifecycle so that animations stay disabled for the full duration of the operation.
- The QML changes gate animations on `!Applet.isResizing`, but the new C++ property is `DockPanel::isResizing`; double-check that `Applet.isResizing` is correctly bound to this new property (or switch the QML condition to use the dock’s property directly) to avoid the flag never actually affecting animations.

## Individual Comments

### Comment 1
<location> `panels/dock/dockpanel.h:133` </location>
<code_context>
     void lockedChanged(bool locked);

     void contextDraggingChanged();
+    void isResizingChanged(bool isResizing);

 private:
</code_context>

<issue_to_address>
**issue (bug_risk):** The NOTIFY signal for `isResizing` is declared as a slot, which may break Q_PROPERTY notifications.

Since `isResizingChanged` is declared in a `Q_SLOTS` section, Qt will not register it as a signal, so the `NOTIFY isResizingChanged` on the `Q_PROPERTY` will not function correctly (e.g., QML bindings won’t update). Please move `isResizingChanged` to the `signals` section, and if you still need a slot for internal connections, keep a separate slot that emits this signal.
</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.

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

@mhduiy mhduiy merged commit 5047717 into linuxdeepin:master Jan 26, 2026
10 of 11 checks passed
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