fix: cache appearance opacity in the shell#1665
Conversation
There was a problem hiding this comment.
Sorry @yixinshark, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
26c9c26 to
e3b4c9a
Compare
Cache the Appearance1 opacity after proxy initialization and update it from OpacityChanged instead of issuing a D-Bus property request for every QML read. Only access the cached property when the task manager uses the X11 window monitor, avoiding unnecessary work on Wayland. 在代理初始化后缓存 Appearance1 透明度,并通过 OpacityChanged 更新,避免每次 QML 读取都发起 D-Bus 属性请求。任务管理器仅在使用 X11 窗口监视器时访问该缓存属性,避免 Wayland 下的无效操作。 Log: cache appearance opacity in the shell
e3b4c9a to
ac09795
Compare
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, yixinshark 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 |
deepin pr auto review★ 总体评分:100分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // 当前修复代码已非常完善,以下为修复后的完整关键函数实现,供参考编译
qreal AppearanceApplet::opacity() const
{
return m_opacity;
}
void AppearanceApplet::initDBusProxy()
{
// ... 前置初始化代码 ...
if (!m_interface->isValid()) {
qWarning() << "Failed to proxy Appearance, error:" << m_interface->lastError();
m_interface.reset();
updateOpacity(-1);
return;
}
QObject::connect(m_interface.data(), &org::deepin::dde::Appearance1::OpacityChanged,
this, &AppearanceApplet::updateOpacity);
updateOpacity(m_interface->opacity());
}
void AppearanceApplet::updateOpacity(qreal opacity)
{
if (opacity >= 0) {
// The minimum opacity is 0.2
opacity = std::max(0.2, opacity);
}
if (qFuzzyCompare(m_opacity, opacity))
return;
m_opacity = opacity;
Q_EMIT opacityChanged();
}
// taskmanager.cpp
void TaskManager::modifyOpacityChanged()
{
DS_NAMESPACE::DAppletBridge appearanceBridge("org.deepin.ds.dde-appearance");
auto appearanceApplet = appearanceBridge.applet();
if (appearanceApplet) {
if (auto x11Monitor = qobject_cast<X11WindowMonitor*>(m_windowMonitor.data())) {
double opacity = appearanceApplet->property("opacity").toReal();
x11Monitor->setPreviewOpacity(opacity);
}
} else {
// ... 其他逻辑 ...
}
} |
|
/forcemerge |
|
This pr force merged! (status: blocked) |
Cache the Appearance1 opacity after proxy initialization and update it from OpacityChanged instead of issuing a D-Bus property request for every QML read. Only access the cached property when the task manager uses the X11 window monitor, avoiding unnecessary work on Wayland.
在代理初始化后缓存 Appearance1 透明度,并通过 OpacityChanged 更新,避免每次 QML 读取都发起 D-Bus 属性请求。任务管理器仅在使用 X11 窗口监视器时访问该缓存属性,避免 Wayland 下的无效操作。
Log: cache appearance opacity in the shell