Skip to content

Conversation

@mhduiy
Copy link
Contributor

@mhduiy mhduiy commented Dec 8, 2025

  1. Added handling for cursor size changes from XSettings DConfig in AppearanceManager
  2. Fixed cursor size initialization from 24 instead of -1 when selecting cursor theme
  3. Corrected GSettings key from "cursor-size" to "cursorSize" for GNOME desktop interface compatibility

Log: Fixed cursor size configuration handling and GNOME desktop integration

Influence:

  1. Test cursor size changes through DConfig settings
  2. Verify cursor theme switching with different available sizes
  3. Test GNOME desktop compatibility with cursor size settings
  4. Verify cursor size persistence across system restarts
  5. Test cursor size changes in different desktop environments

fix: 处理光标大小配置变更

  1. 在 AppearanceManager 中添加了对 XSettings DConfig 中光标大小变更的 处理
  2. 修复了选择光标主题时,光标大小从24而不是-1初始化的逻辑
  3. 更正了 GNOME 桌面接口的 GSettings 键值,从 "cursor-size" 改为 "cursorSize" 以提升兼容性

Log: 修复了光标大小配置处理和 GNOME 桌面集成问题

Influence:

  1. 测试通过 DConfig 设置更改光标大小的功能
  2. 验证在不同可用尺寸下切换光标主题的功能
  3. 测试光标大小设置在 GNOME 桌面环境下的兼容性
  4. 验证光标大小在系统重启后的持久性
  5. 测试在不同桌面环境下更改光标大小的功能

Summary by Sourcery

Handle cursor size configuration changes across DConfig, theme selection, and GNOME integration.

Bug Fixes:

  • Propagate cursor size changes from XSettings DConfig into appearance properties and change notifications.
  • Correct cursor size selection logic when changing cursor theme to use a valid default and nearest available size.
  • Fix GNOME desktop cursor size integration by using the correct GSettings key for the interface schema.

1. Added handling for cursor size changes from XSettings DConfig in
AppearanceManager
2. Fixed cursor size initialization from 24 instead of -1 when selecting
cursor theme
3. Corrected GSettings key from "cursor-size" to "cursorSize" for GNOME
desktop interface compatibility

Log: Fixed cursor size configuration handling and GNOME desktop
integration

Influence:
1. Test cursor size changes through DConfig settings
2. Verify cursor theme switching with different available sizes
3. Test GNOME desktop compatibility with cursor size settings
4. Verify cursor size persistence across system restarts
5. Test cursor size changes in different desktop environments

fix: 处理光标大小配置变更

1. 在 AppearanceManager 中添加了对 XSettings DConfig 中光标大小变更的
处理
2. 修复了选择光标主题时,光标大小从24而不是-1初始化的逻辑
3. 更正了 GNOME 桌面接口的 GSettings 键值,从 "cursor-size" 改为
"cursorSize" 以提升兼容性

Log: 修复了光标大小配置处理和 GNOME 桌面集成问题

Influence:
1. 测试通过 DConfig 设置更改光标大小的功能
2. 验证在不同可用尺寸下切换光标主题的功能
3. 测试光标大小设置在 GNOME 桌面环境下的兼容性
4. 验证光标大小在系统重启后的持久性
5. 测试在不同桌面环境下更改光标大小的功能
@github-actions
Copy link

github-actions bot commented Dec 8, 2025

TAG Bot

TAG: 1.1.74
EXISTED: no
DISTRIBUTION: unstable

@sourcery-ai
Copy link

sourcery-ai bot commented Dec 8, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Implements proper propagation and persistence of cursor size configuration changes from DConfig/XSettings through AppearanceManager, fixes cursor theme size selection defaults, and aligns GNOME interface GSettings keys for cursor size to ensure cross-desktop compatibility.

Sequence diagram for cursor size change via XSettings DConfig

sequenceDiagram
    participant XSettingsDconfig
    participant AppearanceManager
    participant Property
    participant Listener

    XSettingsDconfig->>AppearanceManager: notifyChange(DCKEYCURSORSIZEBASE)
    AppearanceManager->>XSettingsDconfig: value(DCKEYCURSORSIZEBASE)
    XSettingsDconfig-->>AppearanceManager: int cursorSize
    AppearanceManager->>Property: cursorSize = value
    AppearanceManager->>Listener: Changed(CursorSize, cursorSize)
Loading

Sequence diagram for cursor theme change and cursor size selection

sequenceDiagram
    actor User
    participant AppearanceManager
    participant Subthemes
    participant CursorTheme
    participant Utils

    User->>AppearanceManager: doSetCursorTheme(themeId)
    AppearanceManager->>Subthemes: listCursorThemes()
    Subthemes-->>AppearanceManager: cursorThemes
    loop findMatchingTheme
        AppearanceManager->>CursorTheme: getId()
        CursorTheme-->>AppearanceManager: id
    end
    AppearanceManager->>CursorTheme: getPath()
    CursorTheme-->>AppearanceManager: themePath
    AppearanceManager->>Utils: getAvailableCursorSizes(themePath)
    Utils-->>AppearanceManager: availableSizes
    Note over AppearanceManager: initialize cursorSize = 24
    loop chooseClosestSize
        AppearanceManager->>AppearanceManager: cursorSize = closest to Property.cursorSize
    end
    AppearanceManager->>AppearanceManager: apply themeId and cursorSize
Loading

Sequence diagram for GNOME GSettings cursor size synchronization

sequenceDiagram
    participant Client
    participant ThemesApi
    participant QGSettings

    Client->>ThemesApi: setCursorSize(size)
    ThemesApi->>QGSettings: isSchemaInstalled(org.gnome.desktop.interface)
    QGSettings-->>ThemesApi: bool installed
    alt schema installed
        ThemesApi->>QGSettings: QGSettings(schema, path, parent)
        QGSettings-->>ThemesApi: gtkSettings
        ThemesApi->>gtkSettings: keys()
        gtkSettings-->>ThemesApi: keyList
        alt keyList contains cursorSize
            ThemesApi->>gtkSettings: set(cursorSize, size)
        end
    end
Loading

Class diagram for updated cursor size handling

classDiagram
    class AppearanceManager {
        +int handleXsettingDConfigChange(QString key)
        +bool doSetCursorTheme(QString value)
        -int getSuitableCursorSize(QString value)
        -Property* m_property
        -XSettingsDconfig* m_XSettingsDconfig
        -Subthemes* m_subthemes
    }

    class Property {
        +int cursorSize
        +int windowRadius
    }

    class XSettingsDconfig {
        +QVariant value(QString key)
    }

    class Subthemes {
        +QList~CursorTheme*~ listCursorThemes()
    }

    class CursorTheme {
        +QString getId()
        +QString getPath()
    }

    class Utils {
        +QList~int~ getAvailableCursorSizes(QString themePath)
    }

    class ThemesApi {
        +bool setCursorSize(int size)
    }

    class QGSettings {
        +QGSettings(QString schema, QByteArray path, QObject parent)
        +QStringList keys()
        +void set(QString key, int value)
        +static bool isSchemaInstalled(QString schema)
    }

    AppearanceManager --> Property : manages
    AppearanceManager --> XSettingsDconfig : reads_from
    AppearanceManager --> Subthemes : queries
    Subthemes --> CursorTheme : contains
    AppearanceManager ..> Utils : uses
    ThemesApi ..> QGSettings : updates
    ThemesApi ..> Property : affects_cursorSize
Loading

File-Level Changes

Change Details Files
Handle cursor size updates coming from XSettings DConfig within AppearanceManager so runtime config changes propagate to clients.
  • Extend Xsettings DConfig change handler to recognize the cursor size key
  • Update internal cursorSize property from the DConfig value when the key changes
  • Emit the corresponding CursorSize change signal with the new value as a string
src/service/impl/appearancemanager.cpp
Adjust cursor theme setting logic to use a sane default cursor size and correctly pick the closest available size for the selected theme.
  • Initialize the computed cursor size to 24 instead of -1 before resolving theme-specific sizes
  • Iterate through available cursor sizes for the chosen theme and track the closest size to the current cursorSize property
  • Store the chosen closest size directly in the cursorSize variable instead of an unused temporary
src/service/impl/appearancemanager.cpp
Align GNOME desktop cursor size GSettings key usage with the actual key name used by org.gnome.desktop.interface for better compatibility.
  • Change the GSettings key check from cursor-size to cursorSize
  • Write the cursor size using the cursorSize key when updating GNOME interface settings
src/service/modules/api/themes.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

Copy link

@sourcery-ai sourcery-ai bot left a comment

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 - here's some feedback:

  • In doSetCursorTheme, the lambda capture [this, value] still includes value even though it’s no longer used; consider removing it from the capture list to avoid confusion.
  • The getSuitableCursorSize lambda now defaults cursorSize to a hard-coded 24 when no matching theme/sizes are found; consider making this default explicit (e.g., via a named constant or configuration) or handling the "no suitable size" case separately so the behavior is clearer.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `doSetCursorTheme`, the lambda capture `[this, value]` still includes `value` even though it’s no longer used; consider removing it from the capture list to avoid confusion.
- The `getSuitableCursorSize` lambda now defaults `cursorSize` to a hard-coded 24 when no matching theme/sizes are found; consider making this default explicit (e.g., via a named constant or configuration) or handling the "no suitable size" case separately so the behavior is clearer.

## Individual Comments

### Comment 1
<location> `src/service/modules/api/themes.cpp:710-711` </location>
<code_context>
         QGSettings gtkSettings("org.gnome.desktop.interface", QByteArray(), this);
-        if (gtkSettings.keys().contains("cursor-size")) {
-            gtkSettings.set("cursor-size", size);
+        if (gtkSettings.keys().contains("cursorSize")) {
+            gtkSettings.set("cursorSize", size);
         }
     }
</code_context>

<issue_to_address>
**issue (bug_risk):** Changing the GNOME cursor key to `cursorSize` is likely incorrect and will prevent the setting from taking effect.

Upstream `org.gnome.desktop.interface` uses the `cursor-size` key (with a dash). Changing this to `cursorSize` means the `contains` check and `set` call will no longer match the actual schema, so the cursor size won’t be applied to GTK. Unless you’re targeting a forked schema that really uses `cursorSize`, this should stay as `"cursor-size"` for compatibility.
</issue_to_address>

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

deepin pr auto review

我来对这个git diff进行代码审查:

  1. 语法逻辑:
  • 代码语法正确,没有明显的语法错误
  • 逻辑流程清晰,处理cursor size变更的逻辑合理
  • 修改后的getSuitableCursorSize函数使用了更合适的默认值24,而不是-1
  1. 代码质量:
  • 在handleXsettingDConfigChange函数中增加了对DCKEYCURSORSIZEKEY的处理,符合现有的代码风格
  • lambda表达式getSuitableCursorSize的改进很好,移除了未使用的value变量,直接使用cursorSize
  • 代码缩进和格式保持了一致性
  1. 代码性能:
  • 代码性能没有明显问题
  • 在查找合适cursor size时仍然使用线性搜索,考虑到cursor themes数量通常不多,这是可以接受的
  1. 代码安全:
  • 在ThemesApi::setCursorSize中,正确检查了schema是否安装
  • 使用了QGSettings的安全访问方式
  • 没有发现明显的安全隐患

建议改进:

  1. 在handleXsettingDConfigChange函数中,建议添加对cursorSize值的合法性检查,比如:
} else if (key == DCKEYCURSORSIZEBASE) {
    int newSize = m_XSettingsDconfig->value(DCKEYCURSORSIZEBASE).toInt();
    if (newSize > 0) {  // 添加有效性检查
        m_property->cursorSize = newSize;
        Q_EMIT Changed("CursorSize", QString::number(m_property->cursorSize));
    }
}
  1. 在getSuitableCursorSize lambda中,建议添加对availableSizes为空的处理:
auto getSuitableCursorSize = [this, value]() {
    int cursorSize = 24;
    for (auto iter : m_subthemes->listCursorThemes()) {
        if (iter->getId() == value) {
            auto availableSizes = utils::getAvailableCursorSizes(iter->getPath());
            if (availableSizes.isEmpty()) {  // 添加空列表检查
                return cursorSize;
            }
            int len = INT_MAX;
            for (auto size : availableSizes) {
                if (std::abs(size - m_property->cursorSize) < len) {
                    len = std::abs(size - m_property->cursorSize);
                    cursorSize = size;
                }
            }
            break;
        }
    }
    return cursorSize;
};
  1. 建议在themes.cpp中添加对size参数的有效性检查:
bool ThemesApi::setCursorSize(int size)
{
    if (size <= 0) {  // 添加参数有效性检查
        return false;
    }
    // ... 其余代码
}

这些改进建议主要是为了增强代码的健壮性,防止可能的异常情况。整体来说,这次修改的质量是不错的。

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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 merged commit 748ec7f into linuxdeepin:master Dec 8, 2025
16 of 18 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