From a1978b1299952586a2fd016aab682c7fdbe735ee Mon Sep 17 00:00:00 2001 From: Simon Zeni Date: Fri, 28 Jan 2022 13:55:28 -0500 Subject: types/wlr_keyboard: add base wlr_input_device wlr_keyboard owns its base wlr_input_device. It will be initialized when the keyboard is initialized, and finished when the keyboard is destroyed. --- backend/x11/backend.c | 9 +++------ backend/x11/input_device.c | 7 ++++++- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'backend/x11') diff --git a/backend/x11/backend.c b/backend/x11/backend.c index 70fc0478..3f2a9f01 100644 --- a/backend/x11/backend.c +++ b/backend/x11/backend.c @@ -165,7 +165,7 @@ static bool backend_start(struct wlr_backend *backend) { wlr_log(WLR_INFO, "Starting X11 backend"); - wlr_signal_emit_safe(&x11->backend.events.new_input, &x11->keyboard_dev); + wlr_signal_emit_safe(&x11->backend.events.new_input, &x11->keyboard.base); for (size_t i = 0; i < x11->requested_outputs; ++i) { wlr_x11_output_create(&x11->backend); @@ -186,7 +186,7 @@ static void backend_destroy(struct wlr_backend *backend) { wlr_output_destroy(&output->wlr_output); } - wlr_input_device_destroy(&x11->keyboard_dev); + wlr_keyboard_destroy(&x11->keyboard); wlr_backend_finish(backend); @@ -638,10 +638,7 @@ struct wlr_backend *wlr_x11_backend_create(struct wl_display *display, } #endif - wlr_input_device_init(&x11->keyboard_dev, WLR_INPUT_DEVICE_KEYBOARD, - &input_device_impl, "X11 keyboard"); - wlr_keyboard_init(&x11->keyboard, &keyboard_impl); - x11->keyboard_dev.keyboard = &x11->keyboard; + wlr_keyboard_init(&x11->keyboard, &keyboard_impl, "x11-keyboard"); x11->display_destroy.notify = handle_display_destroy; wl_display_add_destroy_listener(display, &x11->display_destroy); diff --git a/backend/x11/input_device.c b/backend/x11/input_device.c index f9541b06..94b70524 100644 --- a/backend/x11/input_device.c +++ b/backend/x11/input_device.c @@ -336,5 +336,10 @@ void update_x11_pointer_position(struct wlr_x11_output *output, } bool wlr_input_device_is_x11(struct wlr_input_device *wlr_dev) { - return wlr_dev->impl == &input_device_impl; + switch (wlr_dev->type) { + case WLR_INPUT_DEVICE_KEYBOARD: + return wlr_dev->keyboard->impl == &keyboard_impl; + default: + return wlr_dev->impl == &input_device_impl; + } } -- cgit v1.2.3