From 4394047710b5c0e7e1d54005ebdb77f4ecd83936 Mon Sep 17 00:00:00 2001 From: caixiangrong Date: Thu, 4 Dec 2025 17:01:58 +0800 Subject: [PATCH] feat: add cursor size scaling with system scale factor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added support for cursor size to scale proportionally with system scaling factor Introduced a new base cursor size configuration item "gtk-cursor-theme- size-base" Removed "gtk-cursor-theme-size" from excluded keys to allow dynamic updates Cursor size is now calculated as base size multiplied by system scale factor This ensures cursor size remains appropriately sized across different display scales Log: Added cursor size scaling feature that adjusts cursor size based on system scaling factor Influence: 1. Test cursor size changes when adjusting system scaling factor 2. Verify base cursor size configuration works correctly 3. Check cursor size updates in real-time when scaling factor changes 4. Test compatibility with existing cursor theme settings 5. Verify cursor size calculation accuracy across different scaling factors feat: 增加光标大小随系统缩放比例调整功能 添加了光标大小随系统缩放比例按比例调整的支持 引入了新的基础光标大小配置项"gtk-cursor-theme-size-base" 将"gtk-cursor-theme-size"从排除列表中移除以支持动态更新 光标大小现在计算为基础大小乘以系统缩放比例 确保光标在不同显示比例下保持合适的大小 Log: 新增光标大小缩放功能,根据系统缩放比例调整光标大小 Influence: 1. 测试调整系统缩放比例时光标大小的变化 2. 验证基础光标大小配置是否正确工作 3. 检查缩放比例改变时光标大小的实时更新 4. 测试与现有光标主题设置的兼容性 5. 验证不同缩放比例下光标大小计算的准确性 PMS: STORY-39797 --- .../xsettings/impl/xsettingsmanager.cpp | 17 +++++++++++++---- .../xsettings/misc/org.deepin.XSettings.json | 15 ++++++++++++--- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/plugin-qt/xsettings/impl/xsettingsmanager.cpp b/src/plugin-qt/xsettings/impl/xsettingsmanager.cpp index 86349e10..65f61b79 100644 --- a/src/plugin-qt/xsettings/impl/xsettingsmanager.cpp +++ b/src/plugin-qt/xsettings/impl/xsettingsmanager.cpp @@ -206,13 +206,18 @@ void XSettingsManager::setString(const QString &prop, const QString &v) void XSettingsManager::handleDConfigChangedCb(const QString &key) { - static const QStringList excludedkeys = { "xft-dpi", "scale-factor", "gtk-cursor-theme-size", "window-scale" }; + static const QStringList excludedkeys = { "xft-dpi", "scale-factor", "window-scale" }; if (excludedkeys.contains(key)) { return; } - if (key == "gtk-cursor-theme-name") { + if (key == "gtk-cursor-theme-name" || key == "gtk-cursor-theme-size") { updateXResources(); + } else if (key == "gtk-cursor-theme-size-base") { + int cursorSizeBase = m_settingDconfig->value(key).toInt(); + m_settingDconfig->setValue("gtk-cursor-theme-size", cursorSizeBase); + return; } + QSharedPointer dconfInfo = m_dconfInfos.getByDconfKey(key); if (dconfInfo.isNull()) { return; @@ -510,7 +515,6 @@ void XSettingsManager::setGSettingsByXProp(const QString &prop, XsValue value) void XSettingsManager::setSingleScaleFactor(double scale, bool emitSignal) { - int cursorSize = static_cast(BASE_CURSORSIZE * scale); int windowScale = qFloor((scale + 0.3) * 10) / 10; if (windowScale < 1) { windowScale = 1; @@ -523,7 +527,12 @@ void XSettingsManager::setSingleScaleFactor(double scale, bool emitSignal) if (windowScale != oldWindowScale) { m_settingDconfig->setValue(dcKeyWindowScale, windowScale); } - + bool ok = false; + int baseCursorSizeInt = m_settingDconfig->value("gtk-cursor-theme-size-base").toInt(&ok); + if (!ok || baseCursorSizeInt <= 0) { + baseCursorSizeInt = BASE_CURSORSIZE; + } + int cursorSize = static_cast(baseCursorSizeInt * scale); m_settingDconfig->setValue(dcKeyGtkCursorThemeSize, cursorSize); } diff --git a/src/plugin-qt/xsettings/misc/org.deepin.XSettings.json b/src/plugin-qt/xsettings/misc/org.deepin.XSettings.json index 46f8569a..6dde7df2 100644 --- a/src/plugin-qt/xsettings/misc/org.deepin.XSettings.json +++ b/src/plugin-qt/xsettings/misc/org.deepin.XSettings.json @@ -150,8 +150,17 @@ "value": 24, "serial": 0, "flags": [], - "name": "Timeout before click repeat", - "description": "Timeout in milliseconds before a click starts repeating (onspinner buttons for example).", + "name": "Cursor theme size", + "description": "Cursor theme size", + "permissions": "readwrite", + "visibility": "private" + }, + "gtk-cursor-theme-size-base": { + "value": 24, + "serial": 0, + "flags": [], + "name": "Base Cursor Size", + "description": "Base size for cursor scaling", "permissions": "readwrite", "visibility": "private" }, @@ -349,4 +358,4 @@ "visibility": "private" } } -} \ No newline at end of file +}