fix: unify screen scaling management with ScreenScale plugin#60
Conversation
Reviewer's GuideRefactors XSettings screen scaling to delegate to a new org.deepin.dde.ScreenScale1 D-Bus plugin as the single source of truth, adds the ScreenScale plugin implementation and service wiring, and updates XSettingsManager to synchronize legacy DConfig/XSettings, Plymouth, and cursor size via the new service with fallback logic when the service is unavailable. Sequence diagram for runtime screen scale change via ScreenScale1sequenceDiagram
actor User
participant App
participant XSettingsManager
participant ScreenScale1
participant DConfig_ScreenScale as DConfig_ScreenScale1
participant DConfig_XSettings as DConfig_XSettings
participant Plymouth
User->>App: Change scale in UI
App->>XSettingsManager: setScreenScaleFactors(factors, emitSignal)
XSettingsManager->>XSettingsManager: setSingleScaleFactor(scale, emitSignal)
XSettingsManager->>ScreenScale1: SetScaleFactor(scale)
ScreenScale1->>DConfig_ScreenScale: setValue("scale-factor", scale)
DConfig_ScreenScale-->>ScreenScale1: write OK
ScreenScale1-->>XSettingsManager: ScaleFactorChanged(scale)
Note over ScreenScale1,XSettingsManager: XSettingsManager subscribed to ScaleFactorChanged signal
XSettingsManager->>XSettingsManager: onScaleFactorChanged(scale)
XSettingsManager->>DConfig_XSettings: setValue(dcKeyScaleFactor, scale)
XSettingsManager->>DConfig_XSettings: setValue(dcKeyWindowScale, windowScale)
XSettingsManager->>DConfig_XSettings: setValue(cKeyIndividualScaling, joinedFactors)
XSettingsManager->>DConfig_XSettings: setValue(dcKeyGtkCursorThemeSize, cursorSize)
XSettingsManager->>Plymouth: setScaleFactorForPlymouth(windowScale, false)
XSettingsManager-->>App: scale change persisted (effective after relogin)
alt ScreenScale1 unavailable
XSettingsManager->>XSettingsManager: onScaleFactorChanged(scale) (fallback)
XSettingsManager->>DConfig_XSettings: update legacy keys
XSettingsManager->>Plymouth: setScaleFactorForPlymouth(windowScale, false)
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
cb7ca9b to
81adb0e
Compare
| } | ||
|
|
||
| double minScaleFactor = 3.0; | ||
| for (auto &&screen : screens) { |
There was a problem hiding this comment.
const auto *screen : screens
| connect(m_config, | ||
| &DTK_CORE_NAMESPACE::DConfig::valueChanged, | ||
| this, | ||
| [this](const QString &key) { |
| , m_config(DTK_CORE_NAMESPACE::DConfig::create( | ||
| "org.deepin.dde.daemon", "org.deepin.dde.ScreenScale1", "", this)) | ||
| { | ||
| if (!m_config) { |
There was a problem hiding this comment.
|| !m_config->isValid()
| return; | ||
| } | ||
|
|
||
| if (m_config->isValid()) { |
| return range; | ||
| } | ||
|
|
||
| double ScreenScale::getRecommendedScale() const |
There was a problem hiding this comment.
推荐值,可以协助调试或者查看当前的缩放。
| found = true; | ||
| break; | ||
| } | ||
| } |
There was a problem hiding this comment.
浮点数精度误差,因此需要qFuzzyCompare比较
| return; | ||
| } | ||
|
|
||
| if (qFuzzyCompare(GetScaleFactor(), factor)) { |
| #include <algorithm> | ||
| #include <cmath> | ||
|
|
||
| namespace { |
There was a problem hiding this comment.
建议这里面的函数都改成类的private, 这里写全局的,没有别人调用。
| @@ -0,0 +1,4 @@ | |||
| [D-BUS Service] | |||
There was a problem hiding this comment.
session 级dbus,不需要配置安全策略
| "magic": "dsg.config.meta", | ||
| "version": "1.0", | ||
| "contents": { | ||
| "scale-factor": { |
| install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/misc/org.deepin.dde.ScreenScale1.service | ||
| DESTINATION lib/systemd/user/ | ||
| RENAME org.deepin.dde.ScreenScale1.service | ||
| ) |
| install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/misc/plugin-dde-screenscale.json DESTINATION ${CMAKE_INSTALL_FULL_DATADIR}/deepin-service-manager/user) | ||
|
|
||
| # Install dconf config meta | ||
| install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/misc/org.deepin.dde.ScreenScale1.json DESTINATION ${CMAKE_INSTALL_FULL_DATADIR}/dsg/configs/org.deepin.dde.daemon) |
There was a problem hiding this comment.
dtk_add_config_meta_files
| @@ -0,0 +1,14 @@ | |||
| [Unit] | |||
There was a problem hiding this comment.
不需要这个文件,只需要dbus的service文件
| return 1; | ||
| } | ||
|
|
||
| screenScale = new ScreenScale(); |
There was a problem hiding this comment.
std::make_unique<>, 推荐使用只能指针
| "/org/deepin/dde/Greeter1", | ||
| "org.deepin.dde.Greeter1", | ||
| QDBusConnection::systemBus())) | ||
| , m_sysDaemonInterface(new QDBusInterface("com.deepin.daemon.Daemon", |
There was a problem hiding this comment.
这个需要,接口名变了而已,dde-daemon中设置plymouth缩放的
4b639da to
7890d93
Compare
deepin pr auto review代码审查报告1. 整体架构与设计优点
改进建议
2. 语法与逻辑问题screenscale.cpp
xsettingsmanager.cpp
3. 代码质量问题
4. 性能问题
5. 安全问题
6. 其他建议
总结整体代码结构清晰,模块化设计良好,但在错误处理、输入验证、性能优化和安全方面还有改进空间。建议优先解决安全和输入验证问题,然后逐步改进代码质量和性能。 |
|
TAG Bot New tag: 1.0.22 |
|
TAG Bot New tag: 1.0.23 |
| 4. 多屏 (笔记本 + 外接显示器): | ||
| [{"widthPx":1920,"heightPx":1080,"widthMm":310,"heightMm":174},{"widthPx":2560,"heightPx":1440,"widthMm":597,"heightMm":336}] | ||
| */ | ||
| QString ScreenScale::GetScreenScaleInfo(const QString &screensJson) |
There was a problem hiding this comment.
widthPx
heightPx
physicalWidthMm
physicalHeightMm
建议参数名称
|
TAG Bot New tag: 1.0.24 |
|
TAG Bot New tag: 1.0.25 |
|
TAG Bot New tag: 1.0.26 |
|
TAG Bot New tag: 1.0.27 |
|
TAG Bot New tag: 1.0.28 |
|
TAG Bot New tag: 1.0.29 |
|
TAG Bot New tag: 1.0.30 |
|
TAG Bot New tag: 1.0.31 |
|
TAG Bot New tag: 1.0.32 |
|
TAG Bot New tag: 1.0.33 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: fly602 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 |
Refactored the XSettings scaling logic to use the new ScreenScale plugin as the primary source of truth. The XSettingsManager now delegates scale factor updates to the "org.deepin.dde.ScreenScale1" D-Bus service. This change removes redundant scaling calculations and ensures that scaling configurations are synchronized correctly between XSettings and the dedicated scaling service. Added a fallback synchronization logic in onScaleFactorChanged for cases where the ScreenScale service is unavailable.
Influence:
fix: 统一屏幕缩放管理到 ScreenScale 插件
重构了 XSettings 缩放逻辑,将 ScreenScale 插件作为缩放配置的事实来源。
XSettingsManager 现在将缩放因子更新操作委托给
"org.deepin.dde.ScreenScale1" D-Bus 服务。此更改删除了冗余的缩放计算逻 辑,并确保 XSettings 与专用缩放服务之间的配置保持同步。同时,在
ScreenScale 服务不可用时,在 onScaleFactorChanged 中提供了回退同步逻辑。
影响范围:
pms: BUG-355227
Change-Id: I2363239245451fc5079c39e6b76042d42a87b2a4
Summary by Sourcery
Unify screen scaling management around a new ScreenScale D-Bus plugin and make it the single source of truth for XSettings and related components.
New Features:
Bug Fixes:
Enhancements:
Build: