aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirill Primak <vyivel@eclair.cafe>2022-02-05 10:29:42 +0300
committerSimon Ser <contact@emersion.fr>2022-02-21 17:26:51 +0000
commitb5b15b26258bc5e29736b3eb0268fa460acc9dd0 (patch)
treeaebf82facaa75ea7c46db0e87af7916e6958241c
parentedfb332b24a2a1e014de10eba1c5bf2b84538d2f (diff)
xdg-{toplevel,popup}: extract destructors
-rw-r--r--include/types/wlr_xdg_shell.h2
-rw-r--r--types/xdg_shell/wlr_xdg_popup.c6
-rw-r--r--types/xdg_shell/wlr_xdg_surface.c8
-rw-r--r--types/xdg_shell/wlr_xdg_toplevel.c5
4 files changed, 15 insertions, 6 deletions
diff --git a/include/types/wlr_xdg_shell.h b/include/types/wlr_xdg_shell.h
index c0f97798..1ad6b0ae 100644
--- a/include/types/wlr_xdg_shell.h
+++ b/include/types/wlr_xdg_shell.h
@@ -31,11 +31,13 @@ void create_xdg_popup(struct wlr_xdg_surface *surface,
struct wlr_xdg_surface *parent,
struct wlr_xdg_positioner_resource *positioner, uint32_t id);
void unmap_xdg_popup(struct wlr_xdg_popup *popup);
+void destroy_xdg_popup(struct wlr_xdg_popup *popup);
void handle_xdg_popup_committed(struct wlr_xdg_popup *popup);
void create_xdg_toplevel(struct wlr_xdg_surface *surface,
uint32_t id);
void unmap_xdg_toplevel(struct wlr_xdg_toplevel *toplevel);
+void destroy_xdg_toplevel(struct wlr_xdg_toplevel *toplevel);
void handle_xdg_toplevel_committed(struct wlr_xdg_toplevel *toplevel);
struct wlr_xdg_toplevel_configure *send_xdg_toplevel_configure(
struct wlr_xdg_toplevel *toplevel);
diff --git a/types/xdg_shell/wlr_xdg_popup.c b/types/xdg_shell/wlr_xdg_popup.c
index d923e923..eba829cc 100644
--- a/types/xdg_shell/wlr_xdg_popup.c
+++ b/types/xdg_shell/wlr_xdg_popup.c
@@ -389,6 +389,12 @@ void unmap_xdg_popup(struct wlr_xdg_popup *popup) {
}
}
+void destroy_xdg_popup(struct wlr_xdg_popup *popup) {
+ wl_list_remove(&popup->link);
+ wl_resource_set_user_data(popup->resource, NULL);
+ free(popup);
+}
+
void wlr_xdg_popup_destroy(struct wlr_xdg_popup *popup) {
if (popup == NULL) {
return;
diff --git a/types/xdg_shell/wlr_xdg_surface.c b/types/xdg_shell/wlr_xdg_surface.c
index a9f7aa82..e65c6afd 100644
--- a/types/xdg_shell/wlr_xdg_surface.c
+++ b/types/xdg_shell/wlr_xdg_surface.c
@@ -411,15 +411,11 @@ void reset_xdg_surface(struct wlr_xdg_surface *surface) {
switch (surface->role) {
case WLR_XDG_SURFACE_ROLE_TOPLEVEL:
- wl_resource_set_user_data(surface->toplevel->resource, NULL);
- free(surface->toplevel);
+ destroy_xdg_toplevel(surface->toplevel);
surface->toplevel = NULL;
break;
case WLR_XDG_SURFACE_ROLE_POPUP:
- wl_list_remove(&surface->popup->link);
-
- wl_resource_set_user_data(surface->popup->resource, NULL);
- free(surface->popup);
+ destroy_xdg_popup(surface->popup);
surface->popup = NULL;
break;
case WLR_XDG_SURFACE_ROLE_NONE:
diff --git a/types/xdg_shell/wlr_xdg_toplevel.c b/types/xdg_shell/wlr_xdg_toplevel.c
index ad2f0501..ed304cfc 100644
--- a/types/xdg_shell/wlr_xdg_toplevel.c
+++ b/types/xdg_shell/wlr_xdg_toplevel.c
@@ -493,6 +493,11 @@ void unmap_xdg_toplevel(struct wlr_xdg_toplevel *toplevel) {
toplevel->requested.minimized = false;
}
+void destroy_xdg_toplevel(struct wlr_xdg_toplevel *toplevel) {
+ wl_resource_set_user_data(toplevel->resource, NULL);
+ free(toplevel);
+}
+
void wlr_xdg_toplevel_send_close(struct wlr_xdg_toplevel *toplevel) {
xdg_toplevel_send_close(toplevel->resource);
}