fix: prevent visual ghosting and flashing during dock position change#1484
fix: prevent visual ghosting and flashing during dock position change#1484robertkill merged 1 commit intolinuxdeepin:masterfrom
Conversation
Fixed the issue where changing dock position caused visual ghosting and flashing in both X11 and Wayland environments. 1. Prevented size bindings from resetting to 0 during position animations in Wayland by ensuring proper from/to dimension values based on the layout's dockSize. 2. Disabled D.DWindow.shadowColor and borderWidth not only during hideShowAnimation.running but also during dockAnimation.running. This cleanly removes the lingering shadow effects and borders while the window manager translates the native window. fix: 修复任务栏停靠位置改变时的视觉残影和闪烁问题 修复了在X11和Wayland环境下更改任务栏位置时导致视觉残影和闪烁的问题。 1. 通过确保正确返回基于布局当前厚度(dockSize)的from/to插值尺寸,防止了 部分环境下的尺寸插值在位置切换动画期间错误回落归零。 2. 不仅在 hideShowAnimation.running 阶段,还在 dockAnimation.running 阶段同样 禁用了D.DWindow.shadowColor和borderWidth。这干净利落地移除了底层窗口管理器 平移或转换窗口位置时残留的阴影效果和黑色边框。 Log: 修复任务栏在切换位置时产生的残影和闪烁瑕疵 Influence: 1. Test moving the dock position (Top, Bottom, Left, Right) to ensure smooth transitions without graphical artifacts or shadow ghosting. 2. Verify normal dock hide/show toggle works correctly with its respective shadows and borders. 3. Check the behavior under both X11 and Wayland display servers if possible. Influence: 1. 测试移动任务栏位置(上、下、左、右),确保平滑过渡,无图形缺陷或阴影残影。 2. 验证正常的任务栏隐藏/显示切换依然拥有正常的阴影和边框表现。 3. 检查在X11和Wayland双环境下的切换行为一致性。 PMS: BUG-352127
deepin pr auto review这段代码的修改主要涉及任务栏在显示/隐藏动画和停靠动画过程中的阴影、边框以及位置属性的控制。以下是对代码的详细审查和改进建议: 1. 语法逻辑审查修改点分析:
逻辑问题:
2. 代码质量审查优点:
改进建议:
3. 代码性能审查潜在问题:
改进建议:
4. 代码安全审查潜在问题:
改进建议:
5. 改进后的代码示例Window {
// 定义常量
readonly property real shadowOpacityHidden: 0
readonly property real shadowOpacityVisible: 0.1
readonly property int borderWidthHidden: 0
readonly property int borderWidthVisible: 1
readonly property int shadowRadiusValue: 40
// 统一判断是否需要隐藏阴影和边框
readonly property bool shouldHideEffects: hideShowAnimation.running || dockAnimation.running
// 阴影和边框控制
D.DWindow.shadowColor: shouldHideEffects ? Qt.rgba(0, 0, 0, shadowOpacityHidden) : Qt.rgba(0, 0, 0, shadowOpacityVisible)
D.DWindow.shadowOffset: Qt.point(0, 0)
D.DWindow.shadowRadius: shadowRadiusValue
D.DWindow.borderWidth: shouldHideEffects ? borderWidthHidden : borderWidthVisible
D.DWindow.enableBlurWindow: Qt.platform.pluginName !== "xcb"
D.DWindow.themeType: Panel.colorTheme
D.DWindow.borderColor: D.DTK.themeType === D.ApplicationHelper.DarkType ? Qt.rgba(0, 0, 0, dock.blendColorAlpha(0.6) + 20 / 255) : Qt.rgba(0, 0, 0, 0.15)
// 动画位置控制
PropertyAnimation {
id: dockAnimation
property bool useTransformBasedAnimation: false
property bool isShowing: false
property int positionForAnimation: Dock.Bottom
from: {
if (dockAnimation.isShowing) {
return dockAnimation.useTransformBasedAnimation ? 0 : Panel.dockSize;
} else {
if (dockAnimation.useTransformBasedAnimation) {
return (dockAnimation.positionForAnimation === Dock.Left || dockAnimation.positionForAnimation === Dock.Top) ? -Panel.dockSize : Panel.dockSize;
}
return dockAnimation.useTransformBasedAnimation ? 0 : Panel.dockSize;
}
}
to: {
if (dockAnimation.isShowing) {
return dockAnimation.useTransformBasedAnimation ? 0 : Panel.dockSize;
} else {
if (dockAnimation.useTransformBasedAnimation) {
return (dockAnimation.positionForAnimation === Dock.Left || dockAnimation.positionForAnimation === Dock.Top) ? -Panel.dockSize : Panel.dockSize;
}
return 0;
}
}
}
}6. 总结这段代码的修改主要是为了优化任务栏动画过程中的视觉效果,但在逻辑一致性和状态管理方面还有改进空间。建议通过提取常量、统一条件判断和增加防御性编程来提高代码质量、性能和安全性。 |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdjusts dock window visual properties and animation size bindings to eliminate ghosting and flashing when changing dock position, especially under Wayland, while preserving normal hide/show behavior. Sequence diagram for dock position change animations and visual cleanupsequenceDiagram
actor User
participant DockUI
participant DockAnimation
participant HideShowAnimation
participant Window
participant DWindow
User->>DockUI: changeDockPosition(newPosition)
DockUI->>DockAnimation: start(newPosition)
DockAnimation->>DockUI: updateProperties(positionForAnimation,useTransformBasedAnimation,isShowing)
DockUI->>Window: requestLayoutUpdate(Panel.dockSize)
DockUI->>DockUI: computeSizeFrom(useTransformBasedAnimation,isShowing,Panel.dockSize)
DockUI->>DockUI: computeSizeTo(useTransformBasedAnimation,isShowing,Panel.dockSize)
Note over DockUI,DWindow: from/to now use Panel.dockSize instead of 0 when not transform based
DockAnimation->>Window: set running true
Window->>DWindow: set shadowColor transparent
Window->>DWindow: set borderWidth 0
DockAnimation-->>DockUI: animationTick
DockUI-->>Window: updateGeometryInterpolated
DockAnimation-->>Window: set running false
alt hideShowAnimation.running is false
Window->>DWindow: restore shadowColor default
Window->>DWindow: restore borderWidth 1
else hideShowAnimation.running is true
Window->>DWindow: keep shadowColor transparent
Window->>DWindow: keep borderWidth 0
end
User-->>User: observes smooth transition without ghosting
Updated class diagram for dock window animations and visual propertiesclassDiagram
class Window {
+QtObject hideShowAnimation
+QtObject dockAnimation
+int Panel_dockSize
}
class DWindow {
+color shadowColor
+point shadowOffset
+int shadowRadius
+int borderWidth
+bool enableBlurWindow
+int themeType
+color borderColor
}
class DockAnimation {
+bool running
+bool isShowing
+bool useTransformBasedAnimation
+int positionForAnimation
}
class HideShowAnimation {
+bool running
}
class Panel {
+int dockSize
}
Window --> DWindow : sets_properties
Window --> DockAnimation : observes_running_isShowing
Window --> HideShowAnimation : observes_running
Window --> Panel : reads_dockSize
class DockSizeBinding {
+int from
+int to
+int computeFrom(bool isShowing,bool useTransformBasedAnimation,int Panel_dockSize)
+int computeTo(bool isShowing,bool useTransformBasedAnimation,int Panel_dockSize)
}
Window --> DockSizeBinding : owns_binding
DockSizeBinding --> DockAnimation : uses_state
DockSizeBinding --> Panel : uses_dockSize
DWindow : shadowColor = if hideShowAnimation.running or dockAnimation.running then transparent else rgba(0,0,0,0.1)
DWindow : borderWidth = if hideShowAnimation.running or dockAnimation.running then 0 else 1
DockSizeBinding : from = if isShowing then 1 else (if useTransformBasedAnimation then 0 else Panel.dockSize)
DockSizeBinding : to = if isShowing then (if useTransformBasedAnimation then 0 else Panel.dockSize) else (if useTransformBasedAnimation then +/-Panel.dockSize else 0)
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The shadowColor and borderWidth bindings now duplicate the same
(hideShowAnimation.running || dockAnimation.running)condition; consider extracting this into a single boolean property (e.g.,isAnyDockAnimationRunning) to improve readability and reduce the chance of future divergence. - In the animation
from/tovalues that usePanel.dockSize, double-check whetherdockSizecan change during the animation; if so, consider capturing the starting size or using a binding that reacts safely, to avoid mid-animation jumps or inconsistencies.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The shadowColor and borderWidth bindings now duplicate the same `(hideShowAnimation.running || dockAnimation.running)` condition; consider extracting this into a single boolean property (e.g., `isAnyDockAnimationRunning`) to improve readability and reduce the chance of future divergence.
- In the animation `from`/`to` values that use `Panel.dockSize`, double-check whether `dockSize` can change during the animation; if so, consider capturing the starting size or using a binding that reacts safely, to avoid mid-animation jumps or inconsistencies.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: BLumia, mhduiy, robertkill The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Fixed the issue where changing dock position caused visual ghosting and flashing in both X11 and Wayland environments.
fix: 修复任务栏停靠位置改变时的视觉残影和闪烁问题
修复了在X11和Wayland环境下更改任务栏位置时导致视觉残影和闪烁的问题。
Log: 修复任务栏在切换位置时产生的残影和闪烁瑕疵
Influence:
Influence:
PMS: BUG-352127
Summary by Sourcery
Fix visual artifacts when changing dock position by adjusting animation dimensions and window decorations during transitions.
Bug Fixes: