opt: support hot-reload xkb_rules
This commit is contained in:
@@ -2935,6 +2935,11 @@ void parse_config(void) {
|
|||||||
|
|
||||||
// 重置config结构体,确保所有指针初始化为NULL
|
// 重置config结构体,确保所有指针初始化为NULL
|
||||||
memset(&config, 0, sizeof(config));
|
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,避免野指针
|
// 初始化动态数组的指针为NULL,避免野指针
|
||||||
config.window_rules = NULL;
|
config.window_rules = NULL;
|
||||||
|
|||||||
17
src/mango.c
17
src/mango.c
@@ -4604,6 +4604,23 @@ void reset_keyboard_layout(void) {
|
|||||||
wlr_seat_set_keyboard(seat, keyboard);
|
wlr_seat_set_keyboard(seat, keyboard);
|
||||||
wlr_seat_keyboard_notify_modifiers(seat, &keyboard->modifiers);
|
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
|
// Cleanup
|
||||||
xkb_keymap_unref(new_keymap);
|
xkb_keymap_unref(new_keymap);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user