mirror of
https://github.com/swaywm/sway.git
synced 2026-06-13 14:33:19 -04:00
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.
This commit is contained in:
parent
c857ca3a97
commit
850e50b9b7
2 changed files with 31 additions and 4 deletions
|
|
@ -141,11 +141,19 @@ struct sway_container {
|
||||||
|
|
||||||
list_t *marks; // char *
|
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 {
|
||||||
struct wl_signal destroy;
|
struct wl_signal destroy;
|
||||||
} events;
|
} events;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void container_init_border_rects(struct sway_container *c, bool *failed);
|
||||||
|
|
||||||
struct sway_container *container_create(struct sway_view *view);
|
struct sway_container *container_create(struct sway_view *view);
|
||||||
|
|
||||||
void container_destroy(struct sway_container *con);
|
void container_destroy(struct sway_container *con);
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
#include <wlr/types/wlr_output_layout.h>
|
#include <wlr/types/wlr_output_layout.h>
|
||||||
#include <wlr/types/wlr_subcompositor.h>
|
#include <wlr/types/wlr_subcompositor.h>
|
||||||
#include "sway/config.h"
|
#include "sway/config.h"
|
||||||
|
#include "sway/criteria.h"
|
||||||
#include "sway/desktop/transaction.h"
|
#include "sway/desktop/transaction.h"
|
||||||
#include "sway/input/input-manager.h"
|
#include "sway/input/input-manager.h"
|
||||||
#include "sway/input/seat.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;
|
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 *container_create(struct sway_view *view) {
|
||||||
struct sway_container *c = calloc(1, sizeof(struct sway_container));
|
struct sway_container *c = calloc(1, sizeof(struct sway_container));
|
||||||
if (!c) {
|
if (!c) {
|
||||||
|
|
@ -87,10 +95,7 @@ struct sway_container *container_create(struct sway_view *view) {
|
||||||
|
|
||||||
if (view) {
|
if (view) {
|
||||||
// only containers with views can have borders
|
// only containers with views can have borders
|
||||||
c->border.top = alloc_rect_node(c->border.tree, &failed);
|
container_init_border_rects(c, &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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!failed && !scene_descriptor_assign(&c->scene_tree->node,
|
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);
|
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) {
|
if (con->view && con->view->container == con) {
|
||||||
con->view->container = NULL;
|
con->view->container = NULL;
|
||||||
if (con->view->destroying) {
|
if (con->view->destroying) {
|
||||||
|
|
@ -509,11 +521,18 @@ void container_reap_empty(struct sway_container *con) {
|
||||||
if (con->view) {
|
if (con->view) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// Placeholders are intentionally view-less; do not reap them.
|
||||||
|
if (con->is_placeholder) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
struct sway_workspace *ws = con->pending.workspace;
|
struct sway_workspace *ws = con->pending.workspace;
|
||||||
while (con) {
|
while (con) {
|
||||||
if (con->pending.children->length) {
|
if (con->pending.children->length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (con->is_placeholder) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
struct sway_container *parent = con->pending.parent;
|
struct sway_container *parent = con->pending.parent;
|
||||||
container_begin_destroy(con);
|
container_begin_destroy(con);
|
||||||
con = parent;
|
con = parent;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue