Skip to content

Conversation

@Ivy233
Copy link
Contributor

@Ivy233 Ivy233 commented Jan 26, 2026

Monitor Panel.rootObject position changes in AppItem and trigger window icon geometry update when position changes. This ensures minimize animations always target the correct taskbar icon position, even after rearranging external displays in extended mode.

PMS: BUG-319249

修复:面板位置变化时更新窗口图标几何信息

在 AppItem 中监听 Panel.rootObject 位置变化,并在位置改变时触发窗口图标
几何信息更新。这确保了最小化动画始终指向正确的任务栏图标位置,即使在
扩展模式下重新排列外接显示器之后也是如此。

PMS: BUG-319249

Summary by Sourcery

Bug Fixes:

  • Refresh window icon geometry when the panel root object's X or Y position changes to keep minimize animation targets accurate after moving panels or rearranging displays.

Monitor Panel.rootObject position changes in AppItem and trigger window
icon geometry update when position changes. This ensures minimize animations
always target the correct taskbar icon position, even after rearranging
external displays in extended mode.

PMS: BUG-319249

修复:面板位置变化时更新窗口图标几何信息

在 AppItem 中监听 Panel.rootObject 位置变化,并在位置改变时触发窗口图标
几何信息更新。这确保了最小化动画始终指向正确的任务栏图标位置,即使在
扩展模式下重新排列外接显示器之后也是如此。

PMS: BUG-319249
@sourcery-ai
Copy link

sourcery-ai bot commented Jan 26, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds reactive handling of panel position changes in AppItem so that window icon geometry is refreshed whenever the dock panel moves, ensuring minimize animations target the correct taskbar icon location after display rearrangements.

Sequence diagram for updating window icon geometry on panel move

sequenceDiagram
    actor User
    participant DisplayManager
    participant PanelRootObject as Panel_rootObject
    participant AppItem
    participant UpdateTimer as updateWindowIconGeometryTimer
    participant GeometryUpdater as WindowIconGeometryUpdater

    User->>DisplayManager: Rearrange_external_displays
    DisplayManager->>PanelRootObject: Update_position_x_y
    PanelRootObject-->>AppItem: xChanged
    AppItem->>UpdateTimer: start()
    PanelRootObject-->>AppItem: yChanged
    AppItem->>UpdateTimer: start()
    UpdateTimer->>GeometryUpdater: updateWindowIconGeometry()
    User->>Window: Minimize_window
    Window->>GeometryUpdater: Request_target_icon_geometry
    GeometryUpdater-->>Window: Current_taskbar_icon_position
    Window->>Window: Play_minimize_animation_to_icon
Loading

Class diagram for AppItem reactive panel position handling

classDiagram
    class PanelRootObject {
        Number x
        Number y
    }

    class UpdateWindowIconGeometryTimer {
        +start()
    }

    class AppItem {
        +implicitWidth
        +updateWindowIconGeometryTimer : UpdateWindowIconGeometryTimer
        +onPanelXChanged()
        +onPanelYChanged()
    }

    class Connections {
        +target : PanelRootObject
        +onXChanged()
        +onYChanged()
    }

    AppItem o-- UpdateWindowIconGeometryTimer : uses
    AppItem o-- Connections : contains
    Connections --> PanelRootObject : target
    AppItem --> PanelRootObject : observes_position_changes
Loading

File-Level Changes

Change Details Files
Trigger window icon geometry updates when the panel (dock) position changes.
  • Add a Connections object bound to Panel.rootObject within AppItem
  • Listen to x and y property changes on the panel root object
  • Start updateWindowIconGeometryTimer whenever the panel’s x or y position changes so icon geometry is recomputed
panels/dock/taskmanager/package/AppItem.qml

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 面板(Panel)位置发生变化时,触发定时器更新应用图标的几何位置信息。以下是对这段代码的审查意见,包括语法逻辑、代码质量、代码性能和代码安全四个方面:

1. 语法逻辑

  • 基本正确:QML 的 Connections 语法使用正确,能够正确连接到 Panel.rootObjectxy 属性变化信号。
  • 潜在空指针风险:代码直接引用了 Panel.rootObject。如果 Panel 单例尚未初始化,或者 rootObjectnull,虽然 QML 的 Connectionstarget 为 null 时通常会静默失败,但这会导致逻辑失效。建议增加对 target 有效性的判断,或者确保 Panel 的初始化顺序早于此组件。

2. 代码质量

  • 可读性:注释清晰,解释了添加这段代码的目的,这很好。
  • 耦合度:直接依赖于 Panel.rootObject 增加了组件间的耦合。如果未来 Panel 的结构发生变化(例如 rootObject 重命名或路径改变),此处需要同步修改。建议考虑通过信号传递或属性绑定的方式解耦,或者在文档中明确依赖关系。
  • 重复代码onXChangedonYChanged 执行了完全相同的操作。虽然逻辑上没问题,但略显冗余。

3. 代码性能

  • 频繁触发xy 属性在窗口拖动或调整大小时会高频触发。直接启动定时器 updateWindowIconGeometryTimer.start() 是一种防抖(debounce)策略,这很好,避免了高频调用更新逻辑。
  • 建议优化:确认 updateWindowIconGeometryTimer 的间隔设置是否合理。如果间隔太短,依然可能导致性能问题;如果太长,图标位置更新会有明显的延迟。通常对于 UI 跟随更新,100ms - 200ms 是一个比较合理的范围。

4. 代码安全

  • 目标对象有效性:如前所述,如果 Panel.rootObject 被销毁或重置,Connections 可能会失去连接。在 QML 中,如果 target 是动态变化的,最好使用 target: Panel.rootObject || null 或者确保生命周期管理正确。
  • 定时器管理:确保 updateWindowIconGeometryTimer 在组件销毁时被正确停止或释放,防止组件销毁后定时器回调仍在执行导致访问已释放内存(尽管 QML 的垃圾回收机制通常能处理这种情况,但在复杂逻辑中需注意)。

改进建议代码示例

    // Monitor Panel position changes to update icon geometry
    Connections {
        // 确保 target 存在,避免运行时警告或逻辑失效
        target: Panel.rootObject ? Panel.rootObject : null
        
        // 忽略 x/y 的微小抖动,或者合并逻辑
        function onXChanged() { updateWindowIconGeometryTimer.restart() }
        function onYChanged() { updateWindowIconGeometryTimer.restart() }
    }

改动点说明:

  1. target: Panel.rootObject ? Panel.rootObject : null:增加了三元表达式,确保在 rootObject 未准备好时 target 为 null,避免潜在的绑定错误。
  2. restart() 代替 start():使用 restart() 是一种更标准的防抖写法。如果在定时器等待期间位置再次变化,它会重置等待时间,只有在位置稳定一段时间后才会真正执行更新,进一步优化性能。

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 left some high level feedback:

  • Consider guarding against Panel.rootObject being null or changing at runtime (e.g., by using a bound target with ignoreUnknownSignals: true or checking availability) to avoid potential runtime warnings from the Connections object.
  • Instead of duplicating logic in onXChanged and onYChanged, you could factor this into a single handler (e.g., using a onPositionChanged-style signal if available, or a helper function) to keep the update trigger logic in one place.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider guarding against `Panel.rootObject` being null or changing at runtime (e.g., by using a bound `target` with `ignoreUnknownSignals: true` or checking availability) to avoid potential runtime warnings from the `Connections` object.
- Instead of duplicating logic in `onXChanged` and `onYChanged`, you could factor this into a single handler (e.g., using a `onPositionChanged`-style signal if available, or a helper function) to keep the update trigger logic in one place.

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

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

@18202781743 18202781743 merged commit 0035f90 into linuxdeepin:master Jan 26, 2026
10 of 11 checks passed
@Ivy233 Ivy233 deleted the fix-minimize-animation-position branch January 26, 2026 03:05
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