mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2024-11-25 16:42:26 +00:00
interface/wlr_switch: rework destroy sequence
The destroy callback in wlr_switch_impl has been removed. The function `wlr_switch_finish` has been introduced to clean up the resources owned by a wlr_switch. `wlr_input_device_destroy` no longer destroys the wlr_switch, attempting to destroy a wlr_switch will result in a no-op. The field `name` has been added to the wlr_switch_impl to be able to identify a given wlr_switch device.
This commit is contained in:
parent
51cd3c0726
commit
0d2be496a8
@ -21,7 +21,7 @@ void destroy_libinput_input_device(struct wlr_libinput_input_device *dev) {
|
|||||||
wlr_pointer_finish(&dev->pointer);
|
wlr_pointer_finish(&dev->pointer);
|
||||||
}
|
}
|
||||||
if (dev->switch_device.impl) {
|
if (dev->switch_device.impl) {
|
||||||
wlr_switch_destroy(&dev->switch_device);
|
wlr_switch_finish(&dev->switch_device);
|
||||||
}
|
}
|
||||||
if (dev->touch.impl) {
|
if (dev->touch.impl) {
|
||||||
wlr_touch_destroy(&dev->touch);
|
wlr_touch_destroy(&dev->touch);
|
||||||
|
@ -4,12 +4,8 @@
|
|||||||
#include "backend/libinput.h"
|
#include "backend/libinput.h"
|
||||||
#include "util/signal.h"
|
#include "util/signal.h"
|
||||||
|
|
||||||
static void switch_destroy(struct wlr_switch *wlr_switch) {
|
|
||||||
/* wlr_switch belongs to the wlr_libinput_input_device */
|
|
||||||
}
|
|
||||||
|
|
||||||
const struct wlr_switch_impl libinput_switch_impl = {
|
const struct wlr_switch_impl libinput_switch_impl = {
|
||||||
.destroy = switch_destroy,
|
.name = "libinput-switch",
|
||||||
};
|
};
|
||||||
|
|
||||||
void init_device_switch(struct wlr_libinput_input_device *dev) {
|
void init_device_switch(struct wlr_libinput_input_device *dev) {
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include <wlr/interfaces/wlr_keyboard.h>
|
#include <wlr/interfaces/wlr_keyboard.h>
|
||||||
#include <wlr/interfaces/wlr_output.h>
|
#include <wlr/interfaces/wlr_output.h>
|
||||||
#include <wlr/interfaces/wlr_pointer.h>
|
#include <wlr/interfaces/wlr_pointer.h>
|
||||||
|
#include <wlr/interfaces/wlr_switch.h>
|
||||||
#include <wlr/interfaces/wlr_touch.h>
|
#include <wlr/interfaces/wlr_touch.h>
|
||||||
#include <wlr/interfaces/wlr_tablet_tool.h>
|
#include <wlr/interfaces/wlr_tablet_tool.h>
|
||||||
#include <wlr/interfaces/wlr_tablet_pad.h>
|
#include <wlr/interfaces/wlr_tablet_pad.h>
|
||||||
@ -555,6 +556,9 @@ void destroy_wl_input_device(struct wlr_wl_input_device *dev) {
|
|||||||
/* Owned by wlr_wl_pointer */
|
/* Owned by wlr_wl_pointer */
|
||||||
pointer_destroy(wlr_dev->pointer);
|
pointer_destroy(wlr_dev->pointer);
|
||||||
break;
|
break;
|
||||||
|
case WLR_INPUT_DEVICE_SWITCH:
|
||||||
|
wlr_switch_finish(wlr_dev->switch_device);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
wlr_input_device_destroy(wlr_dev);
|
wlr_input_device_destroy(wlr_dev);
|
||||||
break;
|
break;
|
||||||
|
@ -12,11 +12,11 @@
|
|||||||
#include <wlr/types/wlr_switch.h>
|
#include <wlr/types/wlr_switch.h>
|
||||||
|
|
||||||
struct wlr_switch_impl {
|
struct wlr_switch_impl {
|
||||||
void (*destroy)(struct wlr_switch *switch_device);
|
const char *name;
|
||||||
};
|
};
|
||||||
|
|
||||||
void wlr_switch_init(struct wlr_switch *switch_device,
|
void wlr_switch_init(struct wlr_switch *switch_device,
|
||||||
const struct wlr_switch_impl *impl, const char *name);
|
const struct wlr_switch_impl *impl, const char *name);
|
||||||
void wlr_switch_destroy(struct wlr_switch *switch_device);
|
void wlr_switch_finish(struct wlr_switch *switch_device);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <wayland-server-core.h>
|
#include <wayland-server-core.h>
|
||||||
#include <wlr/interfaces/wlr_switch.h>
|
|
||||||
#include <wlr/interfaces/wlr_tablet_pad.h>
|
#include <wlr/interfaces/wlr_tablet_pad.h>
|
||||||
#include <wlr/interfaces/wlr_tablet_tool.h>
|
#include <wlr/interfaces/wlr_tablet_tool.h>
|
||||||
#include <wlr/interfaces/wlr_touch.h>
|
#include <wlr/interfaces/wlr_touch.h>
|
||||||
@ -45,7 +44,7 @@ void wlr_input_device_destroy(struct wlr_input_device *dev) {
|
|||||||
wlr_log(WLR_ERROR, "wlr_pointer will not be destroyed");
|
wlr_log(WLR_ERROR, "wlr_pointer will not be destroyed");
|
||||||
break;
|
break;
|
||||||
case WLR_INPUT_DEVICE_SWITCH:
|
case WLR_INPUT_DEVICE_SWITCH:
|
||||||
wlr_switch_destroy(dev->switch_device);
|
wlr_log(WLR_ERROR, "wlr_switch will not be destroyed");
|
||||||
break;
|
break;
|
||||||
case WLR_INPUT_DEVICE_TOUCH:
|
case WLR_INPUT_DEVICE_TOUCH:
|
||||||
wlr_touch_destroy(dev->touch);
|
wlr_touch_destroy(dev->touch);
|
||||||
|
@ -13,14 +13,6 @@ void wlr_switch_init(struct wlr_switch *switch_device,
|
|||||||
wl_signal_init(&switch_device->events.toggle);
|
wl_signal_init(&switch_device->events.toggle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_switch_destroy(struct wlr_switch *switch_device) {
|
void wlr_switch_finish(struct wlr_switch *switch_device) {
|
||||||
if (!switch_device) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
wlr_input_device_finish(&switch_device->base);
|
wlr_input_device_finish(&switch_device->base);
|
||||||
if (switch_device->impl && switch_device->impl->destroy) {
|
|
||||||
switch_device->impl->destroy(switch_device);
|
|
||||||
} else {
|
|
||||||
free(switch_device);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user