aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirill Primak <vyivel@eclair.cafe>2022-11-02 23:44:30 +0300
committerKirill Primak <vyivel@eclair.cafe>2022-11-06 14:16:05 +0300
commit756260ac0580be4cb760b97fa6853fca983ac3c3 (patch)
tree8dfe42bc43228ed6596aacd6679025998ee72d5d
parent1243a855d426aefe5bcf4f9dd7e7d7ac8e46b1c8 (diff)
compositor: introduce wlr_surface_destroy_role_object()
-rw-r--r--include/wlr/types/wlr_compositor.h10
-rw-r--r--types/wlr_compositor.c12
2 files changed, 20 insertions, 2 deletions
diff --git a/include/wlr/types/wlr_compositor.h b/include/wlr/types/wlr_compositor.h
index 50a401ba..f3da622b 100644
--- a/include/wlr/types/wlr_compositor.h
+++ b/include/wlr/types/wlr_compositor.h
@@ -76,6 +76,7 @@ struct wlr_surface_role {
void (*commit)(struct wlr_surface *surface);
void (*precommit)(struct wlr_surface *surface,
const struct wlr_surface_state *state);
+ void (*destroy)(struct wlr_surface *surface);
};
struct wlr_surface_output {
@@ -189,8 +190,13 @@ typedef void (*wlr_surface_iterator_func_t)(struct wlr_surface *surface,
* the role cannot be set.
*/
bool wlr_surface_set_role(struct wlr_surface *surface,
- const struct wlr_surface_role *role, void *role_data,
- struct wl_resource *error_resource, uint32_t error_code);
+ const struct wlr_surface_role *role, void *role_data,
+ struct wl_resource *error_resource, uint32_t error_code);
+
+/**
+ * Destroy the role object for this surface. This doesn't reset the role.
+ */
+void wlr_surface_destroy_role_object(struct wlr_surface *surface);
/**
* Whether or not this surface currently has an attached buffer. A surface has
diff --git a/types/wlr_compositor.c b/types/wlr_compositor.c
index 03acb6ec..302d7b4a 100644
--- a/types/wlr_compositor.c
+++ b/types/wlr_compositor.c
@@ -622,6 +622,8 @@ static void surface_handle_resource_destroy(struct wl_resource *resource) {
surface_output_destroy(surface_output);
}
+ wlr_surface_destroy_role_object(surface);
+
wl_signal_emit_mutable(&surface->events.destroy, surface);
wlr_addon_set_finish(&surface->addons);
@@ -732,6 +734,16 @@ bool wlr_surface_set_role(struct wlr_surface *surface,
return true;
}
+void wlr_surface_destroy_role_object(struct wlr_surface *surface) {
+ if (surface->role_data == NULL) {
+ return;
+ }
+ if (surface->role->destroy != NULL) {
+ surface->role->destroy(surface);
+ }
+ surface->role_data = NULL;
+}
+
uint32_t wlr_surface_lock_pending(struct wlr_surface *surface) {
surface->pending.cached_state_locks++;
return surface->pending.seq;