Skip to content

fix: correct DPI scaling value in XSettings - #38

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
mhduiy:scaledpi
Dec 8, 2025
Merged

deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
mhduiy:scaledpi

Conversation

@mhduiy

@mhduiy mhduiy commented Dec 8, 2025 •

Copy link
Copy Markdown
Contributor

Fixed a bug where the wrong variable was used when updating Xft DPI setting. Changed from using 'scale' variable to 'scaledDpi' variable to ensure the correct DPI value is stored in the configuration.

The issue occurred in the updateDPI() method where the code was incorrectly passing the 'scale' variable instead of 'scaledDpi' when updating the Xft DPI setting in the DConfig. This would cause incorrect DPI values to be stored, potentially leading to improper font scaling and display issues.

Influence:

  1. Test display scaling with different DPI settings
  2. Verify that Xft DPI configuration is correctly updated when display scaling changes
  3. Check font rendering quality after DPI changes
  4. Test configuration persistence across system restarts
  5. Verify that the correct DPI value is stored in DConfig after scaling adjustments

fix: 修复XSettings中DPI缩放值的错误

修复了更新Xft DPI设置时使用错误变量的bug。将使用'scale'变量改为使
用'scaledDpi'变量,确保正确的DPI值被存储到配置中。

问题出现在updateDPI()方法中,代码错误地传递了'scale'变量而不
是'scaledDpi'变量来更新DConfig中的Xft DPI设置。这会导致存储错误的DPI值, 可能引起字体缩放和显示问题。

Influence:

  1. 测试不同DPI设置下的显示缩放
  2. 验证显示缩放改变时Xft DPI配置是否正确更新
  3. 检查DPI更改后的字体渲染质量
  4. 测试配置在系统重启后的持久性
  5. 验证缩放调整后正确的DPI值是否存储在DConfig中

Summary by Sourcery

Bug Fixes:

  • Fix XSettings DPI update to write the computed scaled DPI value to DConfig instead of the raw scale factor.

Fixed a bug where the wrong variable was used when updating Xft DPI
setting. Changed from using 'scale' variable to 'scaledDpi' variable to
ensure the correct DPI value is stored in the configuration.

The issue occurred in the updateDPI() method where the code was
incorrectly passing the 'scale' variable instead of 'scaledDpi' when
updating the Xft DPI setting in the DConfig. This would cause incorrect
DPI values to be stored, potentially leading to improper font scaling
and display issues.

Influence:
1. Test display scaling with different DPI settings
2. Verify that Xft DPI configuration is correctly updated when display
scaling changes
3. Check font rendering quality after DPI changes
4. Test configuration persistence across system restarts
5. Verify that the correct DPI value is stored in DConfig after scaling
adjustments

fix: 修复XSettings中DPI缩放值的错误

修复了更新Xft DPI设置时使用错误变量的bug。将使用'scale'变量改为使
用'scaledDpi'变量,确保正确的DPI值被存储到配置中。

问题出现在updateDPI()方法中,代码错误地传递了'scale'变量而不
是'scaledDpi'变量来更新DConfig中的Xft DPI设置。这会导致存储错误的DPI值,
可能引起字体缩放和显示问题。

Influence:
1. 测试不同DPI设置下的显示缩放
2. 验证显示缩放改变时Xft DPI配置是否正确更新
3. 检查DPI更改后的字体渲染质量
4. 测试配置在系统重启后的持久性
5. 验证缩放调整后正确的DPI值是否存储在DConfig中
@sourcery-ai

sourcery-ai Bot commented Dec 8, 2025

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Corrects the stored Xft DPI configuration by using the computed scaled DPI value instead of the raw scale factor when updating DConfig in updateDPI(), ensuring DPI persistence and font scaling behave as intended.

Sequence diagram for corrected DPI update in updateDPI

sequenceDiagram
    participant DisplayScaleController
    participant XSettingsManager
    participant DConfig

    DisplayScaleController->>XSettingsManager: updateDPI(scale)
    XSettingsManager->>XSettingsManager: compute scaledDpi from scale
    XSettingsManager->>DConfig: value(dcKeyXftDpi) -> tempXftDpi
    DConfig-->>XSettingsManager: tempXftDpi
    XSettingsManager->>XSettingsManager: compare tempXftDpi with scaledDpi
    alt tempXftDpi != scaledDpi
        XSettingsManager->>DConfig: setValue(dcKeyXftDpi, scaledDpi)
        XSettingsManager->>XSettingsManager: create XsSetting with value scaledDpi
        XSettingsManager->>DisplayScaleController: notify DPI updated
    else tempXftDpi == scaledDpi
        XSettingsManager->>DisplayScaleController: no change to Xft DPI
    end
Loading

File-Level Changes

Change Details Files
Use the correctly computed DPI value when persisting Xft DPI to configuration and propagating it via XSettings.
  • In updateDPI(), replace use of the scale variable with scaledDpi when writing the Xft DPI value to DConfig.
  • Ensure that the Xft DPI XSettings update path now consistently uses scaledDpi as the source of truth for DPI values.
src/plugin-qt/xsettings/impl/xsettingsmanager.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

这是一个很好的代码修复,我来分析一下:

  1. 问题分析:
    原代码在更新DPI设置时,错误地将scale值(缩放比例)设置到了XftDpi配置项中,而应该设置的是scaledDpi(实际的DPI值)。

  2. 修改评价:

    • 逻辑正确性:修改后的代码正确地将scaledDpi值写入配置,符合业务逻辑
    • 代码质量:修复后代码更加准确,消除了潜在bug
    • 性能影响:这个修改不会对性能产生影响
    • 安全性:修改不会引入安全问题
  3. 建议改进:
    虽然这个修复是正确的,但为了提高代码的可维护性,建议:

    void XSettingsManager::updateDPI()
    {
        // ... 其他代码 ...
        int tempXftDpi = m_settingDconfig->value(dcKeyXftDpi).toInt(&bOk);
        if (bOk) {
            if (tempXftDpi != scaledDpi) {
                // 添加注释说明为什么使用scaledDpi而不是scale
                // scaledDpi是实际的DPI值,而scale是缩放比例
                m_settingDconfig->setValue(dcKeyXftDpi, scaledDpi);
                XsSetting setting;
                setting.prop = dcKeyXftDpi;
                setting.value = scaledDpi;
    • 建议添加注释说明scaledDpi和scale的区别
    • 可以考虑将scale和scaledDpi的命名更加明确,比如改为scaleRatio和actualDpi
  4. 总体评价:
    这是一个必要且正确的bug修复,修复后代码的逻辑更加准确。建议在后续开发中注意变量命名的清晰度,并添加必要的注释来提高代码的可维护性。

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

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mhduiy, robertkill

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

@mhduiy

mhduiy commented Dec 8, 2025

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Dec 8, 2025

Copy link
Copy Markdown

This pr force merged! (status: blocked)

@deepin-bot
deepin-bot Bot merged commit 89c1459 into linuxdeepin:master Dec 8, 2025
7 of 8 checks passed
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