mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-13 00:45:58 +01:00
input-device: remove wlr_input_device.link
This field's ownership is unclear: it's in wlr_input_device, but it's not managed by the common code, it's up to each individual backend to use it and clean it up. Since this is a backend implementation detail, move it to the backend-specific structs.
This commit is contained in:
parent
c9ba9e82b6
commit
1d9c1bcea6
11 changed files with 44 additions and 44 deletions
|
@ -33,8 +33,7 @@ static bool backend_start(struct wlr_backend *wlr_backend) {
|
|||
}
|
||||
|
||||
struct wlr_headless_input_device *input_device;
|
||||
wl_list_for_each(input_device, &backend->input_devices,
|
||||
wlr_input_device.link) {
|
||||
wl_list_for_each(input_device, &backend->input_devices, link) {
|
||||
wlr_signal_emit_safe(&backend->backend.events.new_input,
|
||||
&input_device->wlr_input_device);
|
||||
}
|
||||
|
@ -59,7 +58,7 @@ static void backend_destroy(struct wlr_backend *wlr_backend) {
|
|||
|
||||
struct wlr_headless_input_device *input_device, *input_device_tmp;
|
||||
wl_list_for_each_safe(input_device, input_device_tmp,
|
||||
&backend->input_devices, wlr_input_device.link) {
|
||||
&backend->input_devices, link) {
|
||||
wlr_input_device_destroy(&input_device->wlr_input_device);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,8 +12,10 @@
|
|||
#include "util/signal.h"
|
||||
|
||||
static void input_device_destroy(struct wlr_input_device *wlr_dev) {
|
||||
wl_list_remove(&wlr_dev->link);
|
||||
free(wlr_dev);
|
||||
struct wlr_headless_input_device *dev =
|
||||
wl_container_of(wlr_dev, dev, wlr_input_device);
|
||||
wl_list_remove(&dev->link);
|
||||
free(dev);
|
||||
}
|
||||
|
||||
static const struct wlr_input_device_impl input_device_impl = {
|
||||
|
@ -93,7 +95,7 @@ struct wlr_input_device *wlr_headless_add_input_device(
|
|||
wlr_switch_init(wlr_device->switch_device, NULL);
|
||||
}
|
||||
|
||||
wl_list_insert(&backend->input_devices, &wlr_device->link);
|
||||
wl_list_insert(&backend->input_devices, &device->link);
|
||||
|
||||
if (backend->started) {
|
||||
wlr_signal_emit_safe(&backend->backend.events.new_input, wlr_device);
|
||||
|
|
|
@ -143,9 +143,9 @@ static void backend_destroy(struct wlr_backend *wlr_backend) {
|
|||
|
||||
struct wl_list **wlr_devices_ptr;
|
||||
wl_array_for_each(wlr_devices_ptr, &backend->wlr_device_lists) {
|
||||
struct wlr_input_device *wlr_dev, *next;
|
||||
wl_list_for_each_safe(wlr_dev, next, *wlr_devices_ptr, link) {
|
||||
wlr_input_device_destroy(wlr_dev);
|
||||
struct wlr_libinput_input_device *dev, *tmp;
|
||||
wl_list_for_each_safe(dev, tmp, *wlr_devices_ptr, link) {
|
||||
wlr_input_device_destroy(&dev->wlr_input_device);
|
||||
}
|
||||
free(*wlr_devices_ptr);
|
||||
}
|
||||
|
|
|
@ -23,10 +23,10 @@ struct wlr_input_device *get_appropriate_device(
|
|||
if (!wlr_devices) {
|
||||
return NULL;
|
||||
}
|
||||
struct wlr_input_device *dev;
|
||||
struct wlr_libinput_input_device *dev;
|
||||
wl_list_for_each(dev, wlr_devices, link) {
|
||||
if (dev->type == desired_type) {
|
||||
return dev;
|
||||
if (dev->wlr_input_device.type == desired_type) {
|
||||
return &dev->wlr_input_device;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
@ -36,7 +36,7 @@ static void input_device_destroy(struct wlr_input_device *wlr_dev) {
|
|||
struct wlr_libinput_input_device *dev =
|
||||
get_libinput_device_from_device(wlr_dev);
|
||||
libinput_device_unref(dev->handle);
|
||||
wl_list_remove(&dev->wlr_input_device.link);
|
||||
wl_list_remove(&dev->link);
|
||||
free(dev);
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ static struct wlr_input_device *allocate_device(
|
|||
if (output_name != NULL) {
|
||||
wlr_dev->output_name = strdup(output_name);
|
||||
}
|
||||
wl_list_insert(wlr_devices, &wlr_dev->link);
|
||||
wl_list_insert(wlr_devices, &dev->link);
|
||||
dev->handle = libinput_dev;
|
||||
libinput_device_ref(libinput_dev);
|
||||
wlr_input_device_init(wlr_dev, type, &input_device_impl,
|
||||
|
@ -198,7 +198,7 @@ static void handle_device_added(struct wlr_libinput_backend *backend,
|
|||
|
||||
fail:
|
||||
wlr_log(WLR_ERROR, "Could not allocate new device");
|
||||
struct wlr_input_device *dev, *tmp_dev;
|
||||
struct wlr_libinput_input_device *dev, *tmp_dev;
|
||||
wl_list_for_each_safe(dev, tmp_dev, wlr_devices, link) {
|
||||
free(dev);
|
||||
}
|
||||
|
@ -215,9 +215,9 @@ static void handle_device_removed(struct wlr_libinput_backend *backend,
|
|||
if (!wlr_devices) {
|
||||
return;
|
||||
}
|
||||
struct wlr_input_device *dev, *tmp_dev;
|
||||
struct wlr_libinput_input_device *dev, *tmp_dev;
|
||||
wl_list_for_each_safe(dev, tmp_dev, wlr_devices, link) {
|
||||
wlr_input_device_destroy(dev);
|
||||
wlr_input_device_destroy(&dev->wlr_input_device);
|
||||
}
|
||||
size_t i = 0;
|
||||
struct wl_list **ptr;
|
||||
|
|
|
@ -314,9 +314,9 @@ static void backend_destroy(struct wlr_backend *backend) {
|
|||
wlr_output_destroy(&output->wlr_output);
|
||||
}
|
||||
|
||||
struct wlr_input_device *input_device, *tmp_input_device;
|
||||
struct wlr_wl_input_device *input_device, *tmp_input_device;
|
||||
wl_list_for_each_safe(input_device, tmp_input_device, &wl->devices, link) {
|
||||
wlr_input_device_destroy(input_device);
|
||||
wlr_input_device_destroy(&input_device->wlr_input_device);
|
||||
}
|
||||
|
||||
struct wlr_wl_buffer *buffer, *tmp_buffer;
|
||||
|
|
|
@ -25,12 +25,13 @@
|
|||
static struct wlr_wl_pointer *output_get_pointer(
|
||||
struct wlr_wl_output *output,
|
||||
const struct wl_pointer *wl_pointer) {
|
||||
struct wlr_input_device *wlr_dev;
|
||||
wl_list_for_each(wlr_dev, &output->backend->devices, link) {
|
||||
if (wlr_dev->type != WLR_INPUT_DEVICE_POINTER) {
|
||||
struct wlr_wl_input_device *dev;
|
||||
wl_list_for_each(dev, &output->backend->devices, link) {
|
||||
if (dev->wlr_input_device.type != WLR_INPUT_DEVICE_POINTER) {
|
||||
continue;
|
||||
}
|
||||
struct wlr_wl_pointer *pointer = pointer_get_wl(wlr_dev->pointer);
|
||||
struct wlr_wl_pointer *pointer =
|
||||
pointer_get_wl(dev->wlr_input_device.pointer);
|
||||
if (pointer->output == output && pointer->wl_pointer == wl_pointer) {
|
||||
return pointer;
|
||||
}
|
||||
|
@ -440,7 +441,7 @@ static void input_device_destroy(struct wlr_input_device *wlr_dev) {
|
|||
}
|
||||
// We can't destroy pointer here because we might have multiple devices
|
||||
// exposing it to compositor.
|
||||
wl_list_remove(&dev->wlr_input_device.link);
|
||||
wl_list_remove(&dev->link);
|
||||
free(dev);
|
||||
}
|
||||
|
||||
|
@ -473,7 +474,7 @@ struct wlr_wl_input_device *create_wl_input_device(
|
|||
|
||||
wlr_input_device_init(wlr_dev, type, &input_device_impl, name, vendor,
|
||||
product);
|
||||
wl_list_insert(&seat->backend->devices, &wlr_dev->link);
|
||||
wl_list_insert(&seat->backend->devices, &dev->link);
|
||||
return dev;
|
||||
}
|
||||
|
||||
|
@ -822,19 +823,20 @@ static void seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
|
|||
|
||||
struct wl_pointer *wl_pointer = seat->pointer;
|
||||
|
||||
struct wlr_input_device *device, *tmp;
|
||||
struct wlr_wl_input_device *device, *tmp;
|
||||
wl_list_for_each_safe(device, tmp, &backend->devices, link) {
|
||||
if (device->type != WLR_INPUT_DEVICE_POINTER) {
|
||||
if (device->wlr_input_device.type != WLR_INPUT_DEVICE_POINTER) {
|
||||
continue;
|
||||
}
|
||||
struct wlr_wl_pointer *pointer = pointer_get_wl(device->pointer);
|
||||
struct wlr_wl_pointer *pointer =
|
||||
pointer_get_wl(device->wlr_input_device.pointer);
|
||||
if (pointer->wl_pointer != wl_pointer) {
|
||||
continue;
|
||||
}
|
||||
wlr_log(WLR_DEBUG, "dropping pointer %s",
|
||||
pointer->input_device->wlr_input_device.name);
|
||||
struct wlr_wl_output *output = pointer->output;
|
||||
wlr_input_device_destroy(device);
|
||||
wlr_input_device_destroy(&device->wlr_input_device);
|
||||
assert(seat->active_pointer != pointer);
|
||||
assert(output->cursor.pointer != pointer);
|
||||
}
|
||||
|
@ -856,18 +858,16 @@ static void seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
|
|||
if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && seat->keyboard != NULL) {
|
||||
wlr_log(WLR_DEBUG, "seat %p dropped keyboard", (void *)wl_seat);
|
||||
|
||||
struct wlr_input_device *device, *tmp;
|
||||
struct wlr_wl_input_device *device, *tmp;
|
||||
wl_list_for_each_safe(device, tmp, &backend->devices, link) {
|
||||
if (device->type != WLR_INPUT_DEVICE_KEYBOARD) {
|
||||
if (device->wlr_input_device.type != WLR_INPUT_DEVICE_KEYBOARD) {
|
||||
continue;
|
||||
}
|
||||
|
||||
struct wlr_wl_input_device *input_device =
|
||||
get_wl_input_device_from_input_device(device);
|
||||
if (input_device->seat != seat) {
|
||||
if (device->seat != seat) {
|
||||
continue;
|
||||
}
|
||||
wlr_input_device_destroy(device);
|
||||
wlr_input_device_destroy(&device->wlr_input_device);
|
||||
}
|
||||
assert(seat->keyboard == NULL); // free'ed by input_device_destroy
|
||||
}
|
||||
|
@ -883,10 +883,10 @@ static void seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
|
|||
if (!(caps & WL_SEAT_CAPABILITY_TOUCH) && seat->touch != NULL) {
|
||||
wlr_log(WLR_DEBUG, "seat %p dropped touch", (void *)wl_seat);
|
||||
|
||||
struct wlr_input_device *device, *tmp;
|
||||
struct wlr_wl_input_device *device, *tmp;
|
||||
wl_list_for_each_safe(device, tmp, &backend->devices, link) {
|
||||
if (device->type == WLR_INPUT_DEVICE_TOUCH) {
|
||||
wlr_input_device_destroy(device);
|
||||
if (device->wlr_input_device.type == WLR_INPUT_DEVICE_TOUCH) {
|
||||
wlr_input_device_destroy(&device->wlr_input_device);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -402,7 +402,7 @@ static void handle_tablet_pad_removed(void *data,
|
|||
/* This doesn't free anything, but emits the destroy signal */
|
||||
wlr_input_device_destroy(&dev->wlr_input_device);
|
||||
/* This is a bit ugly, but we need to remove it from our list */
|
||||
wl_list_remove(&dev->wlr_input_device.link);
|
||||
wl_list_remove(&dev->link);
|
||||
|
||||
struct wlr_wl_tablet_pad_group *group, *it;
|
||||
wl_list_for_each_safe(group, it, &tablet_pad->groups, group.link) {
|
||||
|
@ -873,7 +873,7 @@ static void handle_tablet_removed(void *data,
|
|||
/* This doesn't free anything, but emits the destroy signal */
|
||||
wlr_input_device_destroy(&dev->wlr_input_device);
|
||||
/* This is a bit ugly, but we need to remove it from our list */
|
||||
wl_list_remove(&dev->wlr_input_device.link);
|
||||
wl_list_remove(&dev->link);
|
||||
|
||||
zwp_tablet_v2_destroy(dev->resource);
|
||||
free(dev);
|
||||
|
|
|
@ -29,7 +29,7 @@ struct wlr_headless_output {
|
|||
|
||||
struct wlr_headless_input_device {
|
||||
struct wlr_input_device wlr_input_device;
|
||||
|
||||
struct wl_list link;
|
||||
struct wlr_headless_backend *backend;
|
||||
};
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ struct wlr_libinput_backend {
|
|||
|
||||
struct wlr_libinput_input_device {
|
||||
struct wlr_input_device wlr_input_device;
|
||||
|
||||
struct wl_list link;
|
||||
struct libinput_device *handle;
|
||||
};
|
||||
|
||||
|
|
|
@ -87,6 +87,7 @@ struct wlr_wl_output {
|
|||
|
||||
struct wlr_wl_input_device {
|
||||
struct wlr_input_device wlr_input_device;
|
||||
struct wl_list link;
|
||||
uint32_t fingers;
|
||||
|
||||
struct wlr_wl_backend *backend;
|
||||
|
|
|
@ -53,8 +53,6 @@ struct wlr_input_device {
|
|||
} events;
|
||||
|
||||
void *data;
|
||||
|
||||
struct wl_list link;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue