aboutsummaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
authorSimon Zeni <simon@bl4ckb0ne.ca>2022-03-02 13:57:28 -0500
committerKirill Primak <vyivel@eclair.cafe>2022-03-07 16:37:41 +0000
commit51cd3c07264e1c4967c5baea3f6629ac01334e97 (patch)
tree980d44bb7028c34524c5e4c54f94c9f50d4f58d2 /backend
parent7dc4a3ecd71cf41dd1800c6afd3b16c83a90f031 (diff)
interface/wlr_pointer: rework destroy sequence
The destroy callback in wlr_pointer_impl has been removed. The function `wlr_pointer_finish` has been introduced to clean up the resources owned by a wlr_pointer. `wlr_input_device_destroy` no longer destroys the wlr_pointer, attempting to destroy a wlr_pointer will result in a no-op. The field `name` has been added to the wlr_pointer_impl to be able to identify a given wlr_pointer device.
Diffstat (limited to 'backend')
-rw-r--r--backend/libinput/events.c2
-rw-r--r--backend/libinput/pointer.c6
-rw-r--r--backend/wayland/seat.c53
-rw-r--r--backend/x11/input_device.c6
-rw-r--r--backend/x11/output.c2
5 files changed, 31 insertions, 38 deletions
diff --git a/backend/libinput/events.c b/backend/libinput/events.c
index af54177c..22fdab55 100644
--- a/backend/libinput/events.c
+++ b/backend/libinput/events.c
@@ -18,7 +18,7 @@ void destroy_libinput_input_device(struct wlr_libinput_input_device *dev) {
wlr_keyboard_finish(&dev->keyboard);
}
if (dev->pointer.impl) {
- wlr_pointer_destroy(&dev->pointer);
+ wlr_pointer_finish(&dev->pointer);
}
if (dev->switch_device.impl) {
wlr_switch_destroy(&dev->switch_device);
diff --git a/backend/libinput/pointer.c b/backend/libinput/pointer.c
index 0ac781d7..8daf2005 100644
--- a/backend/libinput/pointer.c
+++ b/backend/libinput/pointer.c
@@ -4,12 +4,8 @@
#include "backend/libinput.h"
#include "util/signal.h"
-static void pointer_destroy(struct wlr_pointer *pointer) {
- /* wlr_pointer belongs to the wlr_libinput_input_device */
-}
-
const struct wlr_pointer_impl libinput_pointer_impl = {
- .destroy = pointer_destroy,
+ .name = "libinput-pointer",
};
void init_device_pointer(struct wlr_libinput_input_device *dev) {
diff --git a/backend/wayland/seat.c b/backend/wayland/seat.c
index e2a61bd4..1edd0f2c 100644
--- a/backend/wayland/seat.c
+++ b/backend/wayland/seat.c
@@ -500,29 +500,6 @@ struct wlr_wl_input_device *create_wl_input_device(
return dev;
}
-void destroy_wl_input_device(struct wlr_wl_input_device *dev) {
- /**
- * TODO remove the redundant wlr_input_device from wlr_wl_input_device
- * wlr_wl_input_device::wlr_input_device is not owned by its input device
- * type, which means we have 2 wlr_input_device to cleanup
- */
- wlr_input_device_finish(&dev->wlr_input_device);
- if (dev->wlr_input_device._device) {
- struct wlr_input_device *wlr_dev = &dev->wlr_input_device;
- switch (wlr_dev->type) {
- case WLR_INPUT_DEVICE_KEYBOARD:
- wlr_keyboard_finish(wlr_dev->keyboard);
- free(wlr_dev->keyboard);
- break;
- default:
- wlr_input_device_destroy(wlr_dev);
- break;
- }
- }
- wl_list_remove(&dev->link);
- free(dev);
-}
-
struct wlr_wl_pointer *pointer_get_wl(struct wlr_pointer *wlr_pointer) {
assert(wlr_pointer->impl == &pointer_impl);
return (struct wlr_wl_pointer *)wlr_pointer;
@@ -555,13 +532,37 @@ static void pointer_destroy(struct wlr_pointer *wlr_pointer) {
zwp_relative_pointer_v1_destroy(pointer->relative_pointer);
}
+ wlr_pointer_finish(&pointer->wlr_pointer);
wl_list_remove(&pointer->output_destroy.link);
free(pointer);
}
-static const struct wlr_pointer_impl pointer_impl = {
- .destroy = pointer_destroy,
-};
+void destroy_wl_input_device(struct wlr_wl_input_device *dev) {
+ /**
+ * TODO remove the redundant wlr_input_device from wlr_wl_input_device
+ * wlr_wl_input_device::wlr_input_device is not owned by its input device
+ * type, which means we have 2 wlr_input_device to cleanup
+ */
+ wlr_input_device_finish(&dev->wlr_input_device);
+ if (dev->wlr_input_device._device) {
+ struct wlr_input_device *wlr_dev = &dev->wlr_input_device;
+ switch (wlr_dev->type) {
+ case WLR_INPUT_DEVICE_KEYBOARD:
+ wlr_keyboard_finish(wlr_dev->keyboard);
+ free(wlr_dev->keyboard);
+ break;
+ case WLR_INPUT_DEVICE_POINTER:
+ /* Owned by wlr_wl_pointer */
+ pointer_destroy(wlr_dev->pointer);
+ break;
+ default:
+ wlr_input_device_destroy(wlr_dev);
+ break;
+ }
+ }
+ wl_list_remove(&dev->link);
+ free(dev);
+}
static void gesture_swipe_begin(void *data,
struct zwp_pointer_gesture_swipe_v1 *zwp_pointer_gesture_swipe_v1,
diff --git a/backend/x11/input_device.c b/backend/x11/input_device.c
index 3bbbe594..9182ba8e 100644
--- a/backend/x11/input_device.c
+++ b/backend/x11/input_device.c
@@ -289,12 +289,8 @@ const struct wlr_keyboard_impl x11_keyboard_impl = {
.name = "x11-keyboard",
};
-static void pointer_destroy(struct wlr_pointer *wlr_pointer) {
- // Don't free the pointer, it's on the stack
-}
-
const struct wlr_pointer_impl x11_pointer_impl = {
- .destroy = pointer_destroy,
+ .name = "x11-pointer",
};
static void touch_destroy(struct wlr_touch *wlr_touch) {
diff --git a/backend/x11/output.c b/backend/x11/output.c
index 7037c36c..24c08fce 100644
--- a/backend/x11/output.c
+++ b/backend/x11/output.c
@@ -76,7 +76,7 @@ static void output_destroy(struct wlr_output *wlr_output) {
pixman_region32_fini(&output->exposed);
- wlr_pointer_destroy(&output->pointer);
+ wlr_pointer_finish(&output->pointer);
wlr_touch_destroy(&output->touch);
struct wlr_x11_buffer *buffer, *buffer_tmp;