aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/types/wlr_xdg_shell.h1
-rw-r--r--include/wlr/types/wlr_xdg_shell.h1
-rw-r--r--types/xdg_shell/wlr_xdg_popup.c3
-rw-r--r--types/xdg_shell/wlr_xdg_shell.c2
-rw-r--r--types/xdg_shell/wlr_xdg_surface.c37
-rw-r--r--types/xdg_shell/wlr_xdg_toplevel.c1
6 files changed, 20 insertions, 25 deletions
diff --git a/include/types/wlr_xdg_shell.h b/include/types/wlr_xdg_shell.h
index 37ef2a95..ddff7b6f 100644
--- a/include/types/wlr_xdg_shell.h
+++ b/include/types/wlr_xdg_shell.h
@@ -17,6 +17,7 @@ void destroy_xdg_surface(struct wlr_xdg_surface *surface);
void xdg_surface_role_commit(struct wlr_surface *wlr_surface);
void xdg_surface_role_precommit(struct wlr_surface *wlr_surface,
const struct wlr_surface_state *state);
+void xdg_surface_role_destroy(struct wlr_surface *wlr_surface);
void create_xdg_positioner(struct wlr_xdg_client *client, uint32_t id);
diff --git a/include/wlr/types/wlr_xdg_shell.h b/include/wlr/types/wlr_xdg_shell.h
index f54f74e2..f2aae252 100644
--- a/include/wlr/types/wlr_xdg_shell.h
+++ b/include/wlr/types/wlr_xdg_shell.h
@@ -258,7 +258,6 @@ struct wlr_xdg_surface {
struct wlr_xdg_surface_state current, pending;
- struct wl_listener surface_destroy;
struct wl_listener surface_commit;
struct {
diff --git a/types/xdg_shell/wlr_xdg_popup.c b/types/xdg_shell/wlr_xdg_popup.c
index d0b83201..184c03fd 100644
--- a/types/xdg_shell/wlr_xdg_popup.c
+++ b/types/xdg_shell/wlr_xdg_popup.c
@@ -191,7 +191,7 @@ static void destroy_xdg_popup_grab(struct wlr_xdg_popup_grab *xdg_grab) {
struct wlr_xdg_popup *popup, *tmp;
wl_list_for_each_safe(popup, tmp, &xdg_grab->popups, grab_link) {
- destroy_xdg_surface(popup->base);
+ wlr_surface_destroy_role_object(popup->base->surface);
}
wl_list_remove(&xdg_grab->link);
@@ -361,6 +361,7 @@ const struct wlr_surface_role xdg_popup_surface_role = {
.name = "xdg_popup",
.commit = xdg_surface_role_commit,
.precommit = xdg_surface_role_precommit,
+ .destroy = xdg_surface_role_destroy,
};
void create_xdg_popup(struct wlr_xdg_surface *surface,
diff --git a/types/xdg_shell/wlr_xdg_shell.c b/types/xdg_shell/wlr_xdg_shell.c
index 69c9a696..70b777dd 100644
--- a/types/xdg_shell/wlr_xdg_shell.c
+++ b/types/xdg_shell/wlr_xdg_shell.c
@@ -67,7 +67,7 @@ static void xdg_client_handle_resource_destroy(struct wl_resource *resource) {
struct wlr_xdg_surface *surface, *tmp = NULL;
wl_list_for_each_safe(surface, tmp, &client->surfaces, link) {
- destroy_xdg_surface(surface);
+ wlr_surface_destroy_role_object(surface->surface);
}
if (client->ping_timer != NULL) {
diff --git a/types/xdg_shell/wlr_xdg_surface.c b/types/xdg_shell/wlr_xdg_surface.c
index ae0dfcc1..b643f21c 100644
--- a/types/xdg_shell/wlr_xdg_surface.c
+++ b/types/xdg_shell/wlr_xdg_surface.c
@@ -256,7 +256,7 @@ static void xdg_surface_handle_resource_destroy(struct wl_resource *resource) {
struct wlr_xdg_surface *surface =
wlr_xdg_surface_from_resource(resource);
if (surface != NULL) {
- destroy_xdg_surface(surface);
+ wlr_surface_destroy_role_object(surface->surface);
}
}
@@ -331,11 +331,20 @@ void xdg_surface_role_precommit(struct wlr_surface *wlr_surface,
}
}
-static void xdg_surface_handle_surface_destroy(struct wl_listener *listener,
- void *data) {
- struct wlr_xdg_surface *xdg_surface =
- wl_container_of(listener, xdg_surface, surface_destroy);
- destroy_xdg_surface(xdg_surface);
+void xdg_surface_role_destroy(struct wlr_surface *wlr_surface) {
+ struct wlr_xdg_surface *surface =
+ wlr_xdg_surface_from_wlr_surface(wlr_surface);
+ if (surface == NULL) {
+ return;
+ }
+
+ reset_xdg_surface(surface);
+
+ wl_list_remove(&surface->link);
+ wl_list_remove(&surface->surface_commit.link);
+
+ wl_resource_set_user_data(surface->resource, NULL);
+ free(surface);
}
struct wlr_xdg_surface *create_xdg_surface(
@@ -380,10 +389,6 @@ struct wlr_xdg_surface *create_xdg_surface(
wl_signal_init(&surface->events.configure);
wl_signal_init(&surface->events.ack_configure);
- wl_signal_add(&surface->surface->events.destroy,
- &surface->surface_destroy);
- surface->surface_destroy.notify = xdg_surface_handle_surface_destroy;
-
wl_signal_add(&surface->surface->events.commit,
&surface->surface_commit);
surface->surface_commit.notify = xdg_surface_handle_surface_commit;
@@ -425,18 +430,6 @@ void reset_xdg_surface(struct wlr_xdg_surface *surface) {
surface->role = WLR_XDG_SURFACE_ROLE_NONE;
}
-void destroy_xdg_surface(struct wlr_xdg_surface *surface) {
- reset_xdg_surface(surface);
-
- wl_resource_set_user_data(surface->resource, NULL);
- surface->surface->role_data = NULL;
-
- wl_list_remove(&surface->link);
- wl_list_remove(&surface->surface_destroy.link);
- wl_list_remove(&surface->surface_commit.link);
- free(surface);
-}
-
struct wlr_xdg_surface *wlr_xdg_surface_from_resource(
struct wl_resource *resource) {
assert(wl_resource_instance_of(resource, &xdg_surface_interface,
diff --git a/types/xdg_shell/wlr_xdg_toplevel.c b/types/xdg_shell/wlr_xdg_toplevel.c
index 54309f96..a3d7f2ef 100644
--- a/types/xdg_shell/wlr_xdg_toplevel.c
+++ b/types/xdg_shell/wlr_xdg_toplevel.c
@@ -453,6 +453,7 @@ const struct wlr_surface_role xdg_toplevel_surface_role = {
.name = "xdg_toplevel",
.commit = xdg_surface_role_commit,
.precommit = xdg_surface_role_precommit,
+ .destroy = xdg_surface_role_destroy,
};
void create_xdg_toplevel(struct wlr_xdg_surface *surface,