From 850e50b9b70f2abb3a3782a611a86f2cb7cd4532 Mon Sep 17 00:00:00 2001 From: codegax <14095200+codegax@users.noreply.github.com> Date: Sat, 25 Apr 2026 14:00:00 -0600 Subject: [PATCH] tree/container: add placeholder leaf scaffolding Add is_placeholder and swallows fields plus container_init_border_rects, used by upcoming append_layout support. No behaviour change. --- include/sway/tree/container.h | 8 ++++++++ sway/tree/container.c | 27 +++++++++++++++++++++++---- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index d8780544d..9b2571c1a 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h @@ -141,11 +141,19 @@ struct sway_container { list_t *marks; // char * + // append_layout placeholder: view==NULL, swallows holds matchers for the + // view that should be installed here. swallows_json retains the original + // i3-shaped array so IPC can echo it verbatim for round-trip. + bool is_placeholder; + list_t *swallows; // struct criteria * + struct { struct wl_signal destroy; } events; }; +void container_init_border_rects(struct sway_container *c, bool *failed); + struct sway_container *container_create(struct sway_view *view); void container_destroy(struct sway_container *con); diff --git a/sway/tree/container.c b/sway/tree/container.c index 6880841bd..c76d4f32d 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -8,6 +8,7 @@ #include #include #include "sway/config.h" +#include "sway/criteria.h" #include "sway/desktop/transaction.h" #include "sway/input/input-manager.h" #include "sway/input/seat.h" @@ -43,6 +44,13 @@ static struct wlr_scene_rect *alloc_rect_node(struct wlr_scene_tree *parent, return rect; } +void container_init_border_rects(struct sway_container *c, bool *failed) { + c->border.top = alloc_rect_node(c->border.tree, failed); + c->border.bottom = alloc_rect_node(c->border.tree, failed); + c->border.left = alloc_rect_node(c->border.tree, failed); + c->border.right = alloc_rect_node(c->border.tree, failed); +} + struct sway_container *container_create(struct sway_view *view) { struct sway_container *c = calloc(1, sizeof(struct sway_container)); if (!c) { @@ -87,10 +95,7 @@ struct sway_container *container_create(struct sway_view *view) { if (view) { // only containers with views can have borders - c->border.top = alloc_rect_node(c->border.tree, &failed); - c->border.bottom = alloc_rect_node(c->border.tree, &failed); - c->border.left = alloc_rect_node(c->border.tree, &failed); - c->border.right = alloc_rect_node(c->border.tree, &failed); + container_init_border_rects(c, &failed); } if (!failed && !scene_descriptor_assign(&c->scene_tree->node, @@ -460,6 +465,13 @@ void container_destroy(struct sway_container *con) { list_free_items_and_destroy(con->marks); + if (con->swallows) { + for (int i = 0; i < con->swallows->length; ++i) { + criteria_destroy(con->swallows->items[i]); + } + list_free(con->swallows); + } + if (con->view && con->view->container == con) { con->view->container = NULL; if (con->view->destroying) { @@ -509,11 +521,18 @@ void container_reap_empty(struct sway_container *con) { if (con->view) { return; } + // Placeholders are intentionally view-less; do not reap them. + if (con->is_placeholder) { + return; + } struct sway_workspace *ws = con->pending.workspace; while (con) { if (con->pending.children->length) { return; } + if (con->is_placeholder) { + return; + } struct sway_container *parent = con->pending.parent; container_begin_destroy(con); con = parent;