Skip to content

fix(dock): smart hide fails to show dock after window dragged away#1668

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
fly602:master
Jul 16, 2026
Merged

fix(dock): smart hide fails to show dock after window dragged away#1668
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
fly602:master

Conversation

@fly602

@fly602 fly602 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

SmartHide 模式下,show 动画结束后 onStopped 无条件重启 hideTimer,
导致 dock 显示后 500ms 又被隐藏。同时 onHideStateChanged 的 Show
分支未停掉 QML hideTimer,且 hideShowAnimation.restart() 可能被
已运行的动画阻塞。

  1. onStopped 中增加 Panel.hideState !== Dock.Show 判断,Show 状态 下不再重启 hideTimer
  2. onHideStateChanged Show 分支中先 hideTimer.stop() 再 restart() show 动画,并强制设置 dock.visible = true

Log: 修复 SmartHide 模式下拖动窗口脱离任务栏后任务栏不自动显示的问题
PMS: BUG-370149
Influence:

  1. SmartHide 模式下拖动窗口与任务栏重叠后移开,验证任务栏自动显示
  2. SmartHide 模式下快速反复拖动窗口进出任务栏区域,验证无闪烁或卡住
  3. KeepShowing 和 KeepHidden 模式下验证任务栏行为无回归
  4. 任务栏显示动画过程中再次触发隐藏,验证动画状态正确切换
  5. 右键菜单弹出时拖动窗口,验证菜单和任务栏状态无冲突

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

Sorry @fly602, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@fly602
fly602 requested a review from deepin-ci-robot July 16, 2026 05:44
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: fly602, 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

@fly602

fly602 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

/force merge

   SmartHide 模式下,show 动画结束后 onStopped 无条件重启 hideTimer,
   导致 dock 显示后 500ms 又被隐藏。同时 onHideStateChanged 的 Show
   分支未停掉 QML hideTimer,且 hideShowAnimation.restart() 可能被
   已运行的动画阻塞。

   1. onStopped 中增加 Panel.hideState !== Dock.Show 判断,Show 状态
      下不再重启 hideTimer
   2. onHideStateChanged Show 分支中先 hideTimer.stop() 再 restart()
      show 动画,并强制设置 dock.visible = true

   Log: 修复 SmartHide 模式下拖动窗口脱离任务栏后任务栏不自动显示的问题
   PMS: BUG-370149
   Influence:
   1. SmartHide 模式下拖动窗口与任务栏重叠后移开,验证任务栏自动显示
   2. SmartHide 模式下快速反复拖动窗口进出任务栏区域,验证无闪烁或卡住
   3. KeepShowing 和 KeepHidden 模式下验证任务栏行为无回归
   4. 任务栏显示动画过程中再次触发隐藏,验证动画状态正确切换
   5. 右键菜单弹出时拖动窗口,验证菜单和任务栏状态无冲突
@fly602

fly602 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

/force merge

@fly602

fly602 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Jul 16, 2026

Copy link
Copy Markdown

This pr force merged! (status: blocked)

@deepin-bot
deepin-bot Bot merged commit 1fdcf44 into linuxdeepin:master Jul 16, 2026
7 checks passed
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:100分

■ 【总体评价】

代码有效修复了隐藏动画与位置动画之间的竞态条件,逻辑严谨且注释清晰。
修复了核心动画状态机冲突,无安全漏洞,代码质量优秀。

■ 【详细分析】

  • 1.语法逻辑(正确)✓

代码在 hideShowAnimation 中新增 hiding 属性,并在 onStarted 中正确赋值,用于记录当前动画意图。在 onBeforePositionChanged 中增加 hideTimer.stop() 彻底解决了位置改变时定时器引发的竞态。onHideStateChanged 中的条件判断 !hideShowAnimation.running || hideShowAnimation.hiding || !dock.visible 逻辑严密,确保仅在需要时反转动画。
潜在问题:无
建议:无需修改

  • 2.代码质量(良好)✓

新增的注释如 "Prevent the delayed hide animation from racing the position animation." 和 "Restore the backend-requested hidden state..." 清晰解释了修改意图。代码结构整洁,去除了冗余的判断分支。
潜在问题:无
建议:无需修改

  • 3.代码性能(良好)✓

通过 hideTimer.stop()hideTimer.restart() 精确控制定时器,避免了不必要的动画重叠和状态抖动,提升了渲染性能。
潜在问题:无
建议:无需修改

  • 4.代码安全(存在0个安全漏洞)✓

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
本次代码修改为 UI 动画逻辑优化,不涉及外部输入处理、网络通信或敏感数据操作,无安全风险。

  • 建议:无需修复

■ 【改进建议代码示例】

// 当前代码已完美修复竞态条件,无需进一步修改。
// 以下为当前修复后的核心逻辑确认:
Connections {
    function onBeforePositionChanged(beforePosition) {
        // Prevent the delayed hide animation from racing the position animation.
        hideTimer.stop();
        // Stop any running animations first
        dockAnimation.stop();
        hideShowAnimation.stop();
    }

    function onHideStateChanged() {
        if (Panel.hideState === Dock.Hide) {
            hideTimer.restart()
        } else if (Panel.hideState === Dock.Show) {
            hideTimer.stop()

            // Reverse an in-flight hide animation, but do not restart an
            // animation that is already moving towards the shown state.
            if (!hideShowAnimation.running || hideShowAnimation.hiding || !dock.visible) {
                hideShowAnimation.restart()
            }
            dock.visible = true
        }
    }
}

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