aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/wlr/types/wlr_subcompositor.h3
-rw-r--r--types/scene/subsurface_tree.c31
-rw-r--r--types/wlr_compositor.c8
-rw-r--r--types/wlr_subcompositor.c61
4 files changed, 37 insertions, 66 deletions
diff --git a/include/wlr/types/wlr_subcompositor.h b/include/wlr/types/wlr_subcompositor.h
index c292ea0c..d20fef94 100644
--- a/include/wlr/types/wlr_subcompositor.h
+++ b/include/wlr/types/wlr_subcompositor.h
@@ -37,7 +37,6 @@ struct wlr_subsurface {
bool synchronized;
bool reordered;
- bool mapped;
bool added;
struct wl_listener surface_client_commit;
@@ -45,8 +44,6 @@ struct wlr_subsurface {
struct {
struct wl_signal destroy;
- struct wl_signal map;
- struct wl_signal unmap;
} events;
void *data;
diff --git a/types/scene/subsurface_tree.c b/types/scene/subsurface_tree.c
index 87cbfb5f..4c37e5b1 100644
--- a/types/scene/subsurface_tree.c
+++ b/types/scene/subsurface_tree.c
@@ -18,6 +18,8 @@ struct wlr_scene_subsurface_tree {
struct wl_listener tree_destroy;
struct wl_listener surface_destroy;
struct wl_listener surface_commit;
+ struct wl_listener surface_map;
+ struct wl_listener surface_unmap;
struct wl_listener surface_new_subsurface;
struct wlr_scene_subsurface_tree *parent; // NULL for the top-level surface
@@ -27,8 +29,6 @@ struct wlr_scene_subsurface_tree {
struct wlr_addon surface_addon;
struct wl_listener subsurface_destroy;
- struct wl_listener subsurface_map;
- struct wl_listener subsurface_unmap;
};
static void subsurface_tree_handle_tree_destroy(struct wl_listener *listener,
@@ -39,12 +39,12 @@ static void subsurface_tree_handle_tree_destroy(struct wl_listener *listener,
if (subsurface_tree->parent) {
wlr_addon_finish(&subsurface_tree->surface_addon);
wl_list_remove(&subsurface_tree->subsurface_destroy.link);
- wl_list_remove(&subsurface_tree->subsurface_map.link);
- wl_list_remove(&subsurface_tree->subsurface_unmap.link);
}
wl_list_remove(&subsurface_tree->tree_destroy.link);
wl_list_remove(&subsurface_tree->surface_destroy.link);
wl_list_remove(&subsurface_tree->surface_commit.link);
+ wl_list_remove(&subsurface_tree->surface_map.link);
+ wl_list_remove(&subsurface_tree->surface_unmap.link);
wl_list_remove(&subsurface_tree->surface_new_subsurface.link);
free(subsurface_tree);
}
@@ -121,18 +121,18 @@ static void subsurface_tree_handle_subsurface_destroy(struct wl_listener *listen
wlr_scene_node_destroy(&subsurface_tree->tree->node);
}
-static void subsurface_tree_handle_subsurface_map(struct wl_listener *listener,
+static void subsurface_tree_handle_surface_map(struct wl_listener *listener,
void *data) {
struct wlr_scene_subsurface_tree *subsurface_tree =
- wl_container_of(listener, subsurface_tree, subsurface_map);
+ wl_container_of(listener, subsurface_tree, surface_map);
wlr_scene_node_set_enabled(&subsurface_tree->tree->node, true);
}
-static void subsurface_tree_handle_subsurface_unmap(struct wl_listener *listener,
+static void subsurface_tree_handle_surface_unmap(struct wl_listener *listener,
void *data) {
struct wlr_scene_subsurface_tree *subsurface_tree =
- wl_container_of(listener, subsurface_tree, subsurface_unmap);
+ wl_container_of(listener, subsurface_tree, surface_unmap);
wlr_scene_node_set_enabled(&subsurface_tree->tree->node, false);
}
@@ -161,7 +161,6 @@ static bool subsurface_tree_create_subsurface(
}
child->parent = parent;
- wlr_scene_node_set_enabled(&child->tree->node, subsurface->mapped);
wlr_addon_init(&child->surface_addon, &subsurface->surface->addons,
parent, &subsurface_tree_addon_impl);
@@ -169,12 +168,6 @@ static bool subsurface_tree_create_subsurface(
child->subsurface_destroy.notify = subsurface_tree_handle_subsurface_destroy;
wl_signal_add(&subsurface->events.destroy, &child->subsurface_destroy);
- child->subsurface_map.notify = subsurface_tree_handle_subsurface_map;
- wl_signal_add(&subsurface->events.map, &child->subsurface_map);
-
- child->subsurface_unmap.notify = subsurface_tree_handle_subsurface_unmap;
- wl_signal_add(&subsurface->events.unmap, &child->subsurface_unmap);
-
return true;
}
@@ -235,11 +228,19 @@ static struct wlr_scene_subsurface_tree *scene_surface_tree_create(
subsurface_tree->surface_commit.notify = subsurface_tree_handle_surface_commit;
wl_signal_add(&surface->events.commit, &subsurface_tree->surface_commit);
+ subsurface_tree->surface_map.notify = subsurface_tree_handle_surface_map;
+ wl_signal_add(&surface->events.map, &subsurface_tree->surface_map);
+
+ subsurface_tree->surface_unmap.notify = subsurface_tree_handle_surface_unmap;
+ wl_signal_add(&surface->events.unmap, &subsurface_tree->surface_unmap);
+
subsurface_tree->surface_new_subsurface.notify =
subsurface_tree_handle_surface_new_subsurface;
wl_signal_add(&surface->events.new_subsurface,
&subsurface_tree->surface_new_subsurface);
+ wlr_scene_node_set_enabled(&subsurface_tree->tree->node, surface->mapped);
+
return subsurface_tree;
error_scene_surface:
diff --git a/types/wlr_compositor.c b/types/wlr_compositor.c
index 0411f547..c24bca67 100644
--- a/types/wlr_compositor.c
+++ b/types/wlr_compositor.c
@@ -859,7 +859,7 @@ struct wlr_surface *wlr_surface_surface_at(struct wlr_surface *surface,
struct wlr_subsurface *subsurface;
wl_list_for_each_reverse(subsurface, &surface->current.subsurfaces_above,
current.link) {
- if (!subsurface->mapped) {
+ if (!subsurface->surface->mapped) {
continue;
}
@@ -884,7 +884,7 @@ struct wlr_surface *wlr_surface_surface_at(struct wlr_surface *surface,
wl_list_for_each_reverse(subsurface, &surface->current.subsurfaces_below,
current.link) {
- if (!subsurface->mapped) {
+ if (!subsurface->surface->mapped) {
continue;
}
@@ -994,7 +994,7 @@ static void surface_for_each_surface(struct wlr_surface *surface, int x, int y,
wlr_surface_iterator_func_t iterator, void *user_data) {
struct wlr_subsurface *subsurface;
wl_list_for_each(subsurface, &surface->current.subsurfaces_below, current.link) {
- if (!subsurface->mapped) {
+ if (!subsurface->surface->mapped) {
continue;
}
@@ -1009,7 +1009,7 @@ static void surface_for_each_surface(struct wlr_surface *surface, int x, int y,
iterator(surface, x, y, user_data);
wl_list_for_each(subsurface, &surface->current.subsurfaces_above, current.link) {
- if (!subsurface->mapped) {
+ if (!subsurface->surface->mapped) {
continue;
}
diff --git a/types/wlr_subcompositor.c b/types/wlr_subcompositor.c
index c18a2335..42c86064 100644
--- a/types/wlr_subcompositor.c
+++ b/types/wlr_subcompositor.c
@@ -22,8 +22,6 @@ static bool subsurface_is_synchronized(struct wlr_subsurface *subsurface) {
return false;
}
-static void subsurface_unmap(struct wlr_subsurface *subsurface);
-
static const struct wl_subsurface_interface subsurface_implementation;
/**
@@ -192,22 +190,16 @@ const struct wlr_surface_role subsurface_role;
* - Its parent is mapped
*/
static void subsurface_consider_map(struct wlr_subsurface *subsurface) {
- if (subsurface->mapped || !wlr_surface_has_buffer(subsurface->surface)) {
+ if (subsurface->surface->mapped || !wlr_surface_has_buffer(subsurface->surface)) {
return;
}
- // TODO: unify "mapped" flag
- if (subsurface->parent->role == &subsurface_role) {
- struct wlr_subsurface *parent =
- wlr_subsurface_try_from_wlr_surface(subsurface->parent);
- if (parent == NULL || !parent->mapped) {
- return;
- }
+ if (!subsurface->parent->mapped) {
+ return;
}
// Now we can map the subsurface
- subsurface->mapped = true;
- wl_signal_emit_mutable(&subsurface->events.map, subsurface);
+ wlr_surface_map(subsurface->surface);
// Try mapping all children too
struct wlr_subsurface *child;
@@ -221,26 +213,6 @@ static void subsurface_consider_map(struct wlr_subsurface *subsurface) {
}
}
-static void subsurface_unmap(struct wlr_subsurface *subsurface) {
- if (!subsurface->mapped) {
- return;
- }
-
- subsurface->mapped = false;
- wl_signal_emit_mutable(&subsurface->events.unmap, subsurface);
-
- // Unmap all children
- struct wlr_subsurface *child;
- wl_list_for_each(child, &subsurface->surface->current.subsurfaces_below,
- current.link) {
- subsurface_unmap(child);
- }
- wl_list_for_each(child, &subsurface->surface->current.subsurfaces_above,
- current.link) {
- subsurface_unmap(child);
- }
-}
-
static void subsurface_role_commit(struct wlr_surface *surface) {
struct wlr_subsurface *subsurface = wlr_subsurface_try_from_wlr_surface(surface);
assert(subsurface != NULL);
@@ -248,14 +220,19 @@ static void subsurface_role_commit(struct wlr_surface *surface) {
subsurface_consider_map(subsurface);
}
-static void subsurface_role_precommit(struct wlr_surface *surface,
- const struct wlr_surface_state *state) {
+static void subsurface_role_unmap(struct wlr_surface *surface) {
struct wlr_subsurface *subsurface = wlr_subsurface_try_from_wlr_surface(surface);
assert(subsurface != NULL);
- if (state->committed & WLR_SURFACE_STATE_BUFFER && state->buffer == NULL) {
- // This is a NULL commit
- subsurface_unmap(subsurface);
+ // Unmap all children
+ struct wlr_subsurface *child;
+ wl_list_for_each(child, &subsurface->surface->current.subsurfaces_below,
+ current.link) {
+ wlr_surface_unmap(child->surface);
+ }
+ wl_list_for_each(child, &subsurface->surface->current.subsurfaces_above,
+ current.link) {
+ wlr_surface_unmap(child->surface);
}
}
@@ -268,8 +245,6 @@ static void subsurface_role_destroy(struct wlr_surface *surface) {
subsurface->cached_seq);
}
- subsurface_unmap(subsurface);
-
wl_signal_emit_mutable(&subsurface->events.destroy, subsurface);
wl_list_remove(&subsurface->surface_client_commit.link);
@@ -284,7 +259,7 @@ static void subsurface_role_destroy(struct wlr_surface *surface) {
const struct wlr_surface_role subsurface_role = {
.name = "wl_subsurface",
.commit = subsurface_role_commit,
- .precommit = subsurface_role_precommit,
+ .unmap = subsurface_role_unmap,
.destroy = subsurface_role_destroy,
};
@@ -332,7 +307,7 @@ void subsurface_handle_parent_commit(struct wlr_subsurface *subsurface) {
bool moved = subsurface->current.x != subsurface->pending.x ||
subsurface->current.y != subsurface->pending.y;
- if (subsurface->mapped && moved) {
+ if (subsurface->surface->mapped && moved) {
wlr_surface_for_each_surface(surface,
collect_damage_iter, subsurface);
}
@@ -344,7 +319,7 @@ void subsurface_handle_parent_commit(struct wlr_subsurface *subsurface) {
subsurface->current.x = subsurface->pending.x;
subsurface->current.y = subsurface->pending.y;
- if (subsurface->mapped && (moved || subsurface->reordered)) {
+ if (subsurface->surface->mapped && (moved || subsurface->reordered)) {
subsurface->reordered = false;
wlr_surface_for_each_surface(surface,
collect_damage_iter, subsurface);
@@ -381,8 +356,6 @@ static struct wlr_subsurface *subsurface_create(struct wlr_surface *surface,
&subsurface_implementation, subsurface, subsurface_resource_destroy);
wl_signal_init(&subsurface->events.destroy);
- wl_signal_init(&subsurface->events.map);
- wl_signal_init(&subsurface->events.unmap);
wl_signal_add(&surface->events.client_commit,
&subsurface->surface_client_commit);