mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-12-22 09:59:48 +01:00
interface/wlr_touch: rework destroy sequence
The destroy callback in wlr_touch_impl has been removed. The function `wlr_touch_finish` has been introduced to clean up the resources owned by a wlr_touch. `wlr_input_device_destroy` no longer destroys the wlr_touch, attempting to destroy a wlr_touch will result in a no-op. The field `name` has been added to the wlr_touch_impl to be able to identify a given wlr_touch device.
This commit is contained in:
parent
8d3cb94b41
commit
10cbb9fbe1
8 changed files with 12 additions and 22 deletions
|
@ -24,7 +24,7 @@ void destroy_libinput_input_device(struct wlr_libinput_input_device *dev) {
|
|||
wlr_switch_finish(&dev->switch_device);
|
||||
}
|
||||
if (dev->touch.impl) {
|
||||
wlr_touch_destroy(&dev->touch);
|
||||
wlr_touch_finish(&dev->touch);
|
||||
}
|
||||
if (dev->tablet.impl) {
|
||||
finish_device_tablet(dev);
|
||||
|
|
|
@ -4,12 +4,8 @@
|
|||
#include "backend/libinput.h"
|
||||
#include "util/signal.h"
|
||||
|
||||
static void touch_destroy(struct wlr_touch *touch) {
|
||||
/* wlr_touch belongs to the wlr_libinput_input_device */
|
||||
}
|
||||
|
||||
const struct wlr_touch_impl libinput_touch_impl = {
|
||||
.destroy = touch_destroy,
|
||||
.name = "libinput-touch",
|
||||
};
|
||||
|
||||
void init_device_touch(struct wlr_libinput_input_device *dev) {
|
||||
|
|
|
@ -567,6 +567,10 @@ void destroy_wl_input_device(struct wlr_wl_input_device *dev) {
|
|||
wlr_tablet_finish(wlr_dev->tablet);
|
||||
free(wlr_dev->tablet);
|
||||
break;
|
||||
case WLR_INPUT_DEVICE_TOUCH:
|
||||
wlr_touch_finish(wlr_dev->touch);
|
||||
free(wlr_dev->touch);
|
||||
break;
|
||||
default:
|
||||
wlr_input_device_destroy(wlr_dev);
|
||||
break;
|
||||
|
|
|
@ -293,12 +293,8 @@ const struct wlr_pointer_impl x11_pointer_impl = {
|
|||
.name = "x11-pointer",
|
||||
};
|
||||
|
||||
static void touch_destroy(struct wlr_touch *wlr_touch) {
|
||||
// Don't free the touch, it's on the stack
|
||||
}
|
||||
|
||||
const struct wlr_touch_impl x11_touch_impl = {
|
||||
.destroy = touch_destroy,
|
||||
.name = "x11-touch",
|
||||
};
|
||||
|
||||
void update_x11_pointer_position(struct wlr_x11_output *output,
|
||||
|
|
|
@ -77,7 +77,7 @@ static void output_destroy(struct wlr_output *wlr_output) {
|
|||
pixman_region32_fini(&output->exposed);
|
||||
|
||||
wlr_pointer_finish(&output->pointer);
|
||||
wlr_touch_destroy(&output->touch);
|
||||
wlr_touch_finish(&output->touch);
|
||||
|
||||
struct wlr_x11_buffer *buffer, *buffer_tmp;
|
||||
wl_list_for_each_safe(buffer, buffer_tmp, &output->buffers, link) {
|
||||
|
|
|
@ -12,11 +12,11 @@
|
|||
#include <wlr/types/wlr_touch.h>
|
||||
|
||||
struct wlr_touch_impl {
|
||||
void (*destroy)(struct wlr_touch *touch);
|
||||
const char *name;
|
||||
};
|
||||
|
||||
void wlr_touch_init(struct wlr_touch *touch,
|
||||
const struct wlr_touch_impl *impl, const char *name);
|
||||
void wlr_touch_destroy(struct wlr_touch *touch);
|
||||
void wlr_touch_finish(struct wlr_touch *touch);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <wayland-server-core.h>
|
||||
#include <wlr/interfaces/wlr_touch.h>
|
||||
#include <wlr/types/wlr_input_device.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include "util/signal.h"
|
||||
|
@ -45,7 +44,7 @@ void wlr_input_device_destroy(struct wlr_input_device *dev) {
|
|||
wlr_log(WLR_ERROR, "wlr_switch will not be destroyed");
|
||||
break;
|
||||
case WLR_INPUT_DEVICE_TOUCH:
|
||||
wlr_touch_destroy(dev->touch);
|
||||
wlr_log(WLR_ERROR, "wlr_touch will not be destroyed");
|
||||
break;
|
||||
case WLR_INPUT_DEVICE_TABLET_TOOL:
|
||||
wlr_log(WLR_ERROR, "wlr_tablet_tool will not be destroyed");
|
||||
|
|
|
@ -17,11 +17,6 @@ void wlr_touch_init(struct wlr_touch *touch,
|
|||
wl_signal_init(&touch->events.frame);
|
||||
}
|
||||
|
||||
void wlr_touch_destroy(struct wlr_touch *touch) {
|
||||
void wlr_touch_finish(struct wlr_touch *touch) {
|
||||
wlr_input_device_finish(&touch->base);
|
||||
if (touch && touch->impl && touch->impl->destroy) {
|
||||
touch->impl->destroy(touch);
|
||||
} else {
|
||||
free(touch);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue