keyboard: Pass struct xkb_rule_names to keyboard_init

pull/95/head
Andri Yngvason 2020-12-26 21:07:42 +00:00
parent 482ebaf168
commit d0aa51aa6e
3 changed files with 10 additions and 10 deletions

View File

@ -39,7 +39,7 @@ struct keyboard {
struct intset key_state; 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_destroy(struct keyboard* self);
void keyboard_feed(struct keyboard* self, xkb_keysym_t symbol, bool is_pressed); void keyboard_feed(struct keyboard* self, xkb_keysym_t symbol, bool is_pressed);
void keyboard_feed_code(struct keyboard* self, xkb_keycode_t code, void keyboard_feed_code(struct keyboard* self, xkb_keycode_t code,

View File

@ -153,7 +153,7 @@ void keyboard_dump_lookup_table(const struct keyboard* self)
keyboard__dump_entry(self, &self->lookup_table[i]); 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); self->context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
if (!self->context) 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) if (intset_init(&self->key_state, 0) < 0)
goto key_state_failure; goto key_state_failure;
struct xkb_rule_names rule_names = { self->keymap = xkb_keymap_new_from_names(self->context, rule_names, 0);
.layout = layout,
.model = "pc105",
.variant = variant,
};
self->keymap = xkb_keymap_new_from_names(self->context, &rule_names, 0);
if (!self->keymap) if (!self->keymap)
goto keymap_failure; goto keymap_failure;

View File

@ -945,7 +945,13 @@ int main(int argc, char* argv[])
zwp_virtual_keyboard_manager_v1_create_virtual_keyboard( zwp_virtual_keyboard_manager_v1_create_virtual_keyboard(
self.keyboard_manager, self.selected_seat->wl_seat); 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.vnc = self.nvnc;
self.pointer_backend.output = self.selected_output; self.pointer_backend.output = self.selected_output;