diff options
author | Tony Crisci <tony@dubstepdish.com> | 2017-10-21 09:43:24 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-21 09:43:24 -0400 |
commit | 3c7ef3aae68e1a38c0ab83c22c0e064b7bde319e (patch) | |
tree | ca85d4ac1f277ca0f997bcffb7adfe36e5157205 /rootston/keyboard.c | |
parent | a87b60e31e5288c1c3e8c8f94c9a7ccb29e38b54 (diff) | |
parent | ce2f945441155fa9d98935dabd6979304f2d2fbc (diff) |
Merge branch 'master' into feature/data-device-selection
Diffstat (limited to 'rootston/keyboard.c')
-rw-r--r-- | rootston/keyboard.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/rootston/keyboard.c b/rootston/keyboard.c index aee6b098..61604da0 100644 --- a/rootston/keyboard.c +++ b/rootston/keyboard.c @@ -127,10 +127,12 @@ static void keyboard_key_notify(struct wl_listener *listener, void *data) { void keyboard_add(struct wlr_input_device *device, struct roots_input *input) { struct roots_keyboard *keyboard = calloc(sizeof(struct roots_keyboard), 1); + if (keyboard == NULL) { + return; + } device->data = keyboard; keyboard->device = device; keyboard->input = input; - wl_list_init(&keyboard->key.link); keyboard->key.notify = keyboard_key_notify; wl_signal_add(&device->keyboard->events.key, &keyboard->key); wl_list_insert(&input->keyboards, &keyboard->link); @@ -142,11 +144,15 @@ void keyboard_add(struct wlr_input_device *device, struct roots_input *input) { rules.layout = getenv("XKB_DEFAULT_LAYOUT"); rules.variant = getenv("XKB_DEFAULT_VARIANT"); rules.options = getenv("XKB_DEFAULT_OPTIONS"); - struct xkb_context *context; - assert(context = xkb_context_new(XKB_CONTEXT_NO_FLAGS)); + struct xkb_context *context = xkb_context_new(XKB_CONTEXT_NO_FLAGS); + if (context == NULL) { + wlr_log(L_ERROR, "Cannot create XKB context"); + return; + } wlr_keyboard_set_keymap(device->keyboard, xkb_map_new_from_names(context, - &rules, XKB_KEYMAP_COMPILE_NO_FLAGS)); + &rules, XKB_KEYMAP_COMPILE_NO_FLAGS)); xkb_context_unref(context); + wlr_seat_attach_keyboard(input->wl_seat, device); } |