Skip to content

fix: sync dock position before position change operations#1477

Merged
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
robertkill:master
Mar 5, 2026
Merged

fix: sync dock position before position change operations#1477
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
robertkill:master

Conversation

@robertkill
Copy link
Contributor

@robertkill robertkill commented Mar 4, 2026

  1. Fixed issue where dock.positionForAnimation was not synchronized with Panel.position before cursorShape and changeDragAreaAnchor operations
  2. Moved dock.positionForAnimation assignment earlier in onPositionChanged function to ensure correct position reference
  3. This prevents cursor shape and drag area anchor calculations from using outdated position data during position transitions

Log: Fixed dock position synchronization issue during panel position changes

Influence:

  1. Test dock position changes through settings or drag operations
  2. Verify cursor shape changes correctly during dock repositioning
  3. Check drag area anchors update properly when dock position changes
  4. Test dock visibility transitions during position changes
  5. Verify dock animation behavior when position is changed while dock is hidden

fix: 修复停靠栏位置在位置变更操作前同步问题

  1. 修复了在cursorShape和changeDragAreaAnchor操作之前 dock.positionForAnimation未与Panel.position同步的问题
  2. 将dock.positionForAnimation赋值移到onPositionChanged函数更早的位置, 确保使用正确的位置参考
  3. 防止在位置转换期间,光标形状和拖拽区域锚点计算使用过时的位置数据

Log: 修复了面板位置变化期间停靠栏位置同步问题

Influence:

  1. 测试通过设置或拖拽操作更改停靠栏位置
  2. 验证在停靠栏重新定位期间光标形状正确变化
  3. 检查拖拽区域锚点在停靠栏位置变化时正确更新
  4. 测试位置变化期间的停靠栏可见性转换
  5. 验证停靠栏隐藏时位置变化的动画行为

PMS: BUG-351781

Summary by Sourcery

Bug Fixes:

  • Fix desynchronization between dock.positionForAnimation and Panel.position that could cause incorrect cursor shape, drag area anchors, and visibility behavior when the dock position changes.

@sourcery-ai
Copy link

sourcery-ai bot commented Mar 4, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Synchronizes dock.positionForAnimation with Panel.position earlier in the onPositionChanged lifecycle so cursor shape, drag area anchors, and visibility/animation logic use the current dock position during position transitions.

Sequence diagram for updated dock onPositionChanged handling

sequenceDiagram
    participant Panel
    participant Dock as dock
    participant DockAnimation as dockAnimation

    Panel->>Panel: onPositionChanged()
    Panel->>Dock: set positionForAnimation = Panel.position
    Panel->>Dock: changeDragAreaAnchor()
    Panel->>Panel: requestClosePopup()
    Panel->>DockAnimation: check isPositionChanging
    Panel->>Dock: check visible
    alt dockAnimation.isPositionChanging == false and dock.visible == false
        Panel->>DockAnimation: setTransformToHiddenPosition()
        Panel->>Dock: show at new position
    end
Loading

Flow diagram for updated onPositionChanged logic

flowchart TD
    A[onPositionChanged called] --> B[Set dock.positionForAnimation = Panel.position]
    B --> C[changeDragAreaAnchor]
    C --> D[Panel.requestClosePopup]
    D --> E{dockAnimation.isPositionChanging == false<br/>and dock.visible == false}
    E -- Yes --> F[dockAnimation.setTransformToHiddenPosition]
    F --> G[Show dock at new position]
    E -- No --> H[End]
    G --> H[End]
Loading

File-Level Changes

Change Details Files
Ensure dock.positionForAnimation is updated before drag/interaction logic on position change.
  • Assign dock.positionForAnimation = Panel.position at the start of onPositionChanged.
  • Call changeDragAreaAnchor and Panel.requestClosePopup after positionForAnimation is updated so they use the current position.
  • Remove the later, redundant assignment of dock.positionForAnimation inside the visibility/animation conditional to avoid using stale position data.
panels/dock/package/main.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

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:

  • The new inline comment is quite verbose and includes bug history; consider shortening it to a concise description of the behavior (e.g., “Keep positionForAnimation in sync with Panel.position before cursor/drag area updates”) to avoid embedding PR-specific context in the code.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new inline comment is quite verbose and includes bug history; consider shortening it to a concise description of the behavior (e.g., “Keep positionForAnimation in sync with Panel.position before cursor/drag area updates”) to avoid embedding PR-specific context in the code.

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.

@robertkill robertkill force-pushed the master branch 4 times, most recently from 8b78689 to 031a1b5 Compare March 4, 2026 08:59
1. Fixed issue where dock.positionForAnimation was not synchronized with
Panel.position before cursorShape and changeDragAreaAnchor operations
2. Moved dock.positionForAnimation assignment earlier in
onPositionChanged function to ensure correct position reference
3. This prevents cursor shape and drag area anchor calculations from
using outdated position data during position transitions

Log: Fixed dock position synchronization issue during panel position
changes

Influence:
1. Test dock position changes through settings or drag operations
2. Verify cursor shape changes correctly during dock repositioning
3. Check drag area anchors update properly when dock position changes
4. Test dock visibility transitions during position changes
5. Verify dock animation behavior when position is changed while dock
is hidden

fix: 修复停靠栏位置在位置变更操作前同步问题

1. 修复了在cursorShape和changeDragAreaAnchor操作之前
dock.positionForAnimation未与Panel.position同步的问题
2. 将dock.positionForAnimation赋值移到onPositionChanged函数更早的位置,
确保使用正确的位置参考
3. 防止在位置转换期间,光标形状和拖拽区域锚点计算使用过时的位置数据

Log: 修复了面板位置变化期间停靠栏位置同步问题

Influence:
1. 测试通过设置或拖拽操作更改停靠栏位置
2. 验证在停靠栏重新定位期间光标形状正确变化
3. 检查拖拽区域锚点在停靠栏位置变化时正确更新
4. 测试位置变化期间的停靠栏可见性转换
5. 验证停靠栏隐藏时位置变化的动画行为

PMS: BUG-351781
@deepin-ci-robot
Copy link

deepin pr auto review

这段代码的修改主要涉及 QML 文件中关于 Dock 栏位置变化时的动画处理逻辑。下面是对这段 diff 的详细审查和改进建议:

代码变更分析

  1. 版权年份更新:将版权年份从 2023 扩展到 2023-2026
  2. 逻辑顺序调整:将 dock.positionForAnimationchangeDragAreaAnchor() 的调用位置从条件判断块内移到了条件判断之前

审查意见

1. 语法逻辑

优点

  • 逻辑调整是合理的,将位置动画的准备工作提前,确保无论是否满足条件,都先记录位置和调整拖拽区域
  • 这样可以避免在 isPositionChanging && !isShowing 条件不满足时遗漏这些必要的初始化操作

潜在问题

  • changeDragAreaAnchor() 的调用位置从 onPositionChanged 移到了 isPositionChanging 的条件块外,这可能导致在非位置变化时也调用该函数,需要确认这是否符合预期行为

2. 代码质量

优点

  • 提高了代码的可维护性,将公共操作提取到条件判断之前
  • 减少了代码重复,避免了在多个分支中重复相同的操作

改进建议

// 建议添加注释说明为什么需要提前设置这些值
// 提前设置位置动画参数,确保在任何情况下都有正确的初始值
dock.positionForAnimation = Panel.position;
// 调整拖拽区域锚点,为可能的动画做准备
changeDragAreaAnchor();

3. 代码性能

优点

  • 将公共操作提取到条件判断外,减少了条件分支内的代码量,理论上可以略微提高性能
  • 避免了在条件分支内重复计算相同的值

潜在问题

  • changeDragAreaAnchor() 如果在非必要情况下被调用,可能会带来不必要的性能开销
  • 建议检查该函数的实现,确保其在非位置变化时的调用是安全的且性能开销可接受

4. 代码安全

优点

  • 修改不会引入新的安全漏洞
  • 逻辑调整使得状态管理更加一致

改进建议

  • 建议添加状态检查,确保 dockPanel 对象在调用前已正确初始化
  • 可以考虑添加断言或日志记录,帮助调试位置变化时的状态

综合改进建议

// 添加状态检查
if (!dock || !Panel) {
    console.error("Dock or Panel not initialized");
    return;
}

// 提前设置位置动画参数,确保在任何情况下都有正确的初始值
dock.positionForAnimation = Panel.position;

// 只在位置真正变化时调整拖拽区域
if (isPositionChanging) {
    changeDragAreaAnchor();
}

// If this was a hide animation during position change, prepare for show animation
if (isPositionChanging && !isShowing) {
    isPositionChanging = false;
    
    // Set transform to hidden position before showing
    setTransformToHiddenPosition();
    // ... 其余代码
}

总结

这段代码的修改总体上是合理的,提高了代码的一致性和可维护性。主要改进点在于将位置动画的准备工作提前,确保状态管理更加一致。建议添加适当的注释和状态检查,以提高代码的健壮性和可维护性。

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Ivy233, robertkill

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

@robertkill
Copy link
Contributor Author

/forcemerge

@deepin-bot
Copy link

deepin-bot bot commented Mar 5, 2026

This pr force merged! (status: unknown)

@deepin-bot deepin-bot bot merged commit 8568d24 into linuxdeepin:master Mar 5, 2026
11 of 12 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.

4 participants