Skip to content

feat: add shortcut manager plugin#55

Open
yixinshark wants to merge 1 commit into
linuxdeepin:masterfrom
yixinshark:feat-shortcut
Open

feat: add shortcut manager plugin#55
yixinshark wants to merge 1 commit into
linuxdeepin:masterfrom
yixinshark:feat-shortcut

Conversation

@yixinshark
Copy link
Copy Markdown
Contributor

-Keyboard shortcut management in X11;
-Keyboard shortcut and gesture management in Treeland -develop-guide document

Log: add shortcut manager plugin

Copy link
Copy Markdown

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

Sorry @yixinshark, your pull request is larger than the review limit of 150000 diff characters

@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 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

1 similar comment
@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 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

@yixinshark
Copy link
Copy Markdown
Contributor Author

TODO:
1.进一步测试triggers触发重新加载快捷键配置
2.treeland的联调,已初步测试。关注协议的变化。

Comment thread debian/control Outdated
Comment thread src/plugin-qt/shortcut/src/backend/wayland/treelandshortcutwrapper.cpp Outdated
Comment thread src/plugin-qt/shortcut/src/backend/wayland/treelandshortcutwrapper.cpp Outdated
Comment thread src/plugin-qt/shortcut/src/config/configloader.cpp Outdated
Comment thread src/plugin-qt/shortcut/src/config/configloader.h
Comment thread src/plugin-qt/shortcut/src/core/gesturemanager.cpp Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new shortcut manager plugin for Deepin, including a core daemon/service with X11 and Wayland backends, a helper CLI (dde-shortcut-tool), DConfig-based shortcut/gesture definitions, translations, and Debian packaging hooks to reload shortcuts when configs change.

Changes:

  • Add a full-featured dde-shortcut Qt plugin and optional standalone debug binary that manage global keyboard shortcuts and gestures across X11 and Treeland/Wayland, with X11/Wayland-specific handlers and DBus APIs (org.deepin.dde.Keybinding1 / org.deepin.dde.Gesture1).
  • Introduce dde-shortcut-tool CLI with multiple controllers (audio, display, power, touchpad, network, keyboard backlight, lock keys, app launcher) to execute system actions used by the shortcut configs.
  • Define a large set of DConfig-based shortcut/gesture metadata under org.deepin.dde.keybinding, translation infrastructure (TS files, i18n extraction tool and CMake helpers), and Debian integration (extra build/runtime deps, triggers, and postinst logic to call ReloadConfigs on running sessions).

Notable Issue

  • Bug – ConfigLoader cannot persist updated values to DConfig
    In src/plugin-qt/shortcut/src/config/configloader.cpp, loadConfig() calls DConfig::create(APP_ID, CONFIG_NAME, "/" + subPath, ...) and later sets keyConfig.subPath = config->subpath();, so keyConfig.getId() is based on config->subpath() (which includes the leading /).
    However, m_configs is keyed by the unprefixed subPath (m_configs.insert(subPath, config); around lines 140–221), while updateValue() checks if (m_configs.contains(id)) and uses m_configs[id] (lines ~85–92), where id is passed from KeybindingManager as config.getId() (the prefixed form).
    This mismatch means updateValue() will never find the entry and thus will not call setValue, so DBus methods like ModifyHotkeys and Disable update the in-memory maps and grabs but will not persist changes back into DConfig. A concrete fix would be to key m_configs by the same string used for getId() (e.g. config->subpath()) or to translate from id back to subPath via m_subPathToId before indexing m_configs.

Reviewed changes

Copilot reviewed 176 out of 176 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/plugin-qt/CMakeLists.txt Adds the shortcut plugin subdirectory to the Qt plugin build, wiring the new module into the overall project.
src/plugin-qt/shortcut/CMakeLists.txt Defines build of the plugin-dde-shortcut library and optional dde-shortcut-debug binary, sets up Wayland protocol codegen, installs configs, i18n tooling, and integrates translation generation.
src/plugin-qt/shortcut/src/main.cpp Standalone debug entry point that initializes ShortcutManager in a QGuiApplication, supports --list to dump configs.
src/plugin-qt/shortcut/src/core/shortcutmanager.h/.cpp Coordinates config loading, backend selection (X11 vs Wayland), and creation of KeybindingManager/GestureManager; handles Wayland protocol lifecycle and registration.
src/plugin-qt/shortcut/src/core/keybindingmanager.h/.cpp Implements DBus interface org.deepin.dde.Keybinding1, manages key shortcut registration, conflict checking, lock-key properties, and delegates execution to ActionExecutor; affected by the ConfigLoader::updateValue bug described above.
src/plugin-qt/shortcut/src/core/gesturemanager.h/.cpp Implements DBus interface org.deepin.dde.Gesture1, manages gesture registration, config updates, and activation signals for Wayland sessions.
src/plugin-qt/shortcut/src/core/shortcutconfig.h Defines shared configuration structs/enums for shortcuts and gestures (trigger types, categories, key event flags, gesture types/directions).
src/plugin-qt/shortcut/src/core/qkeysequenceconverter.h/.cpp Provides conversions between Qt key sequence names, XKB-style strings, and Qt key combinations; used by X11 backend and Wayland binding names.
src/plugin-qt/shortcut/src/core/actionexecutor.h/.cpp Executes configured actions based on TriggerType (command/app/action), invoking /usr/bin/dde-am or launching app IDs.
src/plugin-qt/shortcut/src/core/translationmanager.h/.cpp Manages per-app-id QTranslator instances loaded from /usr/share/deepin/org.deepin.dde.keybinding/translations, and provides translation lookup used in DBus structs.
src/plugin-qt/shortcut/src/config/configloader.h/.cpp Loads DConfig-based shortcut and gesture definitions from .ini + org.deepin.shortcut.json files, exposes lists and change signals, and attempts to update DConfig on changes; contains the id/subPath key mismatch bug for updateValue().
src/plugin-qt/shortcut/src/backend/abstractkeyhandler.h Abstract interface for key backends (register/unregister, commit, lock-key operations, and activation signal).
src/plugin-qt/shortcut/src/backend/abstractgesturehandler.h Abstract interface for gesture backends (register/unregister, commit, and activation signal).
src/plugin-qt/shortcut/src/backend/specialkeyhandler.h/.cpp Handles “special” keys that come via org.deepin.dde.KeyEvent1 (libinput), mapping numeric keycodes to shortcut IDs with support for press/release/repeat semantics.
src/plugin-qt/shortcut/src/backend/x11/x11keyhandler.h/.cpp Implements AbstractKeyHandler for X11 using XCB/XTest, including key grabbing, repeat detection, standalone modifier handling, and Caps/Num Lock state get/set.
src/plugin-qt/shortcut/src/backend/x11/modifierkeymonitor.h/.cpp Polling-based helper that tracks standalone modifier presses/releases and emits modifierKeyReleased for use by X11KeyHandler.
src/plugin-qt/shortcut/src/backend/x11/x11helper.cpp Wraps XStringToKeysym in a C-accessible function used by the X11 backend.
src/plugin-qt/shortcut/src/backend/wayland/treelandshortcutwrapper.h/.cpp Wraps the Treeland shortcut manager Wayland protocol (treeland_shortcut_manager_v2), handling bind/unbind, commit semantics, and activation callbacks.
src/plugin-qt/shortcut/src/backend/wayland/waylandkeyhandler.h/.cpp Implements AbstractKeyHandler on Wayland via TreelandShortcutWrapper and KDE keystate protocol, managing bindings and Caps/Num Lock state where compositor support is available.
src/plugin-qt/shortcut/src/backend/wayland/waylandgesturehandler.h/.cpp Implements AbstractGestureHandler on Wayland, binding swipe/hold gestures via Treeland, tracking active bindings, and forwarding activations.
src/plugin-qt/shortcut/src/3rdparty/kde-keystate.xml Bundles the KDE keystate Wayland protocol description used to generate client stubs.
src/plugin-qt/shortcut/pluginshortcutmanager.h/.cpp Adapter that owns a ShortcutManager in plugin mode and uses a provided QDBusConnection to register/unregister Keybinding and Gesture DBus objects and org.deepin.dde.Keybinding1 service.
src/plugin-qt/shortcut/plugin.cpp Defines DSM plugin entry points DSMRegister / DSMUnRegister, creating and cleaning up PluginShortcutManager.
src/plugin-qt/shortcut/plugin-dde-shortcut.json Deepin service-manager plugin metadata for the shortcut plugin (name, library path, exposed DBus paths, residency policy).
src/plugin-qt/shortcut/tools/extract_shortcuts_i18n.py Helper script that scans org.deepin.shortcut.json configs for modifiable shortcuts and generates a C++ file with QT_TRANSLATE_NOOP entries for lupdate.
src/plugin-qt/shortcut/tools/CMakeLists.txt Adds the dde-shortcut-tool subdirectory to the tools build.
src/plugin-qt/shortcut/tools/dde-shortcut-tool/CMakeLists.txt Builds the dde-shortcut-tool CLI, links Qt6, Dtk6, XCB, and installs the binary.
src/plugin-qt/shortcut/tools/dde-shortcut-tool/main.cpp Entry point for dde-shortcut-tool, setting up CommandParser and registering all controllers.
src/plugin-qt/shortcut/tools/dde-shortcut-tool/commandparser.h/.cpp CLI parser that dispatches subcommands like audio, display, network, etc., to their respective controllers and prints usage/help.
src/plugin-qt/shortcut/tools/dde-shortcut-tool/basecontroller.h Abstract base class for individual CLI controllers (name, supported actions, execute, help).
src/plugin-qt/shortcut/tools/dde-shortcut-tool/audiocontroller.h/.cpp Controls system audio via DBus (mute/unmute, volume up/down) and optional OSD signalling.
src/plugin-qt/shortcut/tools/dde-shortcut-tool/displaycontroller.h/.cpp Controls display brightness and mode via Deepin display DBus APIs and DConfig, and can turn off the screen.
src/plugin-qt/shortcut/tools/dde-shortcut-tool/powercontroller.h/.cpp Exposes power-related actions (shutdown/suspend/hibernate/turn-off-screen/away/etc.) via DBus integrations and DConfig.
src/plugin-qt/shortcut/tools/dde-shortcut-tool/touchpadcontroller.h/.cpp Toggles and controls touchpad enabled state via DBus, with OSD signalling.
src/plugin-qt/shortcut/tools/dde-shortcut-tool/networkcontroller.h/.cpp Toggles WiFi and airplane mode via org.deepin.dde.AirplaneMode1 on the system bus.
src/plugin-qt/shortcut/tools/dde-shortcut-tool/mediaplayercontroller.h/.cpp Controls media players (play/pause/next/prev/seek/rewind/forward) via MPRIS DBus interfaces.
src/plugin-qt/shortcut/tools/dde-shortcut-tool/kbdlightcontroller.h/.cpp Manages keyboard backlight toggling and brightness via DBus and backlight interfaces.
src/plugin-qt/shortcut/tools/dde-shortcut-tool/lockkeycontroller.h/.cpp Shows OSD for CapsLock/NumLock state changes and queries/sets lock states across X11 and Wayland sessions.
src/plugin-qt/shortcut/tools/dde-shortcut-tool/launchcontroller.h/.cpp Launches default applications for given MIME types or URL scheme handlers using xdg-mime and dde-am.
src/plugin-qt/shortcut/tools/dde-shortcut-tool/networkcontroller.h/.cpp See above; used by WLAN shortcut config to toggle WiFi.
src/plugin-qt/shortcut/tools/dde-shortcut-tool/constant.h Defines enums for audio/media/display/touchpad actions and DConfig key constants used across controllers.
src/plugin-qt/shortcut/tools/dde-shortcut-tool/test_shortcut_tool.sh Shell script to exercise and validate dde-shortcut-tool actions, serving as an integration test harness.
src/plugin-qt/shortcut/translations/org.deepin.dde.keybinding*.ts New TS stubs (per-locale) containing Display switch and terminal sources, marked as unfinished translations for future localization.
src/plugin-qt/shortcut/configs/org.deepin.dde.keybinding.ini Registers all shortcut and gesture DConfig subpaths so ConfigLoader can discover them at runtime.
src/plugin-qt/shortcut/configs/org.deepin.dde.keybinding.shortcut.*/org.deepin.shortcut.json Define a comprehensive set of system keyboard shortcuts (volume, brightness, media, power, WLAN, touchpad, lock keys, default terminal, apps, etc.) with metadata (appId, displayName, hotkeys, triggerType/value, category, enabled, modifiable).
src/plugin-qt/shortcut/configs/org.deepin.dde.keybinding.gesture.*/org.deepin.shortcut.json Define touchpad gesture shortcuts (3/4-finger swipes and taps) for Wayland, mapping to compositor action IDs used in Treeland protocol.
src/plugin-qt/shortcut/src/3rdparty/kde-keystate.xml (Already noted above) Wayland protocol spec for key states, used by KeyStateManager.
debian/control Extends build-deps (Qt Wayland, tools, XCB keysyms/xtest, Wayland, treeland-protocols, Python) and runtime deps (Qt6, Dtk6, Wayland/XCB libs) to support the new plugin and tools; updates package description to mention the shortcut manager.
debian/dde-services.triggers Adds a trigger on /usr/share/deepin/org.deepin.dde.keybinding so DConfig metadata changes will cause postinst to run with triggered.
debian/dde-services.postinst On trigger, iterates active user DBus session buses and calls org.deepin.dde.Keybinding1.ReloadConfigs for each, so running sessions pick up updated shortcut configs without restart.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@deepin-bot
Copy link
Copy Markdown

deepin-bot Bot commented Jan 29, 2026

TAG Bot

New tag: 1.0.20
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #56

@deepin-bot
Copy link
Copy Markdown

deepin-bot Bot commented Feb 27, 2026

TAG Bot

New tag: 1.0.21
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #58

@deepin-bot
Copy link
Copy Markdown

deepin-bot Bot commented Apr 24, 2026

TAG Bot

New tag: 1.0.22
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #62

@deepin-bot
Copy link
Copy Markdown

deepin-bot Bot commented Apr 24, 2026

TAG Bot

New tag: 1.0.23
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #64

@deepin-bot
Copy link
Copy Markdown

deepin-bot Bot commented May 8, 2026

TAG Bot

New tag: 1.0.24
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #66

@deepin-bot
Copy link
Copy Markdown

deepin-bot Bot commented May 15, 2026

TAG Bot

New tag: 1.0.25
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #68

@yixinshark yixinshark force-pushed the feat-shortcut branch 2 times, most recently from 90dbe23 to 4de56c4 Compare May 29, 2026 09:59
- Add dde-app-shortcuts config module for built-in app shortcuts and translations.
- Route logout shortcut through dde-shortcut-tool power show-ui.
- Lazily create dde-shortcut-tool controllers and expose static command metadata.
- Keep power shortcut actions stateless and initialize dependencies per action.
- Skip Display1 initialization on Wayland to avoid shortcut command DBus timeout.
- Print Treeland bind error names on commit failure.

Log: add shortcut manager plugin
Pms: TASK-390447
Change-Id: I4c8ad94a31d4703d78bafb756e5c6b81c36375fd
@deepin-ci-robot
Copy link
Copy Markdown

deepin pr auto review

本次代码审查针对 dde-services 项目中新增的 dde-shortcut 插件及相关工具、配置文件进行了全面检查。该模块实现了基于 DConfig 的动态快捷键管理框架,支持 X11 和 Wayland 双平台,并引入了手势、国际化等特性。

整体来看,代码架构清晰,模块化良好,对 Wayland 协议的封装和 X11 底层操作的处理都比较专业。但在代码安全性、健壮性、性能以及部分逻辑一致性方面,仍有一些需要改进的地方。

以下是详细的审查意见:

1. 代码安全

1.1 Shell 命令注入风险 (严重)

actionexecutor.cpp 中,通过 QProcess::startDetached 执行命令时,直接将配置文件中的 triggerValue 作为参数传递。如果 triggerValue 被恶意篡改(例如包含空格、引号或特殊字符),可能导致命令注入或非预期执行。

// actionexecutor.cpp:31
void ActionExecutor::runCommand(const QStringList &cmd)
{
    if (cmd.isEmpty()) return;
    
    QString program = cmd.first();
    QStringList args = cmd.mid(1);
    
    QStringList argsList;
    argsList << "-c" << program; // 将 program 作为 shell -c 的参数
    if (!args.isEmpty()) {
        argsList << "--" << args;
    }
    
    qDebug() << "Running command via dde-am:" << argsList;
    QProcess::startDetached("/usr/bin/dde-am", argsList);
}

改进建议:
应避免通过 dde-am -c 间接执行,而是直接执行目标程序并传递参数,利用 QProcess 的参数分离机制来防止注入。

void ActionExecutor::runCommand(const QStringList &cmd)
{
    if (cmd.isEmpty()) return;
    
    QString program = cmd.first();
    QStringList args = cmd.mid(1);
    
    // 直接执行目标程序,而不是通过 dde-am -c
    // QProcess 会正确处理参数分离,防止注入
    if (!QProcess::startDetached(program, args)) {
        qWarning() << "Failed to start command:" << program << args;
    }
}

(注:如果必须使用 dde-am 启动以利用其沙箱或环境隔离功能,请确保 dde-am 内部对参数做了严格的校验和转义,但从当前代码看,dde-am -c 的用法更像是一个包装器,存在风险。)

1.2 权限提升风险 (中等)

dde-services.postinst 脚本中,使用 runuser -u "$user_name" 在用户会话中执行 dbus-send。虽然脚本逻辑看起来合理,但遍历 /run/user/*/bus 并自动以对应用户身份执行命令的模式,在多用户系统中可能存在潜在风险(例如,如果 /run/user/ 目录权限配置不当)。

改进建议:
确保系统对 /run/user/ 目录的权限遵循标准规范(仅对对应用户可读可执行)。当前实现已经检查了 [ -S "$user_session" ],这是好的。建议在日志中明确记录执行动作,以便审计。

2. 代码逻辑与健壮性

2.1 DConfig permissionsmodifiable 不一致 (严重)

根据开发者指南 DEVELOPER_GUIDE.md 中的“问题 5”描述,如果 modifiabletrue,但 hotkeysenabledpermissionsreadonly,会导致用户修改无法持久化。然而,在新增的 JSON 配置文件中,存在多处这种不一致的情况。

示例: shortcut/app.launcher/org.deepin.shortcut.json

"hotkeys": {
    "value": ["Meta"],
    "permissions": "readwrite", // ✅ 正确
},
"modifiable": {
    "value": true,
    "permissions": "", // ❌ 错误,空字符串可能导致 DConfig 视其为 readonly
}

改进建议:
统一检查所有 JSON 配置文件,确保:

  1. modifiable.valuetrue 时,hotkeysenabledpermissions 必须显式设置为 "readwrite"
  2. modifiable 自身的 permissions 也建议设置为 "readwrite"(如果允许应用重置快捷键)或 "readonly"(如果不允许),避免使用空字符串。

2.2 X11 修饰键轮询的性能与可靠性 (中等)

modifierkeymonitor.cpp 中,使用 10ms 间隔的 QTimer 轮询 X11 键盘状态(XQueryKeymap)。

m_timer->setInterval(10);  // 10ms polling interval

问题:

  1. 性能开销:10ms 的轮询频率对于 GUI/后台服务来说过于频繁,会导致不必要的 CPU 唤醒和系统调用开销。
  2. 可靠性XQueryKeymap 是异步查询,可能会漏掉快速的按键事件。

改进建议:

  1. 降低频率:将轮询间隔调整为 50ms 或 100ms,对于修饰键释放检测,这个延迟是用户无法感知的。
  2. 使用 XCB 事件替代轮询:更优的方案是监听 X11 的 XCB_KEY_PRESSXCB_KEY_RELEASE 事件,通过事件驱动来检测修饰键状态,而不是轮询。X11KeyHandler 已经在监听 XCB 事件,可以将修饰键状态跟踪逻辑整合进去。

2.3 ConfigLoader::discoverSubPaths 分隔符不一致 (中等)

configloader.cpp 中,解析 INI 文件时使用逗号作为分隔符,但根据 DEVELOPER_GUIDE.md 中的描述,INI 文件的 SubPaths 字段使用分号(;)分隔。

// configloader.cpp:108
QStringList subPaths = subPathsStr.split(",", Qt::SkipEmptyParts);

org.deepin.dde.keybinding.ini 中使用的是逗号:

SubPaths=org.deepin.dde.keybinding.shortcut.audiofastforward,org.deepin.dde.keybinding.shortcut.audiomedia,...

改进建议:
明确规范分隔符,建议统一使用分号(符合 INI 文件常见规范),并修改代码:

QStringList subPaths = subPathsStr.split(";", Qt::SkipEmptyParts);

同时更新所有 INI 配置文件。

2.4 WaylandKeyHandler 中 Action 解析的假设 (低)

waylandkeyhandler.cpp 中,解析 triggerValue 为 Action ID 时,假设 triggerValue.first() 可以被 toInt() 解析。

if (config.triggerType == (int)TriggerType::Action && !config.triggerValue.isEmpty()) {
     bool ok;
     int val = config.triggerValue.first().toInt(&ok);
     if (ok) action = val;
}

改进建议:
如果 triggerValue 不是数字(例如是未来的字符串 Action ID),toInt 会失败但不会报错,而是静默回退到 action_notify。建议增加日志警告:

if (ok) {
    action = val;
} else {
    qWarning() << "WaylandKeyHandler: Failed to parse action ID from triggerValue:" << config.triggerValue.first();
}

3. 代码性能

3.1 QKeySequenceConverter 中的静态 Map 初始化 (低)

qkeysequenceconverter.cpp 中使用了函数内静态 QMap 来存储键名映射。每次调用 getQtToXkbMap() 时都会检查是否初始化。

改进建议:
在 Qt 6 中,QMap 的初始化开销较小,但如果是高频调用场景,可以考虑使用 QHash 替代 QMap(查找复杂度从 O(log n) 降为 O(1)),或者使用编译期常量数据结构(如 std::unordered_map 或数组)。

3.2 KeybindingManager::ListAllShortcuts 的过滤逻辑 (低)

QList<ShortcutInfo> KeybindingManager::ListAllShortcuts()
{
    QList<ShortcutInfo> list;
    for (const auto &config : m_keyConfigsMap) {
        // Only expose modifiable shortcuts
        if (!config.modifiable) {
            continue;
        }
        list.append(toShortcutInfo(config));
    }
    return list;
}

改进建议:
这里过滤掉了 modifiable == false 的快捷键。如果控制中心或其他客户端需要显示所有快捷键(包括只读的),此逻辑会导致数据丢失。建议根据调用者的需求(例如通过参数)决定是否过滤,或者默认返回所有快捷键,由客户端自行过滤。

4. 代码风格与维护性

4.1 魔法数字

代码中存在一些魔法数字,例如 triggerType 的 1, 2, 3 和 keyEventFlags 的 0x1, 0x2, 0x4。

改进建议:
虽然 shortcutconfig.h 中定义了枚举 TriggerTypeKeyEventFlag,但在 JSON 解析和部分逻辑中仍直接使用数字。建议在代码中统一使用枚举值,提高可读性。

// 改进前
if (config.triggerType == 3) { ... }

// 改进后
if (config.triggerType == static_cast<int>(TriggerType::Action)) { ... }

4.2 内存管理

PluginShortcutManager::init 中,如果 registerObjectregisterService 失败,直接返回 false,但没有清理已经创建的 ShortcutManager 及其子对象。

改进建议:
由于 m_shortcutManager 的父对象是 this,在 PluginShortcutManager 析构时会自动删除,所以不会内存泄漏。但为了逻辑严谨,建议在失败时显式清理或回滚已注册的 DBus 对象。

总结

本次提交的代码量较大,整体架构设计合理,特别是对 Wayland 协议的封装和 DConfig 的集成做得很好。**最需要优先修复的是 JSON 配置文件中 permissions 字段的不一致问题,这会导致用户修改快捷键无法持久化的严重 Bug。**其次,Shell 命令执行的安全性和 X11 轮询的性能问题也值得关注。INI 文件分隔符的不一致需要统一规范。

修复上述问题后,代码质量将得到显著提升。

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.

4 participants