wlr_scene: Introduce visibily to subsurface_tree
-
wlr_scene_xdg_surface_create()
will return astruct wlr_scene_xdg_surface
-
wlr_scene_subsurface_tree_create()
will return astruct wlr_scene_subsurface_tree
-
wlr_scene_subsurface_tree_set_clip()
takesstruct wlr_scene_subsurface_tree
as the first parameter now
The old design of _set_clip relied on implicitly walking the scene tree to find surfaces. This is not type safe and just generally creates more questions than answers. The reason this was done in the first place was because creating an xdg_surface or whatever would hide the subsurface tree and the compositor wouldn't have access. Instead, let's just return proper structs for all these cases.
This new design allows us to add a events
struct for visibility changes.
diff --git a/tinywl/tinywl.c b/tinywl/tinywl.c
index 640373b74..c07f53164 100644
--- a/tinywl/tinywl.c
+++ b/tinywl/tinywl.c
@@ -91,6 +91,8 @@ struct tinywl_toplevel {
struct wl_listener request_resize;
struct wl_listener request_maximize;
struct wl_listener request_fullscreen;
+
+ struct wl_listener test;
};
struct tinywl_popup {
@@ -794,6 +796,12 @@ static void xdg_toplevel_request_fullscreen(
}
}
+static void test(struct wl_listener *listener, void *data) {
+ struct tinywl_toplevel *toplevel = wl_container_of(listener, toplevel, test);
+
+ printf("visibility: %i\n", toplevel->scene->surface_tree->is_visible);
+}
+
static void server_new_xdg_toplevel(struct wl_listener *listener, void *data) {
/* This event is raised when a client creates a new toplevel (application window). */
struct tinywl_server *server = wl_container_of(listener, server, new_xdg_toplevel);
@@ -808,6 +816,9 @@ static void server_new_xdg_toplevel(struct wl_listener *listener, void *data) {
toplevel->scene->tree->node.data = toplevel;
xdg_toplevel->base->data = toplevel->scene->tree;
+ toplevel->test.notify = test;
+ wl_signal_add(&toplevel->scene->surface_tree->events.visibility, &toplevel->test);
+
/* Listen to the various events it can emit */
toplevel->map.notify = xdg_toplevel_map;
wl_signal_add(&xdg_toplevel->base->surface->events.map, &toplevel->map);