Simplify globals implementation by removing destructors

Some globals are static and it doesn't make sense to destroy them before
the wl_display. For instance, wl_compositor should be created before the
display is started and shouldn't be destroyed.

For these globals, we can simplify the code by removing the destructor
and stop keeping track of wl_resources (these will be destroyed with the
wl_display by libwayland).
This commit is contained in:
Simon Ser 2019-11-16 18:31:33 +01:00 committed by Drew DeVault
parent bcd5f7d259
commit 5cde35923c
57 changed files with 216 additions and 846 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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;
@ -162,11 +161,6 @@ struct wlr_drag_drop_event {
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

View file

@ -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

View file

@ -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);

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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.

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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(

View file

@ -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

View file

@ -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.
*

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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,

View file

@ -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

View file

@ -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

View file

@ -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,

View file

@ -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

View file

@ -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);

View file

@ -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