feat(input): support configurable XKB keyboard settings - #1406
Conversation
Reviewer's GuideThis PR introduces runtime-configurable XKB layout, model, variant, and options through user-seat DConfig. InputManager initializes and observes the settings, propagates owned rule-name copies to all seats, and each WSeat compiles and assigns the resulting keymap to its group and physical keyboards while preserving NumLock application. Sequence diagram for runtime XKB configuration applicationsequenceDiagram
participant DConfig as SeatUserDConfig
participant InputManager
participant SeatManager
participant WSeat
participant XKB as xkbcommon
participant Keyboard as GroupAndPhysicalKeyboards
DConfig->>InputManager: onConfigInitializeSucceed()
InputManager->>InputManager: applyXkbConfig()
InputManager->>DConfig: xkbLayout()
InputManager->>DConfig: xkbModel()
InputManager->>DConfig: xkbVariant()
InputManager->>DConfig: xkbOptions()
InputManager->>SeatManager: seats()
loop each seat
InputManager->>WSeat: setXkbRuleNames(rules)
InputManager->>WSeat: applyXkbConfig()
WSeat->>XKB: xkb_keymap_new_from_names(xkbRules)
XKB-->>WSeat: compiled keymap
WSeat->>Keyboard: wlr_keyboard_set_keymap(keymap)
end
InputManager->>InputManager: applyNumLockToKeyboards()
DConfig-->>InputManager: xkbLayoutChanged / xkbModelChanged / xkbVariantChanged / xkbOptionsChanged
InputManager->>InputManager: applyXkbConfig()
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="waylib/src/server/kernel/wseat.cpp" line_range="1235-1249" />
<code_context>
+ return;
+ }
+
+ if (d->groupkeyboardDevice && d->groupkeyboardDevice->handle()->type == WLR_INPUT_DEVICE_KEYBOARD) {
+ auto *keyboard = wlr_keyboard_from_input_device(d->groupkeyboardDevice->handle());
+ wlr_keyboard_set_keymap(keyboard, keymap);
+ }
+
+ for (auto *device : std::as_const(d->deviceList)) {
+ if (device->type() != WInputDevice::Type::Keyboard)
</code_context>
<issue_to_address>
**issue (bug_risk):** The return value from `wlr_keyboard_set_keymap` is ignored, so a keymap update that fails while allocating shared memory or creating the keyboard state leaves that keyboard using its previous keymap while the configuration update is reported as complete.
**Triggers:** When wlroots cannot allocate the keymap shared-memory resources or create the XKB state for one keyboard.
**Suggested fix:** Check the return value and log or otherwise handle per-keyboard application failures instead of silently continuing.
</issue_to_address>Add xkbLayout, xkbModel, xkbVariant, and xkbOptions to the user seat DConfig and apply them to all seats via InputManager::applyXkbConfig. WSeat now stores an owned copy of xkb_rule_names and re-applies the compiled keymap to the group keyboard and all physical keyboards. Log: support configurable XKB keyboard layout/model/variant/options PMS: BUG-377251 Influence: keyboard layout and XKB options are now configurable via DConfig and applied to keyboards at runtime
|
// 切回到正常的布局 // 切换布局,键盘z输出y码,y输出z码 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: zccrs, zzxyb 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 |
Add xkbLayout, xkbModel, xkbVariant, and xkbOptions to the user seat DConfig and apply them to all seats via InputManager::applyXkbConfig. WSeat now stores an owned copy of xkb_rule_names and re-applies the compiled keymap to the group keyboard and all physical keyboards.
Log: support configurable XKB keyboard layout/model/variant/options PMS: BUG-377251
Influence: keyboard layout and XKB options are now configurable via DConfig and applied to keyboards at runtime
Summary by Sourcery
Support runtime configuration of XKB keyboard settings through the user seat configuration.
New Features:
Enhancements: