Port 0.16 scene changes

This commit is contained in:
Alexander Orzechowski 2022-12-14 13:56:15 -05:00 committed by Jente Hidskes Ankarberg
parent 979ff58a24
commit 32c44ddb5f
5 changed files with 37 additions and 26 deletions

33
seat.c
View file

@ -53,20 +53,31 @@ static void drag_icon_update_position(struct cg_drag_icon *drag_icon);
static struct cg_view *
desktop_view_at(struct cg_server *server, double lx, double ly, struct wlr_surface **surface, double *sx, double *sy)
{
struct wlr_scene_node *node = wlr_scene_node_at(&server->scene->node, lx, ly, sx, sy);
if (node == NULL || node->type != WLR_SCENE_NODE_SURFACE) {
struct wlr_scene_node *node = wlr_scene_node_at(&server->scene->tree.node, lx, ly, sx, sy);
if (node == NULL || node->type != WLR_SCENE_NODE_BUFFER) {
return NULL;
}
*surface = wlr_scene_surface_from_node(node)->surface;
struct wlr_scene_buffer *scene_buffer = wlr_scene_buffer_from_node(node);
struct wlr_scene_surface *scene_surface = wlr_scene_surface_from_buffer(scene_buffer);
if (!scene_surface) {
return NULL;
}
*surface = scene_surface->surface;
/* Walk up the tree until we find a node with a data pointer. When done,
* we've found the node representing the view. */
while (node != NULL && node->data == NULL) {
node = node->parent;
}
assert(node != NULL);
while (!node->data) {
if (!node->parent) {
node = NULL;
break;
}
node = &node->parent->node;
}
assert(node != NULL);
return node->data;
}
@ -609,7 +620,7 @@ drag_icon_update_position(struct cg_drag_icon *drag_icon)
break;
}
wlr_scene_node_set_position(drag_icon->scene_node, drag_icon->lx, drag_icon->ly);
wlr_scene_node_set_position(&drag_icon->scene_tree->node, drag_icon->lx, drag_icon->ly);
}
static void
@ -619,7 +630,7 @@ handle_drag_icon_destroy(struct wl_listener *listener, void *data)
wl_list_remove(&drag_icon->link);
wl_list_remove(&drag_icon->destroy.link);
wlr_scene_node_destroy(drag_icon->scene_node);
wlr_scene_node_destroy(&drag_icon->scene_tree->node);
free(drag_icon);
}
@ -662,8 +673,8 @@ handle_start_drag(struct wl_listener *listener, void *data)
}
drag_icon->seat = seat;
drag_icon->wlr_drag_icon = wlr_drag_icon;
drag_icon->scene_node = wlr_scene_subsurface_tree_create(&seat->server->scene->node, wlr_drag_icon->surface);
if (!drag_icon->scene_node) {
drag_icon->scene_tree = wlr_scene_subsurface_tree_create(&seat->server->scene->tree, wlr_drag_icon->surface);
if (!drag_icon->scene_tree) {
free(drag_icon);
return;
}

2
seat.h
View file

@ -77,7 +77,7 @@ struct cg_drag_icon {
struct wl_list link; // seat::drag_icons
struct cg_seat *seat;
struct wlr_drag_icon *wlr_drag_icon;
struct wlr_scene_node *scene_node;
struct wlr_scene_tree *scene_tree;
/* The drag icon has a position in layout coordinates. */
double lx, ly;

12
view.c
View file

@ -68,7 +68,7 @@ view_maximize(struct cg_view *view, struct wlr_box *layout_box)
view->lx = layout_box->x;
view->ly = layout_box->y;
wlr_scene_node_set_position(view->scene_node, view->lx, view->ly);
wlr_scene_node_set_position(&view->scene_tree->node, view->lx, view->ly);
view->impl->maximize(view, layout_box->width, layout_box->height);
}
@ -82,7 +82,7 @@ view_center(struct cg_view *view, struct wlr_box *layout_box)
view->lx = (layout_box->width - width) / 2;
view->ly = (layout_box->height - height) / 2;
wlr_scene_node_set_position(view->scene_node, view->lx, view->ly);
wlr_scene_node_set_position(&view->scene_tree->node, view->lx, view->ly);
}
void
@ -103,7 +103,7 @@ view_unmap(struct cg_view *view)
{
wl_list_remove(&view->link);
wlr_scene_node_destroy(view->scene_node);
wlr_scene_node_destroy(&view->scene_tree->node);
view->wlr_surface->data = NULL;
view->wlr_surface = NULL;
@ -112,12 +112,12 @@ view_unmap(struct cg_view *view)
void
view_map(struct cg_view *view, struct wlr_surface *surface)
{
view->scene_node = wlr_scene_subsurface_tree_create(&view->server->scene->node, surface);
if (!view->scene_node) {
view->scene_tree = wlr_scene_subsurface_tree_create(&view->server->scene->tree, surface);
if (!view->scene_tree) {
wl_resource_post_no_memory(surface->resource);
return;
}
view->scene_node->data = view;
view->scene_tree->node.data = view;
view->wlr_surface = surface;
surface->data = view;

2
view.h
View file

@ -25,7 +25,7 @@ struct cg_view {
struct cg_server *server;
struct wl_list link; // server::views
struct wlr_surface *wlr_surface;
struct wlr_scene_node *scene_node;
struct wlr_scene_tree *scene_tree;
/* The view has a position in layout coordinates. */
int lx, ly;

View file

@ -253,31 +253,31 @@ handle_xdg_shell_surface_new(struct wl_listener *listener, void *data)
return;
}
struct wlr_scene_node *parent_scene_node = NULL;
struct wlr_scene_tree *parent_scene_tree = NULL;
struct wlr_xdg_surface *parent = wlr_xdg_surface_from_wlr_surface(popup->parent);
switch (parent->role) {
case WLR_XDG_SURFACE_ROLE_TOPLEVEL:;
parent_scene_node = view->scene_node;
parent_scene_tree = view->scene_tree;
break;
case WLR_XDG_SURFACE_ROLE_POPUP:
parent_scene_node = parent->data;
parent_scene_tree = parent->data;
break;
case WLR_XDG_SURFACE_ROLE_NONE:
break;
}
if (parent_scene_node == NULL) {
if (parent_scene_tree == NULL) {
return;
}
struct wlr_scene_node *popup_scene_node = wlr_scene_xdg_surface_create(parent_scene_node, xdg_surface);
if (popup_scene_node == NULL) {
struct wlr_scene_tree *popup_scene_tree = wlr_scene_xdg_surface_create(parent_scene_tree, xdg_surface);
if (popup_scene_tree == NULL) {
wlr_log(WLR_ERROR, "Failed to allocate scene-graph node for XDG popup");
return;
}
popup_unconstrain(view, popup);
xdg_surface->data = popup_scene_node;
xdg_surface->data = popup_scene_tree;
break;
case WLR_XDG_SURFACE_ROLE_NONE:
assert(false); // unreachable