From d0aa51aa6e377e359127bc2fee74920c18ed6a99 Mon Sep 17 00:00:00 2001 From: Andri Yngvason Date: Sat, 26 Dec 2020 21:07:42 +0000 Subject: [PATCH] keyboard: Pass struct xkb_rule_names to keyboard_init --- include/keyboard.h | 2 +- src/keyboard.c | 10 ++-------- src/main.c | 8 +++++++- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/keyboard.h b/include/keyboard.h index 3804f52..558de39 100644 --- a/include/keyboard.h +++ b/include/keyboard.h @@ -39,7 +39,7 @@ struct keyboard { struct intset key_state; }; -int keyboard_init(struct keyboard* self, const char* layout, const char* variant); +int keyboard_init(struct keyboard* self, const struct xkb_rule_names* rule_names); void keyboard_destroy(struct keyboard* self); void keyboard_feed(struct keyboard* self, xkb_keysym_t symbol, bool is_pressed); void keyboard_feed_code(struct keyboard* self, xkb_keycode_t code, diff --git a/src/keyboard.c b/src/keyboard.c index 5877a46..a0980ec 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -153,7 +153,7 @@ void keyboard_dump_lookup_table(const struct keyboard* self) keyboard__dump_entry(self, &self->lookup_table[i]); } -int keyboard_init(struct keyboard* self, const char* layout, const char* variant) +int keyboard_init(struct keyboard* self, const struct xkb_rule_names* rule_names) { self->context = xkb_context_new(XKB_CONTEXT_NO_FLAGS); if (!self->context) @@ -162,13 +162,7 @@ int keyboard_init(struct keyboard* self, const char* layout, const char* variant if (intset_init(&self->key_state, 0) < 0) goto key_state_failure; - struct xkb_rule_names rule_names = { - .layout = layout, - .model = "pc105", - .variant = variant, - }; - - self->keymap = xkb_keymap_new_from_names(self->context, &rule_names, 0); + self->keymap = xkb_keymap_new_from_names(self->context, rule_names, 0); if (!self->keymap) goto keymap_failure; diff --git a/src/main.c b/src/main.c index 05476df..2eb4534 100644 --- a/src/main.c +++ b/src/main.c @@ -945,7 +945,13 @@ int main(int argc, char* argv[]) zwp_virtual_keyboard_manager_v1_create_virtual_keyboard( self.keyboard_manager, self.selected_seat->wl_seat); - keyboard_init(&self.keyboard_backend, self.kb_layout, self.kb_variant); + struct xkb_rule_names rule_names = { + .layout = self.kb_layout, + .model = "pc105", + .variant = self.kb_variant, + }; + + keyboard_init(&self.keyboard_backend, &rule_names); self.pointer_backend.vnc = self.nvnc; self.pointer_backend.output = self.selected_output;