mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-12-25 08:56:37 -05:00
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.
This commit is contained in:
parent
130c3bcf63
commit
a1978b1299
12 changed files with 66 additions and 85 deletions
|
|
@ -49,7 +49,10 @@ struct wlr_keyboard *create_libinput_keyboard(
|
|||
libinput_device_ref(libinput_dev);
|
||||
libinput_device_led_update(libinput_dev, 0);
|
||||
struct wlr_keyboard *wlr_kb = &kb->wlr_keyboard;
|
||||
wlr_keyboard_init(wlr_kb, &impl);
|
||||
const char *name = libinput_device_get_name(libinput_dev);
|
||||
wlr_keyboard_init(wlr_kb, &impl, name);
|
||||
wlr_kb->base.vendor = libinput_device_get_id_vendor(libinput_dev);
|
||||
wlr_kb->base.product = libinput_device_get_id_product(libinput_dev);
|
||||
return wlr_kb;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -785,14 +785,14 @@ void create_wl_keyboard(struct wlr_wl_seat *seat) {
|
|||
}
|
||||
|
||||
struct wlr_input_device *wlr_dev = &dev->wlr_input_device;
|
||||
|
||||
wlr_dev->keyboard = calloc(1, sizeof(*wlr_dev->keyboard));
|
||||
if (!wlr_dev->keyboard) {
|
||||
wlr_log_errno(WLR_ERROR, "Allocation failed");
|
||||
wlr_input_device_destroy(wlr_dev);
|
||||
return;
|
||||
}
|
||||
wlr_keyboard_init(wlr_dev->keyboard, NULL);
|
||||
|
||||
wlr_keyboard_init(wlr_dev->keyboard, NULL, wlr_dev->name);
|
||||
|
||||
wl_keyboard_add_listener(wl_keyboard, &keyboard_listener, wlr_dev);
|
||||
wlr_signal_emit_safe(&seat->backend->backend.events.new_input, wlr_dev);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue