diff options
author | Simon Zeni <simon@bl4ckb0ne.ca> | 2022-02-28 15:11:31 -0500 |
---|---|---|
committer | Kirill Primak <vyivel@eclair.cafe> | 2022-02-28 22:02:57 +0000 |
commit | cdb3e80b3934d740d4702a062bc5e10a67d21f57 (patch) | |
tree | 7f3bf2e6a842c1740163ad9f70335f5ea08650bf | |
parent | 17a289e36e920ebf18af6e9215388ee6c20029c7 (diff) |
types/wlr_virtual_keyboard_v1: fix wlr_keyboard destroy sequence
-rw-r--r-- | types/wlr_virtual_keyboard_v1.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/types/wlr_virtual_keyboard_v1.c b/types/wlr_virtual_keyboard_v1.c index 07eeb367..e40a97e8 100644 --- a/types/wlr_virtual_keyboard_v1.c +++ b/types/wlr_virtual_keyboard_v1.c @@ -34,14 +34,7 @@ static void keyboard_release_pressed_keys(struct wlr_keyboard *keyboard) { } static void keyboard_destroy(struct wlr_keyboard *wlr_kb) { - struct wlr_virtual_keyboard_v1 *keyboard = - (struct wlr_virtual_keyboard_v1 *)wlr_kb; - - keyboard_release_pressed_keys(&keyboard->keyboard); - wl_resource_set_user_data(keyboard->resource, NULL); - wlr_signal_emit_safe(&keyboard->events.destroy, keyboard); - wl_list_remove(&keyboard->link); - free(keyboard); + /* no-op, keyboard belongs to the wlr_virtual_keyboard_v1 */ } static const struct wlr_keyboard_impl keyboard_impl = { @@ -138,9 +131,17 @@ static void virtual_keyboard_modifiers(struct wl_client *client, static void virtual_keyboard_destroy_resource(struct wl_resource *resource) { struct wlr_virtual_keyboard_v1 *keyboard = virtual_keyboard_from_resource(resource); - if (keyboard != NULL) { - wlr_keyboard_destroy(&keyboard->keyboard); + if (keyboard == NULL) { + return; } + + /* TODO: rework wlr_keyboard device destruction */ + keyboard_release_pressed_keys(&keyboard->keyboard); + wlr_signal_emit_safe(&keyboard->events.destroy, keyboard); + wlr_keyboard_destroy(&keyboard->keyboard); + wl_resource_set_user_data(keyboard->resource, NULL); + wl_list_remove(&keyboard->link); + free(keyboard); } static void virtual_keyboard_destroy(struct wl_client *client, |