mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-25 22:25:58 +01:00
subcompositor: destroy subsurface with parent
When the parent surface is destroyed, also destroy the child wl_subsurface. No need to handle the wlr_subsurface.parent == NULL case anymore. Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/1709
This commit is contained in:
parent
7ce966a5d4
commit
1d1b845410
2 changed files with 13 additions and 30 deletions
|
@ -789,9 +789,6 @@ struct wlr_surface *wlr_surface_get_root_surface(struct wlr_surface *surface) {
|
|||
if (subsurface == NULL) {
|
||||
break;
|
||||
}
|
||||
if (subsurface->parent == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
surface = subsurface->parent;
|
||||
}
|
||||
return surface;
|
||||
|
|
|
@ -14,10 +14,6 @@ static bool subsurface_is_synchronized(struct wlr_subsurface *subsurface) {
|
|||
return true;
|
||||
}
|
||||
|
||||
if (!subsurface->parent) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!wlr_surface_is_subsurface(subsurface->parent)) {
|
||||
break;
|
||||
}
|
||||
|
@ -45,12 +41,9 @@ static void subsurface_destroy(struct wlr_subsurface *subsurface) {
|
|||
|
||||
wl_list_remove(&subsurface->surface_destroy.link);
|
||||
wl_list_remove(&subsurface->surface_client_commit.link);
|
||||
|
||||
if (subsurface->parent) {
|
||||
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);
|
||||
if (subsurface->surface) {
|
||||
|
@ -64,8 +57,8 @@ static const struct wl_subsurface_interface subsurface_implementation;
|
|||
/**
|
||||
* Get a wlr_subsurface from a wl_subsurface resource.
|
||||
*
|
||||
* Returns NULL if the subsurface is inert (e.g. the wl_surface object got
|
||||
* destroyed).
|
||||
* Returns NULL if the subsurface is inert (e.g. the wl_surface object or the
|
||||
* parent surface got destroyed).
|
||||
*/
|
||||
static struct wlr_subsurface *subsurface_from_resource(
|
||||
struct wl_resource *resource) {
|
||||
|
@ -227,18 +220,13 @@ static void subsurface_consider_map(struct wlr_subsurface *subsurface,
|
|||
return;
|
||||
}
|
||||
|
||||
if (check_parent) {
|
||||
if (subsurface->parent == NULL) {
|
||||
return;
|
||||
}
|
||||
if (wlr_surface_is_subsurface(subsurface->parent)) {
|
||||
if (check_parent && wlr_surface_is_subsurface(subsurface->parent)) {
|
||||
struct wlr_subsurface *parent =
|
||||
wlr_subsurface_from_wlr_surface(subsurface->parent);
|
||||
if (parent == NULL || !parent->mapped) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now we can map the subsurface
|
||||
wlr_signal_emit_safe(&subsurface->events.map, subsurface);
|
||||
|
@ -310,11 +298,9 @@ static void subsurface_handle_parent_destroy(struct wl_listener *listener,
|
|||
void *data) {
|
||||
struct wlr_subsurface *subsurface =
|
||||
wl_container_of(listener, subsurface, parent_destroy);
|
||||
subsurface_unmap(subsurface);
|
||||
wl_list_remove(&subsurface->current.link);
|
||||
wl_list_remove(&subsurface->pending.link);
|
||||
wl_list_remove(&subsurface->parent_destroy.link);
|
||||
subsurface->parent = NULL;
|
||||
// Once the parent is destroyed, the client has no way to use the
|
||||
// wl_subsurface object anymore, so we can destroy it.
|
||||
subsurface_destroy(subsurface);
|
||||
}
|
||||
|
||||
static void subsurface_handle_surface_destroy(struct wl_listener *listener,
|
||||
|
|
Loading…
Reference in a new issue