mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2025-11-25 06:59:50 -05:00
opt: support hot-reload xkb_rules
This commit is contained in:
parent
f5669bb9c6
commit
844b6e049f
2 changed files with 22 additions and 0 deletions
|
|
@ -2831,6 +2831,11 @@ void parse_config(void) {
|
|||
|
||||
// 重置config结构体,确保所有指针初始化为NULL
|
||||
memset(&config, 0, sizeof(config));
|
||||
memset(&xkb_rules_rules, 0, sizeof(xkb_rules_rules));
|
||||
memset(&xkb_rules_model, 0, sizeof(xkb_rules_model));
|
||||
memset(&xkb_rules_layout, 0, sizeof(xkb_rules_layout));
|
||||
memset(&xkb_rules_variant, 0, sizeof(xkb_rules_variant));
|
||||
memset(&xkb_rules_options, 0, sizeof(xkb_rules_options));
|
||||
|
||||
// 初始化动态数组的指针为NULL,避免野指针
|
||||
config.window_rules = NULL;
|
||||
|
|
|
|||
17
src/mango.c
17
src/mango.c
|
|
@ -4542,6 +4542,23 @@ void reset_keyboard_layout(void) {
|
|||
wlr_seat_set_keyboard(seat, keyboard);
|
||||
wlr_seat_keyboard_notify_modifiers(seat, &keyboard->modifiers);
|
||||
|
||||
InputDevice *id;
|
||||
wl_list_for_each(id, &inputdevices, link) {
|
||||
if (id->wlr_device->type != WLR_INPUT_DEVICE_KEYBOARD) {
|
||||
continue;
|
||||
}
|
||||
|
||||
struct wlr_keyboard *tkb = (struct wlr_keyboard *)id->device_data;
|
||||
|
||||
wlr_keyboard_set_keymap(tkb, keyboard->keymap);
|
||||
wlr_keyboard_notify_modifiers(tkb, depressed, latched, locked, 0);
|
||||
tkb->modifiers.group = 0;
|
||||
|
||||
// 7. 更新 seat
|
||||
wlr_seat_set_keyboard(seat, tkb);
|
||||
wlr_seat_keyboard_notify_modifiers(seat, &tkb->modifiers);
|
||||
}
|
||||
|
||||
// Cleanup
|
||||
xkb_keymap_unref(new_keymap);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue