aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CONTRIBUTING.md11
-rw-r--r--include/wlr/types/wlr_compositor.h6
-rw-r--r--include/wlr/types/wlr_data_control_v1.h3
-rw-r--r--include/wlr/types/wlr_data_device.h6
-rw-r--r--include/wlr/types/wlr_export_dmabuf_v1.h3
-rw-r--r--include/wlr/types/wlr_foreign_toplevel_management_v1.h4
-rw-r--r--include/wlr/types/wlr_fullscreen_shell_v1.h2
-rw-r--r--include/wlr/types/wlr_gamma_control_v1.h3
-rw-r--r--include/wlr/types/wlr_gtk_primary_selection.h3
-rw-r--r--include/wlr/types/wlr_idle.h2
-rw-r--r--include/wlr/types/wlr_idle_inhibit_v1.h2
-rw-r--r--include/wlr/types/wlr_input_inhibitor.h2
-rw-r--r--include/wlr/types/wlr_input_method_v2.h4
-rw-r--r--include/wlr/types/wlr_layer_shell_v1.h2
-rw-r--r--include/wlr/types/wlr_linux_dmabuf_v1.h5
-rw-r--r--include/wlr/types/wlr_pointer_constraints_v1.h6
-rw-r--r--include/wlr/types/wlr_pointer_gestures_v1.h8
-rw-r--r--include/wlr/types/wlr_presentation_time.h2
-rw-r--r--include/wlr/types/wlr_primary_selection_v1.h3
-rw-r--r--include/wlr/types/wlr_relative_pointer_v1.h3
-rw-r--r--include/wlr/types/wlr_screencopy_v1.h3
-rw-r--r--include/wlr/types/wlr_server_decoration.h4
-rw-r--r--include/wlr/types/wlr_tablet_v2.h1
-rw-r--r--include/wlr/types/wlr_text_input_v3.h5
-rw-r--r--include/wlr/types/wlr_virtual_keyboard_v1.h3
-rw-r--r--include/wlr/types/wlr_xdg_decoration_v1.h3
-rw-r--r--include/wlr/types/wlr_xdg_output_v1.h13
-rw-r--r--include/wlr/types/wlr_xdg_shell.h1
-rw-r--r--include/wlr/types/wlr_xdg_shell_v6.h1
-rw-r--r--types/data_device/wlr_data_device.c30
-rw-r--r--types/tablet_v2/wlr_tablet_v2.c18
-rw-r--r--types/wlr_compositor.c78
-rw-r--r--types/wlr_data_control_v1.c37
-rw-r--r--types/wlr_export_dmabuf_v1.c33
-rw-r--r--types/wlr_foreign_toplevel_management_v1.c26
-rw-r--r--types/wlr_fullscreen_shell_v1.c29
-rw-r--r--types/wlr_gamma_control_v1.c31
-rw-r--r--types/wlr_gtk_primary_selection.c30
-rw-r--r--types/wlr_idle.c17
-rw-r--r--types/wlr_idle_inhibit_v1.c50
-rw-r--r--types/wlr_input_inhibitor.c19
-rw-r--r--types/wlr_input_method_v2.c43
-rw-r--r--types/wlr_layer_shell_v1.c35
-rw-r--r--types/wlr_linux_dmabuf_v1.c23
-rw-r--r--types/wlr_pointer_constraints_v1.c40
-rw-r--r--types/wlr_pointer_gestures_v1.c23
-rw-r--r--types/wlr_presentation_time.c38
-rw-r--r--types/wlr_primary_selection_v1.c30
-rw-r--r--types/wlr_relative_pointer_v1.c43
-rw-r--r--types/wlr_screencopy_v1.c28
-rw-r--r--types/wlr_server_decoration.c23
-rw-r--r--types/wlr_text_input_v3.c47
-rw-r--r--types/wlr_virtual_keyboard_v1.c44
-rw-r--r--types/wlr_xdg_decoration_v1.c35
-rw-r--r--types/wlr_xdg_output_v1.c48
-rw-r--r--types/xdg_shell/wlr_xdg_shell.c15
-rw-r--r--types/xdg_shell_v6/wlr_xdg_shell_v6.c15
57 files changed, 206 insertions, 836 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 10e3ac22..e8eb8917 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -242,14 +242,12 @@ at least one struct for each interface in the protocol. For instance,
### Globals
Global interfaces generally have public constructors and destructors. Their
-struct has a field holding the `wl_global` itself, a list of resources clients
-created by binding to the global, a destroy signal and a `wl_display` destroy
-listener. Example:
+struct has a field holding the `wl_global` itself, a destroy signal and a
+`wl_display` destroy listener. Example:
```c
struct wlr_compositor {
struct wl_global *global;
- struct wl_list resources;
struct wl_listener display_destroy;
@@ -262,8 +260,9 @@ struct wlr_compositor {
```
When the destructor is called, it should emit the destroy signal, remove the
-display destroy listener, destroy the `wl_global`, destroy all bound resources
-and then destroy the struct.
+display destroy listener, destroy the `wl_global` and then destroy the struct.
+The destructor can assume all clients and resources have been already
+destroyed.
### Resources
diff --git a/include/wlr/types/wlr_compositor.h b/include/wlr/types/wlr_compositor.h
index 6aaea9c7..04391c74 100644
--- a/include/wlr/types/wlr_compositor.h
+++ b/include/wlr/types/wlr_compositor.h
@@ -16,16 +16,11 @@ struct wlr_surface;
struct wlr_subcompositor {
struct wl_global *global;
- struct wl_list resources;
- struct wl_list subsurface_resources;
};
struct wlr_compositor {
struct wl_global *global;
- struct wl_list resources;
struct wlr_renderer *renderer;
- struct wl_list surface_resources;
- struct wl_list region_resources;
struct wlr_subcompositor subcompositor;
@@ -37,7 +32,6 @@ struct wlr_compositor {
} events;
};
-void wlr_compositor_destroy(struct wlr_compositor *wlr_compositor);
struct wlr_compositor *wlr_compositor_create(struct wl_display *display,
struct wlr_renderer *renderer);
diff --git a/include/wlr/types/wlr_data_control_v1.h b/include/wlr/types/wlr_data_control_v1.h
index d487a7db..c7e0adf0 100644
--- a/include/wlr/types/wlr_data_control_v1.h
+++ b/include/wlr/types/wlr_data_control_v1.h
@@ -14,7 +14,6 @@
struct wlr_data_control_manager_v1 {
struct wl_global *global;
- struct wl_list resources; // wl_resource_get_link
struct wl_list devices; // wlr_data_control_device_v1::link
struct {
@@ -41,8 +40,6 @@ struct wlr_data_control_device_v1 {
struct wlr_data_control_manager_v1 *wlr_data_control_manager_v1_create(
struct wl_display *display);
-void wlr_data_control_manager_v1_destroy(
- struct wlr_data_control_manager_v1 *manager);
void wlr_data_control_device_v1_destroy(
struct wlr_data_control_device_v1 *device);
diff --git a/include/wlr/types/wlr_data_device.h b/include/wlr/types/wlr_data_device.h
index c017e428..555eeab0 100644
--- a/include/wlr/types/wlr_data_device.h
+++ b/include/wlr/types/wlr_data_device.h
@@ -23,7 +23,6 @@ extern const struct wlr_touch_grab_interface
struct wlr_data_device_manager {
struct wl_global *global;
- struct wl_list resources;
struct wl_list data_sources;
struct wl_listener display_destroy;
@@ -163,11 +162,6 @@ struct wlr_data_device_manager *wlr_data_device_manager_create(
struct wl_display *display);
/**
- * Destroys a wlr_data_device_manager and removes its wl_data_device_manager global.
- */
-void wlr_data_device_manager_destroy(struct wlr_data_device_manager *manager);
-
-/**
* Requests a selection to be set for the seat. If the request comes from
* a client, then set `client` to be the matching seat client so that this
* function can verify that the serial provided was once sent to the client
diff --git a/include/wlr/types/wlr_export_dmabuf_v1.h b/include/wlr/types/wlr_export_dmabuf_v1.h
index 5b3fbc2c..817bb1a0 100644
--- a/include/wlr/types/wlr_export_dmabuf_v1.h
+++ b/include/wlr/types/wlr_export_dmabuf_v1.h
@@ -15,7 +15,6 @@
struct wlr_export_dmabuf_manager_v1 {
struct wl_global *global;
- struct wl_list resources; // wl_resource_get_link
struct wl_list frames; // wlr_export_dmabuf_frame_v1::link
struct wl_listener display_destroy;
@@ -40,7 +39,5 @@ struct wlr_export_dmabuf_frame_v1 {
struct wlr_export_dmabuf_manager_v1 *wlr_export_dmabuf_manager_v1_create(
struct wl_display *display);
-void wlr_export_dmabuf_manager_v1_destroy(
- struct wlr_export_dmabuf_manager_v1 *manager);
#endif
diff --git a/include/wlr/types/wlr_foreign_toplevel_management_v1.h b/include/wlr/types/wlr_foreign_toplevel_management_v1.h
index 3adf2de5..90d88637 100644
--- a/include/wlr/types/wlr_foreign_toplevel_management_v1.h
+++ b/include/wlr/types/wlr_foreign_toplevel_management_v1.h
@@ -15,7 +15,7 @@
struct wlr_foreign_toplevel_manager_v1 {
struct wl_event_loop *event_loop;
struct wl_global *global;
- struct wl_list resources;
+ struct wl_list resources; // wl_resource_get_link
struct wl_list toplevels; // wlr_foreign_toplevel_handle_v1::link
struct wl_listener display_destroy;
@@ -101,8 +101,6 @@ struct wlr_foreign_toplevel_handle_v1_set_rectangle_event {
struct wlr_foreign_toplevel_manager_v1 *wlr_foreign_toplevel_manager_v1_create(
struct wl_display *display);
-void wlr_foreign_toplevel_manager_v1_destroy(
- struct wlr_foreign_toplevel_manager_v1 *manager);
struct wlr_foreign_toplevel_handle_v1 *wlr_foreign_toplevel_handle_v1_create(
struct wlr_foreign_toplevel_manager_v1 *manager);
diff --git a/include/wlr/types/wlr_fullscreen_shell_v1.h b/include/wlr/types/wlr_fullscreen_shell_v1.h
index b014bf28..ea8057f1 100644
--- a/include/wlr/types/wlr_fullscreen_shell_v1.h
+++ b/include/wlr/types/wlr_fullscreen_shell_v1.h
@@ -14,7 +14,6 @@
struct wlr_fullscreen_shell_v1 {
struct wl_global *global;
- struct wl_list resources;
struct {
struct wl_signal destroy;
@@ -36,6 +35,5 @@ struct wlr_fullscreen_shell_v1_present_surface_event {
struct wlr_fullscreen_shell_v1 *wlr_fullscreen_shell_v1_create(
struct wl_display *display);
-void wlr_fullscreen_shell_v1_destroy(struct wlr_fullscreen_shell_v1 *shell);
#endif
diff --git a/include/wlr/types/wlr_gamma_control_v1.h b/include/wlr/types/wlr_gamma_control_v1.h
index 202fde12..290a86e9 100644
--- a/include/wlr/types/wlr_gamma_control_v1.h
+++ b/include/wlr/types/wlr_gamma_control_v1.h
@@ -5,7 +5,6 @@
struct wlr_gamma_control_manager_v1 {
struct wl_global *global;
- struct wl_list resources;
struct wl_list controls; // wlr_gamma_control_v1::link
struct wl_listener display_destroy;
@@ -29,7 +28,5 @@ struct wlr_gamma_control_v1 {
struct wlr_gamma_control_manager_v1 *wlr_gamma_control_manager_v1_create(
struct wl_display *display);
-void wlr_gamma_control_manager_v1_destroy(
- struct wlr_gamma_control_manager_v1 *manager);
#endif
diff --git a/include/wlr/types/wlr_gtk_primary_selection.h b/include/wlr/types/wlr_gtk_primary_selection.h
index bb16b4e3..0d97eba0 100644
--- a/include/wlr/types/wlr_gtk_primary_selection.h
+++ b/include/wlr/types/wlr_gtk_primary_selection.h
@@ -22,7 +22,6 @@
*/
struct wlr_gtk_primary_selection_device_manager {
struct wl_global *global;
- struct wl_list resources; // wl_resource_get_link
struct wl_list devices; // wlr_gtk_primary_selection_device::link
struct wl_listener display_destroy;
@@ -54,7 +53,5 @@ struct wlr_gtk_primary_selection_device {
struct wlr_gtk_primary_selection_device_manager *
wlr_gtk_primary_selection_device_manager_create(struct wl_display *display);
-void wlr_gtk_primary_selection_device_manager_destroy(
- struct wlr_gtk_primary_selection_device_manager *manager);
#endif
diff --git a/include/wlr/types/wlr_idle.h b/include/wlr/types/wlr_idle.h
index d16932f5..acb98dfe 100644
--- a/include/wlr/types/wlr_idle.h
+++ b/include/wlr/types/wlr_idle.h
@@ -60,8 +60,6 @@ struct wlr_idle_timeout {
struct wlr_idle *wlr_idle_create(struct wl_display *display);
-void wlr_idle_destroy(struct wlr_idle *idle);
-
/**
* Send notification to restart all timers for the given seat. Called by
* compositor when there is an user activity event on that seat.
diff --git a/include/wlr/types/wlr_idle_inhibit_v1.h b/include/wlr/types/wlr_idle_inhibit_v1.h
index 0d007f9f..59ec83ff 100644
--- a/include/wlr/types/wlr_idle_inhibit_v1.h
+++ b/include/wlr/types/wlr_idle_inhibit_v1.h
@@ -24,7 +24,6 @@
*/
struct wlr_idle_inhibit_manager_v1 {
- struct wl_list resources; // wl_resource_get_link
struct wl_list inhibitors; // wlr_idle_inhibit_inhibitor_v1::link
struct wl_global *global;
@@ -53,6 +52,5 @@ struct wlr_idle_inhibitor_v1 {
};
struct wlr_idle_inhibit_manager_v1 *wlr_idle_inhibit_v1_create(struct wl_display *display);
-void wlr_idle_inhibit_v1_destroy(struct wlr_idle_inhibit_manager_v1 *idle_inhibit);
#endif
diff --git a/include/wlr/types/wlr_input_inhibitor.h b/include/wlr/types/wlr_input_inhibitor.h
index 2dc007be..1de20733 100644
--- a/include/wlr/types/wlr_input_inhibitor.h
+++ b/include/wlr/types/wlr_input_inhibitor.h
@@ -28,7 +28,5 @@ struct wlr_input_inhibit_manager {
struct wlr_input_inhibit_manager *wlr_input_inhibit_manager_create(
struct wl_display *display);
-void wlr_input_inhibit_manager_destroy(
- struct wlr_input_inhibit_manager *manager);
#endif
diff --git a/include/wlr/types/wlr_input_method_v2.h b/include/wlr/types/wlr_input_method_v2.h
index 9b600c1e..2ea4a6e5 100644
--- a/include/wlr/types/wlr_input_method_v2.h
+++ b/include/wlr/types/wlr_input_method_v2.h
@@ -53,7 +53,6 @@ struct wlr_input_method_v2 {
struct wlr_input_method_manager_v2 {
struct wl_global *global;
- struct wl_list bound_resources; // struct wl_resource*::link
struct wl_list input_methods; // struct wlr_input_method_v2*::link
struct wl_listener display_destroy;
@@ -66,8 +65,6 @@ struct wlr_input_method_manager_v2 {
struct wlr_input_method_manager_v2 *wlr_input_method_manager_v2_create(
struct wl_display *display);
-void wlr_input_method_manager_v2_destroy(
- struct wlr_input_method_manager_v2 *manager);
void wlr_input_method_v2_send_activate(
struct wlr_input_method_v2 *input_method);
@@ -84,4 +81,5 @@ void wlr_input_method_v2_send_text_change_cause(
void wlr_input_method_v2_send_done(struct wlr_input_method_v2 *input_method);
void wlr_input_method_v2_send_unavailable(
struct wlr_input_method_v2 *input_method);
+
#endif
diff --git a/include/wlr/types/wlr_layer_shell_v1.h b/include/wlr/types/wlr_layer_shell_v1.h
index 588da650..4e5f969b 100644
--- a/include/wlr/types/wlr_layer_shell_v1.h
+++ b/include/wlr/types/wlr_layer_shell_v1.h
@@ -29,7 +29,6 @@
*/
struct wlr_layer_shell_v1 {
struct wl_global *global;
- struct wl_list resources; // wl_resource
struct wl_list surfaces; // wl_layer_surface
struct wl_listener display_destroy;
@@ -97,7 +96,6 @@ struct wlr_layer_surface_v1 {
};
struct wlr_layer_shell_v1 *wlr_layer_shell_v1_create(struct wl_display *display);
-void wlr_layer_shell_v1_destroy(struct wlr_layer_shell_v1 *layer_shell);
/**
* Notifies the layer surface to configure itself with this width/height. The
diff --git a/include/wlr/types/wlr_linux_dmabuf_v1.h b/include/wlr/types/wlr_linux_dmabuf_v1.h
index f21b0b3a..aefa3afa 100644
--- a/include/wlr/types/wlr_linux_dmabuf_v1.h
+++ b/include/wlr/types/wlr_linux_dmabuf_v1.h
@@ -45,7 +45,6 @@ struct wlr_dmabuf_v1_buffer *wlr_dmabuf_v1_buffer_from_params_resource(
struct wlr_linux_dmabuf_v1 {
struct wl_global *global;
struct wlr_renderer *renderer;
- struct wl_list resources;
struct {
struct wl_signal destroy;
@@ -60,10 +59,6 @@ struct wlr_linux_dmabuf_v1 {
*/
struct wlr_linux_dmabuf_v1 *wlr_linux_dmabuf_v1_create(struct wl_display *display,
struct wlr_renderer *renderer);
-/**
- * Destroy the linux-dmabuf interface
- */
-void wlr_linux_dmabuf_v1_destroy(struct wlr_linux_dmabuf_v1 *linux_dmabuf);
/**
* Returns the wlr_linux_dmabuf if the given resource was created
diff --git a/include/wlr/types/wlr_pointer_constraints_v1.h b/include/wlr/types/wlr_pointer_constraints_v1.h
index e030a375..c13432e9 100644
--- a/include/wlr/types/wlr_pointer_constraints_v1.h
+++ b/include/wlr/types/wlr_pointer_constraints_v1.h
@@ -64,8 +64,8 @@ struct wlr_pointer_constraint_v1 {
};
struct wlr_pointer_constraints_v1 {
- struct wl_list resources; // wl_resource_get_link
struct wl_global *global;
+ struct wl_list constraints; // wlr_pointer_constraint_v1::link
struct {
/**
@@ -76,15 +76,13 @@ struct wlr_pointer_constraints_v1 {
struct wl_signal new_constraint;
} events;
- struct wl_list constraints; // wlr_pointer_constraint_v1::link
+ struct wl_listener display_destroy;
void *data;
};
struct wlr_pointer_constraints_v1 *wlr_pointer_constraints_v1_create(
struct wl_display *display);
-void wlr_pointer_constraints_v1_destroy(
- struct wlr_pointer_constraints_v1 *pointer_constraints);
struct wlr_pointer_constraint_v1 *
wlr_pointer_constraints_v1_constraint_for_surface(
diff --git a/include/wlr/types/wlr_pointer_gestures_v1.h b/include/wlr/types/wlr_pointer_gestures_v1.h
index 86fcaf3d..bb250389 100644
--- a/include/wlr/types/wlr_pointer_gestures_v1.h
+++ b/include/wlr/types/wlr_pointer_gestures_v1.h
@@ -15,9 +15,8 @@
struct wlr_pointer_gestures_v1 {
struct wl_global *global;
- struct wl_list resources; // wl_resource_get_link
- struct wl_list swipes; // wl_resource_get_link
- struct wl_list pinches; // wl_resource_get_link
+ struct wl_list swipes; // wl_resource_get_link
+ struct wl_list pinches; // wl_resource_get_link
struct wl_listener display_destroy;
@@ -67,7 +66,4 @@ void wlr_pointer_gestures_v1_send_pinch_end(
uint32_t time_msec,
bool cancelled);
-void wlr_pointer_gestures_v1_destroy(
- struct wlr_pointer_gestures_v1 *pointer_gestures_v1);
-
#endif
diff --git a/include/wlr/types/wlr_presentation_time.h b/include/wlr/types/wlr_presentation_time.h
index 9a7e6e70..51570c04 100644
--- a/include/wlr/types/wlr_presentation_time.h
+++ b/include/wlr/types/wlr_presentation_time.h
@@ -19,7 +19,6 @@ struct wlr_output_event_present;
struct wlr_presentation {
struct wl_global *global;
- struct wl_list resources; // wl_resource_get_link
struct wl_list feedbacks; // wlr_presentation_feedback::link
clockid_t clock;
@@ -71,7 +70,6 @@ struct wlr_backend;
struct wlr_presentation *wlr_presentation_create(struct wl_display *display,
struct wlr_backend *backend);
-void wlr_presentation_destroy(struct wlr_presentation *presentation);
/**
* Mark the current surface's buffer as sampled.
*
diff --git a/include/wlr/types/wlr_primary_selection_v1.h b/include/wlr/types/wlr_primary_selection_v1.h
index b380ea61..7434d831 100644
--- a/include/wlr/types/wlr_primary_selection_v1.h
+++ b/include/wlr/types/wlr_primary_selection_v1.h
@@ -14,7 +14,6 @@
struct wlr_primary_selection_v1_device_manager {
struct wl_global *global;
- struct wl_list resources; // wl_resource_get_link
struct wl_list devices; // wlr_primary_selection_v1_device::link
struct wl_listener display_destroy;
@@ -46,7 +45,5 @@ struct wlr_primary_selection_v1_device {
struct wlr_primary_selection_v1_device_manager *
wlr_primary_selection_v1_device_manager_create(struct wl_display *display);
-void wlr_primary_selection_v1_device_manager_destroy(
- struct wlr_primary_selection_v1_device_manager *manager);
#endif
diff --git a/include/wlr/types/wlr_relative_pointer_v1.h b/include/wlr/types/wlr_relative_pointer_v1.h
index d4aa6fa8..59dd98d6 100644
--- a/include/wlr/types/wlr_relative_pointer_v1.h
+++ b/include/wlr/types/wlr_relative_pointer_v1.h
@@ -23,7 +23,6 @@
*/
struct wlr_relative_pointer_manager_v1 {
struct wl_global *global;
- struct wl_list resources; // wl_resource_get_link()
struct wl_list relative_pointers; // wlr_relative_pointer_v1::link
struct {
@@ -60,8 +59,6 @@ struct wlr_relative_pointer_v1 {
struct wlr_relative_pointer_manager_v1 *wlr_relative_pointer_manager_v1_create(
struct wl_display *display);
-void wlr_relative_pointer_manager_v1_destroy(
- struct wlr_relative_pointer_manager_v1 *manager);
/**
* Send a relative motion event to the seat. Time is given in microseconds
diff --git a/include/wlr/types/wlr_screencopy_v1.h b/include/wlr/types/wlr_screencopy_v1.h
index b42ec3a8..76f49e03 100644
--- a/include/wlr/types/wlr_screencopy_v1.h
+++ b/include/wlr/types/wlr_screencopy_v1.h
@@ -15,7 +15,6 @@
struct wlr_screencopy_manager_v1 {
struct wl_global *global;
- struct wl_list resources; // wl_resource
struct wl_list frames; // wlr_screencopy_frame_v1::link
struct wl_listener display_destroy;
@@ -59,7 +58,5 @@ struct wlr_screencopy_frame_v1 {
struct wlr_screencopy_manager_v1 *wlr_screencopy_manager_v1_create(
struct wl_display *display);
-void wlr_screencopy_manager_v1_destroy(
- struct wlr_screencopy_manager_v1 *screencopy);
#endif
diff --git a/include/wlr/types/wlr_server_decoration.h b/include/wlr/types/wlr_server_decoration.h
index f4a55589..28467a21 100644
--- a/include/wlr/types/wlr_server_decoration.h
+++ b/include/wlr/types/wlr_server_decoration.h
@@ -44,7 +44,7 @@ enum wlr_server_decoration_manager_mode {
*/
struct wlr_server_decoration_manager {
struct wl_global *global;
- struct wl_list resources;
+ struct wl_list resources; // wl_resource_get_link
struct wl_list decorations; // wlr_server_decoration::link
uint32_t default_mode; // enum wlr_server_decoration_manager_mode
@@ -80,7 +80,5 @@ struct wlr_server_decoration_manager *wlr_server_decoration_manager_create(
struct wl_display *display);
void wlr_server_decoration_manager_set_default_mode(
struct wlr_server_decoration_manager *manager, uint32_t default_mode);
-void wlr_server_decoration_manager_destroy(
- struct wlr_server_decoration_manager *manager);
#endif
diff --git a/include/wlr/types/wlr_tablet_v2.h b/include/wlr/types/wlr_tablet_v2.h
index 894b062d..72d3abd3 100644
--- a/include/wlr/types/wlr_tablet_v2.h
+++ b/include/wlr/types/wlr_tablet_v2.h
@@ -141,7 +141,6 @@ struct wlr_tablet_v2_tablet_tool *wlr_tablet_tool_create(
struct wlr_tablet_tool *wlr_tool);
struct wlr_tablet_manager_v2 *wlr_tablet_v2_create(struct wl_display *display);
-void wlr_tablet_v2_destroy(struct wlr_tablet_manager_v2 *manager);
void wlr_send_tablet_v2_tablet_tool_proximity_in(
struct wlr_tablet_v2_tablet_tool *tool,
diff --git a/include/wlr/types/wlr_text_input_v3.h b/include/wlr/types/wlr_text_input_v3.h
index ac1b0a69..079a3e8a 100644
--- a/include/wlr/types/wlr_text_input_v3.h
+++ b/include/wlr/types/wlr_text_input_v3.h
@@ -60,8 +60,6 @@ struct wlr_text_input_v3 {
struct wlr_text_input_manager_v3 {
struct wl_global *global;
-
- struct wl_list bound_resources; // struct wl_resource*::link
struct wl_list text_inputs; // struct wlr_text_input_v3::resource::link
struct wl_listener display_destroy;
@@ -74,8 +72,6 @@ struct wlr_text_input_manager_v3 {
struct wlr_text_input_manager_v3 *wlr_text_input_manager_v3_create(
struct wl_display *wl_display);
-void wlr_text_input_manager_v3_destroy(
- struct wlr_text_input_manager_v3 *manager);
// Sends enter to the surface and saves it
void wlr_text_input_v3_send_enter(struct wlr_text_input_v3 *text_input,
@@ -90,4 +86,5 @@ void wlr_text_input_v3_send_delete_surrounding_text(
struct wlr_text_input_v3 *text_input, uint32_t before_length,
uint32_t after_length);
void wlr_text_input_v3_send_done(struct wlr_text_input_v3 *text_input);
+
#endif
diff --git a/include/wlr/types/wlr_virtual_keyboard_v1.h b/include/wlr/types/wlr_virtual_keyboard_v1.h
index ea172056..78f80fbb 100644
--- a/include/wlr/types/wlr_virtual_keyboard_v1.h
+++ b/include/wlr/types/wlr_virtual_keyboard_v1.h
@@ -15,7 +15,6 @@
struct wlr_virtual_keyboard_manager_v1 {
struct wl_global *global;
- struct wl_list resources; // struct wl_resource*
struct wl_list virtual_keyboards; // struct wlr_virtual_keyboard_v1*
struct wl_listener display_destroy;
@@ -41,7 +40,5 @@ struct wlr_virtual_keyboard_v1 {
struct wlr_virtual_keyboard_manager_v1* wlr_virtual_keyboard_manager_v1_create(
struct wl_display *display);
-void wlr_virtual_keyboard_manager_v1_destroy(
- struct wlr_virtual_keyboard_manager_v1 *manager);
#endif
diff --git a/include/wlr/types/wlr_xdg_decoration_v1.h b/include/wlr/types/wlr_xdg_decoration_v1.h
index 468872a5..eafa05cc 100644
--- a/include/wlr/types/wlr_xdg_decoration_v1.h
+++ b/include/wlr/types/wlr_xdg_decoration_v1.h
@@ -12,7 +12,6 @@ enum wlr_xdg_toplevel_decoration_v1_mode {
struct wlr_xdg_decoration_manager_v1 {
struct wl_global *global;
- struct wl_list resources;
struct wl_list decorations; // wlr_xdg_toplevel_decoration::link
struct wl_listener display_destroy;
@@ -59,8 +58,6 @@ struct wlr_xdg_toplevel_decoration_v1 {
struct wlr_xdg_decoration_manager_v1 *
wlr_xdg_decoration_manager_v1_create(struct wl_display *display);
-void wlr_xdg_decoration_manager_v1_destroy(
- struct wlr_xdg_decoration_manager_v1 *manager);
uint32_t wlr_xdg_toplevel_decoration_v1_set_mode(
struct wlr_xdg_toplevel_decoration_v1 *decoration,
diff --git a/include/wlr/types/wlr_xdg_output_v1.h b/include/wlr/types/wlr_xdg_output_v1.h
index d9e2b905..02cbd60d 100644
--- a/include/wlr/types/wlr_xdg_output_v1.h
+++ b/include/wlr/types/wlr_xdg_output_v1.h
@@ -26,22 +26,21 @@ struct wlr_xdg_output_v1 {
struct wlr_xdg_output_manager_v1 {
struct wl_global *global;
- struct wl_list resources;
struct wlr_output_layout *layout;
struct wl_list outputs;
- struct wl_listener layout_add;
- struct wl_listener layout_change;
- struct wl_listener layout_destroy;
-
struct {
struct wl_signal destroy;
} events;
+
+ struct wl_listener display_destroy;
+ struct wl_listener layout_add;
+ struct wl_listener layout_change;
+ struct wl_listener layout_destroy;
};
struct wlr_xdg_output_manager_v1 *wlr_xdg_output_manager_v1_create(
- struct wl_display *display, struct wlr_output_layout *layout);
-void wlr_xdg_output_manager_v1_destroy(struct wlr_xdg_output_manager_v1 *manager);
+ struct wl_display *display, struct wlr_output_layout *layout);
#endif
diff --git a/include/wlr/types/wlr_xdg_shell.h b/include/wlr/types/wlr_xdg_shell.h
index 70572bf5..7c787a16 100644
--- a/include/wlr/types/wlr_xdg_shell.h
+++ b/include/wlr/types/wlr_xdg_shell.h
@@ -243,7 +243,6 @@ struct wlr_xdg_toplevel_show_window_menu_event {
};
struct wlr_xdg_shell *wlr_xdg_shell_create(struct wl_display *display);
-void wlr_xdg_shell_destroy(struct wlr_xdg_shell *xdg_shell);
struct wlr_xdg_surface *wlr_xdg_surface_from_resource(
struct wl_resource *resource);
diff --git a/include/wlr/types/wlr_xdg_shell_v6.h b/include/wlr/types/wlr_xdg_shell_v6.h
index 13866c18..5a6cf72f 100644
--- a/include/wlr/types/wlr_xdg_shell_v6.h
+++ b/include/wlr/types/wlr_xdg_shell_v6.h
@@ -243,7 +243,6 @@ struct wlr_xdg_toplevel_v6_show_window_menu_event {
};
struct wlr_xdg_shell_v6 *wlr_xdg_shell_v6_create(struct wl_display *display);
-void wlr_xdg_shell_v6_destroy(struct wlr_xdg_shell_v6 *xdg_shell);
/**
* Send a ping to the surface. If the surface does not respond in a reasonable
diff --git a/types/data_device/wlr_data_device.c b/types/data_device/wlr_data_device.c
index 4c908620..6cd84ec0 100644
--- a/types/data_device/wlr_data_device.c
+++ b/types/data_device/wlr_data_device.c
@@ -262,11 +262,6 @@ static const struct wl_data_device_manager_interface
.get_data_device = data_device_manager_get_data_device,
};
-static void data_device_manager_handle_resource_destroy(
- struct wl_resource *resource) {
- wl_list_remove(wl_resource_get_link(resource));
-}
-
static void data_device_manager_bind(struct wl_client *client,
void *data, uint32_t version, uint32_t id) {
struct wlr_data_device_manager *manager = data;
@@ -278,34 +273,18 @@ static void data_device_manager_bind(struct wl_client *client,
return;
}
wl_resource_set_implementation(resource, &data_device_manager_impl,
- manager, data_device_manager_handle_resource_destroy);
-
- wl_list_insert(&manager->resources, wl_resource_get_link(resource));
+ manager, NULL);
}
-void wlr_data_device_manager_destroy(struct wlr_data_device_manager *manager) {
- if (!manager) {
- return;
- }
+static void handle_display_destroy(struct wl_listener *listener, void *data) {
+ struct wlr_data_device_manager *manager =
+ wl_container_of(listener, manager, display_destroy);
wlr_signal_emit_safe(&manager->events.destroy, manager);
wl_list_remove(&manager->display_destroy.link);
wl_global_destroy(manager->global);
- struct wl_resource *resource, *tmp;
- wl_resource_for_each_safe(resource, tmp, &manager->resources) {
- wl_resource_destroy(resource);
- }
- wl_resource_for_each_safe(resource, tmp, &manager->data_sources) {
- wl_resource_destroy(resource);
- }
free(manager);
}
-static void handle_display_destroy(struct wl_listener *listener, void *data) {
- struct wlr_data_device_manager *manager =
- wl_container_of(listener, manager, display_destroy);
- wlr_data_device_manager_destroy(manager);
-}
-
struct wlr_data_device_manager *wlr_data_device_manager_create(
struct wl_display *display) {
struct wlr_data_device_manager *manager =
@@ -315,7 +294,6 @@ struct wlr_data_device_manager *wlr_data_device_manager_create(
return NULL;
}
- wl_list_init(&manager->resources);
wl_list_init(&manager->data_sources);
wl_signal_init(&manager->events.destroy);
diff --git a/types/tablet_v2/wlr_tablet_v2.c b/types/tablet_v2/wlr_tablet_v2.c
index b470d128..5da94e2e 100644
--- a/types/tablet_v2/wlr_tablet_v2.c
+++ b/types/tablet_v2/wlr_tablet_v2.c
@@ -273,22 +273,8 @@ static void tablet_v2_bind(struct wl_client *wl_client, void *data,
}
static void handle_display_destroy(struct wl_listener *listener, void *data) {
- struct wlr_tablet_manager_v2 *tablet =
- wl_container_of(listener, tablet, display_destroy);
- wlr_tablet_v2_destroy(tablet);
-}
-
-void wlr_tablet_v2_destroy(struct wlr_tablet_manager_v2 *manager) {
- struct wlr_tablet_manager_client_v2 *client, *client_tmp;
- wl_list_for_each_safe(client, client_tmp, &manager->clients, link) {
- wlr_tablet_manager_v2_destroy(client->resource);
- }
-
- struct wlr_tablet_seat_v2 *seat, *seat_tmp;
- wl_list_for_each_safe(seat, seat_tmp, &manager->seats, link) {
- tablet_seat_destroy(seat);
- }
-
+ struct wlr_tablet_manager_v2 *manager =
+ wl_container_of(listener, manager, display_destroy);
wlr_signal_emit_safe(&manager->events.destroy, manager);
wl_list_remove(&manager->display_destroy.link);
wl_global_destroy(manager->wl_global);
diff --git a/types/wlr_compositor.c b/types/wlr_compositor.c
index f3ea8cbb..11f22923 100644
--- a/types/wlr_compositor.c
+++ b/types/wlr_compositor.c
@@ -22,15 +22,6 @@ struct wlr_subsurface *wlr_subsurface_from_wlr_surface(
return (struct wlr_subsurface *)surface->role_data;
}
-static const struct wl_subcompositor_interface subcompositor_impl;
-
-static struct wlr_subcompositor *subcompositor_from_resource(
- struct wl_resource *resource) {
- assert(wl_resource_instance_of(resource, &wl_subcompositor_interface,
- &subcompositor_impl));
- return wl_resource_get_user_data(resource);
-}
-
static void subcompositor_handle_destroy(struct wl_client *client,
struct wl_resource *resource) {
wl_resource_destroy(resource);
@@ -40,8 +31,6 @@ static void subcompositor_handle_get_subsurface(struct wl_client *client,
struct wl_resource *resource, uint32_t id,
struct wl_resource *surface_resource,
struct wl_resource *parent_resource) {
- struct wlr_subcompositor *subcompositor =
- subcompositor_from_resource(resource);
struct wlr_surface *surface = wlr_surface_from_resource(surface_resource);
struct wlr_surface *parent = wlr_surface_from_resource(parent_resource);
@@ -78,7 +67,7 @@ static void subcompositor_handle_get_subsurface(struct wl_client *client,
}
wlr_subsurface_create(surface, parent, wl_resource_get_version(resource),
- id, &subcompositor->subsurface_resources);
+ id, NULL);
}
static const struct wl_subcompositor_interface subcompositor_impl = {
@@ -86,10 +75,6 @@ static const struct wl_subcompositor_interface subcompositor_impl = {
.get_subsurface = subcompositor_handle_get_subsurface,
};
-static void subcompositor_resource_destroy(struct wl_resource *resource) {
- wl_list_remove(wl_resource_get_link(resource));
-}
-
static void subcompositor_bind(struct wl_client *client, void *data,
uint32_t version, uint32_t id) {
struct wlr_subcompositor *subcompositor = data;
@@ -100,33 +85,24 @@ static void subcompositor_bind(struct wl_client *client, void *data,
return;
}
wl_resource_set_implementation(resource, &subcompositor_impl,
- subcompositor, subcompositor_resource_destroy);
- wl_list_insert(&subcompositor->resources, wl_resource_get_link(resource));
+ subcompositor, NULL);
}
-static void subcompositor_init(struct wlr_subcompositor *subcompositor,
+static bool subcompositor_init(struct wlr_subcompositor *subcompositor,
struct wl_display *display) {
subcompositor->global = wl_global_create(display,
&wl_subcompositor_interface, SUBCOMPOSITOR_VERSION, subcompositor,
subcompositor_bind);
if (subcompositor->global == NULL) {
wlr_log_errno(WLR_ERROR, "Could not allocate subcompositor global");
- return;
+ return false;
}
- wl_list_init(&subcompositor->resources);
- wl_list_init(&subcompositor->subsurface_resources);
+
+ return true;
}
static void subcompositor_finish(struct wlr_subcompositor *subcompositor) {
wl_global_destroy(subcompositor->global);
- struct wl_resource *resource, *tmp;
- wl_resource_for_each_safe(resource, tmp,
- &subcompositor->subsurface_resources) {
- wl_resource_destroy(resource);
- }
- wl_resource_for_each_safe(resource, tmp, &subcompositor->resources) {
- wl_resource_destroy(resource);
- }
}
@@ -144,8 +120,7 @@ static void compositor_create_surface(struct wl_client *client,
struct wlr_compositor *compositor = compositor_from_resource(resource);
struct wlr_surface *surface = wlr_surface_create(client,
- wl_resource_get_version(resource), id, compositor->renderer,
- &compositor->surface_resources);
+ wl_resource_get_version(resource), id, compositor->renderer, NULL);
if (surface == NULL) {
wl_client_post_no_memory(client);
return;
@@ -156,9 +131,7 @@ static void compositor_create_surface(struct wl_client *client,
static void compositor_create_region(struct wl_client *client,
struct wl_resource *resource, uint32_t id) {
- struct wlr_compositor *compositor = compositor_from_resource(resource);
-
- wlr_region_create(client, 1, id, &compositor->region_resources);
+ wlr_region_create(client, wl_resource_get_version(resource), id, NULL);
}
static const struct wl_compositor_interface compositor_impl = {
@@ -166,14 +139,9 @@ static const struct wl_compositor_interface compositor_impl = {
.create_region = compositor_create_region,
};
-static void compositor_resource_destroy(struct wl_resource *resource) {
- wl_list_remove(wl_resource_get_link(resource));
-}
-
static void compositor_bind(struct wl_client *wl_client, void *data,
uint32_t version, uint32_t id) {
struct wlr_compositor *compositor = data;
- assert(wl_client && compositor);
struct wl_resource *resource =
wl_resource_create(wl_client, &wl_compositor_interface, version, id);
@@ -181,38 +149,19 @@ static void compositor_bind(struct wl_client *wl_client, void *data,
wl_client_post_no_memory(wl_client);
return;
}
- wl_resource_set_implementation(resource, &compositor_impl,
- compositor, compositor_resource_destroy);
- wl_list_insert(&compositor->resources, wl_resource_get_link(resource));
+ wl_resource_set_implementation(resource, &compositor_impl, compositor, NULL);
}
-void wlr_compositor_destroy(struct wlr_compositor *compositor) {
- if (compositor == NULL) {
- return;
- }
+static void handle_display_destroy(struct wl_listener *listener, void *data) {
+ struct wlr_compositor *compositor =
+ wl_container_of(listener, compositor, display_destroy);
wlr_signal_emit_safe(&compositor->events.destroy, compositor);
subcompositor_finish(&compositor->subcompositor);
wl_list_remove(&compositor->display_destroy.link);
wl_global_destroy(compositor->global);
- struct wl_resource *resource, *tmp;
- wl_resource_for_each_safe(resource, tmp, &compositor->surface_resources) {
- wl_resource_destroy(resource);
- }
- wl_resource_for_each_safe(resource, tmp, &compositor->region_resources) {
- wl_resource_destroy(resource);
- }
- wl_resource_for_each_safe(resource, tmp, &compositor->resources) {
- wl_resource_destroy(resource);
- }
free(compositor);
}
-static void handle_display_destroy(struct wl_listener *listener, void *data) {
- struct wlr_compositor *compositor =
- wl_container_of(listener, compositor, display_destroy);
- wlr_compositor_destroy(compositor);
-}
-
struct wlr_compositor *wlr_compositor_create(struct wl_display *display,
struct wlr_renderer *renderer) {
struct wlr_compositor *compositor =
@@ -231,9 +180,6 @@ struct wlr_compositor *wlr_compositor_create(struct wl_display *display,
}
compositor->renderer = renderer;
- wl_list_init(&compositor->resources);
- wl_list_init(&compositor->surface_resources);
- wl_list_init(&compositor->region_resources);
wl_signal_init(&compositor->events.new_surface);
wl_signal_init(&compositor->events.destroy);
diff --git a/types/wlr_data_control_v1.c b/types/wlr_data_control_v1.c
index 4b1c87fc..239e238a 100644
--- a/types/wlr_data_control_v1.c
+++ b/types/wlr_data_control_v1.c
@@ -650,10 +650,6 @@ static const struct zwlr_data_control_manager_v1_interface manager_impl = {
.destroy = manager_handle_destroy,
};
-static void manager_handle_resource_destroy(struct wl_resource *resource) {
- wl_list_remove(wl_resource_get_link(resource));
-}
-
static void manager_bind(struct wl_client *client, void *data, uint32_t version,
uint32_t id) {
struct wlr_data_control_manager_v1 *manager = data;
@@ -664,16 +660,16 @@ static void manager_bind(struct wl_client *client, void *data, uint32_t version,
wl_client_post_no_memory(client);
return;
}
- wl_resource_set_implementation(resource, &manager_impl, manager,
- manager_handle_resource_destroy);
-
- wl_list_insert(&manager->resources, wl_resource_get_link(resource));
+ wl_resource_set_implementation(resource, &manager_impl, manager, NULL);
}
static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_data_control_manager_v1 *manager =
wl_container_of(listener, manager, display_destroy);
- wlr_data_control_manager_v1_destroy(manager);
+ wlr_signal_emit_safe(&manager->events.destroy, manager);
+ wl_list_remove(&manager->display_destroy.link);
+ wl_global_destroy(manager->global);
+ free(manager);
}
struct wlr_data_control_manager_v1 *wlr_data_control_manager_v1_create(
@@ -683,7 +679,6 @@ struct wlr_data_control_manager_v1 *wlr_data_control_manager_v1_create(
if (manager == NULL) {
return NULL;
}
- wl_list_init(&manager->resources);
wl_list_init(&manager->devices);
wl_signal_init(&manager->events.destroy);
wl_signal_init(&manager->events.new_device);
@@ -701,25 +696,3 @@ struct wlr_data_control_manager_v1 *wlr_data_control_manager_v1_create(
return manager;
}
-
-void wlr_data_control_manager_v1_destroy(
- struct wlr_data_control_manager_v1 *manager) {
- if (manager == NULL) {
- return;
- }
-
- wlr_signal_emit_safe(&manager->events.destroy, manager);
-
- struct wlr_data_control_device_v1 *device, *control_tmp;
- wl_list_for_each_safe(device, control_tmp, &manager->devices, link) {
- wl_resource_destroy(device->resource);
- }
-
- struct wl_resource *resource, *resource_tmp;
- wl_resource_for_each_safe(resource, resource_tmp, &manager->resources) {
- wl_resource_destroy(resource);
- }
-
- wl_list_remove(&manager->display_destroy.link);
- free(manager);
-}
diff --git a/types/wlr_export_dmabuf_v1.c b/types/wlr_export_dmabuf_v1.c
index 80efbdaa..2be9e028 100644
--- a/types/wlr_export_dmabuf_v1.c
+++ b/types/wlr_export_dmabuf_v1.c
@@ -165,10 +165,6 @@ static const struct zwlr_export_dmabuf_manager_v1_interface manager_impl = {
.destroy = manager_handle_destroy,
};
-static void manager_handle_resource_destroy(struct wl_resource *resource) {
- wl_list_remove(wl_resource_get_link(resource));
-}
-
static void manager_bind(struct wl_client *client, void *data, uint32_t version,
uint32_t id) {
struct wlr_export_dmabuf_manager_v1 *manager = data;
@@ -180,15 +176,16 @@ static void manager_bind(struct wl_client *client, void *data, uint32_t version,
return;
}
wl_resource_set_implementation(resource, &manager_impl, manager,
- manager_handle_resource_destroy);
-
- wl_list_insert(&manager->resources, wl_resource_get_link(resource));
+ NULL);
}
static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_export_dmabuf_manager_v1 *manager =
wl_container_of(listener, manager, display_destroy);
- wlr_export_dmabuf_manager_v1_destroy(manager);
+ wlr_signal_emit_safe(&manager->events.destroy, manager);
+ wl_list_remove(&manager->display_destroy.link);
+ wl_global_destroy(manager->global);
+ free(manager);
}
struct wlr_export_dmabuf_manager_v1 *wlr_export_dmabuf_manager_v1_create(
@@ -198,7 +195,6 @@ struct wlr_export_dmabuf_manager_v1 *wlr_export_dmabuf_manager_v1_create(
if (manager == NULL) {
return NULL;
}
- wl_list_init(&manager->resources);
wl_list_init(&manager->frames);
wl_signal_init(&manager->events.destroy);
@@ -215,22 +211,3 @@ struct wlr_export_dmabuf_manager_v1 *wlr_export_dmabuf_manager_v1_create(
return manager;
}
-
-void wlr_export_dmabuf_manager_v1_destroy(
- struct wlr_export_dmabuf_manager_v1 *manager) {
- if (manager == NULL) {
- return;
- }
- wlr_signal_emit_safe(&manager->events.destroy, manager);
- wl_list_remove(&manager->display_destroy.link);
- wl_global_destroy(manager->global);
- struct wl_resource *resource, *resource_tmp;
- wl_resource_for_each_safe(resource, resource_tmp, &manager->resources) {
- wl_resource_destroy(resource);
- }
- struct wlr_export_dmabuf_frame_v1 *frame, *frame_tmp;
- wl_list_for_each_safe(frame, frame_tmp, &manager->frames, link) {
- wl_resource_destroy(frame->resource);
- }
- free(manager);
-}
diff --git a/types/wlr_foreign_toplevel_management_v1.c b/types/wlr_foreign_toplevel_management_v1.c
index 6d256077..aed0e203 100644
--- a/types/wlr_foreign_toplevel_management_v1.c
+++ b/types/wlr_foreign_toplevel_management_v1.c
@@ -568,35 +568,15 @@ static void foreign_toplevel_manager_bind(struct wl_client *client, void *data,
}
}
-void wlr_foreign_toplevel_manager_v1_destroy(
- struct wlr_foreign_toplevel_manager_v1 *manager) {
- if (!manager) {
- return;
- }
-
- struct wlr_foreign_toplevel_handle_v1 *toplevel, *tmp_toplevel;
- wl_list_for_each_safe(toplevel, tmp_toplevel, &manager->toplevels, link) {
- wlr_foreign_toplevel_handle_v1_destroy(toplevel);
- }
-
- struct wl_resource *resource, *tmp_resource;
- wl_resource_for_each_safe(resource, tmp_resource, &manager->resources) {
- wl_resource_destroy(resource);
- }
-
+static void handle_display_destroy(struct wl_listener *listener, void *data) {
+ struct wlr_foreign_toplevel_manager_v1 *manager =
+ wl_container_of(listener, manager, display_destroy);
wlr_signal_emit_safe(&manager->events.destroy, manager);
wl_list_remove(&manager->display_destroy.link);
-
wl_global_destroy(manager->global);
free(manager);
}
-static void handle_display_destroy(struct wl_listener *listener, void *data) {
- struct wlr_foreign_toplevel_manager_v1 *manager =
- wl_container_of(listener, manager, display_destroy);
- wlr_foreign_toplevel_manager_v1_destroy(manager);
-}
-
struct wlr_foreign_toplevel_manager_v1 *wlr_foreign_toplevel_manager_v1_create(
struct wl_display *display) {
struct wlr_foreign_toplevel_manager_v1 *manager = calloc(1,
diff --git a/types/wlr_fullscreen_shell_v1.c b/types/wlr_fullscreen_shell_v1.c
index 5bff72ff..59636e4c 100644
--- a/types/wlr_fullscreen_shell_v1.c
+++ b/types/wlr_fullscreen_shell_v1.c
@@ -63,10 +63,6 @@ static const struct zwp_fullscreen_shell_v1_interface shell_impl = {
.present_surface_for_mode = shell_handle_present_surface_for_mode,
};
-static void shell_handle_resource_destroy(struct wl_resource *resource) {
- wl_list_remove(wl_resource_get_link(resource));
-}
-
static void shell_bind(struct wl_client *client, void *data, uint32_t version,
uint32_t id) {
struct wlr_fullscreen_shell_v1 *shell = data;
@@ -77,16 +73,16 @@ static void shell_bind(struct wl_client *client, void *data, uint32_t version,
wl_client_post_no_memory(client);
return;
}
- wl_resource_set_implementation(resource, &shell_impl, shell,
- shell_handle_resource_destroy);
-
- wl_list_insert(&shell->resources, wl_resource_get_link(resource));
+ wl_resource_set_implementation(resource, &shell_impl, shell, NULL);
}
static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_fullscreen_shell_v1 *shell =
wl_container_of(listener, shell, display_destroy);
- wlr_fullscreen_shell_v1_destroy(shell);
+ wlr_signal_emit_safe(&shell->events.destroy, shell);
+ wl_list_remove(&shell->display_destroy.link);
+ wl_global_destroy(shell->global);
+ free(shell);
}
struct wlr_fullscreen_shell_v1 *wlr_fullscreen_shell_v1_create(
@@ -96,7 +92,6 @@ struct wlr_fullscreen_shell_v1 *wlr_fullscreen_shell_v1_create(
if (shell == NULL) {
return NULL;
}
- wl_list_init(&shell->resources);
wl_signal_init(&shell->events.destroy);
wl_signal_init(&shell->events.present_surface);
@@ -113,17 +108,3 @@ struct wlr_fullscreen_shell_v1 *wlr_fullscreen_shell_v1_create(
return shell;
}
-
-void wlr_fullscreen_shell_v1_destroy(struct wlr_fullscreen_shell_v1 *shell) {
- if (shell == NULL) {
- return;
- }
- wlr_signal_emit_safe(&shell->events.destroy, shell);
- wl_list_remove(&shell->display_destroy.link);
- wl_global_destroy(shell->global);
- struct wl_resource *resource, *resource_tmp;
- wl_resource_for_each_safe(resource, resource_tmp, &shell->resources) {
- wl_resource_destroy(resource);
- }
- free(shell);
-}
diff --git a/types/wlr_gamma_control_v1.c b/types/wlr_gamma_control_v1.c
index 4e8abaf2..7eb5df5b 100644
--- a/types/wlr_gamma_control_v1.c
+++ b/types/wlr_gamma_control_v1.c
@@ -200,11 +200,6 @@ static const struct zwlr_gamma_control_manager_v1_interface
.destroy = gamma_control_manager_destroy,
};
-static void gamma_control_manager_handle_resource_destroy(
- struct wl_resource *resource) {
- wl_list_remove(wl_resource_get_link(resource));
-}
-
static void gamma_control_manager_bind(struct wl_client *client, void *data,
uint32_t version, uint32_t id) {
struct wlr_gamma_control_manager_v1 *manager = data;
@@ -216,35 +211,18 @@ static void gamma_control_manager_bind(struct wl_client *client, void *data,
return;
}
wl_resource_set_implementation(resource, &gamma_control_manager_impl,
- manager, gamma_control_manager_handle_resource_destroy);
- wl_list_insert(&manager->resources, wl_resource_get_link(resource));
+ manager, NULL);
}
-void wlr_gamma_control_manager_v1_destroy(
- struct wlr_gamma_control_manager_v1 *manager) {
- if (!manager) {
- return;
- }
- struct wlr_gamma_control_v1 *gamma_control, *tmp;
- wl_list_for_each_safe(gamma_control, tmp, &manager->controls, link) {
- wl_resource_destroy(gamma_control->resource);
- }
+static void handle_display_destroy(struct wl_listener *listener, void *data) {
+ struct wlr_gamma_control_manager_v1 *manager =
+ wl_container_of(listener, manager, display_destroy);
wlr_signal_emit_safe(&manager->events.destroy, manager);
wl_list_remove(&manager->display_destroy.link);
- struct wl_resource *resource, *resource_tmp;
- wl_resource_for_each_safe(resource, resource_tmp, &manager->resources) {
- wl_resource_destroy(resource);
- }
wl_global_destroy(manager->global);
free(manager);
}
-static void handle_display_destroy(struct wl_listener *listener, void *data) {
- struct wlr_gamma_control_manager_v1 *manager =
- wl_container_of(listener, manager, display_destroy);
- wlr_gamma_control_manager_v1_destroy(manager);
-}
-
struct wlr_gamma_control_manager_v1 *wlr_gamma_control_manager_v1_create(
struct wl_display *display) {
struct wlr_gamma_control_manager_v1 *manager =
@@ -262,7 +240,6 @@ struct wlr_gamma_control_manager_v1 *wlr_gamma_control_manager_v1_create(
}
wl_signal_init(&manager->events.destroy);
- wl_list_init(&manager->resources);
wl_list_init(&manager->controls);
manager->display_destroy.notify = handle_display_destroy;
diff --git a/types/wlr_gtk_primary_selection.c b/types/wlr_gtk_primary_selection.c
index fe50972e..0bf4c70f 100644
--- a/types/wlr_gtk_primary_selection.c
+++ b/types/wlr_gtk_primary_selection.c
@@ -434,11 +434,6 @@ static const struct gtk_primary_selection_device_manager_interface
.destroy = device_manager_handle_destroy,
};
-static void device_manager_handle_resource_destroy(
- struct wl_resource *resource) {
- wl_list_remove(wl_resource_get_link(resource));
-}
-
static void primary_selection_device_manager_bind(struct wl_client *client,
void *data, uint32_t version, uint32_t id) {
@@ -451,15 +446,16 @@ static void primary_selection_device_manager_bind(struct wl_client *client,
return;
}
wl_resource_set_implementation(resource, &device_manager_impl, manager,
- device_manager_handle_resource_destroy);
-
- wl_list_insert(&manager->resources, wl_resource_get_link(resource));
+ NULL);
}
static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_gtk_primary_selection_device_manager *manager =
wl_container_of(listener, manager, display_destroy);
- wlr_gtk_primary_selection_device_manager_destroy(manager);
+ wlr_signal_emit_safe(&manager->events.destroy, manager);
+ wl_list_remove(&manager->display_destroy.link);
+ wl_global_destroy(manager->global);
+ free(manager);
}
struct wlr_gtk_primary_selection_device_manager *
@@ -478,7 +474,6 @@ struct wlr_gtk_primary_selection_device_manager *
return NULL;
}
- wl_list_init(&manager->resources);
wl_list_init(&manager->devices);
wl_signal_init(&manager->events.destroy);
@@ -487,18 +482,3 @@ struct wlr_gtk_primary_selection_device_manager *
return manager;
}
-
-void wlr_gtk_primary_selection_device_manager_destroy(
- struct wlr_gtk_primary_selection_device_manager *manager) {
- if (manager == NULL) {
- return;
- }
- wlr_signal_emit_safe(&manager->events.destroy, manager);
- wl_list_remove(&manager->display_destroy.link);
- struct wl_resource *resource, *resource_tmp;
- wl_resource_for_each_safe(resource, resource_tmp, &manager->resources) {
- wl_resource_destroy(resource);
- }
- wl_global_destroy(manager->global);
- free(manager);
-}
diff --git a/types/wlr_idle.c b/types/wlr_idle.c
index ffa6131f..4c338931 100644
--- a/types/wlr_idle.c
+++ b/types/wlr_idle.c
@@ -210,25 +210,14 @@ static void idle_bind(struct wl_client *wl_client, void *data,
wl_resource_set_implementation(wl_resource, &idle_impl, idle, NULL);
}
-void wlr_idle_destroy(struct wlr_idle *idle) {
- if (!idle) {
- return;
- }
+static void handle_display_destroy(struct wl_listener *listener, void *data) {
+ struct wlr_idle *idle = wl_container_of(listener, idle, display_destroy);
wlr_signal_emit_safe(&idle->events.destroy, idle);
wl_list_remove(&idle->display_destroy.link);
- struct wlr_idle_timeout *timer, *tmp;
- wl_list_for_each_safe(timer, tmp, &idle->idle_timers, link) {
- wlr_idle_timeout_destroy(timer);
- }
wl_global_destroy(idle->global);
free(idle);
}
-static void handle_display_destroy(struct wl_listener *listener, void *data) {
- struct wlr_idle *idle = wl_container_of(listener, idle, display_destroy);
- wlr_idle_destroy(idle);
-}
-
struct wlr_idle *wlr_idle_create(struct wl_display *display) {
struct wlr_idle *idle = calloc(1, sizeof(struct wlr_idle));
if (!idle) {
@@ -249,7 +238,7 @@ struct wlr_idle *wlr_idle_create(struct wl_display *display) {
wl_display_add_destroy_listener(display, &idle->display_destroy);
idle->global = wl_global_create(display, &org_kde_kwin_idle_interface,
- 1, idle, idle_bind);
+ 1, idle, idle_bind);
if (idle->global == NULL) {
wl_list_remove(&idle->display_destroy.link);
free(idle);
diff --git a/types/wlr_idle_inhibit_v1.c b/types/wlr_idle_inhibit_v1.c
index 72b9e540..c4c615d4 100644
--- a/types/wlr_idle_inhibit_v1.c
+++ b/types/wlr_idle_inhibit_v1.c
@@ -98,11 +98,6 @@ static void manager_handle_create_inhibitor(struct wl_client *client,
wlr_signal_emit_safe(&manager->events.new_inhibitor, inhibitor);
}
-static void idle_inhibit_manager_v1_handle_resource_destroy(
- struct wl_resource *resource) {
- wl_list_remove(wl_resource_get_link(resource));
-}
-
static void manager_handle_destroy(struct wl_client *client,
struct wl_resource *manager_resource) {
wl_resource_destroy(manager_resource);
@@ -116,8 +111,10 @@ static const struct zwp_idle_inhibit_manager_v1_interface idle_inhibit_impl = {
static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_idle_inhibit_manager_v1 *idle_inhibit =
wl_container_of(listener, idle_inhibit, display_destroy);
-
- wlr_idle_inhibit_v1_destroy(idle_inhibit);
+ wlr_signal_emit_safe(&idle_inhibit->events.destroy, idle_inhibit);
+ wl_list_remove(&idle_inhibit->display_destroy.link);
+ wl_global_destroy(idle_inhibit->global);
+ free(idle_inhibit);
}
static void idle_inhibit_bind(struct wl_client *wl_client, void *data,
@@ -126,69 +123,36 @@ static void idle_inhibit_bind(struct wl_client *wl_client, void *data,
struct wl_resource *wl_resource = wl_resource_create(wl_client,
&zwp_idle_inhibit_manager_v1_interface, version, id);
-
if (!wl_resource) {
wl_client_post_no_memory(wl_client);
return;
}
- wl_list_insert(&idle_inhibit->resources, wl_resource_get_link(wl_resource));
-
wl_resource_set_implementation(wl_resource, &idle_inhibit_impl,
- idle_inhibit, idle_inhibit_manager_v1_handle_resource_destroy);
- wlr_log(WLR_DEBUG, "idle_inhibit bound");
-}
-
-void wlr_idle_inhibit_v1_destroy(struct wlr_idle_inhibit_manager_v1 *idle_inhibit) {
- if (!idle_inhibit) {
- return;
- }
-
- struct wlr_idle_inhibitor_v1 *inhibitor;
- struct wlr_idle_inhibitor_v1 *tmp;
- wl_list_for_each_safe(inhibitor, tmp, &idle_inhibit->inhibitors, link) {
- idle_inhibitor_v1_destroy(inhibitor);
- }
-
- wlr_signal_emit_safe(&idle_inhibit->events.destroy, idle_inhibit);
- wl_list_remove(&idle_inhibit->display_destroy.link);
-
- struct wl_resource *resource;
- struct wl_resource *tmp_resource;
- wl_resource_for_each_safe(resource, tmp_resource, &idle_inhibit->resources) {
- wl_resource_destroy(resource);
- }
-
- wl_global_destroy(idle_inhibit->global);
- free(idle_inhibit);
+ idle_inhibit, NULL);
}
struct wlr_idle_inhibit_manager_v1 *wlr_idle_inhibit_v1_create(struct wl_display *display) {
struct wlr_idle_inhibit_manager_v1 *idle_inhibit =
calloc(1, sizeof(struct wlr_idle_inhibit_manager_v1));
-
if (!idle_inhibit) {
return NULL;
}
- wl_list_init(&idle_inhibit->resources);
wl_list_init(&idle_inhibit->inhibitors);
- idle_inhibit->display_destroy.notify = handle_display_destroy;
- wl_display_add_destroy_listener(display, &idle_inhibit->display_destroy);
wl_signal_init(&idle_inhibit->events.new_inhibitor);
wl_signal_init(&idle_inhibit->events.destroy);
idle_inhibit->global = wl_global_create(display,
&zwp_idle_inhibit_manager_v1_interface, 1,
idle_inhibit, idle_inhibit_bind);
-
if (!idle_inhibit->global) {
- wl_list_remove(&idle_inhibit->display_destroy.link);
free(idle_inhibit);
return NULL;
}
- wlr_log(WLR_DEBUG, "idle_inhibit manager created");
+ idle_inhibit->display_destroy.notify = handle_display_destroy;
+ wl_display_add_destroy_listener(display, &idle_inhibit->display_destroy);
return idle_inhibit;
}
diff --git a/types/wlr_input_inhibitor.c b/types/wlr_input_inhibitor.c
index 699ec941..2f97b967 100644
--- a/types/wlr_input_inhibitor.c
+++ b/types/wlr_input_inhibitor.c
@@ -103,27 +103,15 @@ static void inhibit_manager_bind(struct wl_client *wl_client, void *data,
input_manager_resource_destroy);
}
-void wlr_input_inhibit_manager_destroy(
- struct wlr_input_inhibit_manager *manager) {
- if (!manager) {
- return;
- }
- if (manager->active_client) {
- input_inhibitor_destroy(manager->active_client,
- manager->active_inhibitor);
- }
+static void handle_display_destroy(struct wl_listener *listener, void *data) {
+ struct wlr_input_inhibit_manager *manager =
+ wl_container_of(listener, manager, display_destroy);
wlr_signal_emit_safe(&manager->events.destroy, manager);
wl_list_remove(&manager->display_destroy.link);
wl_global_destroy(manager->global);
free(manager);
}
-static void handle_display_destroy(struct wl_listener *listener, void *data) {
- struct wlr_input_inhibit_manager *manager =
- wl_container_of(listener, manager, display_destroy);
- wlr_input_inhibit_manager_destroy(manager);
-}
-
struct wlr_input_inhibit_manager *wlr_input_inhibit_manager_create(
struct wl_display *display) {
// TODO: Client destroy
@@ -137,7 +125,6 @@ struct wlr_input_inhibit_manager *wlr_input_inhibit_manager_create(
&zwlr_input_inhibit_manager_v1_interface,
1, manager, inhibit_manager_bind);
if (manager->global == NULL){
- wl_list_remove(&manager->display_destroy.link);
free(manager);
return NULL;
}
diff --git a/types/wlr_input_method_v2.c b/types/wlr_input_method_v2.c
index 6dcc70bc..525b3616 100644
--- a/types/wlr_input_method_v2.c
+++ b/types/wlr_input_method_v2.c
@@ -1,4 +1,4 @@
-#ifndef _POSIX_C_SOURCE
+#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809L
#endif
#include <assert.h>
@@ -232,10 +232,6 @@ static const struct zwp_input_method_manager_v2_interface
.destroy = manager_destroy,
};
-static void input_method_manager_unbind(struct wl_resource *resource) {
- wl_list_remove(wl_resource_get_link(resource));
-}
-
static void input_method_manager_bind(struct wl_client *wl_client, void *data,
uint32_t version, uint32_t id) {
assert(wl_client);
@@ -248,15 +244,16 @@ static void input_method_manager_bind(struct wl_client *wl_client, void *data,
return;
}
wl_resource_set_implementation(bound_resource, &input_method_manager_impl,
- im_manager, input_method_manager_unbind);
- wl_list_insert(&im_manager->bound_resources,
- wl_resource_get_link(bound_resource));
+ im_manager, NULL);
}
static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_input_method_manager_v2 *manager =
wl_container_of(listener, manager, display_destroy);
- wlr_input_method_manager_v2_destroy(manager);
+ wlr_signal_emit_safe(&manager->events.destroy, manager);
+ wl_list_remove(&manager->display_destroy.link);
+ wl_global_destroy(manager->global);
+ free(manager);
}
struct wlr_input_method_manager_v2 *wlr_input_method_manager_v2_create(
@@ -268,32 +265,18 @@ struct wlr_input_method_manager_v2 *wlr_input_method_manager_v2_create(
}
wl_signal_init(&im_manager->events.input_method);
wl_signal_init(&im_manager->events.destroy);
- wl_list_init(&im_manager->bound_resources);
wl_list_init(&im_manager->input_methods);
- im_manager->display_destroy.notify = handle_display_destroy;
- wl_display_add_destroy_listener(display, &im_manager->display_destroy);
-
im_manager->global = wl_global_create(display,
&zwp_input_method_manager_v2_interface, 1, im_manager,
input_method_manager_bind);
- return im_manager;
-}
+ if (!im_manager->global) {
+ free(im_manager);
+ return NULL;
+ }
-void wlr_input_method_manager_v2_destroy(
- struct wlr_input_method_manager_v2 *manager) {
- wlr_signal_emit_safe(&manager->events.destroy, manager);
- wl_list_remove(&manager->display_destroy.link);
+ im_manager->display_destroy.notify = handle_display_destroy;
+ wl_display_add_destroy_listener(display, &im_manager->display_destroy);
- struct wl_resource *resource, *resource_tmp;
- wl_resource_for_each_safe(resource, resource_tmp,
- &manager->bound_resources) {
- wl_resource_destroy(resource);
- }
- struct wlr_input_method_v2 *im, *im_tmp;
- wl_list_for_each_safe(im, im_tmp, &manager->input_methods, link) {
- wl_resource_destroy(im->resource);
- }
- wl_global_destroy(manager->global);
- free(manager);
+ return im_manager;
}
diff --git a/types/wlr_layer_shell_v1.c b/types/wlr_layer_shell_v1.c
index 1b5c426a..46ab1e10 100644
--- a/types/wlr_layer_shell_v1.c
+++ b/types/wlr_layer_shell_v1.c
@@ -441,18 +441,6 @@ static const struct zwlr_layer_shell_v1_interface layer_shell_implementation = {
.get_layer_surface = layer_shell_handle_get_layer_surface,
};
-static void client_handle_destroy(struct wl_resource *resource) {
- struct wl_client *client = wl_resource_get_client(resource);
- struct wlr_layer_shell_v1 *shell = layer_shell_from_resource(resource);
- struct wlr_layer_surface_v1 *surface, *tmp = NULL;
- wl_list_for_each_safe(surface, tmp, &shell->surfaces, link) {
- if (wl_resource_get_client(surface->resource) == client) {
- layer_surface_destroy(surface);
- }
- }
- wl_list_remove(wl_resource_get_link(resource));
-}
-
static void layer_shell_bind(struct wl_client *wl_client, void *data,
uint32_t version, uint32_t id) {
struct wlr_layer_shell_v1 *layer_shell = data;
@@ -465,14 +453,16 @@ static void layer_shell_bind(struct wl_client *wl_client, void *data,
return;
}
wl_resource_set_implementation(resource,
- &layer_shell_implementation, layer_shell, client_handle_destroy);
- wl_list_insert(&layer_shell->resources, wl_resource_get_link(resource));
+ &layer_shell_implementation, layer_shell, NULL);
}
static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_layer_shell_v1 *layer_shell =
wl_container_of(listener, layer_shell, display_destroy);
- wlr_layer_shell_v1_destroy(layer_shell);
+ wlr_signal_emit_safe(&layer_shell->events.destroy, layer_shell);
+ wl_list_remove(&layer_shell->display_destroy.link);
+ wl_global_destroy(layer_shell->global);
+ free(layer_shell);
}
struct wlr_layer_shell_v1 *wlr_layer_shell_v1_create(struct wl_display *display) {
@@ -482,7 +472,6 @@ struct wlr_layer_shell_v1 *wlr_layer_shell_v1_create(struct wl_display *display)
return NULL;
}
- wl_list_init(&layer_shell->resources);
wl_list_init(&layer_shell->surfaces);
struct wl_global *global = wl_global_create(display,
@@ -502,20 +491,6 @@ struct wlr_layer_shell_v1 *wlr_layer_shell_v1_create(struct wl_display *display)
return layer_shell;
}
-void wlr_layer_shell_v1_destroy(struct wlr_layer_shell_v1 *layer_shell) {
- if (!layer_shell) {
- return;
- }
- struct wl_resource *resource, *tmp;
- wl_resource_for_each_safe(resource, tmp, &layer_shell->resources) {
- wl_resource_destroy(resource);
- }
- wlr_signal_emit_safe(&layer_shell->events.destroy, layer_shell);
- wl_list_remove(&layer_shell->display_destroy.link);
- wl_global_destroy(layer_shell->global);
- free(layer_shell);
-}
-
struct layer_surface_iterator_data {
wlr_surface_iterator_func_t user_iterator;
void *user_data;
diff --git a/types/wlr_linux_dmabuf_v1.c b/types/wlr_linux_dmabuf_v1.c
index 76d80b83..7db99eb6 100644
--- a/types/wlr_linux_dmabuf_v1.c
+++ b/types/wlr_linux_dmabuf_v1.c
@@ -422,10 +422,6 @@ static void linux_dmabuf_send_formats(struct wlr_linux_dmabuf_v1 *linux_dmabuf,
}
}
-static void linux_dmabuf_resource_destroy(struct wl_resource *resource) {
- wl_list_remove(wl_resource_get_link(resource));
-}
-
static void linux_dmabuf_bind(struct wl_client *client, void *data,
uint32_t version, uint32_t id) {
struct wlr_linux_dmabuf_v1 *linux_dmabuf = data;
@@ -437,26 +433,16 @@ static void linux_dmabuf_bind(struct wl_client *client, void *data,
return;
}
wl_resource_set_implementation(resource, &linux_dmabuf_impl,
- linux_dmabuf, linux_dmabuf_resource_destroy);
- wl_list_insert(&linux_dmabuf->resources, wl_resource_get_link(resource));
+ linux_dmabuf, NULL);
linux_dmabuf_send_formats(linux_dmabuf, resource, version);
}
-void wlr_linux_dmabuf_v1_destroy(struct wlr_linux_dmabuf_v1 *linux_dmabuf) {
- if (!linux_dmabuf) {
- return;
- }
-
+static void linux_dmabuf_v1_destroy(struct wlr_linux_dmabuf_v1 *linux_dmabuf) {
wlr_signal_emit_safe(&linux_dmabuf->events.destroy, linux_dmabuf);
wl_list_remove(&linux_dmabuf->display_destroy.link);
wl_list_remove(&linux_dmabuf->renderer_destroy.link);
- struct wl_resource *resource, *tmp;
- wl_resource_for_each_safe(resource, tmp, &linux_dmabuf->resources) {
- wl_resource_destroy(resource);
- }
-
wl_global_destroy(linux_dmabuf->global);
free(linux_dmabuf);
}
@@ -464,13 +450,13 @@ void wlr_linux_dmabuf_v1_destroy(struct wlr_linux_dmabuf_v1 *linux_dmabuf) {
static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_linux_dmabuf_v1 *linux_dmabuf =
wl_container_of(listener, linux_dmabuf, display_destroy);
- wlr_linux_dmabuf_v1_destroy(linux_dmabuf);
+ linux_dmabuf_v1_destroy(linux_dmabuf);
}
static void handle_renderer_destroy(struct wl_listener *listener, void *data) {
struct wlr_linux_dmabuf_v1 *linux_dmabuf =
wl_container_of(listener, linux_dmabuf, renderer_destroy);
- wlr_linux_dmabuf_v1_destroy(linux_dmabuf);
+ linux_dmabuf_v1_destroy(linux_dmabuf);
}
struct wlr_linux_dmabuf_v1 *wlr_linux_dmabuf_v1_create(struct wl_display *display,
@@ -483,7 +469,6 @@ struct wlr_linux_dmabuf_v1 *wlr_linux_dmabuf_v1_create(struct wl_display *displa
}
linux_dmabuf->renderer = renderer;
- wl_list_init(&linux_dmabuf->resources);
wl_signal_init(&linux_dmabuf->events.destroy);
linux_dmabuf->global =
diff --git a/types/wlr_pointer_constraints_v1.c b/types/wlr_pointer_constraints_v1.c
index 04e48416..379333d5 100644
--- a/types/wlr_pointer_constraints_v1.c
+++ b/types/wlr_pointer_constraints_v1.c
@@ -267,10 +267,6 @@ static const struct zwp_pointer_constraints_v1_interface
.confine_pointer = pointer_constraints_confine_pointer,
};
-static void pointer_constraints_destroy(struct wl_resource *resource) {
- wl_list_remove(wl_resource_get_link(resource));
-}
-
static void pointer_constraints_bind(struct wl_client *client, void *data,
uint32_t version, uint32_t id) {
struct wlr_pointer_constraints_v1 *pointer_constraints = data;
@@ -283,17 +279,22 @@ static void pointer_constraints_bind(struct wl_client *client, void *data,
return;
}
- wl_list_insert(&pointer_constraints->resources,
- wl_resource_get_link(resource));
wl_resource_set_implementation(resource, &pointer_constraints_impl,
- pointer_constraints, pointer_constraints_destroy);
+ pointer_constraints, NULL);
+}
+
+static void handle_display_destroy(struct wl_listener *listener, void *data) {
+ struct wlr_pointer_constraints_v1 *pointer_constraints =
+ wl_container_of(listener, pointer_constraints, display_destroy);
+ wl_list_remove(&pointer_constraints->display_destroy.link);
+ wl_global_destroy(pointer_constraints->global);
+ free(pointer_constraints);
}
struct wlr_pointer_constraints_v1 *wlr_pointer_constraints_v1_create(
struct wl_display *display) {
struct wlr_pointer_constraints_v1 *pointer_constraints =
calloc(1, sizeof(*pointer_constraints));
-
if (!pointer_constraints) {
return NULL;
}
@@ -307,29 +308,14 @@ struct wlr_pointer_constraints_v1 *wlr_pointer_constraints_v1_create(
}
pointer_constraints->global = wl_global;
- wl_list_init(&pointer_constraints->resources);
wl_list_init(&pointer_constraints->constraints);
wl_signal_init(&pointer_constraints->events.new_constraint);
- return pointer_constraints;
-}
-
-void wlr_pointer_constraints_v1_destroy(
- struct wlr_pointer_constraints_v1 *pointer_constraints) {
- struct wl_resource *resource, *_tmp_res;
- wl_resource_for_each_safe(resource, _tmp_res,
- &pointer_constraints->resources) {
- wl_resource_destroy(resource);
- }
+ pointer_constraints->display_destroy.notify = handle_display_destroy;
+ wl_display_add_destroy_listener(display,
+ &pointer_constraints->display_destroy);
- struct wlr_pointer_constraint_v1 *constraint, *_tmp_cons;
- wl_list_for_each_safe(constraint, _tmp_cons,
- &pointer_constraints->constraints, link) {
- wl_resource_destroy(constraint->resource);
- }
-
- wl_global_destroy(pointer_constraints->global);
- free(pointer_constraints);
+ return pointer_constraints;
}
struct wlr_pointer_constraint_v1 *
diff --git a/types/wlr_pointer_gestures_v1.c b/types/wlr_pointer_gestures_v1.c
index 6d453774..509007a1 100644
--- a/types/wlr_pointer_gestures_v1.c
+++ b/types/wlr_pointer_gestures_v1.c
@@ -287,27 +287,13 @@ static void pointer_gestures_v1_bind(struct wl_client *wl_client, void *data,
}
wl_resource_set_implementation(resource,
- &gestures_impl, gestures, resource_remove_from_list);
- wl_list_insert(&gestures->resources, wl_resource_get_link(resource));
+ &gestures_impl, gestures, NULL);
}
static void handle_display_destroy(struct wl_listener *listener, void *data) {
- struct wlr_pointer_gestures_v1 *tablet =
- wl_container_of(listener, tablet, display_destroy);
- wlr_pointer_gestures_v1_destroy(tablet);
-}
-
-void wlr_pointer_gestures_v1_destroy(struct wlr_pointer_gestures_v1 *gestures) {
- struct wl_resource *resource, *tmp;
- wl_resource_for_each_safe(resource, tmp, &gestures->resources) {
- wl_resource_destroy(resource);
- }
- wl_resource_for_each_safe(resource, tmp, &gestures->swipes) {
- wl_resource_destroy(resource);
- }
- wl_resource_for_each_safe(resource, tmp, &gestures->pinches) {
- wl_resource_destroy(resource);
- }
+ struct wlr_pointer_gestures_v1 *gestures =
+ wl_container_of(listener, gestures, display_destroy);
+ wl_list_remove(&gestures->display_destroy.link);
wl_global_destroy(gestures->global);
free(gestures);
}
@@ -320,7 +306,6 @@ struct wlr_pointer_gestures_v1 *wlr_pointer_gestures_v1_create(
return NULL;
}
- wl_list_init(&gestures->resources);
wl_list_init(&gestures->swipes);
wl_list_init(&gestures->pinches);
diff --git a/types/wlr_presentation_time.c b/types/wlr_presentation_time.c
index 97d24042..8acdcf1c 100644
--- a/types/wlr_presentation_time.c
+++ b/types/wlr_presentation_time.c
@@ -146,10 +146,6 @@ static const struct wp_presentation_interface presentation_impl = {
.destroy = presentation_handle_destroy,
};
-static void presentation_handle_resource_destroy(struct wl_resource *resource) {
- wl_list_remove(wl_resource_get_link(resource));
-}
-
static void presentation_bind(struct wl_client *client, void *data,
uint32_t version, uint32_t id) {
struct wlr_presentation *presentation = data;
@@ -161,8 +157,7 @@ static void presentation_bind(struct wl_client *client, void *data,
return;
}
wl_resource_set_implementation(resource, &presentation_impl, presentation,
- presentation_handle_resource_destroy);
- wl_list_insert(&presentation->resources, wl_resource_get_link(resource));
+ NULL);
wp_presentation_send_clock_id(resource, (uint32_t)presentation->clock);
}
@@ -170,7 +165,10 @@ static void presentation_bind(struct wl_client *client, void *data,
static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_presentation *presentation =
wl_container_of(listener, presentation, display_destroy);
- wlr_presentation_destroy(presentation);
+ wlr_signal_emit_safe(&presentation->events.destroy, presentation);
+ wl_list_remove(&presentation->display_destroy.link);
+ wl_global_destroy(presentation->global);
+ free(presentation);
}
struct wlr_presentation *wlr_presentation_create(struct wl_display *display,
@@ -190,7 +188,6 @@ struct wlr_presentation *wlr_presentation_create(struct wl_display *display,
presentation->clock = wlr_backend_get_presentation_clock(backend);
- wl_list_init(&presentation->resources);
wl_list_init(&presentation->feedbacks);
wl_signal_init(&presentation->events.destroy);
@@ -200,31 +197,6 @@ struct wlr_presentation *wlr_presentation_create(struct wl_display *display,
return presentation;
}
-void wlr_presentation_destroy(struct wlr_presentation *presentation) {
- if (presentation == NULL) {
- return;
- }
-
- wlr_signal_emit_safe(&presentation->events.destroy, presentation);
-
- wl_global_destroy(presentation->global);
-
- struct wlr_presentation_feedback *feedback, *feedback_tmp;
- wl_list_for_each_safe(feedback, feedback_tmp, &presentation->feedbacks,
- link) {
- wlr_presentation_feedback_destroy(feedback);
- }
-
- struct wl_resource *resource, *resource_tmp;
- wl_resource_for_each_safe(resource, resource_tmp,
- &presentation->resources) {
- wl_resource_destroy(resource);
- }
-
- wl_list_remove(&presentation->display_destroy.link);
- free(presentation);
-}
-
void wlr_presentation_feedback_send_presented(
struct wlr_presentation_feedback *feedback,
struct wlr_presentation_event *event) {
diff --git a/types/wlr_primary_selection_v1.c b/types/wlr_primary_selection_v1.c
index e3a6620c..e5f2d01c 100644
--- a/types/wlr_primary_selection_v1.c
+++ b/types/wlr_primary_selection_v1.c
@@ -434,11 +434,6 @@ static const struct zwp_primary_selection_device_manager_v1_interface
.destroy = device_manager_handle_destroy,
};
-static void device_manager_handle_resource_destroy(
- struct wl_resource *resource) {
- wl_list_remove(wl_resource_get_link(resource));
-}
-
static void primary_selection_device_manager_bind(struct wl_client *client,
void *data, uint32_t version, uint32_t id) {
@@ -451,15 +446,16 @@ static void primary_selection_device_manager_bind(struct wl_client *client,
return;
}
wl_resource_set_implementation(resource, &device_manager_impl, manager,
- device_manager_handle_resource_destroy);
-
- wl_list_insert(&manager->resources, wl_resource_get_link(resource));
+ NULL);
}
static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_primary_selection_v1_device_manager *manager =
wl_container_of(listener, manager, display_destroy);
- wlr_primary_selection_v1_device_manager_destroy(manager);
+ wlr_signal_emit_safe(&manager->events.destroy, manager);
+ wl_list_remove(&manager->display_destroy.link);
+ wl_global_destroy(manager->global);
+ free(manager);
}
struct wlr_primary_selection_v1_device_manager *
@@ -478,7 +474,6 @@ struct wlr_primary_selection_v1_device_manager *
return NULL;
}
- wl_list_init(&manager->resources);
wl_list_init(&manager->devices);
wl_signal_init(&manager->events.destroy);
@@ -487,18 +482,3 @@ struct wlr_primary_selection_v1_device_manager *
return manager;
}
-
-void wlr_primary_selection_v1_device_manager_destroy(
- struct wlr_primary_selection_v1_device_manager *manager) {
- if (manager == NULL) {
- return;
- }
- wlr_signal_emit_safe(&manager->events.destroy, manager);
- wl_list_remove(&manager->display_destroy.link);
- struct wl_resource *resource, *resource_tmp;
- wl_resource_for_each_safe(resource, resource_tmp, &manager->resources) {
- wl_resource_destroy(resource);
- }
- wl_global_destroy(manager->global);
- free(manager);
-}
diff --git a/types/wlr_relative_pointer_v1.c b/types/wlr_relative_pointer_v1.c
index 5210e0ce..8613f2b9 100644
--- a/types/wlr_relative_pointer_v1.c
+++ b/types/wlr_relative_pointer_v1.c
@@ -88,11 +88,6 @@ static void relative_pointer_handle_pointer_destroy(struct wl_listener *listener
* relative_pointer_manager handler functions
*/
-static void relative_pointer_manager_v1_handle_resource_destroy(struct wl_resource *resource) {
- wl_list_remove(wl_resource_get_link(resource));
-}
-
-
static void relative_pointer_manager_v1_handle_destroy(struct wl_client *client,
struct wl_resource *resource) {
wl_resource_destroy(resource);
@@ -158,25 +153,22 @@ static void relative_pointer_manager_v1_bind(struct wl_client *wl_client, void *
struct wl_resource *manager_resource = wl_resource_create(wl_client,
&zwp_relative_pointer_manager_v1_interface, version, id);
-
if (manager_resource == NULL) {
wl_client_post_no_memory(wl_client);
return;
}
- wl_list_insert(&manager->resources, wl_resource_get_link(manager_resource));
-
wl_resource_set_implementation(manager_resource, &relative_pointer_manager_v1_impl,
- manager, relative_pointer_manager_v1_handle_resource_destroy);
-
- wlr_log(WLR_DEBUG, "relative_pointer_v1 manager bound to client %p",
- wl_client);
+ manager, NULL);
}
static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_relative_pointer_manager_v1 *manager =
wl_container_of(listener, manager, display_destroy_listener);
- wlr_relative_pointer_manager_v1_destroy(manager);
+ wlr_signal_emit_safe(&manager->events.destroy, manager);
+ wl_list_remove(&manager->display_destroy_listener.link);
+ wl_global_destroy(manager->global);
+ free(manager);
}
@@ -202,18 +194,15 @@ static const struct zwp_relative_pointer_v1_interface relative_pointer_v1_impl =
struct wlr_relative_pointer_manager_v1 *wlr_relative_pointer_manager_v1_create(struct wl_display *display) {
struct wlr_relative_pointer_manager_v1 *manager =
calloc(1, sizeof(struct wlr_relative_pointer_manager_v1));
-
if (manager == NULL) {
return NULL;
}
- wl_list_init(&manager->resources);
wl_list_init(&manager->relative_pointers);
manager->global = wl_global_create(display,
&zwp_relative_pointer_manager_v1_interface, RELATIVE_POINTER_MANAGER_VERSION,
manager, relative_pointer_manager_v1_bind);
-
if (manager->global == NULL) {
free(manager);
return NULL;
@@ -225,31 +214,9 @@ struct wlr_relative_pointer_manager_v1 *wlr_relative_pointer_manager_v1_create(s
manager->display_destroy_listener.notify = handle_display_destroy;
wl_display_add_destroy_listener(display, &manager->display_destroy_listener);
- wlr_log(WLR_DEBUG, "relative_pointer_v1 manager created");
-
return manager;
}
-
-void wlr_relative_pointer_manager_v1_destroy(struct wlr_relative_pointer_manager_v1 *manager) {
- if (manager == NULL) {
- return;
- }
-
- wlr_signal_emit_safe(&manager->events.destroy, manager);
- wl_list_remove(&manager->display_destroy_listener.link);
-
- struct wl_resource *resource;
- struct wl_resource *tmp_resource;
- wl_resource_for_each_safe(resource, tmp_resource, &manager->resources) {
- wl_resource_destroy(resource);
- }
-
- wl_global_destroy(manager->global);
- free(manager);
-}
-
-
void wlr_relative_pointer_manager_v1_send_relative_motion(
struct wlr_relative_pointer_manager_v1 *manager, struct wlr_seat *seat,
uint64_t time_usec, double dx, double dy,
diff --git a/types/wlr_screencopy_v1.c b/types/wlr_screencopy_v1.c
index 0ad93fa4..f0f8f8c9 100644
--- a/types/wlr_screencopy_v1.c
+++ b/types/wlr_screencopy_v1.c
@@ -481,7 +481,6 @@ static void manager_handle_resource_destroy(struct wl_resource *resource) {
struct wlr_screencopy_v1_client *client =
client_from_resource(resource);
client_unref(client);
- wl_list_remove(wl_resource_get_link(resource));
}
static void manager_bind(struct wl_client *wl_client, void *data,
@@ -507,8 +506,6 @@ static void manager_bind(struct wl_client *wl_client, void *data,
wl_resource_set_implementation(resource, &manager_impl, client,
manager_handle_resource_destroy);
- wl_list_insert(&manager->resources, wl_resource_get_link(resource));
-
return;
failure:
free(client);
@@ -518,7 +515,10 @@ failure:
static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_screencopy_manager_v1 *manager =
wl_container_of(listener, manager, display_destroy);
- wlr_screencopy_manager_v1_destroy(manager);
+ wlr_signal_emit_safe(&manager->events.destroy, manager);
+ wl_list_remove(&manager->display_destroy.link);
+ wl_global_destroy(manager->global);
+ free(manager);
}
struct wlr_screencopy_manager_v1 *wlr_screencopy_manager_v1_create(
@@ -536,7 +536,6 @@ struct wlr_screencopy_manager_v1 *wlr_screencopy_manager_v1_create(
free(manager);
return NULL;
}
- wl_list_init(&manager->resources);
wl_list_init(&manager->frames);
wl_signal_init(&manager->events.destroy);
@@ -546,22 +545,3 @@ struct wlr_screencopy_manager_v1 *wlr_screencopy_manager_v1_create(
return manager;
}
-
-void wlr_screencopy_manager_v1_destroy(
- struct wlr_screencopy_manager_v1 *manager) {
- if (manager == NULL) {
- return;
- }
- wlr_signal_emit_safe(&manager->events.destroy, manager);
- wl_list_remove(&manager->display_destroy.link);
- struct wlr_screencopy_frame_v1 *frame, *tmp_frame;
- wl_list_for_each_safe(frame, tmp_frame, &manager->frames, link) {
- wl_resource_destroy(frame->resource);
- }
- struct wl_resource *resource, *tmp_resource;
- wl_resource_for_each_safe(resource, tmp_resource, &manager->resources) {
- wl_resource_destroy(resource);
- }
- wl_global_destroy(manager->global);
- free(manager);
-}
diff --git a/types/wlr_server_decoration.c b/types/wlr_server_decoration.c
index 5a2d2ef5..39ba624a 100644
--- a/types/wlr_server_decoration.c
+++ b/types/wlr_server_decoration.c
@@ -163,32 +163,15 @@ static void server_decoration_manager_bind(struct wl_client *client, void *data,
manager->default_mode);
}
-void wlr_server_decoration_manager_destroy(
- struct wlr_server_decoration_manager *manager) {
- if (manager == NULL) {
- return;
- }
- struct wlr_server_decoration *decoration, *tmp_decoration;
- wl_list_for_each_safe(decoration, tmp_decoration, &manager->decorations,
- link) {
- server_decoration_destroy(decoration);
- }
+static void handle_display_destroy(struct wl_listener *listener, void *data) {
+ struct wlr_server_decoration_manager *manager =
+ wl_container_of(listener, manager, display_destroy);
wlr_signal_emit_safe(&manager->events.destroy, manager);
wl_list_remove(&manager->display_destroy.link);
- struct wl_resource *resource, *tmp_resource;
- wl_resource_for_each_safe(resource, tmp_resource, &manager->resources) {
- server_decoration_manager_destroy_resource(resource);
- }
wl_global_destroy(manager->global);
free(manager);
}
-static void handle_display_destroy(struct wl_listener *listener, void *data) {
- struct wlr_server_decoration_manager *manager =
- wl_container_of(listener, manager, display_destroy);
- wlr_server_decoration_manager_destroy(manager);
-}
-
struct wlr_server_decoration_manager *wlr_server_decoration_manager_create(
struct wl_display *display) {
struct wlr_server_decoration_manager *manager =
diff --git a/types/wlr_text_input_v3.c b/types/wlr_text_input_v3.c
index e8f7a613..66f7be84 100644
--- a/types/wlr_text_input_v3.c
+++ b/types/wlr_text_input_v3.c
@@ -280,10 +280,6 @@ static const struct zwp_text_input_manager_v3_interface
.get_text_input = text_input_manager_get_text_input,
};
-static void text_input_manager_unbind(struct wl_resource *resource) {
- wl_list_remove(wl_resource_get_link(resource));
-}
-
static void text_input_manager_bind(struct wl_client *wl_client, void *data,
uint32_t version, uint32_t id) {
struct wlr_text_input_manager_v3 *manager = data;
@@ -295,43 +291,40 @@ static void text_input_manager_bind(struct wl_client *wl_client, void *data,
wl_client_post_no_memory(wl_client);
return;
}
- wl_list_insert(&manager->bound_resources, wl_resource_get_link(resource));
wl_resource_set_implementation(resource, &text_input_manager_impl,
- manager, text_input_manager_unbind);
+ manager, NULL);
+}
+
+static void handle_display_destroy(struct wl_listener *listener, void *data) {
+ struct wlr_text_input_manager_v3 *manager =
+ wl_container_of(listener, manager, display_destroy);
+ wlr_signal_emit_safe(&manager->events.destroy, manager);
+ wl_list_remove(&manager->display_destroy.link);
+ wl_global_destroy(manager->global);
+ free(manager);
}
struct wlr_text_input_manager_v3 *wlr_text_input_manager_v3_create(
- struct wl_display *wl_display) {
+ struct wl_display *display) {
struct wlr_text_input_manager_v3 *manager =
calloc(1, sizeof(struct wlr_text_input_manager_v3));
- wl_list_init(&manager->bound_resources);
+ if (!manager) {
+ return NULL;
+ }
+
wl_list_init(&manager->text_inputs);
wl_signal_init(&manager->events.text_input);
- manager->global = wl_global_create(wl_display,
+
+ manager->global = wl_global_create(display,
&zwp_text_input_manager_v3_interface, 1, manager,
text_input_manager_bind);
if (!manager->global) {
free(manager);
return NULL;
}
- return manager;
-}
-void wlr_text_input_manager_v3_destroy(
- struct wlr_text_input_manager_v3 *manager) {
- wlr_signal_emit_safe(&manager->events.destroy, manager);
- wl_list_remove(&manager->display_destroy.link);
+ manager->display_destroy.notify = handle_display_destroy;
+ wl_display_add_destroy_listener(display, &manager->display_destroy);
- struct wl_resource *resource, *resource_tmp;
- wl_resource_for_each_safe(resource, resource_tmp,
- &manager->bound_resources) {
- wl_resource_destroy(resource);
- }
- struct wlr_text_input_v3 *text_input, *text_input_tmp;
- wl_list_for_each_safe(text_input, text_input_tmp, &manager->text_inputs,
- link) {
- wl_resource_destroy(text_input->resource);
- }
- wl_global_destroy(manager->global);
- free(manager);
+ return manager;
}
diff --git a/types/wlr_virtual_keyboard_v1.c b/types/wlr_virtual_keyboard_v1.c
index ddd38880..df656367 100644
--- a/types/wlr_virtual_keyboard_v1.c
+++ b/types/wlr_virtual_keyboard_v1.c
@@ -196,31 +196,27 @@ static const struct zwp_virtual_keyboard_manager_v1_interface manager_impl = {
.create_virtual_keyboard = virtual_keyboard_manager_create_virtual_keyboard,
};
-static void handle_manager_unbind(struct wl_resource *resource) {
- wl_list_remove(wl_resource_get_link(resource));
-}
-
static void virtual_keyboard_manager_bind(struct wl_client *client, void *data,
uint32_t version, uint32_t id) {
struct wlr_virtual_keyboard_manager_v1 *manager = data;
struct wl_resource *resource = wl_resource_create(client,
&zwp_virtual_keyboard_manager_v1_interface, version, id);
-
if (!resource) {
wl_client_post_no_memory(client);
return;
}
- wl_resource_set_implementation(resource, &manager_impl, manager,
- handle_manager_unbind);
- wl_list_insert(&manager->resources, wl_resource_get_link(resource));
+ wl_resource_set_implementation(resource, &manager_impl, manager, NULL);
}
static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_virtual_keyboard_manager_v1 *manager =
wl_container_of(listener, manager, display_destroy);
- wlr_virtual_keyboard_manager_v1_destroy(manager);
+ wlr_signal_emit_safe(&manager->events.destroy, manager);
+ wl_list_remove(&manager->display_destroy.link);
+ wl_global_destroy(manager->global);
+ free(manager);
}
struct wlr_virtual_keyboard_manager_v1*
@@ -232,33 +228,21 @@ struct wlr_virtual_keyboard_manager_v1*
return NULL;
}
+ manager->global = wl_global_create(display,
+ &zwp_virtual_keyboard_manager_v1_interface, 1, manager,
+ virtual_keyboard_manager_bind);
+ if (!manager->global) {
+ free(manager);
+ return NULL;
+ }
+
manager->display_destroy.notify = handle_display_destroy;
wl_display_add_destroy_listener(display, &manager->display_destroy);
- wl_list_init(&manager->resources);
wl_list_init(&manager->virtual_keyboards);
wl_signal_init(&manager->events.new_virtual_keyboard);
wl_signal_init(&manager->events.destroy);
- manager->global = wl_global_create(display,
- &zwp_virtual_keyboard_manager_v1_interface, 1, manager,
- virtual_keyboard_manager_bind);
- return manager;
-}
-void wlr_virtual_keyboard_manager_v1_destroy(
- struct wlr_virtual_keyboard_manager_v1 *manager) {
- wlr_signal_emit_safe(&manager->events.destroy, manager);
- wl_list_remove(&manager->display_destroy.link);
- wl_global_destroy(manager->global);
- struct wl_resource *resource, *resource_tmp;
- wl_resource_for_each_safe(resource, resource_tmp, &manager->resources) {
- wl_resource_destroy(resource);
- }
- struct wlr_virtual_keyboard_v1 *keyboard, *keyboard_tmp;
- wl_list_for_each_safe(keyboard, keyboard_tmp, &manager->virtual_keyboards,
- link) {
- wl_resource_destroy(keyboard->resource);
- }
- free(manager);
+ return manager;
}
diff --git a/types/wlr_xdg_decoration_v1.c b/types/wlr_xdg_decoration_v1.c
index 4b5fa61c..e8538097 100644
--- a/types/wlr_xdg_decoration_v1.c
+++ b/types/wlr_xdg_decoration_v1.c
@@ -238,11 +238,6 @@ static const struct zxdg_decoration_manager_v1_interface
.get_toplevel_decoration = decoration_manager_handle_get_toplevel_decoration,
};
-static void decoration_manager_handle_resource_destroy(
- struct wl_resource *resource) {
- wl_list_remove(wl_resource_get_link(resource));
-}
-
static void decoration_manager_bind(struct wl_client *client, void *data,
uint32_t version, uint32_t id) {
struct wlr_xdg_decoration_manager_v1 *manager = data;
@@ -254,15 +249,16 @@ static void decoration_manager_bind(struct wl_client *client, void *data,
return;
}
wl_resource_set_implementation(resource, &decoration_manager_impl,
- manager, decoration_manager_handle_resource_destroy);
-
- wl_list_insert(&manager->resources, wl_resource_get_link(resource));
+ manager, NULL);
}
static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_xdg_decoration_manager_v1 *manager =
wl_container_of(listener, manager, display_destroy);
- wlr_xdg_decoration_manager_v1_destroy(manager);
+ wlr_signal_emit_safe(&manager->events.destroy, manager);
+ wl_list_remove(&manager->display_destroy.link);
+ wl_global_destroy(manager->global);
+ free(manager);
}
struct wlr_xdg_decoration_manager_v1 *
@@ -279,7 +275,6 @@ struct wlr_xdg_decoration_manager_v1 *
free(manager);
return NULL;
}
- wl_list_init(&manager->resources);
wl_list_init(&manager->decorations);
wl_signal_init(&manager->events.new_toplevel_decoration);
wl_signal_init(&manager->events.destroy);
@@ -289,23 +284,3 @@ struct wlr_xdg_decoration_manager_v1 *
return manager;
}
-
-void wlr_xdg_decoration_manager_v1_destroy(
- struct wlr_xdg_decoration_manager_v1 *manager) {
- if (manager == NULL) {
- return;
- }
- wlr_signal_emit_safe(&manager->events.destroy, manager);
- wl_list_remove(&manager->display_destroy.link);
- struct wlr_xdg_toplevel_decoration_v1 *decoration, *tmp_decoration;
- wl_list_for_each_safe(decoration, tmp_decoration, &manager->decorations,
- link) {
- wl_resource_destroy(decoration->resource);
- }
- struct wl_resource *resource, *tmp_resource;
- wl_resource_for_each_safe(resource, tmp_resource, &manager->resources) {
- wl_resource_destroy(resource);
- }
- wl_global_destroy(manager->global);
- free(manager);
-}
diff --git a/types/wlr_xdg_output_v1.c b/types/wlr_xdg_output_v1.c
index 8c481d2a..9e6bcce2 100644
--- a/types/wlr_xdg_output_v1.c
+++ b/types/wlr_xdg_output_v1.c
@@ -142,11 +142,6 @@ static const struct zxdg_output_manager_v1_interface
.get_xdg_output = output_manager_handle_get_xdg_output,
};
-static void output_manager_handle_resource_destroy(
- struct wl_resource *resource) {
- wl_list_remove(wl_resource_get_link(resource));
-}
-
static void output_manager_bind(struct wl_client *wl_client, void *data,
uint32_t version, uint32_t id) {
struct wlr_xdg_output_manager_v1 *manager = data;
@@ -158,8 +153,7 @@ static void output_manager_bind(struct wl_client *wl_client, void *data,
return;
}
wl_resource_set_implementation(resource, &output_manager_implementation,
- manager, output_manager_handle_resource_destroy);
- wl_list_insert(&manager->resources, wl_resource_get_link(resource));
+ manager, NULL);
}
static void handle_output_destroy(struct wl_listener *listener, void *data) {
@@ -203,16 +197,29 @@ static void handle_layout_change(struct wl_listener *listener, void *data) {
output_manager_send_details(manager);
}
+static void manager_destroy(struct wlr_xdg_output_manager_v1 *manager) {
+ wlr_signal_emit_safe(&manager->events.destroy, manager);
+ wl_list_remove(&manager->display_destroy.link);
+ wl_list_remove(&manager->layout_add.link);
+ wl_list_remove(&manager->layout_change.link);
+ wl_list_remove(&manager->layout_destroy.link);
+ free(manager);
+}
+
static void handle_layout_destroy(struct wl_listener *listener, void *data) {
struct wlr_xdg_output_manager_v1 *manager =
wl_container_of(listener, manager, layout_destroy);
- wlr_xdg_output_manager_v1_destroy(manager);
+ manager_destroy(manager);
+}
+
+static void handle_display_destroy(struct wl_listener *listener, void *data) {
+ struct wlr_xdg_output_manager_v1 *manager =
+ wl_container_of(listener, manager, display_destroy);
+ manager_destroy(manager);
}
struct wlr_xdg_output_manager_v1 *wlr_xdg_output_manager_v1_create(
struct wl_display *display, struct wlr_output_layout *layout) {
- assert(display && layout);
-
// TODO: require wayland-protocols 1.18 and remove this condition
int version = OUTPUT_MANAGER_VERSION;
if (version > zxdg_output_manager_v1_interface.version) {
@@ -233,7 +240,6 @@ struct wlr_xdg_output_manager_v1 *wlr_xdg_output_manager_v1_create(
return NULL;
}
- wl_list_init(&manager->resources);
wl_list_init(&manager->outputs);
struct wlr_output_layout_output *layout_output;
wl_list_for_each(layout_output, &layout->outputs, link) {
@@ -248,21 +254,9 @@ struct wlr_xdg_output_manager_v1 *wlr_xdg_output_manager_v1_create(
wl_signal_add(&layout->events.change, &manager->layout_change);
manager->layout_destroy.notify = handle_layout_destroy;
wl_signal_add(&layout->events.destroy, &manager->layout_destroy);
- return manager;
-}
-void wlr_xdg_output_manager_v1_destroy(struct wlr_xdg_output_manager_v1 *manager) {
- struct wlr_xdg_output_v1 *output, *output_tmp;
- wl_list_for_each_safe(output, output_tmp, &manager->outputs, link) {
- output_destroy(output);
- }
- struct wl_resource *resource, *resource_tmp;
- wl_resource_for_each_safe(resource, resource_tmp, &manager->resources) {
- wl_resource_destroy(resource);
- }
- wlr_signal_emit_safe(&manager->events.destroy, manager);
- wl_list_remove(&manager->layout_add.link);
- wl_list_remove(&manager->layout_change.link);
- wl_list_remove(&manager->layout_destroy.link);
- free(manager);
+ manager->display_destroy.notify = handle_display_destroy;
+ wl_display_add_destroy_listener(display, &manager->display_destroy);
+
+ return manager;
}
diff --git a/types/xdg_shell/wlr_xdg_shell.c b/types/xdg_shell/wlr_xdg_shell.c
index 58dc376c..0480d5f3 100644
--- a/types/xdg_shell/wlr_xdg_shell.c
+++ b/types/xdg_shell/wlr_xdg_shell.c
@@ -131,7 +131,10 @@ static void xdg_shell_bind(struct wl_client *wl_client, void *data,
static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_xdg_shell *xdg_shell =
wl_container_of(listener, xdg_shell, display_destroy);
- wlr_xdg_shell_destroy(xdg_shell);
+ wlr_signal_emit_safe(&xdg_shell->events.destroy, xdg_shell);
+ wl_list_remove(&xdg_shell->display_destroy.link);
+ wl_global_destroy(xdg_shell->global);
+ free(xdg_shell);
}
struct wlr_xdg_shell *wlr_xdg_shell_create(struct wl_display *display) {
@@ -162,13 +165,3 @@ struct wlr_xdg_shell *wlr_xdg_shell_create(struct wl_display *display) {
return xdg_shell;
}
-
-void wlr_xdg_shell_destroy(struct wlr_xdg_shell *xdg_shell) {
- if (!xdg_shell) {
- return;
- }
- wlr_signal_emit_safe(&xdg_shell->events.destroy, xdg_shell);
- wl_list_remove(&xdg_shell->display_destroy.link);
- wl_global_destroy(xdg_shell->global);
- free(xdg_shell);
-}
diff --git a/types/xdg_shell_v6/wlr_xdg_shell_v6.c b/types/xdg_shell_v6/wlr_xdg_shell_v6.c
index fce8e96a..fcaa41e1 100644
--- a/types/xdg_shell_v6/wlr_xdg_shell_v6.c
+++ b/types/xdg_shell_v6/wlr_xdg_shell_v6.c
@@ -132,7 +132,10 @@ static void xdg_shell_bind(struct wl_client *wl_client, void *data,
static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_xdg_shell_v6 *xdg_shell =
wl_container_of(listener, xdg_shell, display_destroy);
- wlr_xdg_shell_v6_destroy(xdg_shell);
+ wlr_signal_emit_safe(&xdg_shell->events.destroy, xdg_shell);
+ wl_list_remove(&xdg_shell->display_destroy.link);
+ wl_global_destroy(xdg_shell->global);
+ free(xdg_shell);
}
struct wlr_xdg_shell_v6 *wlr_xdg_shell_v6_create(struct wl_display *display) {
@@ -163,13 +166,3 @@ struct wlr_xdg_shell_v6 *wlr_xdg_shell_v6_create(struct wl_display *display) {
return xdg_shell;
}
-
-void wlr_xdg_shell_v6_destroy(struct wlr_xdg_shell_v6 *xdg_shell) {
- if (!xdg_shell) {
- return;
- }
- wlr_signal_emit_safe(&xdg_shell->events.destroy, xdg_shell);
- wl_list_remove(&xdg_shell->display_destroy.link);
- wl_global_destroy(xdg_shell->global);
- free(xdg_shell);
-}