Skip to content

Commit

Permalink
chance wlroots scene parenting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Nefsen402 committed Apr 4, 2022
1 parent 5f99862 commit b7f0b4a
Show file tree
Hide file tree
Showing 26 changed files with 261 additions and 254 deletions.
8 changes: 4 additions & 4 deletions include/sway/input/seat.h
Expand Up @@ -51,7 +51,7 @@ struct sway_seat_node {

struct sway_drag_icon {
struct wlr_drag_icon *wlr_drag_icon;
struct wlr_scene_node *node;
struct wlr_scene_tree *tree;
struct wlr_scene_surface *surface;

struct wl_listener destroy;
Expand All @@ -69,13 +69,13 @@ struct sway_seat {
struct sway_cursor *cursor;

// Seat scene tree structure
// - scene_node
// - scene_tree
// - drag icons
// - drag icon 1
// - drag icon 2
// - seatop specific stuff
struct wlr_scene_node *scene_node;
struct wlr_scene_node *drag_icons;
struct wlr_scene_tree *scene_tree;
struct wlr_scene_tree *drag_icons;

bool has_focus;
struct wl_list focus_stack; // list of containers in focus order
Expand Down
2 changes: 1 addition & 1 deletion include/sway/layers.h
Expand Up @@ -20,7 +20,7 @@ struct sway_layer_surface {

struct sway_layer_popup {
struct wlr_xdg_popup *wlr_popup;
struct wlr_scene_node *scene;
struct wlr_scene_tree *scene;

struct wl_listener destroy;
struct wl_listener new_popup;
Expand Down
12 changes: 6 additions & 6 deletions include/sway/output.h
Expand Up @@ -21,12 +21,12 @@ struct sway_output {
struct sway_node node;

struct {
struct wlr_scene_node *shell_background;
struct wlr_scene_node *shell_bottom;
struct wlr_scene_node *tiling;
struct wlr_scene_node *fullscreen;
struct wlr_scene_node *shell_top;
struct wlr_scene_node *shell_overlay;
struct wlr_scene_tree *shell_background;
struct wlr_scene_tree *shell_bottom;
struct wlr_scene_tree *tiling;
struct wlr_scene_tree *fullscreen;
struct wlr_scene_tree *shell_top;
struct wlr_scene_tree *shell_overlay;
} layers;

struct wlr_output *wlr_output;
Expand Down
1 change: 0 additions & 1 deletion include/sway/server.h
Expand Up @@ -39,7 +39,6 @@ struct sway_server {
struct wlr_allocator *allocator;

struct wlr_compositor *compositor;
struct wl_listener compositor_new_surface;

struct wlr_linux_dmabuf_v1 *linux_dmabuf_v1;

Expand Down
2 changes: 1 addition & 1 deletion include/sway/sway_buffer.h
Expand Up @@ -13,7 +13,7 @@ struct sway_text_node {
struct wlr_scene_node *node;
};

struct sway_text_node *sway_text_node_create(struct wlr_scene_node *parent,
struct sway_text_node *sway_text_node_create(struct wlr_scene_tree *parent,
char *text, const float *color, bool pango_markup);

void sway_text_node_set_color(struct sway_text_node *node, const float *color);
Expand Down
8 changes: 4 additions & 4 deletions include/sway/tree/container.h
Expand Up @@ -69,10 +69,10 @@ struct sway_container {
struct sway_node node;
struct sway_view *view;

struct wlr_scene_node *scene_node;
struct wlr_scene_tree *scene_tree;

struct {
struct wlr_scene_node *node;
struct wlr_scene_tree *tree;

struct wlr_scene_rect *border;
struct wlr_scene_rect *background;
Expand All @@ -82,15 +82,15 @@ struct sway_container {
} title_bar;

struct {
struct wlr_scene_node *node;
struct wlr_scene_tree *tree;

struct wlr_scene_rect *top;
struct wlr_scene_rect *bottom;
struct wlr_scene_rect *left;
struct wlr_scene_rect *right;
} border;

struct wlr_scene_node *content_node;
struct wlr_scene_tree *content_tree;
struct wlr_scene_buffer *output_handler;

struct wl_listener output_enter;
Expand Down
4 changes: 2 additions & 2 deletions include/sway/tree/node.h
Expand Up @@ -78,12 +78,12 @@ bool node_has_ancestor(struct sway_node *node, struct sway_node *ancestor);
// when destroying a sway tree, it's not known which order the tree will be
// destroyed. To prevent freeing of scene_nodes recursing up the tree,
// let's use this helper function to disown them to the staging node.
void scene_node_disown_children(struct wlr_scene_node *node);
void scene_node_disown_children(struct wlr_scene_tree *tree);

// a helper function used to allocate tree nodes. If an allocation failure
// occurs a flag is flipped that can be checked later to destroy a parent
// of this scene node preventing memory leaks.
struct wlr_scene_node *alloc_scene_node(struct wlr_scene_node *parent,
struct wlr_scene_tree *alloc_scene_tree(struct wlr_scene_tree *parent,
bool *failed);

#endif
28 changes: 14 additions & 14 deletions include/sway/tree/root.h
Expand Up @@ -33,26 +33,26 @@ struct sway_root {
// have a parent, use this staging scene_tree so that a
// node always have a valid parent. Nothing in this
// staging node will be visible.
struct wlr_scene_node *staging;
struct wlr_scene_tree *staging;

// only some layers are supposed to be interactive through input.
struct wlr_scene_node *interactive;
struct wlr_scene_node *noninteractive;
struct wlr_scene_tree *interactive;
struct wlr_scene_tree *noninteractive;

struct {
struct wlr_scene_node *shell_background;
struct wlr_scene_node *shell_bottom;
struct wlr_scene_node *tiling;
struct wlr_scene_node *floating;
struct wlr_scene_node *shell_top;
struct wlr_scene_node *fullscreen;
struct wlr_scene_node *fullscreen_global;
struct wlr_scene_node *popup;
struct wlr_scene_tree *shell_background;
struct wlr_scene_tree *shell_bottom;
struct wlr_scene_tree *tiling;
struct wlr_scene_tree *floating;
struct wlr_scene_tree *shell_top;
struct wlr_scene_tree *fullscreen;
struct wlr_scene_tree *fullscreen_global;
struct wlr_scene_tree *popup;
#if HAVE_XWAYLAND
struct wlr_scene_node *unmanaged;
struct wlr_scene_tree *unmanaged;
#endif
struct wlr_scene_node *shell_overlay;
struct wlr_scene_node *seat;
struct wlr_scene_tree *shell_overlay;
struct wlr_scene_tree *seat;
} layers;

// Includes disabled outputs
Expand Down
10 changes: 5 additions & 5 deletions include/sway/tree/view.h
Expand Up @@ -57,9 +57,9 @@ struct sway_view {
enum sway_view_type type;
const struct sway_view_impl *impl;

struct wlr_scene_node *scene_node;
struct wlr_scene_node *content_node;
struct wlr_scene_node *saved_surface_node;
struct wlr_scene_tree *scene_tree;
struct wlr_scene_tree *content_tree;
struct wlr_scene_tree *saved_surface_tree;

struct sway_container *container; // NULL if unmapped and transactions finished
struct wlr_surface *surface; // NULL for unmapped views
Expand Down Expand Up @@ -183,8 +183,8 @@ struct sway_view_child {
struct wl_list children; // sway_view_child::link
struct wlr_surface *surface;

struct wlr_scene_node *scene_node;
struct wlr_scene_node *xdg_surface_node;
struct wlr_scene_tree *scene_tree;
struct wlr_scene_tree *xdg_surface_tree;
};

struct sway_xdg_popup {
Expand Down
4 changes: 2 additions & 2 deletions include/sway/tree/workspace.h
Expand Up @@ -25,8 +25,8 @@ struct sway_workspace {
struct sway_node node;

struct {
struct wlr_scene_node *tiling;
struct wlr_scene_node *fullscreen;
struct wlr_scene_tree *tiling;
struct wlr_scene_tree *fullscreen;
} layers;

struct sway_container *fullscreen;
Expand Down
39 changes: 20 additions & 19 deletions sway/desktop/layer_shell.c
Expand Up @@ -20,9 +20,9 @@
#include <wlr/types/wlr_scene.h>

static void arrange_surface(struct sway_output *output, const struct wlr_box *full_area,
struct wlr_box *usable_area, struct wlr_scene_node *scene_node) {
struct wlr_box *usable_area, struct wlr_scene_tree *tree) {
struct wlr_scene_node *node;
wl_list_for_each(node, &scene_node->state.children, state.link) {
wl_list_for_each(node, &tree->children, link) {
struct sway_scene_descriptor *desc = node->data;

sway_assert(desc && desc->type == SWAY_SCENE_DESC_LAYER_SHELL,
Expand Down Expand Up @@ -53,7 +53,7 @@ void arrange_layers(struct sway_output *output) {
}
}

static struct wlr_scene_node *sway_layer_get_scene(struct sway_output *output,
static struct wlr_scene_tree *sway_layer_get_scene(struct sway_output *output,
enum zwlr_layer_shell_v1_layer type) {
switch (type) {
case ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND:
Expand Down Expand Up @@ -91,8 +91,7 @@ static struct sway_layer_surface *find_mapped_layer_by_client(
}
// For now we'll only check the overlay layer
struct wlr_scene_node *node;
wl_list_for_each (node, &output->layers.shell_overlay->state.children,
state.link) {
wl_list_for_each (node, &output->layers.shell_overlay->children, link) {
struct sway_scene_descriptor *desc = node->data;
struct sway_layer_surface *surface = desc->data;
struct wlr_layer_surface_v1 *layer_surface =
Expand Down Expand Up @@ -141,9 +140,9 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) {

if (committed & WLR_LAYER_SURFACE_V1_STATE_LAYER) {
enum zwlr_layer_shell_v1_layer layer_type = layer_surface->current.layer;
struct wlr_scene_node *output_layer = sway_layer_get_scene(
struct wlr_scene_tree *output_layer = sway_layer_get_scene(
surface->output, layer_type);
wlr_scene_node_reparent(surface->scene->node, output_layer);
wlr_scene_node_reparent(&surface->scene->tree->node, output_layer);
}

if (committed || layer_surface->mapped != surface->mapped) {
Expand Down Expand Up @@ -228,19 +227,21 @@ static void popup_handle_destroy(struct wl_listener *listener, void *data) {

static struct sway_layer_surface *popup_get_layer(
struct sway_layer_popup *popup) {
struct wlr_scene_node *current = popup->scene;
while (current) {
struct wlr_scene_node *current = &popup->scene->node;
while (true) {
if (current->data) {
struct sway_scene_descriptor *desc = current->data;
if (desc->type == SWAY_SCENE_DESC_LAYER_SHELL) {
return desc->data;
}
}

current = current->parent;
}
if (!current->parent) {
return NULL;
}

return NULL;
current = &current->parent->node;
}
}

static void popup_unconstrain(struct sway_layer_popup *popup) {
Expand All @@ -253,7 +254,7 @@ static void popup_unconstrain(struct sway_layer_popup *popup) {
struct sway_output *output = surface->output;

int lx, ly;
wlr_scene_node_coords(popup->scene, &lx, &ly);
wlr_scene_node_coords(&popup->scene->node, &lx, &ly);

// the output box expressed in the coordinate system of the toplevel parent
// of the popup
Expand All @@ -270,7 +271,7 @@ static void popup_unconstrain(struct sway_layer_popup *popup) {
static void popup_handle_new_popup(struct wl_listener *listener, void *data);

static struct sway_layer_popup *create_popup(struct wlr_xdg_popup *wlr_popup,
struct wlr_scene_node *parent) {
struct wlr_scene_tree *parent) {
struct sway_layer_popup *popup =
calloc(1, sizeof(struct sway_layer_popup));
if (popup == NULL) {
Expand All @@ -286,7 +287,7 @@ static struct sway_layer_popup *create_popup(struct wlr_xdg_popup *wlr_popup,
return NULL;
}

scene_descriptor_assign(popup->scene, SWAY_SCENE_DESC_LAYER_SHELL_POPUP,
scene_descriptor_assign(&popup->scene->node, SWAY_SCENE_DESC_LAYER_SHELL_POPUP,
popup);

popup->destroy.notify = popup_handle_destroy;
Expand All @@ -310,7 +311,7 @@ static void handle_new_popup(struct wl_listener *listener, void *data) {
struct sway_layer_surface *sway_layer_surface =
wl_container_of(listener, sway_layer_surface, new_popup);
struct wlr_xdg_popup *wlr_popup = data;
create_popup(wlr_popup, sway_layer_surface->scene->node);
create_popup(wlr_popup, sway_layer_surface->scene->tree);
}

void handle_layer_shell_surface(struct wl_listener *listener, void *data) {
Expand Down Expand Up @@ -352,7 +353,7 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data) {
struct sway_output *output = layer_surface->output->data;

enum zwlr_layer_shell_v1_layer layer_type = layer_surface->pending.layer;
struct wlr_scene_node *output_layer = sway_layer_get_scene(
struct wlr_scene_tree *output_layer = sway_layer_get_scene(
output, layer_type);
struct wlr_scene_layer_surface_v1 *scene_surface =
wlr_scene_layer_surface_v1_create(output_layer, layer_surface);
Expand All @@ -370,9 +371,9 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data) {
return;
}

scene_descriptor_assign(scene_surface->node,
scene_descriptor_assign(&scene_surface->tree->node,
SWAY_SCENE_DESC_LAYER_SHELL, surface);
if (!scene_surface->node->data) {
if (!scene_surface->tree->node.data) {
// destroying the layer_surface will also destroy its corresponding
// scene node
wlr_layer_surface_v1_destroy(layer_surface);
Expand Down
8 changes: 6 additions & 2 deletions sway/desktop/output.c
Expand Up @@ -126,7 +126,7 @@ static void send_frame_done_iterator(struct wlr_scene_buffer *buffer,

struct wlr_scene_node *current = &buffer->node;

while (current) {
while (true) {
if (current->data) {
struct sway_scene_descriptor *desc = current->data;

Expand All @@ -144,7 +144,11 @@ static void send_frame_done_iterator(struct wlr_scene_buffer *buffer,
}
}

current = current->parent;
if (!current->parent) {
break;
}

current = &current->parent->node;
}

struct send_frame_done_data *data = user_data;
Expand Down

0 comments on commit b7f0b4a

Please sign in to comment.