mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-05 05:05:57 +01:00
wlr_scene: Only allow parenting on a wlr_scene_tree
This commit is contained in:
parent
9eb71146ae
commit
ccd0f85c2a
8 changed files with 93 additions and 75 deletions
|
@ -122,12 +122,12 @@ static void server_handle_new_surface(struct wl_listener *listener,
|
|||
wl_signal_add(&wlr_surface->events.destroy, &surface->destroy);
|
||||
|
||||
/* Border dimensions will be set in surface.commit handler */
|
||||
surface->border = wlr_scene_rect_create(&server->scene->tree.node,
|
||||
surface->border = wlr_scene_rect_create(&server->scene->tree,
|
||||
0, 0, (float[4]){ 0.5f, 0.5f, 0.5f, 1 });
|
||||
wlr_scene_node_set_position(&surface->border->node, pos, pos);
|
||||
|
||||
surface->scene_surface =
|
||||
wlr_scene_surface_create(&server->scene->tree.node, wlr_surface);
|
||||
wlr_scene_surface_create(&server->scene->tree, wlr_surface);
|
||||
|
||||
wlr_scene_node_set_position(&surface->scene_surface->buffer->node,
|
||||
pos + border_width, pos + border_width);
|
||||
|
|
|
@ -58,7 +58,7 @@ struct wlr_scene_node_state {
|
|||
/** A node is an object in the scene. */
|
||||
struct wlr_scene_node {
|
||||
enum wlr_scene_node_type type;
|
||||
struct wlr_scene_node *parent;
|
||||
struct wlr_scene_tree *parent;
|
||||
struct wlr_scene_node_state state;
|
||||
|
||||
struct {
|
||||
|
@ -178,7 +178,7 @@ struct wlr_scene_output {
|
|||
|
||||
/** A layer shell scene helper */
|
||||
struct wlr_scene_layer_surface_v1 {
|
||||
struct wlr_scene_node *node;
|
||||
struct wlr_scene_tree *tree;
|
||||
struct wlr_layer_surface_v1 *layer_surface;
|
||||
|
||||
// private state
|
||||
|
@ -226,7 +226,7 @@ void wlr_scene_node_lower_to_bottom(struct wlr_scene_node *node);
|
|||
* Move the node to another location in the tree.
|
||||
*/
|
||||
void wlr_scene_node_reparent(struct wlr_scene_node *node,
|
||||
struct wlr_scene_node *new_parent);
|
||||
struct wlr_scene_tree *new_parent);
|
||||
/**
|
||||
* Get the node's layout-local coordinates.
|
||||
*
|
||||
|
@ -265,7 +265,7 @@ void wlr_scene_set_presentation(struct wlr_scene *scene,
|
|||
/**
|
||||
* Add a node displaying nothing but its children.
|
||||
*/
|
||||
struct wlr_scene_tree *wlr_scene_tree_create(struct wlr_scene_node *parent);
|
||||
struct wlr_scene_tree *wlr_scene_tree_create(struct wlr_scene_tree *parent);
|
||||
|
||||
/**
|
||||
* Add a node displaying a single surface to the scene-graph.
|
||||
|
@ -276,7 +276,7 @@ struct wlr_scene_tree *wlr_scene_tree_create(struct wlr_scene_node *parent);
|
|||
* automatically based on the position of the surface and outputs in
|
||||
* the scene.
|
||||
*/
|
||||
struct wlr_scene_surface *wlr_scene_surface_create(struct wlr_scene_node *parent,
|
||||
struct wlr_scene_surface *wlr_scene_surface_create(struct wlr_scene_tree *parent,
|
||||
struct wlr_surface *surface);
|
||||
|
||||
struct wlr_scene_buffer *wlr_scene_buffer_from_node(struct wlr_scene_node *node);
|
||||
|
@ -291,7 +291,7 @@ struct wlr_scene_surface *wlr_scene_surface_from_buffer(
|
|||
/**
|
||||
* Add a node displaying a solid-colored rectangle to the scene-graph.
|
||||
*/
|
||||
struct wlr_scene_rect *wlr_scene_rect_create(struct wlr_scene_node *parent,
|
||||
struct wlr_scene_rect *wlr_scene_rect_create(struct wlr_scene_tree *parent,
|
||||
int width, int height, const float color[static 4]);
|
||||
|
||||
/**
|
||||
|
@ -309,7 +309,7 @@ void wlr_scene_rect_set_color(struct wlr_scene_rect *rect, const float color[sta
|
|||
*
|
||||
* If the buffer is NULL, this node will not be displayed.
|
||||
*/
|
||||
struct wlr_scene_buffer *wlr_scene_buffer_create(struct wlr_scene_node *parent,
|
||||
struct wlr_scene_buffer *wlr_scene_buffer_create(struct wlr_scene_tree *parent,
|
||||
struct wlr_buffer *buffer);
|
||||
|
||||
/**
|
||||
|
@ -415,8 +415,8 @@ bool wlr_scene_attach_output_layout(struct wlr_scene *scene,
|
|||
* Add a node displaying a surface and all of its sub-surfaces to the
|
||||
* scene-graph.
|
||||
*/
|
||||
struct wlr_scene_node *wlr_scene_subsurface_tree_create(
|
||||
struct wlr_scene_node *parent, struct wlr_surface *surface);
|
||||
struct wlr_scene_tree *wlr_scene_subsurface_tree_create(
|
||||
struct wlr_scene_tree *parent, struct wlr_surface *surface);
|
||||
|
||||
/**
|
||||
* Add a node displaying an xdg_surface and all of its sub-surfaces to the
|
||||
|
@ -425,8 +425,8 @@ struct wlr_scene_node *wlr_scene_subsurface_tree_create(
|
|||
* The origin of the returned scene-graph node will match the top-left corner
|
||||
* of the xdg_surface window geometry.
|
||||
*/
|
||||
struct wlr_scene_node *wlr_scene_xdg_surface_create(
|
||||
struct wlr_scene_node *parent, struct wlr_xdg_surface *xdg_surface);
|
||||
struct wlr_scene_tree *wlr_scene_xdg_surface_create(
|
||||
struct wlr_scene_tree *parent, struct wlr_xdg_surface *xdg_surface);
|
||||
|
||||
/**
|
||||
* Add a node displaying a layer_surface_v1 and all of its sub-surfaces to the
|
||||
|
@ -436,7 +436,7 @@ struct wlr_scene_node *wlr_scene_xdg_surface_create(
|
|||
* of the layer surface.
|
||||
*/
|
||||
struct wlr_scene_layer_surface_v1 *wlr_scene_layer_surface_v1_create(
|
||||
struct wlr_scene_node *parent, struct wlr_layer_surface_v1 *layer_surface);
|
||||
struct wlr_scene_tree *parent, struct wlr_layer_surface_v1 *layer_surface);
|
||||
|
||||
/**
|
||||
* Configure a layer_surface_v1, position its scene node in accordance to its
|
||||
|
|
|
@ -80,7 +80,7 @@ struct tinywl_view {
|
|||
struct wl_list link;
|
||||
struct tinywl_server *server;
|
||||
struct wlr_xdg_toplevel *xdg_toplevel;
|
||||
struct wlr_scene_node *scene_node;
|
||||
struct wlr_scene_tree *scene_tree;
|
||||
struct wl_listener map;
|
||||
struct wl_listener unmap;
|
||||
struct wl_listener destroy;
|
||||
|
@ -126,7 +126,7 @@ static void focus_view(struct tinywl_view *view, struct wlr_surface *surface) {
|
|||
}
|
||||
struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat);
|
||||
/* Move the view to the front */
|
||||
wlr_scene_node_raise_to_top(view->scene_node);
|
||||
wlr_scene_node_raise_to_top(&view->scene_tree->node);
|
||||
wl_list_remove(&view->link);
|
||||
wl_list_insert(&server->views, &view->link);
|
||||
/* Activate the new surface */
|
||||
|
@ -354,10 +354,11 @@ static struct tinywl_view *desktop_view_at(
|
|||
*surface = scene_surface->surface;
|
||||
/* Find the node corresponding to the tinywl_view at the root of this
|
||||
* surface tree, it is the only one for which we set the data field. */
|
||||
while (node != NULL && node->data == NULL) {
|
||||
node = node->parent;
|
||||
struct wlr_scene_tree *tree = node->parent;
|
||||
while (tree != NULL && tree->node.data == NULL) {
|
||||
tree = tree->node.parent;
|
||||
}
|
||||
return node->data;
|
||||
return tree->node.data;
|
||||
}
|
||||
|
||||
static void process_cursor_move(struct tinywl_server *server, uint32_t time) {
|
||||
|
@ -365,7 +366,7 @@ static void process_cursor_move(struct tinywl_server *server, uint32_t time) {
|
|||
struct tinywl_view *view = server->grabbed_view;
|
||||
view->x = server->cursor->x - server->grab_x;
|
||||
view->y = server->cursor->y - server->grab_y;
|
||||
wlr_scene_node_set_position(view->scene_node, view->x, view->y);
|
||||
wlr_scene_node_set_position(&view->scene_tree->node, view->x, view->y);
|
||||
}
|
||||
|
||||
static void process_cursor_resize(struct tinywl_server *server, uint32_t time) {
|
||||
|
@ -414,7 +415,7 @@ static void process_cursor_resize(struct tinywl_server *server, uint32_t time) {
|
|||
wlr_xdg_surface_get_geometry(view->xdg_toplevel->base, &geo_box);
|
||||
view->x = new_left - geo_box.x;
|
||||
view->y = new_top - geo_box.y;
|
||||
wlr_scene_node_set_position(view->scene_node, view->x, view->y);
|
||||
wlr_scene_node_set_position(&view->scene_tree->node, view->x, view->y);
|
||||
|
||||
int new_width = new_right - new_left;
|
||||
int new_height = new_bottom - new_top;
|
||||
|
@ -747,9 +748,9 @@ static void server_new_xdg_surface(struct wl_listener *listener, void *data) {
|
|||
if (xdg_surface->role == WLR_XDG_SURFACE_ROLE_POPUP) {
|
||||
struct wlr_xdg_surface *parent = wlr_xdg_surface_from_wlr_surface(
|
||||
xdg_surface->popup->parent);
|
||||
struct wlr_scene_node *parent_node = parent->data;
|
||||
struct wlr_scene_tree *parent_tree = parent->data;
|
||||
xdg_surface->data = wlr_scene_xdg_surface_create(
|
||||
parent_node, xdg_surface);
|
||||
parent_tree, xdg_surface);
|
||||
return;
|
||||
}
|
||||
assert(xdg_surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL);
|
||||
|
@ -759,10 +760,10 @@ static void server_new_xdg_surface(struct wl_listener *listener, void *data) {
|
|||
calloc(1, sizeof(struct tinywl_view));
|
||||
view->server = server;
|
||||
view->xdg_toplevel = xdg_surface->toplevel;
|
||||
view->scene_node = wlr_scene_xdg_surface_create(
|
||||
&view->server->scene->tree.node, view->xdg_toplevel->base);
|
||||
view->scene_node->data = view;
|
||||
xdg_surface->data = view->scene_node;
|
||||
view->scene_tree = wlr_scene_xdg_surface_create(
|
||||
&view->server->scene->tree, view->xdg_toplevel->base);
|
||||
view->scene_tree->node.data = view;
|
||||
xdg_surface->data = view->scene_tree;
|
||||
|
||||
/* Listen to the various events it can emit */
|
||||
view->map.notify = xdg_toplevel_map;
|
||||
|
|
|
@ -18,21 +18,21 @@ static void scene_layer_surface_handle_layer_surface_destroy(
|
|||
struct wl_listener *listener, void *data) {
|
||||
struct wlr_scene_layer_surface_v1 *scene_layer_surface =
|
||||
wl_container_of(listener, scene_layer_surface, layer_surface_destroy);
|
||||
wlr_scene_node_destroy(scene_layer_surface->node);
|
||||
wlr_scene_node_destroy(&scene_layer_surface->tree->node);
|
||||
}
|
||||
|
||||
static void scene_layer_surface_handle_layer_surface_map(
|
||||
struct wl_listener *listener, void *data) {
|
||||
struct wlr_scene_layer_surface_v1 *scene_layer_surface =
|
||||
wl_container_of(listener, scene_layer_surface, layer_surface_map);
|
||||
wlr_scene_node_set_enabled(scene_layer_surface->node, true);
|
||||
wlr_scene_node_set_enabled(&scene_layer_surface->tree->node, true);
|
||||
}
|
||||
|
||||
static void scene_layer_surface_handle_layer_surface_unmap(
|
||||
struct wl_listener *listener, void *data) {
|
||||
struct wlr_scene_layer_surface_v1 *scene_layer_surface =
|
||||
wl_container_of(listener, scene_layer_surface, layer_surface_unmap);
|
||||
wlr_scene_node_set_enabled(scene_layer_surface->node, false);
|
||||
wlr_scene_node_set_enabled(&scene_layer_surface->tree->node, false);
|
||||
}
|
||||
|
||||
static void layer_surface_exclusive_zone(
|
||||
|
@ -122,7 +122,7 @@ void wlr_scene_layer_surface_v1_configure(
|
|||
box.y = bounds.y + bounds.height/2 - box.height/2;
|
||||
}
|
||||
|
||||
wlr_scene_node_set_position(scene_layer_surface->node, box.x, box.y);
|
||||
wlr_scene_node_set_position(&scene_layer_surface->tree->node, box.x, box.y);
|
||||
wlr_layer_surface_v1_configure(layer_surface, box.width, box.height);
|
||||
|
||||
if (state->exclusive_zone > 0) {
|
||||
|
@ -131,7 +131,7 @@ void wlr_scene_layer_surface_v1_configure(
|
|||
}
|
||||
|
||||
struct wlr_scene_layer_surface_v1 *wlr_scene_layer_surface_v1_create(
|
||||
struct wlr_scene_node *parent,
|
||||
struct wlr_scene_tree *parent,
|
||||
struct wlr_layer_surface_v1 *layer_surface) {
|
||||
struct wlr_scene_layer_surface_v1 *scene_layer_surface =
|
||||
calloc(1, sizeof(*scene_layer_surface));
|
||||
|
@ -141,24 +141,23 @@ struct wlr_scene_layer_surface_v1 *wlr_scene_layer_surface_v1_create(
|
|||
|
||||
scene_layer_surface->layer_surface = layer_surface;
|
||||
|
||||
struct wlr_scene_tree *tree = wlr_scene_tree_create(parent);
|
||||
if (tree == NULL) {
|
||||
scene_layer_surface->tree = wlr_scene_tree_create(parent);
|
||||
if (scene_layer_surface->tree == NULL) {
|
||||
free(scene_layer_surface);
|
||||
return NULL;
|
||||
}
|
||||
scene_layer_surface->node = &tree->node;
|
||||
|
||||
struct wlr_scene_node *surface_node = wlr_scene_subsurface_tree_create(
|
||||
scene_layer_surface->node, layer_surface->surface);
|
||||
if (surface_node == NULL) {
|
||||
wlr_scene_node_destroy(scene_layer_surface->node);
|
||||
struct wlr_scene_tree *surface_tree = wlr_scene_subsurface_tree_create(
|
||||
scene_layer_surface->tree, layer_surface->surface);
|
||||
if (surface_tree == NULL) {
|
||||
wlr_scene_node_destroy(&scene_layer_surface->tree->node);
|
||||
free(scene_layer_surface);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
scene_layer_surface->tree_destroy.notify =
|
||||
scene_layer_surface_handle_tree_destroy;
|
||||
wl_signal_add(&scene_layer_surface->node->events.destroy,
|
||||
wl_signal_add(&scene_layer_surface->tree->node.events.destroy,
|
||||
&scene_layer_surface->tree_destroy);
|
||||
|
||||
scene_layer_surface->layer_surface_destroy.notify =
|
||||
|
@ -176,7 +175,7 @@ struct wlr_scene_layer_surface_v1 *wlr_scene_layer_surface_v1_create(
|
|||
wl_signal_add(&layer_surface->events.unmap,
|
||||
&scene_layer_surface->layer_surface_unmap);
|
||||
|
||||
wlr_scene_node_set_enabled(scene_layer_surface->node,
|
||||
wlr_scene_node_set_enabled(&scene_layer_surface->tree->node,
|
||||
layer_surface->mapped);
|
||||
|
||||
return scene_layer_surface;
|
||||
|
|
|
@ -148,13 +148,13 @@ static const struct wlr_addon_interface subsurface_tree_addon_impl = {
|
|||
};
|
||||
|
||||
static struct wlr_scene_subsurface_tree *scene_surface_tree_create(
|
||||
struct wlr_scene_node *parent, struct wlr_surface *surface);
|
||||
struct wlr_scene_tree *parent, struct wlr_surface *surface);
|
||||
|
||||
static bool subsurface_tree_create_subsurface(
|
||||
struct wlr_scene_subsurface_tree *parent,
|
||||
struct wlr_subsurface *subsurface) {
|
||||
struct wlr_scene_subsurface_tree *child = scene_surface_tree_create(
|
||||
&parent->tree->node, subsurface->surface);
|
||||
parent->tree, subsurface->surface);
|
||||
if (child == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ static void subsurface_tree_handle_surface_new_subsurface(
|
|||
}
|
||||
|
||||
static struct wlr_scene_subsurface_tree *scene_surface_tree_create(
|
||||
struct wlr_scene_node *parent, struct wlr_surface *surface) {
|
||||
struct wlr_scene_tree *parent, struct wlr_surface *surface) {
|
||||
struct wlr_scene_subsurface_tree *subsurface_tree =
|
||||
calloc(1, sizeof(*subsurface_tree));
|
||||
if (subsurface_tree == NULL) {
|
||||
|
@ -201,7 +201,7 @@ static struct wlr_scene_subsurface_tree *scene_surface_tree_create(
|
|||
}
|
||||
|
||||
subsurface_tree->scene_surface =
|
||||
wlr_scene_surface_create(&subsurface_tree->tree->node, surface);
|
||||
wlr_scene_surface_create(subsurface_tree->tree, surface);
|
||||
if (subsurface_tree->scene_surface == NULL) {
|
||||
goto error_scene_surface;
|
||||
}
|
||||
|
@ -248,12 +248,12 @@ error_surface_tree:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
struct wlr_scene_node *wlr_scene_subsurface_tree_create(
|
||||
struct wlr_scene_node *parent, struct wlr_surface *surface) {
|
||||
struct wlr_scene_tree *wlr_scene_subsurface_tree_create(
|
||||
struct wlr_scene_tree *parent, struct wlr_surface *surface) {
|
||||
struct wlr_scene_subsurface_tree *subsurface_tree =
|
||||
scene_surface_tree_create(parent, surface);
|
||||
if (subsurface_tree == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
return &subsurface_tree->tree->node;
|
||||
return subsurface_tree->tree;
|
||||
}
|
||||
|
|
|
@ -135,7 +135,7 @@ struct wlr_scene_surface *wlr_scene_surface_from_buffer(
|
|||
return surface;
|
||||
}
|
||||
|
||||
struct wlr_scene_surface *wlr_scene_surface_create(struct wlr_scene_node *parent,
|
||||
struct wlr_scene_surface *wlr_scene_surface_create(struct wlr_scene_tree *parent,
|
||||
struct wlr_surface *wlr_surface) {
|
||||
struct wlr_scene_surface *surface = calloc(1, sizeof(*surface));
|
||||
if (surface == NULL) {
|
||||
|
|
|
@ -17,6 +17,11 @@
|
|||
|
||||
#define HIGHLIGHT_DAMAGE_FADEOUT_TIME 250
|
||||
|
||||
static struct wlr_scene_tree *scene_tree_from_node(struct wlr_scene_node *node) {
|
||||
assert(node->type == WLR_SCENE_NODE_TREE);
|
||||
return (struct wlr_scene_tree *)node;
|
||||
}
|
||||
|
||||
static struct wlr_scene_rect *scene_rect_from_node(
|
||||
struct wlr_scene_node *node) {
|
||||
assert(node->type == WLR_SCENE_NODE_RECT);
|
||||
|
@ -30,10 +35,17 @@ struct wlr_scene_buffer *wlr_scene_buffer_from_node(
|
|||
}
|
||||
|
||||
struct wlr_scene *scene_node_get_root(struct wlr_scene_node *node) {
|
||||
while (node->parent != NULL) {
|
||||
node = node->parent;
|
||||
struct wlr_scene_tree *tree;
|
||||
if (node->type == WLR_SCENE_NODE_TREE) {
|
||||
tree = scene_tree_from_node(node);
|
||||
} else {
|
||||
tree = node->parent;
|
||||
}
|
||||
return (struct wlr_scene *)node;
|
||||
|
||||
while (tree->node.parent != NULL) {
|
||||
tree = tree->node.parent;
|
||||
}
|
||||
return (struct wlr_scene *)tree;
|
||||
}
|
||||
|
||||
static void scene_node_state_init(struct wlr_scene_node_state *state) {
|
||||
|
@ -48,7 +60,7 @@ static void scene_node_state_finish(struct wlr_scene_node_state *state) {
|
|||
}
|
||||
|
||||
static void scene_node_init(struct wlr_scene_node *node,
|
||||
enum wlr_scene_node_type type, struct wlr_scene_node *parent) {
|
||||
enum wlr_scene_node_type type, struct wlr_scene_tree *parent) {
|
||||
memset(node, 0, sizeof(*node));
|
||||
node->type = type;
|
||||
node->parent = parent;
|
||||
|
@ -56,7 +68,7 @@ static void scene_node_init(struct wlr_scene_node *node,
|
|||
wl_signal_init(&node->events.destroy);
|
||||
|
||||
if (parent != NULL) {
|
||||
wl_list_insert(parent->state.children.prev, &node->state.link);
|
||||
wl_list_insert(parent->node.state.children.prev, &node->state.link);
|
||||
}
|
||||
|
||||
wlr_addon_set_init(&node->addons);
|
||||
|
@ -136,7 +148,7 @@ void wlr_scene_node_destroy(struct wlr_scene_node *node) {
|
|||
}
|
||||
|
||||
static void scene_tree_init(struct wlr_scene_tree *tree,
|
||||
struct wlr_scene_node *parent) {
|
||||
struct wlr_scene_tree *parent) {
|
||||
memset(tree, 0, sizeof(*tree));
|
||||
scene_node_init(&tree->node, WLR_SCENE_NODE_TREE, parent);
|
||||
}
|
||||
|
@ -172,7 +184,7 @@ struct wlr_scene *wlr_scene_create(void) {
|
|||
return scene;
|
||||
}
|
||||
|
||||
struct wlr_scene_tree *wlr_scene_tree_create(struct wlr_scene_node *parent) {
|
||||
struct wlr_scene_tree *wlr_scene_tree_create(struct wlr_scene_tree *parent) {
|
||||
assert(parent);
|
||||
|
||||
struct wlr_scene_tree *tree = calloc(1, sizeof(struct wlr_scene_tree));
|
||||
|
@ -251,7 +263,7 @@ static void scene_node_update_outputs(struct wlr_scene_node *node) {
|
|||
_scene_node_update_outputs(node, lx, ly, scene);
|
||||
}
|
||||
|
||||
struct wlr_scene_rect *wlr_scene_rect_create(struct wlr_scene_node *parent,
|
||||
struct wlr_scene_rect *wlr_scene_rect_create(struct wlr_scene_tree *parent,
|
||||
int width, int height, const float color[static 4]) {
|
||||
struct wlr_scene_rect *scene_rect =
|
||||
calloc(1, sizeof(struct wlr_scene_rect));
|
||||
|
@ -290,7 +302,7 @@ void wlr_scene_rect_set_color(struct wlr_scene_rect *rect, const float color[sta
|
|||
scene_node_damage_whole(&rect->node);
|
||||
}
|
||||
|
||||
struct wlr_scene_buffer *wlr_scene_buffer_create(struct wlr_scene_node *parent,
|
||||
struct wlr_scene_buffer *wlr_scene_buffer_create(struct wlr_scene_tree *parent,
|
||||
struct wlr_buffer *buffer) {
|
||||
struct wlr_scene_buffer *scene_buffer = calloc(1, sizeof(*scene_buffer));
|
||||
if (scene_buffer == NULL) {
|
||||
|
@ -615,7 +627,7 @@ void wlr_scene_node_place_below(struct wlr_scene_node *node,
|
|||
|
||||
void wlr_scene_node_raise_to_top(struct wlr_scene_node *node) {
|
||||
struct wlr_scene_node *current_top = wl_container_of(
|
||||
node->parent->state.children.prev, current_top, state.link);
|
||||
node->parent->node.state.children.prev, current_top, state.link);
|
||||
if (node == current_top) {
|
||||
return;
|
||||
}
|
||||
|
@ -624,7 +636,7 @@ void wlr_scene_node_raise_to_top(struct wlr_scene_node *node) {
|
|||
|
||||
void wlr_scene_node_lower_to_bottom(struct wlr_scene_node *node) {
|
||||
struct wlr_scene_node *current_bottom = wl_container_of(
|
||||
node->parent->state.children.next, current_bottom, state.link);
|
||||
node->parent->node.state.children.next, current_bottom, state.link);
|
||||
if (node == current_bottom) {
|
||||
return;
|
||||
}
|
||||
|
@ -632,7 +644,7 @@ void wlr_scene_node_lower_to_bottom(struct wlr_scene_node *node) {
|
|||
}
|
||||
|
||||
void wlr_scene_node_reparent(struct wlr_scene_node *node,
|
||||
struct wlr_scene_node *new_parent) {
|
||||
struct wlr_scene_tree *new_parent) {
|
||||
assert(new_parent != NULL);
|
||||
|
||||
if (node->parent == new_parent) {
|
||||
|
@ -640,16 +652,16 @@ void wlr_scene_node_reparent(struct wlr_scene_node *node,
|
|||
}
|
||||
|
||||
/* Ensure that a node cannot become its own ancestor */
|
||||
for (struct wlr_scene_node *ancestor = new_parent; ancestor != NULL;
|
||||
ancestor = ancestor->parent) {
|
||||
assert(ancestor != node);
|
||||
for (struct wlr_scene_tree *ancestor = new_parent; ancestor != NULL;
|
||||
ancestor = ancestor->node.parent) {
|
||||
assert(&ancestor->node != node);
|
||||
}
|
||||
|
||||
scene_node_damage_whole(node);
|
||||
|
||||
wl_list_remove(&node->state.link);
|
||||
node->parent = new_parent;
|
||||
wl_list_insert(new_parent->state.children.prev, &node->state.link);
|
||||
wl_list_insert(new_parent->node.state.children.prev, &node->state.link);
|
||||
|
||||
scene_node_damage_whole(node);
|
||||
|
||||
|
@ -658,13 +670,19 @@ void wlr_scene_node_reparent(struct wlr_scene_node *node,
|
|||
|
||||
bool wlr_scene_node_coords(struct wlr_scene_node *node,
|
||||
int *lx_ptr, int *ly_ptr) {
|
||||
assert(node);
|
||||
|
||||
int lx = 0, ly = 0;
|
||||
bool enabled = true;
|
||||
while (node != NULL) {
|
||||
while (true) {
|
||||
lx += node->state.x;
|
||||
ly += node->state.y;
|
||||
enabled = enabled && node->state.enabled;
|
||||
node = node->parent;
|
||||
if (node->parent == NULL) {
|
||||
break;
|
||||
}
|
||||
|
||||
node = &node->parent->node;
|
||||
}
|
||||
|
||||
*lx_ptr = lx;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
struct wlr_scene_xdg_surface {
|
||||
struct wlr_scene_tree *tree;
|
||||
struct wlr_xdg_surface *xdg_surface;
|
||||
struct wlr_scene_node *surface_node;
|
||||
struct wlr_scene_tree *surface_tree;
|
||||
|
||||
struct wl_listener tree_destroy;
|
||||
struct wl_listener xdg_surface_destroy;
|
||||
|
@ -54,7 +54,7 @@ static void scene_xdg_surface_update_position(
|
|||
|
||||
struct wlr_box geo = {0};
|
||||
wlr_xdg_surface_get_geometry(xdg_surface, &geo);
|
||||
wlr_scene_node_set_position(scene_xdg_surface->surface_node,
|
||||
wlr_scene_node_set_position(&scene_xdg_surface->surface_tree->node,
|
||||
-geo.x, -geo.y);
|
||||
|
||||
if (xdg_surface->role == WLR_XDG_SURFACE_ROLE_POPUP) {
|
||||
|
@ -71,8 +71,8 @@ static void scene_xdg_surface_handle_xdg_surface_commit(struct wl_listener *list
|
|||
scene_xdg_surface_update_position(scene_xdg_surface);
|
||||
}
|
||||
|
||||
struct wlr_scene_node *wlr_scene_xdg_surface_create(
|
||||
struct wlr_scene_node *parent, struct wlr_xdg_surface *xdg_surface) {
|
||||
struct wlr_scene_tree *wlr_scene_xdg_surface_create(
|
||||
struct wlr_scene_tree *parent, struct wlr_xdg_surface *xdg_surface) {
|
||||
struct wlr_scene_xdg_surface *scene_xdg_surface =
|
||||
calloc(1, sizeof(*scene_xdg_surface));
|
||||
if (scene_xdg_surface == NULL) {
|
||||
|
@ -87,9 +87,9 @@ struct wlr_scene_node *wlr_scene_xdg_surface_create(
|
|||
return NULL;
|
||||
}
|
||||
|
||||
scene_xdg_surface->surface_node = wlr_scene_subsurface_tree_create(
|
||||
&scene_xdg_surface->tree->node, xdg_surface->surface);
|
||||
if (scene_xdg_surface->surface_node == NULL) {
|
||||
scene_xdg_surface->surface_tree = wlr_scene_subsurface_tree_create(
|
||||
scene_xdg_surface->tree, xdg_surface->surface);
|
||||
if (scene_xdg_surface->surface_tree == NULL) {
|
||||
wlr_scene_node_destroy(&scene_xdg_surface->tree->node);
|
||||
free(scene_xdg_surface);
|
||||
return NULL;
|
||||
|
@ -120,5 +120,5 @@ struct wlr_scene_node *wlr_scene_xdg_surface_create(
|
|||
wlr_scene_node_set_enabled(&scene_xdg_surface->tree->node, xdg_surface->mapped);
|
||||
scene_xdg_surface_update_position(scene_xdg_surface);
|
||||
|
||||
return &scene_xdg_surface->tree->node;
|
||||
return scene_xdg_surface->tree;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue