diff options
author | Simon Zeni <simon@bl4ckb0ne.ca> | 2022-02-08 11:20:44 -0500 |
---|---|---|
committer | Kirill Primak <vyivel@eclair.cafe> | 2022-02-21 17:11:32 +0000 |
commit | fd80329c53ed00b9411095b60e9d0611c016ec03 (patch) | |
tree | c909f2aa19ff67b070028b329daaf839a1da14a2 | |
parent | 71577e351e7954467e2376ac7bb92edc4ce53159 (diff) |
interfaces/wlr_input_device: introduce wlr_input_device_finish
This function releases the wlr_input_device allocated memory (it's name and
it's output name), and signals its destroy event.
-rw-r--r-- | include/wlr/interfaces/wlr_input_device.h | 7 | ||||
-rw-r--r-- | types/wlr_input_device.c | 11 |
2 files changed, 18 insertions, 0 deletions
diff --git a/include/wlr/interfaces/wlr_input_device.h b/include/wlr/interfaces/wlr_input_device.h index 04d5644f..de527393 100644 --- a/include/wlr/interfaces/wlr_input_device.h +++ b/include/wlr/interfaces/wlr_input_device.h @@ -18,6 +18,13 @@ struct wlr_input_device_impl { void wlr_input_device_init(struct wlr_input_device *wlr_device, enum wlr_input_device_type type, const struct wlr_input_device_impl *impl, const char *name); + +/** + * Cleans up all of the provided wlr_input_device resources and signals the + * destroy event. + */ +void wlr_input_device_finish(struct wlr_input_device *wlr_device); + void wlr_input_device_destroy(struct wlr_input_device *dev); #endif diff --git a/types/wlr_input_device.c b/types/wlr_input_device.c index 7f9654e5..50afdaff 100644 --- a/types/wlr_input_device.c +++ b/types/wlr_input_device.c @@ -25,6 +25,17 @@ void wlr_input_device_init(struct wlr_input_device *dev, wl_signal_init(&dev->events.destroy); } +void wlr_input_device_finish(struct wlr_input_device *wlr_device) { + if (!wlr_device) { + return; + } + + wlr_signal_emit_safe(&wlr_device->events.destroy, wlr_device); + + free(wlr_device->name); + free(wlr_device->output_name); +} + void wlr_input_device_destroy(struct wlr_input_device *dev) { if (!dev) { return; |