aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirill Primak <vyivel@eclair.cafe>2023-07-06 21:39:22 +0300
committerSimon Ser <contact@emersion.fr>2023-07-10 10:03:08 +0200
commit7d176b6237b7a043d5b643a21d43b419032750de (patch)
tree820d6c3ef5d3f9f9ffba7bd367e319242a4baee6
parent27edd024f83892f4af9c5084d47b73f26966aaf1 (diff)
subcompositor: don't remove inert role resource
Now that role objects are stored as resources, we can distinguish the inert object case from it being destroyed by the client: - When the resource is destroyed by the client, role_resource == NULL - When the resource is made inert, role_resource != NULL but its user_data is NULL
-rw-r--r--types/wlr_subcompositor.c39
1 files changed, 23 insertions, 16 deletions
diff --git a/types/wlr_subcompositor.c b/types/wlr_subcompositor.c
index 96bedb69..95ddb8ca 100644
--- a/types/wlr_subcompositor.c
+++ b/types/wlr_subcompositor.c
@@ -24,6 +24,22 @@ static bool subsurface_is_synchronized(struct wlr_subsurface *subsurface) {
static const struct wl_subsurface_interface subsurface_implementation;
+static void subsurface_destroy(struct wlr_subsurface *subsurface) {
+ if (subsurface->has_cache) {
+ wlr_surface_unlock_cached(subsurface->surface, subsurface->cached_seq);
+ }
+
+ wl_signal_emit_mutable(&subsurface->events.destroy, subsurface);
+
+ wl_list_remove(&subsurface->surface_client_commit.link);
+ wl_list_remove(&subsurface->current.link);
+ wl_list_remove(&subsurface->pending.link);
+ wl_list_remove(&subsurface->parent_destroy.link);
+
+ wl_resource_set_user_data(subsurface->resource, NULL);
+ free(subsurface);
+}
+
/**
* Get a wlr_subsurface from a wl_subsurface resource.
*
@@ -184,29 +200,20 @@ void subsurface_consider_map(struct wlr_subsurface *subsurface) {
static void subsurface_role_commit(struct wlr_surface *surface) {
struct wlr_subsurface *subsurface = wlr_subsurface_try_from_wlr_surface(surface);
- assert(subsurface != NULL);
+ if (subsurface == NULL) {
+ return;
+ }
subsurface_consider_map(subsurface);
}
static void subsurface_role_destroy(struct wlr_surface *surface) {
struct wlr_subsurface *subsurface = wlr_subsurface_try_from_wlr_surface(surface);
- assert(subsurface != NULL);
-
- if (subsurface->has_cache) {
- wlr_surface_unlock_cached(subsurface->surface,
- subsurface->cached_seq);
+ if (subsurface == NULL) {
+ return;
}
- wl_signal_emit_mutable(&subsurface->events.destroy, subsurface);
-
- wl_list_remove(&subsurface->surface_client_commit.link);
- wl_list_remove(&subsurface->current.link);
- wl_list_remove(&subsurface->pending.link);
- wl_list_remove(&subsurface->parent_destroy.link);
-
- wl_resource_set_user_data(subsurface->resource, NULL);
- free(subsurface);
+ subsurface_destroy(subsurface);
}
const struct wlr_surface_role subsurface_role = {
@@ -221,7 +228,7 @@ static void subsurface_handle_parent_destroy(struct wl_listener *listener,
wl_container_of(listener, subsurface, parent_destroy);
// Once the parent is destroyed, the client has no way to use the
// wl_subsurface object anymore, so we can destroy it.
- wlr_surface_destroy_role_object(subsurface->surface);
+ subsurface_destroy(subsurface);
}
static void subsurface_handle_surface_client_commit(