fix: optimize window button display delay issue#584
fix: optimize window button display delay issue#58418202781743 merged 1 commit intolinuxdeepin:masterfrom
Conversation
Reviewer's GuideRefactors WindowButtonGroup to use direct WindowButton instances instead of Loaders, introduces cached motifFunctions-derived properties, and simplifies resizability logic to remove unnecessary object creation and visibility indirections, fixing delayed/flashy display of window control buttons and improving performance. Flow diagram for WindowButton visibility and enablement logicflowchart TD
subgraph Inputs
flags["Window.window.flags"]
visibility["Window.window.visibility"]
dwindowEnabled["__dwindow.enabled"]
embedMode["embedMode"]
fullScreenBtnVisible["control.fullScreenButtonVisible"]
motifFunctions["__dwindow.motifFunctions"]
maxWidth["Window.window.maximumWidth"]
minWidth["Window.window.minimumWidth"]
maxHeight["Window.window.maximumHeight"]
minHeight["Window.window.minimumHeight"]
end
subgraph Cached_bitwise_properties
canMinimize["__canMinimize = motifFunctions & FUNC_MINIMIZE"]
canMaximize["__canMaximize = motifFunctions & FUNC_MAXIMIZE"]
canResize["__canResize = motifFunctions & FUNC_RESIZE"]
canClose["__canClose = motifFunctions & FUNC_CLOSE"]
end
subgraph Common_state
forceHind["__forceHind = !__dwindow.enabled || embedMode || visibility == FullScreen"]
sizeResizable["__sizeResizable = (maxWidth != minWidth) || (maxHeight != minHeight)"]
end
subgraph Minimize_button
minHasFlag["hasWindowFlag = flags & WindowMinimizeButtonHint"]
minVisible["minimizeBtn.visible = hasWindowFlag && !forceHind"]
minEnabled["minimizeBtn.enabled = canMinimize"]
end
subgraph Quit_fullscreen_button
quitVisible["quitFullBtn.visible = fullScreenBtnVisible && __dwindow.enabled && visibility == FullScreen"]
end
subgraph Maximize_restore_button
maxHasFlag["hasWindowFlag = flags & WindowMaximizeButtonHint"]
maxVisible["maxOrWindedBtn.visible = hasWindowFlag && !forceHind && canResize && sizeResizable"]
maxEnabled["maxOrWindedBtn.enabled = canMaximize && canResize"]
end
subgraph Close_button
closeHasFlag["hasWindowFlag = flags & WindowCloseButtonHint"]
closeVisible["closeBtn.visible = hasWindowFlag && __dwindow.enabled"]
closeEnabled["closeBtn.enabled = canClose"]
end
flags --> minHasFlag
flags --> maxHasFlag
flags --> closeHasFlag
dwindowEnabled --> forceHind
embedMode --> forceHind
visibility --> forceHind
visibility --> quitVisible
fullScreenBtnVisible --> quitVisible
dwindowEnabled --> quitVisible
motifFunctions --> canMinimize
motifFunctions --> canMaximize
motifFunctions --> canResize
motifFunctions --> canClose
canMinimize --> minEnabled
canMaximize --> maxEnabled
canResize --> maxVisible
canResize --> maxEnabled
canClose --> closeEnabled
forceHind --> minVisible
forceHind --> maxVisible
maxWidth --> sizeResizable
minWidth --> sizeResizable
maxHeight --> sizeResizable
minHeight --> sizeResizable
minHasFlag --> minVisible
maxHasFlag --> maxVisible
closeHasFlag --> closeVisible
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:
- For the cached motifFunctions flags (e.g.,
__canMinimize,__canMaximize), consider making the bitwise checks explicitly boolean (e.g.,(__dwindow.motifFunctions & D.WindowManagerHelper.FUNC_MINIMIZE) !== 0) to avoid relying on implicit int-to-bool coercion and make the intent clearer. - Now that
Loaderhas been removed, severalvisibleexpressions directly embed relatively complex conditions; consider extracting shared pieces (like the fullscreen visibility logic) into small helper properties to keep the button definitions easier to read and maintain.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- For the cached motifFunctions flags (e.g., `__canMinimize`, `__canMaximize`), consider making the bitwise checks explicitly boolean (e.g., `(__dwindow.motifFunctions & D.WindowManagerHelper.FUNC_MINIMIZE) !== 0`) to avoid relying on implicit int-to-bool coercion and make the intent clearer.
- Now that `Loader` has been removed, several `visible` expressions directly embed relatively complex conditions; consider extracting shared pieces (like the fullscreen visibility logic) into small helper properties to keep the button definitions easier to read and maintain.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
1. Replaced Loader components with direct WindowButton instances to eliminate loading delays 2. Added cached properties for motifFunctions bitwise operations to avoid repeated calculations 3. Simplified size resizable check by comparing width/height values directly instead of creating Size objects 4. Changed visibility control from Loader.active to WindowButton.visible for smoother transitions 5. Improved performance by reducing object creation and property recalculations Log: Fixed window control buttons flashing/delayed appearance issue Influence: 1. Test window minimize/maximize/close buttons appear instantly without delay 2. Verify button visibility changes correctly when entering/exiting fullscreen mode 3. Test button states update properly when window flags change 4. Verify all window buttons remain functional with correct enabled/ disabled states 5. Test performance impact during window resizing and state transitions 6. Verify no visual glitches when toggling between windowed and fullscreen modes fix: 优化标题栏窗口按钮延迟闪现问题 1. 将 Loader 组件替换为直接的 WindowButton 实例,消除加载延迟 2. 添加缓存的 motifFunctions 位运算属性,避免重复计算 3. 简化可调整大小检查,直接比较宽高值而不是创建 Size 对象 4. 将可见性控制从 Loader.active 改为 WindowButton.visible,实现更平滑的 过渡 5. 通过减少对象创建和属性重计算来提升性能 Log: 修复窗口控制按钮闪现/延迟显示问题 Influence: 1. 测试窗口最小化/最大化/关闭按钮是否立即显示无延迟 2. 验证进入/退出全屏模式时按钮可见性是否正确变化 3. 测试窗口标志改变时按钮状态是否正确更新 4. 验证所有窗口按钮功能正常,启用/禁用状态正确 5. 测试窗口调整大小和状态转换时的性能影响 6. 验证在窗口模式和全屏模式切换时无视觉闪烁 PMS: BUG-351921
deepin pr auto reviewGit Diff 代码审查报告概述这段代码是对
详细审查1. 版权信息更新// SPDX-FileCopyrightText: 2021 - 2026 UnionTech Software Technology Co., Ltd.
2. motifFunctions 位运算结果缓存// 缓存 motifFunctions 位运算结果,避免重复计算
readonly property bool __canMinimize: __dwindow.motifFunctions & D.WindowManagerHelper.FUNC_MINIMIZE
readonly property bool __canMaximize: __dwindow.motifFunctions & D.WindowManagerHelper.FUNC_MAXIMIZE
readonly property bool __canResize: __dwindow.motifFunctions & D.WindowManagerHelper.FUNC_RESIZE
readonly property bool __canClose: __dwindow.motifFunctions & D.WindowManagerHelper.FUNC_CLOSE
3. Loader 组件替换// 之前使用 Loader
Loader {
active: hasWindowFlag && !__forceHind
visible: active
enabled: (__dwindow.motifFunctions & D.WindowManagerHelper.FUNC_MINIMIZE)
sourceComponent: WindowButton {
// ...
}
}
// 现在直接使用 WindowButton
WindowButton {
visible: hasWindowFlag && !__forceHind
enabled: __canMinimize
// ...
}
4. 窗口大小可调整性判断优化// 之前使用对象创建
readonly property size maxSize: Qt.size(Window.window.maximumWidth, Window.window.maximumHeight)
readonly property size minSize: Qt.size(Window.window.minimumWidth, Window.window.minimumHeight)
active: (hasWindowFlag && !__forceHind &&
(__dwindow.motifFunctions & D.WindowManagerHelper.FUNC_RESIZE) &&
maxSize != minSize)
// 现在使用简单值比较
readonly property bool __sizeResizable: (Window.window.maximumWidth !== Window.window.minimumWidth ||
Window.window.maximumHeight !== Window.window.minimumHeight)
visible: (hasWindowFlag && !__forceHind && __canResize && __sizeResizable)
5. 其他改进
潜在问题和建议
总结总体而言,这次代码修改提高了代码的可读性和性能,通过缓存位运算结果和简化组件结构,使代码更加高效。主要的改进包括:
建议在实际部署前考虑上述潜在问题,特别是关于属性更新和内存使用的考虑。 |
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
eliminate loading delays
avoid repeated calculations
directly instead of creating Size objects
for smoother transitions
recalculations
Log: Fixed window control buttons flashing/delayed appearance issue
Influence:
delay
fullscreen mode
disabled states
fullscreen modes
fix: 优化标题栏窗口按钮延迟闪现问题
过渡
Log: 修复窗口控制按钮闪现/延迟显示问题
Influence:
PMS: BUG-351921
Summary by Sourcery
Optimize window titlebar button rendering to remove display delays and reduce unnecessary recomputation.
Bug Fixes:
Enhancements: