aboutsummaryrefslogtreecommitdiff
path: root/sway/tree
diff options
context:
space:
mode:
authorKenny Levinsen <kl@kl.wtf>2021-02-12 23:22:51 +0100
committerTudor Brindus <me@tbrindus.ca>2021-02-16 22:05:00 -0500
commita047b5ee4a2a67d30d93641ff86531d54b8e0879 (patch)
tree271666c6254e4fabf943c1153224059411a5ce56 /sway/tree
parent28cadf558090854ace1df1a0a64f5fbc059541c0 (diff)
container: Move pending state to state struct
Pending state is currently inlined directly in the container struct, while the current state is in a state struct. A side-effect of this is that it is not immediately obvious that pending double-buffered state is accessed, nor is it obvious what state is double-buffered. Instead, use the state struct for both current and pending.
Diffstat (limited to 'sway/tree')
-rw-r--r--sway/tree/arrange.c70
-rw-r--r--sway/tree/container.c408
-rw-r--r--sway/tree/node.c18
-rw-r--r--sway/tree/output.c14
-rw-r--r--sway/tree/root.c22
-rw-r--r--sway/tree/view.c208
-rw-r--r--sway/tree/workspace.c30
7 files changed, 385 insertions, 385 deletions
diff --git a/sway/tree/arrange.c b/sway/tree/arrange.c
index bac9f2fa..4aa82c35 100644
--- a/sway/tree/arrange.c
+++ b/sway/tree/arrange.c
@@ -55,7 +55,7 @@ static void apply_horiz_layout(list_t *children, struct wlr_box *parent) {
// Calculate gap size
double inner_gap = 0;
struct sway_container *child = children->items[0];
- struct sway_workspace *ws = child->workspace;
+ struct sway_workspace *ws = child->pending.workspace;
if (ws) {
inner_gap = ws->gaps_inner;
}
@@ -66,7 +66,7 @@ static void apply_horiz_layout(list_t *children, struct wlr_box *parent) {
if (layout == L_TABBED || layout == L_STACKED) {
inner_gap = 0;
}
- temp = temp->parent;
+ temp = temp->pending.parent;
}
double total_gap = fmin(inner_gap * (children->length - 1),
fmax(0, parent->width - MIN_SANE_W * children->length));
@@ -79,15 +79,15 @@ static void apply_horiz_layout(list_t *children, struct wlr_box *parent) {
for (int i = 0; i < children->length; ++i) {
struct sway_container *child = children->items[i];
child->child_total_width = child_total_width;
- child->x = child_x;
- child->y = parent->y;
- child->width = round(child->width_fraction * child_total_width);
- child->height = parent->height;
- child_x += child->width + inner_gap;
+ child->pending.x = child_x;
+ child->pending.y = parent->y;
+ child->pending.width = round(child->width_fraction * child_total_width);
+ child->pending.height = parent->height;
+ child_x += child->pending.width + inner_gap;
// Make last child use remaining width of parent
if (i == children->length - 1) {
- child->width = parent->x + parent->width - child->x;
+ child->pending.width = parent->x + parent->width - child->pending.x;
}
}
}
@@ -134,7 +134,7 @@ static void apply_vert_layout(list_t *children, struct wlr_box *parent) {
// Calculate gap size
double inner_gap = 0;
struct sway_container *child = children->items[0];
- struct sway_workspace *ws = child->workspace;
+ struct sway_workspace *ws = child->pending.workspace;
if (ws) {
inner_gap = ws->gaps_inner;
}
@@ -145,7 +145,7 @@ static void apply_vert_layout(list_t *children, struct wlr_box *parent) {
if (layout == L_TABBED || layout == L_STACKED) {
inner_gap = 0;
}
- temp = temp->parent;
+ temp = temp->pending.parent;
}
double total_gap = fmin(inner_gap * (children->length - 1),
fmax(0, parent->height - MIN_SANE_H * children->length));
@@ -158,15 +158,15 @@ static void apply_vert_layout(list_t *children, struct wlr_box *parent) {
for (int i = 0; i < children->length; ++i) {
struct sway_container *child = children->items[i];
child->child_total_height = child_total_height;
- child->x = parent->x;
- child->y = child_y;
- child->width = parent->width;
- child->height = round(child->height_fraction * child_total_height);
- child_y += child->height + inner_gap;
+ child->pending.x = parent->x;
+ child->pending.y = child_y;
+ child->pending.width = parent->width;
+ child->pending.height = round(child->height_fraction * child_total_height);
+ child_y += child->pending.height + inner_gap;
// Make last child use remaining height of parent
if (i == children->length - 1) {
- child->height = parent->y + parent->height - child->y;
+ child->pending.height = parent->y + parent->height - child->pending.y;
}
}
}
@@ -178,10 +178,10 @@ static void apply_tabbed_layout(list_t *children, struct wlr_box *parent) {
for (int i = 0; i < children->length; ++i) {
struct sway_container *child = children->items[i];
int parent_offset = child->view ? 0 : container_titlebar_height();
- child->x = parent->x;
- child->y = parent->y + parent_offset;
- child->width = parent->width;
- child->height = parent->height - parent_offset;
+ child->pending.x = parent->x;
+ child->pending.y = parent->y + parent_offset;
+ child->pending.width = parent->width;
+ child->pending.height = parent->height - parent_offset;
}
}
@@ -193,10 +193,10 @@ static void apply_stacked_layout(list_t *children, struct wlr_box *parent) {
struct sway_container *child = children->items[i];
int parent_offset = child->view ? 0 :
container_titlebar_height() * children->length;
- child->x = parent->x;
- child->y = parent->y + parent_offset;
- child->width = parent->width;
- child->height = parent->height - parent_offset;
+ child->pending.x = parent->x;
+ child->pending.y = parent->y + parent_offset;
+ child->pending.width = parent->width;
+ child->pending.height = parent->height - parent_offset;
}
}
@@ -246,7 +246,7 @@ void arrange_container(struct sway_container *container) {
}
struct wlr_box box;
container_get_box(container, &box);
- arrange_children(container->children, container->layout, &box);
+ arrange_children(container->pending.children, container->pending.layout, &box);
node_set_dirty(&container->node);
}
@@ -278,8 +278,8 @@ void arrange_workspace(struct sway_workspace *workspace) {
for (int i = 0; i < workspace->floating->length; ++i) {
struct sway_container *floater = workspace->floating->items[i];
container_floating_translate(floater, diff_x, diff_y);
- double center_x = floater->x + floater->width / 2;
- double center_y = floater->y + floater->height / 2;
+ double center_x = floater->pending.x + floater->pending.width / 2;
+ double center_y = floater->pending.y + floater->pending.height / 2;
struct wlr_box workspace_box;
workspace_get_box(workspace, &workspace_box);
if (!wlr_box_contains_point(&workspace_box, center_x, center_y)) {
@@ -294,10 +294,10 @@ void arrange_workspace(struct sway_workspace *workspace) {
workspace->x, workspace->y);
if (workspace->fullscreen) {
struct sway_container *fs = workspace->fullscreen;
- fs->x = output->lx;
- fs->y = output->ly;
- fs->width = output->width;
- fs->height = output->height;
+ fs->pending.x = output->lx;
+ fs->pending.y = output->ly;
+ fs->pending.width = output->width;
+ fs->pending.height = output->height;
arrange_container(fs);
} else {
struct wlr_box box;
@@ -337,10 +337,10 @@ void arrange_root(void) {
if (root->fullscreen_global) {
struct sway_container *fs = root->fullscreen_global;
- fs->x = root->x;
- fs->y = root->y;
- fs->width = root->width;
- fs->height = root->height;
+ fs->pending.x = root->x;
+ fs->pending.y = root->y;
+ fs->pending.width = root->width;
+ fs->pending.height = root->height;
arrange_container(fs);
} else {
for (int i = 0; i < root->outputs->length; ++i) {
diff --git a/sway/tree/container.c b/sway/tree/container.c
index 6a9ce1c4..8c8dfb3b 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -30,12 +30,12 @@ struct sway_container *container_create(struct sway_view *view) {
return NULL;
}
node_init(&c->node, N_CONTAINER, c);
- c->layout = L_NONE;
+ c->pending.layout = L_NONE;
c->view = view;
c->alpha = 1.0f;
if (!view) {
- c->children = create_list();
+ c->pending.children = create_list();
c->current.children = create_list();
}
c->marks = create_list();
@@ -62,7 +62,7 @@ void container_destroy(struct sway_container *con) {
wlr_texture_destroy(con->title_focused_inactive);
wlr_texture_destroy(con->title_unfocused);
wlr_texture_destroy(con->title_urgent);
- list_free(con->children);
+ list_free(con->pending.children);
list_free(con->current.children);
list_free(con->outputs);
@@ -90,10 +90,10 @@ void container_begin_destroy(struct sway_container *con) {
}
// The workspace must have the fullscreen pointer cleared so that the
// seat code can find an appropriate new focus.
- if (con->fullscreen_mode == FULLSCREEN_WORKSPACE && con->workspace) {
- con->workspace->fullscreen = NULL;
+ if (con->pending.fullscreen_mode == FULLSCREEN_WORKSPACE && con->pending.workspace) {
+ con->pending.workspace->fullscreen = NULL;
}
- if (con->scratchpad && con->fullscreen_mode == FULLSCREEN_GLOBAL) {
+ if (con->scratchpad && con->pending.fullscreen_mode == FULLSCREEN_GLOBAL) {
container_fullscreen_disable(con);
}
@@ -108,11 +108,11 @@ void container_begin_destroy(struct sway_container *con) {
root_scratchpad_remove_container(con);
}
- if (con->fullscreen_mode == FULLSCREEN_GLOBAL) {
+ if (con->pending.fullscreen_mode == FULLSCREEN_GLOBAL) {
container_fullscreen_disable(con);
}
- if (con->parent || con->workspace) {
+ if (con->pending.parent || con->pending.workspace) {
container_detach(con);
}
}
@@ -121,12 +121,12 @@ void container_reap_empty(struct sway_container *con) {
if (con->view) {
return;
}
- struct sway_workspace *ws = con->workspace;
+ struct sway_workspace *ws = con->pending.workspace;
while (con) {
- if (con->children->length) {
+ if (con->pending.children->length) {
return;
}
- struct sway_container *parent = con->parent;
+ struct sway_container *parent = con->pending.parent;
container_begin_destroy(con);
con = parent;
}
@@ -139,9 +139,9 @@ struct sway_container *container_flatten(struct sway_container *container) {
if (container->view) {
return NULL;
}
- while (container && container->children->length == 1) {
- struct sway_container *child = container->children->items[0];
- struct sway_container *parent = container->parent;
+ while (container && container->pending.children->length == 1) {
+ struct sway_container *child = container->pending.children->items[0];
+ struct sway_container *parent = container->pending.parent;
container_replace(container, child);
container_begin_destroy(container);
container = parent;
@@ -151,11 +151,11 @@ struct sway_container *container_flatten(struct sway_container *container) {
struct sway_container *container_find_child(struct sway_container *container,
bool (*test)(struct sway_container *con, void *data), void *data) {
- if (!container->children) {
+ if (!container->pending.children) {
return NULL;
}
- for (int i = 0; i < container->children->length; ++i) {
- struct sway_container *child = container->children->items[i];
+ for (int i = 0; i < container->pending.children->length; ++i) {
+ struct sway_container *child = container->pending.children->items[i];
if (test(child, data)) {
return child;
}
@@ -319,10 +319,10 @@ struct sway_container *view_container_at(struct sway_node *parent,
struct sway_container *container = parent->sway_container;
struct wlr_box box = {
- .x = container->x,
- .y = container->y,
- .width = container->width,
- .height = container->height,
+ .x = container->pending.x,
+ .y = container->pending.y,
+ .width = container->pending.width,
+ .height = container->pending.height,
};
if (wlr_box_contains_point(&box, lx, ly)) {
@@ -408,9 +408,9 @@ struct sway_container *container_at(struct sway_workspace *workspace,
void container_for_each_child(struct sway_container *container,
void (*f)(struct sway_container *container, void *data),
void *data) {
- if (container->children) {
- for (int i = 0; i < container->children->length; ++i) {
- struct sway_container *child = container->children->items[i];
+ if (container->pending.children) {
+ for (int i = 0; i < container->pending.children->length; ++i) {
+ struct sway_container *child = container->pending.children->items[i];
f(child, data);
container_for_each_child(child, f, data);
}
@@ -420,7 +420,7 @@ void container_for_each_child(struct sway_container *container,
bool container_has_ancestor(struct sway_container *descendant,
struct sway_container *ancestor) {
while (descendant) {
- descendant = descendant->parent;
+ descendant = descendant->pending.parent;
if (descendant == ancestor) {
return true;
}
@@ -596,23 +596,23 @@ size_t container_build_representation(enum sway_container_layout layout,
void container_update_representation(struct sway_container *con) {
if (!con->view) {
- size_t len = container_build_representation(con->layout,
- con->children, NULL);
+ size_t len = container_build_representation(con->pending.layout,
+ con->pending.children, NULL);
free(con->formatted_title);
con->formatted_title = calloc(len + 1, sizeof(char));
if (!sway_assert(con->formatted_title,
"Unable to allocate title string")) {
return;
}
- container_build_representation(con->layout, con->children,
+ container_build_representation(con->pending.layout, con->pending.children,
con->formatted_title);
container_calculate_title_height(con);
container_update_title_textures(con);
}
- if (con->parent) {
- container_update_representation(con->parent);
- } else if (con->workspace) {
- workspace_update_representation(con->workspace);
+ if (con->pending.parent) {
+ container_update_representation(con->pending.parent);
+ } else if (con->pending.workspace) {
+ workspace_update_representation(con->pending.workspace);
}
}
@@ -663,20 +663,20 @@ static void floating_natural_resize(struct sway_container *con) {
floating_calculate_constraints(&min_width, &max_width,
&min_height, &max_height);
if (!con->view) {
- con->width = fmax(min_width, fmin(con->width, max_width));
- con->height = fmax(min_height, fmin(con->height, max_height));
+ con->pending.width = fmax(min_width, fmin(con->pending.width, max_width));
+ con->pending.height = fmax(min_height, fmin(con->pending.height, max_height));
} else {
struct sway_view *view = con->view;
- con->content_width =
+ con->pending.content_width =
fmax(min_width, fmin(view->natural_width, max_width));
- con->content_height =
+ con->pending.content_height =
fmax(min_height, fmin(view->natural_height, max_height));
container_set_geometry_from_content(con);
}
}
void container_floating_resize_and_center(struct sway_container *con) {
- struct sway_workspace *ws = con->workspace;
+ struct sway_workspace *ws = con->pending.workspace;
if (!ws) {
// On scratchpad, just resize
floating_natural_resize(con);
@@ -687,42 +687,42 @@ void container_floating_resize_and_center(struct sway_container *con) {
ws->output->wlr_output);
if (!ob) {
// On NOOP output. Will be called again when moved to an output
- con->x = 0;
- con->y = 0;
- con->width = 0;
- con->height = 0;
+ con->pending.x = 0;
+ con->pending.y = 0;
+ con->pending.width = 0;
+ con->pending.height = 0;
return;
}
floating_natural_resize(con);
if (!con->view) {
- if (con->width > ws->width || con->height > ws->height) {
- con->x = ob->x + (ob->width - con->width) / 2;
- con->y = ob->y + (ob->height - con->height) / 2;
+ if (con->pending.width > ws->width || con->pending.height > ws->height) {
+ con->pending.x = ob->x + (ob->width - con->pending.width) / 2;
+ con->pending.y = ob->y + (ob->height - con->pending.height) / 2;
} else {
- con->x = ws->x + (ws->width - con->width) / 2;
- con->y = ws->y + (ws->height - con->height) / 2;
+ con->pending.x = ws->x + (ws->width - con->pending.width) / 2;
+ con->pending.y = ws->y + (ws->height - con->pending.height) / 2;
}
} else {
- if (con->content_width > ws->width
- || con->content_height > ws->height) {
- con->content_x = ob->x + (ob->width - con->content_width) / 2;
- con->content_y = ob->y + (ob->height - con->content_height) / 2;
+ if (con->pending.content_width > ws->width
+ || con->pending.content_height > ws->height) {
+ con->pending.content_x = ob->x + (ob->width - con->pending.content_width) / 2;
+ con->pending.content_y = ob->y + (ob->height - con->pending.content_height) / 2;
} else {
- con->content_x = ws->x + (ws->width - con->content_width) / 2;
- con->content_y = ws->y + (ws->height - con->content_height) / 2;
+ con->pending.content_x = ws->x + (ws->width - con->pending.content_width) / 2;
+ con->pending.content_y = ws->y + (ws->height - con->pending.content_height) / 2;
}
// If the view's border is B_NONE then these properties are ignored.
- con->border_top = con->border_bottom = true;
- con->border_left = con->border_right = true;
+ con->pending.border_top = con->pending.border_bottom = true;
+ con->pending.border_left = con->pending.border_right = true;
container_set_geometry_from_content(con);
}
}
void container_floating_set_default_size(struct sway_container *con) {
- if (!sway_assert(con->workspace, "Expected a container on a workspace")) {
+ if (!sway_assert(con->pending.workspace, "Expected a container on a workspace")) {
return;
}
@@ -730,16 +730,16 @@ void container_floating_set_default_size(struct sway_container *con) {
floating_calculate_constraints(&min_width, &max_width,
&min_height, &max_height);
struct wlr_box *box = calloc(1, sizeof(struct wlr_box));
- workspace_get_box(con->workspace, box);
+ workspace_get_box(con->pending.workspace, box);
double width = fmax(min_width, fmin(box->width * 0.5, max_width));
double height = fmax(min_height, fmin(box->height * 0.75, max_height));
if (!con->view) {
- con->width = width;
- con->height = height;
+ con->pending.width = width;
+ con->pending.height = height;
} else {
- con->content_width = width;
- con->content_height = height;
+ con->pending.content_width = width;
+ con->pending.content_height = height;
container_set_geometry_from_content(con);
}
@@ -761,8 +761,8 @@ void container_set_resizing(struct sway_container *con, bool resizing) {
con->view->impl->set_resizing(con->view, resizing);
}
} else {
- for (int i = 0; i < con->children->length; ++i ) {
- struct sway_container *child = con->children->items[i];
+ for (int i = 0; i < con->pending.children->length; ++i ) {
+ struct sway_container *child = con->pending.children->items[i];
container_set_resizing(child, resizing);
}
}
@@ -774,16 +774,16 @@ void container_set_floating(struct sway_container *container, bool enable) {
}
struct sway_seat *seat = input_manager_current_seat();
- struct sway_workspace *workspace = container->workspace;
+ struct sway_workspace *workspace = container->pending.workspace;
if (enable) {
- struct sway_container *old_parent = container->parent;
+ struct sway_container *old_parent = container->pending.parent;
container_detach(container);
workspace_add_floating(workspace, container);
if (container->view) {
view_set_tiled(container->view, false);
if (container->view->using_csd) {
- container->border = B_CSD;
+ container->pending.border = B_CSD;
}
}
container_floating_set_default_size(container);
@@ -801,18 +801,18 @@ void container_set_floating(struct sway_container *container, bool enable) {
seat_get_focus_inactive_tiling(seat, workspace);
if (reference) {
container_add_sibling(reference, container, 1);
- container->width = reference->width;
- container->height = reference->height;
+ container->pending.width = reference->pending.width;
+ container->pending.height = reference->pending.height;
} else {
struct sway_container *other =
workspace_add_tiling(workspace, container);
- other->width = workspace->width;
- other->height = workspace->height;
+ other->pending.width = workspace->width;
+ other->pending.height = workspace->height;
}
if (container->view) {
view_set_tiled(container->view, true);
if (container->view->using_csd) {
- container->border = container->saved_border;
+ container->pending.border = container->saved_border;
}
}
container->width_fraction = 0;
@@ -834,22 +834,22 @@ void container_set_geometry_from_content(struct sway_container *con) {
size_t border_width = 0;
size_t top = 0;
- if (con->border != B_CSD) {
- border_width = con->border_thickness * (con->border != B_NONE);
- top = con->border == B_NORMAL ?
+ if (con->pending.border != B_CSD) {
+ border_width = con->pending.border_thickness * (con->pending.border != B_NONE);
+ top = con->pending.border == B_NORMAL ?
container_titlebar_height() : border_width;
}
- con->x = con->content_x - border_width;
- con->y = con->content_y - top;
- con->width = con->content_width + border_width * 2;
- con->height = top + con->content_height + border_width;
+ con->pending.x = con->pending.content_x - border_width;
+ con->pending.y = con->pending.content_y - top;
+ con->pending.width = con->pending.content_width + border_width * 2;
+ con->pending.height = top + con->pending.content_height + border_width;
node_set_dirty(&con->node);
}
bool container_is_floating(struct sway_container *container) {
- if (!container->parent && container->workspace &&
- list_find(container->workspace->floating, container) != -1) {
+ if (!container->pending.parent && container->pending.workspace &&
+ list_find(container->pending.workspace->floating, container) != -1) {
return true;
}
if (container->scratchpad) {
@@ -859,10 +859,10 @@ bool container_is_floating(struct sway_container *container) {
}
void container_get_box(struct sway_container *container, struct wlr_box *box) {
- box->x = container->x;
- box->y = container->y;
- box->width = container->width;
- box->height = container->height;
+ box->x = container->pending.x;
+ box->y = container->pending.y;
+ box->width = container->pending.width;
+ box->height = container->pending.height;
}
/**
@@ -870,14 +870,14 @@ void container_get_box(struct sway_container *container, struct wlr_box *box) {
*/
void container_floating_translate(struct sway_container *con,
double x_amount, double y_amount) {
- con->x += x_amount;
- con->y += y_amount;
- con->content_x += x_amount;
- con->content_y += y_amount;
-
- if (con->children) {
- for (int i = 0; i < con->children->length; ++i) {
- struct sway_container *child = con->children->items[i];
+ con->pending.x += x_amount;
+ con->pending.y += y_amount;
+ con->pending.content_x += x_amount;
+ con->pending.content_y += y_amount;
+
+ if (con->pending.children) {
+ for (int i = 0; i < con->pending.children->length; ++i) {
+ struct sway_container *child = con->pending.children->items[i];
container_floating_translate(child, x_amount, y_amount);
}
}
@@ -893,8 +893,8 @@ void container_floating_translate(struct sway_container *con,
* center.
*/
struct sway_output *container_floating_find_output(struct sway_container *con) {
- double center_x = con->x + con->width / 2;
- double center_y = con->y + con->height / 2;
+ double center_x = con->pending.x + con->pending.width / 2;
+ double center_y = con->pending.y + con->pending.height / 2;
struct sway_output *closest_output = NULL;
double closest_distance = DBL_MAX;
for (int i = 0; i < root->outputs->length; ++i) {
@@ -925,11 +925,11 @@ void container_floating_move_to(struct sway_container *con,
"Expected a floating container")) {
return;
}
- container_floating_translate(con, lx - con->x, ly - con->y);
+ container_floating_translate(con, lx - con->pending.x, ly - con->pending.y);
if (container_is_scratchpad_hidden(con)) {
return;
}
- struct sway_workspace *old_workspace = con->workspace;
+ struct sway_workspace *old_workspace = con->pending.workspace;
struct sway_output *new_output = container_floating_find_output(con);
if (!sway_assert(new_output, "Unable to find any output")) {
return;
@@ -951,10 +951,10 @@ void container_floating_move_to_center(struct sway_container *con) {
"Expected a floating container")) {
return;
}
- struct sway_workspace *ws = con->workspace;
- double new_lx = ws->x + (ws->width - con->width) / 2;
- double new_ly = ws->y + (ws->height - con->height) / 2;
- container_floating_translate(con, new_lx - con->x, new_ly - con->y);
+ struct sway_workspace *ws = con->pending.workspace;
+ double new_lx = ws->x + (ws->width - con->pending.width) / 2;
+ double new_ly = ws->y + (ws->height - con->pending.height) / 2;
+ container_floating_translate(con, new_lx - con->pending.x, new_ly - con->pending.y);
}
static bool find_urgent_iterator(struct sway_container *con, void *data) {
@@ -987,27 +987,27 @@ static void set_fullscreen_iterator(struct sway_container *con, void *data) {
}
static void container_fullscreen_workspace(struct sway_container *con) {
- if (!sway_assert(con->fullscreen_mode == FULLSCREEN_NONE,
+ if (!sway_assert(con->pending.fullscreen_mode == FULLSCREEN_NONE,
"Expected a non-fullscreen container")) {
return;
}
bool enable = true;
set_fullscreen_iterator(con, &enable);
container_for_each_child(con, set_fullscreen_iterator, &enable);
- con->fullscreen_mode = FULLSCREEN_WORKSPACE;
+ con->pending.fullscreen_mode = FULLSCREEN_WORKSPACE;
- con->saved_x = con->x;
- con->saved_y = con->y;
- con->saved_width = con->width;
- con->saved_height = con->height;
+ con->saved_x = con->pending.x;
+ con->saved_y = con->pending.y;
+ con->saved_width = con->pending.width;
+ con->saved_height = con->pending.height;
- if (con->workspace) {
- con->workspace->fullscreen = con;
+ if (con->pending.workspace) {
+ con->pending.workspace->fullscreen = con;
struct sway_seat *seat;
struct sway_workspace *focus_ws;
wl_list_for_each(seat, &server.input->seats, link) {
focus_ws = seat_get_focused_workspace(seat);
- if (focus_ws == con->workspace) {
+ if (focus_ws == con->pending.workspace) {
seat_set_focus_container(seat, con);
} else {
struct sway_node *focus =
@@ -1023,7 +1023,7 @@ static void container_fullscreen_workspace(struct sway_container *con) {
}
static void container_fullscreen_global(struct sway_container *con) {
- if (!sway_assert(con->fullscreen_mode == FULLSCREEN_NONE,
+ if (!sway_assert(con->pending.fullscreen_mode == FULLSCREEN_NONE,
"Expected a non-fullscreen container")) {
return;
}
@@ -1032,10 +1032,10 @@ static void container_fullscreen_global(struct sway_container *con) {
container_for_each_child(con, set_fullscreen_iterator, &enable);
root->fullscreen_global = con;
- con->saved_x = con->x;
- con->saved_y = con->y;
- con->saved_width = con->width;
- con->saved_height = con->height;
+ con->saved_x = con->pending.x;
+ con->saved_y = con->pending.y;
+ con->saved_width = con->pending.width;
+ con->saved_height = con->pending.height;
struct sway_seat *seat;
wl_list_for_each(seat, &server.input->seats, link) {
@@ -1045,13 +1045,13 @@ static void container_fullscreen_global(struct sway_container *con) {
}
}
- con->fullscreen_mode = FULLSCREEN_GLOBAL;
+ con->pending.fullscreen_mode = FULLSCREEN_GLOBAL;
container_end_mouse_operation(con);
ipc_event_window(con, "fullscreen_mode");
}
void container_fullscreen_disable(struct sway_container *con) {
- if (!sway_assert(con->fullscreen_mode != FULLSCREEN_NONE,
+ if (!sway_assert(con->pending.fullscreen_mode != FULLSCREEN_NONE,
"Expected a fullscreen container")) {
return;
}
@@ -1060,19 +1060,19 @@ void container_fullscreen_disable(struct sway_container *con) {
container_for_each_child(con, set_fullscreen_iterator, &enable);
if (container_is_floating(con)) {
- con->x = con->saved_x;
- con->y = con->saved_y;
- con->width = con->saved_width;
- con->height = con->saved_height;
+ con->pending.x = con->saved_x;
+ con->pending.y = con->saved_y;
+ con->pending.width = con->saved_width;
+ con->pending.height = con->saved_height;
}
- if (con->fullscreen_mode == FULLSCREEN_WORKSPACE) {
- if (con->workspace) {
- con->workspace->fullscreen = NULL;
+ if (con->pending.fullscreen_mode == FULLSCREEN_WORKSPACE) {
+ if (con->pending.workspace) {
+ con->pending.workspace->fullscreen = NULL;
if (container_is_floating(con)) {
struct sway_output *output =
container_floating_find_output(con);
- if (con->workspace->output != output) {
+ if (con->pending.workspace->output != output) {
container_floating_move_to_center(con);
}
}
@@ -1084,11 +1084,11 @@ void container_fullscreen_disable(struct sway_container *con) {
// If the container was mapped as fullscreen and set as floating by
// criteria, it needs to be reinitialized as floating to get the proper
// size and location
- if (container_is_floating(con) && (con->width == 0 || con->height == 0)) {
+ if (container_is_floating(con) && (con->pending.width == 0 || con->pending.height == 0)) {
container_floating_resize_and_center(con);
}
- con->fullscreen_mode = FULLSCREEN_NONE;
+ con->pending.fullscreen_mode = FULLSCREEN_NONE;
container_end_mouse_operation(con);
ipc_event_window(con, "fullscreen_mode");
@@ -1106,7 +1106,7 @@ void container_fullscreen_disable(struct sway_container *con) {
void container_set_fullscreen(struct sway_container *con,
enum sway_fullscreen_mode mode) {
- if (con->fullscreen_mode == mode) {
+ if (con->pending.fullscreen_mode == mode) {
return;
}
@@ -1118,8 +1118,8 @@ void container_set_fullscreen(struct sway_container *con,
if (root->fullscreen_global) {
container_fullscreen_disable(root->fullscreen_global);
}
- if (con->workspace && con->workspace->fullscreen) {
- container_fullscreen_disable(con->workspace->fullscreen);
+ if (con->pending.workspace && con->pending.workspace->fullscreen) {
+ container_fullscreen_disable(con->pending.workspace->fullscreen);
}
container_fullscreen_workspace(con);
break;
@@ -1127,7 +1127,7 @@ void container_set_fullscreen(struct sway_container *con,
if (root->fullscreen_global) {
container_fullscreen_disable(root->fullscreen_global);
}
- if (con->fullscreen_mode == FULLSCREEN_WORKSPACE) {
+ if (con->pending.fullscreen_mode == FULLSCREEN_WORKSPACE) {
container_fullscreen_disable(con);
}
container_fullscreen_global(con);
@@ -1137,8 +1137,8 @@ void container_set_fullscreen(struct sway_container *con,
struct sway_container *container_toplevel_ancestor(
struct sway_container *container) {
- while (container->parent) {
- container = container->parent;
+ while (container->pending.parent) {
+ container = container->pending.parent;
}
return container;
@@ -1150,10 +1150,10 @@ bool container_is_floating_or_child(struct sway_container *container) {
bool container_is_fullscreen_or_child(struct sway_container *container) {
do {
- if (container->fullscreen_mode) {
+ if (container->pending.fullscreen_mode) {
return true;
}
- container = container->parent;
+ container = container->pending.parent;
} while (container);
return false;
@@ -1226,11 +1226,11 @@ void container_discover_outputs(struct sway_container *con) {
}
enum sway_container_layout container_parent_layout(struct sway_container *con) {
- if (con->parent) {
- return con->parent->layout;
+ if (con->pending.parent) {
+ return con->pending.parent->pending.layout;
}
- if (con->workspace) {
- return con->workspace->layout;
+ if (con->pending.workspace) {
+ return con->pending.workspace->layout;
}
return L_NONE;
}
@@ -1244,16 +1244,16 @@ enum sway_container_layout container_current_parent_layout(
}
list_t *container_get_siblings(struct sway_container *container) {
- if (container->parent) {
- return container->parent->children;
+ if (container->pending.parent) {
+ return container->pending.parent->pending.children;
}
if (container_is_scratchpad_hidden(container)) {
return NULL;
}
- if (list_find(container->workspace->tiling, container) != -1) {
- return container->workspace->tiling;
+ if (list_find(container->pending.workspace->tiling, container) != -1) {
+ return container->pending.workspace->tiling;
}
- return container->workspace->floating;
+ return container->pending.workspace->floating;
}
int container_sibling_index(struct sway_container *child) {
@@ -1268,30 +1268,30 @@ list_t *container_get_current_siblings(struct sway_container *container) {
}
void container_handle_fullscreen_reparent(struct sway_container *con) {
- if (con->fullscreen_mode != FULLSCREEN_WORKSPACE || !con->workspace ||
- con->workspace->fullscreen == con) {
+ if (con->pending.fullscreen_mode != FULLSCREEN_WORKSPACE || !con->pending.workspace ||
+ con->pending.workspace->fullscreen == con) {
return;
}
- if (con->workspace->fullscreen) {
- container_fullscreen_disable(con->workspace->fullscreen);
+ if (con->pending.workspace->fullscreen) {
+ container_fullscreen_disable(con->pending.workspace->fullscreen);
}
- con->workspace->fullscreen = con;
+ con->pending.workspace->fullscreen = con;
- arrange_workspace(con->workspace);
+ arrange_workspace(con->pending.workspace);
}
static void set_workspace(struct sway_container *container, void *data) {
- container->workspace = container->parent->workspace;
+ container->pending.workspace = container->pending.parent->pending.workspace;
}
void container_insert_child(struct sway_container *parent,
struct sway_container *child, int i) {
- if (child->workspace) {
+ if (child->pending.workspace) {
container_detach(child);
}
- list_insert(parent->children, i, child);
- child->parent = parent;
- child->workspace = parent->workspace;
+ list_insert(parent->pending.children, i, child);
+ child->pending.parent = parent;
+ child->pending.workspace = parent->pending.workspace;
container_for_each_child(child, set_workspace, NULL);
container_handle_fullscreen_reparent(child);
container_update_representation(parent);
@@ -1299,14 +1299,14 @@ void container_insert_child(struct sway_container *parent,
void container_add_sibling(struct sway_container *fixed,
struct sway_container *active, bool after) {
- if (active->workspace) {
+ if (active->pending.workspace) {
container_detach(active);
}
list_t *siblings = container_get_siblings(fixed);
int index = list_find(siblings, fixed);
list_insert(siblings, index + after, active);
- active->parent = fixed->parent;
- active->workspace = fixed->workspace;
+ active->pending.parent = fixed->pending.parent;
+ active->pending.workspace = fixed->pending.workspace;
container_for_each_child(active, set_workspace, NULL);
container_handle_fullscreen_reparent(active);
container_update_representation(active);
@@ -1314,15 +1314,15 @@ void container_add_sibling(struct sway_container *fixed,
void container_add_child(struct sway_container *parent,
struct sway_container *child) {
- if (child->workspace) {
+ if (child->pending.workspace) {
container_detach(child);
}
- list_add(parent->children, child);
- child->parent = parent;
- child->workspace = parent->workspace;
+ list_add(parent->pending.children, child);
+ child->pending.parent = parent;
+ child->pending.workspace = parent->pending.workspace;
container_for_each_child(child, set_workspace, NULL);
- bool fullscreen = child->fullscreen_mode != FULLSCREEN_NONE ||
- parent->fullscreen_mode != FULLSCREEN_NONE;
+ bool fullscreen = child->pending.fullscreen_mode != FULLSCREEN_NONE ||
+ parent->pending.fullscreen_mode != FULLSCREEN_NONE;
set_fullscreen_iterator(child, &fullscreen);
container_for_each_child(child, set_fullscreen_iterator, &fullscreen);
container_handle_fullscreen_reparent(child);
@@ -1332,15 +1332,15 @@ void container_add_child(struct sway_container *parent,
}
void container_detach(struct sway_container *child) {
- if (child->fullscreen_mode == FULLSCREEN_WORKSPACE) {
- child->workspace->fullscreen = NULL;
+ if (child->pending.fullscreen_mode == FULLSCREEN_WORKSPACE) {
+ child->pending.workspace->fullscreen = NULL;
}
- if (child->fullscreen_mode == FULLSCREEN_GLOBAL) {
+ if (child->pending.fullscreen_mode == FULLSCREEN_GLOBAL) {
root->fullscreen_global = NULL;
}
- struct sway_container *old_parent = child->parent;
- struct sway_workspace *old_workspace = child->workspace;
+ struct sway_container *old_parent = child->pending.parent;
+ struct sway_workspace *old_workspace = child->pending.workspace;
list_t *siblings = container_get_siblings(child);
if (siblings) {
int index = list_find(siblings, child);
@@ -1348,8 +1348,8 @@ void container_detach(struct sway_container *child) {
list_del(siblings, index);
}
}
- child->parent = NULL;
- child->workspace = NULL;
+ child->pending.parent = NULL;
+ child->pending.workspace = NULL;
container_for_each_child(child, set_workspace, NULL);
if (old_parent) {
@@ -1364,18 +1364,18 @@ void container_detach(struct sway_container *child) {
void container_replace(struct sway_container *container,
struct sway_container *replacement) {
- enum sway_fullscreen_mode fullscreen = container->fullscreen_mode;
+ enum sway_fullscreen_mode fullscreen = container->pending.fullscreen_mode;
bool scratchpad = container->scratchpad;
struct sway_workspace *ws = NULL;
if (fullscreen != FULLSCREEN_NONE) {
container_fullscreen_disable(container);
}
if (scratchpad) {
- ws = container->workspace;
+ ws = container->pending.workspace;
root_scratchpad_show(container);
root_scratchpad_remove_container(container);
}
- if (container->parent || container->workspace) {
+ if (container->pending.parent || container->pending.workspace) {
float width_fraction = container->width_fraction;
float height_fraction = container->height_fraction;
container_add_sibling(container, replacement, 1);
@@ -1403,7 +1403,7 @@ struct sway_container *container_split(struct sway_container *child,
enum sway_container_layout layout) {
// i3 doesn't split singleton H/V containers
// https://github.com/i3/i3/blob/3cd1c45eba6de073bc4300eebb4e1cc1a0c4479a/src/tree.c#L354
- if (child->parent || child->workspace) {
+ if (child->pending.parent || child->pending.workspace) {
list_t *siblings = container_get_siblings(child);
if (siblings->length == 1) {
enum sway_container_layout current = container_parent_layout(child);
@@ -1411,12 +1411,12 @@ struct sway_container *container_split(struct sway_container *child,
current = L_NONE;
}
if (current == L_HORIZ || current == L_VERT) {
- if (child->parent) {
- child->parent->layout = layout;
- container_update_representation(child->parent);
+ if (child->pending.parent) {
+ child->pending.parent->pending.layout = layout;
+ container_update_representation(child->pending.parent);
} else {
- child->workspace->layout = layout;
- workspace_update_representation(child->workspace);
+ child->pending.workspace->layout = layout;
+ workspace_update_representation(child->pending.workspace);
}
return child;
}
@@ -1429,25 +1429,25 @@ struct sway_container *container_split(struct sway_container *child,
if (container_is_floating(child) && child->view) {
view_set_tiled(child->view, true);
if (child->view->using_csd) {
- child->border = child->saved_border;
+ child->pending.border = child->saved_border;
}
}
struct sway_container *cont = container_create(NULL);
- cont->width = child->width;
- cont->height = child->height;
+ cont->pending.width = child->pending.width;
+ cont->pending.height = child->pending.height;
cont->width_fraction = child->width_fraction;
cont->height_fraction = child->height_fraction;
- cont->x = child->x;
- cont->y = child->y;
- cont->layout = layout;
+ cont->pending.x = child->pending.x;
+ cont->pending.y = child->pending.y;
+ cont->pending.layout = layout;
container_replace(child, cont);
container_add_child(cont, child);
if (set_focus) {
seat_set_raw_focus(seat, &cont->node);
- if (cont->fullscreen_mode == FULLSCREEN_GLOBAL) {
+ if (cont->pending.fullscreen_mode == FULLSCREEN_GLOBAL) {
seat_set_focus(seat, &child->node);
} else {
seat_set_raw_focus(seat, &child->node);
@@ -1608,19 +1608,19 @@ void container_update_marks_textures(struct sway_container *con) {
void container_raise_floating(struct sway_container *con) {
// Bring container to front by putting it at the end of the floating list.
struct sway_container *floater = container_toplevel_ancestor(con);
- if (container_is_floating(floater) && floater->workspace) {
- list_move_to_end(floater->workspace->floating, floater);
- node_set_dirty(&floater->workspace->node);
+ if (container_is_floating(floater) && floater->pending.workspace) {
+ list_move_to_end(floater->pending.workspace->floating, floater);
+ node_set_dirty(&floater->pending.workspace->node);
}
}
bool container_is_scratchpad_hidden(struct sway_container *con) {
- return con->scratchpad && !con->workspace;
+ return con->scratchpad && !con->pending.workspace;
}
bool container_is_scratchpad_hidden_or_child(struct sway_container *con) {
con = container_toplevel_ancestor(con);
- return con->scratchpad && !con->workspace;
+ return con->scratchpad && !con->pending.workspace;
}
bool container_is_sticky(struct sway_container *con) {
@@ -1648,39 +1648,39 @@ static bool is_parallel(enum sway_container_layout first,
static bool container_is_squashable(struct sway_container *con,
struct sway_container *child) {
enum sway_container_layout gp_layout = container_parent_layout(con);
- return (con->layout == L_HORIZ || con->layout == L_VERT) &&
- (child->layout == L_HORIZ || child->layout == L_VERT) &&
- !is_parallel(con->layout, child->layout) &&
- is_parallel(gp_layout, child->layout);
+ return (con->pending.layout == L_HORIZ || con->pending.layout == L_VERT) &&
+ (child->pending.layout == L_HORIZ || child->pending.layout == L_VERT) &&
+ !is_parallel(con->pending.layout, child->pending.layout) &&
+ is_parallel(gp_layout, child->pending.layout);
}
static void container_squash_children(struct sway_container *con) {
- for (int i = 0; i < con->children->length; i++) {
- struct sway_container *child = con->children->items[i];
+ for (int i = 0; i < con->pending.children->length; i++) {
+ struct sway_container *child = con->pending.children->items[i];
i += container_squash(child);
}
}
int container_squash(struct sway_container *con) {
- if (!con->children) {
+ if (!con->pending.children) {
return 0;
}
- if (con->children->length != 1) {
+ if (con->pending.children->length != 1) {
container_squash_children(con);
return 0;
}
- struct sway_container *child = con->children->items[0];
+ struct sway_container *child = con->pending.children->items[0];
int idx = container_sibling_index(con);
int change = 0;
if (container_is_squashable(con, child)) {
// con and child are a redundant H/V pair. Destroy them.
- while (child->children->length) {
- struct sway_container *current = child->children->items[0];
+ while (child->pending.children->length) {
+ struct sway_container *current = child->pending.children->items[0];
container_detach(current);
- if (con->parent) {
- container_insert_child(con->parent, current, idx);
+ if (con->pending.parent) {
+ container_insert_child(con->pending.parent, current, idx);
} else {
- workspace_insert_tiling_direct(con->workspace, current, idx);
+ workspace_insert_tiling_direct(con->pending.workspace, current, idx);
}
change++;
}
diff --git a/sway/tree/node.c b/sway/tree/node.c
index ffa7f2cc..bc7e2aa5 100644
--- a/sway/tree/node.c
+++ b/sway/tree/node.c
@@ -75,7 +75,7 @@ void node_get_box(struct sway_node *node, struct wlr_box *box) {
struct sway_output *node_get_output(struct sway_node *node) {
switch (node->type) {
case N_CONTAINER: {
- struct sway_workspace *ws = node->sway_container->workspace;
+ struct sway_workspace *ws = node->sway_container->pending.workspace;
return ws ? ws->output : NULL;
}
case N_WORKSPACE:
@@ -91,7 +91,7 @@ struct sway_output *node_get_output(struct sway_node *node) {
enum sway_container_layout node_get_layout(struct sway_node *node) {
switch (node->type) {
case N_CONTAINER:
- return node->sway_container->layout;
+ return node->sway_container->pending.layout;
case N_WORKSPACE:
return node->sway_workspace->layout;
case N_OUTPUT:
@@ -105,11 +105,11 @@ struct sway_node *node_get_parent(struct sway_node *node) {
switch (node->type) {
case N_CONTAINER: {
struct sway_container *con = node->sway_container;
- if (con->parent) {
- return &con->parent->node;
+ if (con->pending.parent) {
+ return &con->pending.parent->node;
}
- if (con->workspace) {
- return &con->workspace->node;
+ if (con->pending.workspace) {
+ return &con->pending.workspace->node;
}
}
return NULL;
@@ -131,7 +131,7 @@ struct sway_node *node_get_parent(struct sway_node *node) {
list_t *node_get_children(struct sway_node *node) {
switch (node->type) {
case N_CONTAINER:
- return node->sway_container->children;
+ return node->sway_container->pending.children;
case N_WORKSPACE:
return node->sway_workspace->tiling;
case N_OUTPUT:
@@ -143,7 +143,7 @@ list_t *node_get_children(struct sway_node *node) {
bool node_has_ancestor(struct sway_node *node, struct sway_node *ancestor) {
if (ancestor->type == N_ROOT && node->type == N_CONTAINER &&
- node->sway_container->fullscreen_mode == FULLSCREEN_GLOBAL) {
+ node->sway_container->pending.fullscreen_mode == FULLSCREEN_GLOBAL) {
return true;
}
struct sway_node *parent = node_get_parent(node);
@@ -152,7 +152,7 @@ bool node_has_ancestor(struct sway_node *node, struct sway_node *ancestor) {
return true;
}
if (ancestor->type == N_ROOT && parent->type == N_CONTAINER &&
- parent->sway_container->fullscreen_mode == FULLSCREEN_GLOBAL) {
+ parent->sway_container->pending.fullscreen_mode == FULLSCREEN_GLOBAL) {
return true;
}
parent = node_get_parent(parent);
diff --git a/sway/tree/output.c b/sway/tree/output.c
index a8ae30f7..c095dce0 100644
--- a/sway/tree/output.c
+++ b/sway/tree/output.c
@@ -70,13 +70,13 @@ static void restore_workspaces(struct sway_output *output) {
// floater re-centered
for (int i = 0; i < ws->floating->length; i++) {
struct sway_container *floater = ws->floating->items[i];
- if (floater->width == 0 || floater->height == 0 ||
- floater->width > output->width ||
- floater->height > output->height ||
- floater->x > output->lx + output->width ||
- floater->y > output->ly + output->height ||
- floater->x + floater->width < output->lx ||
- floater->y + floater->height < output->ly) {
+ if (floater->pending.width == 0 || floater->pending.height == 0 ||
+ floater->pending.width > output->width ||
+ floater->pending.height > output->height ||
+ floater->pending.x > output->lx + output->width ||
+ floater->pending.y > output->ly + output->height ||
+ floater->pending.x + floater->pending.width < output->lx ||
+ floater->pending.y + floater->pending.height < output->ly) {
container_floating_resize_and_center(floater);
}
}
diff --git a/sway/tree/root.c b/sway/tree/root.c
index 7a594538..dd4d8e33 100644
--- a/sway/tree/root.c
+++ b/sway/tree/root.c
@@ -59,11 +59,11 @@ void root_scratchpad_add_container(struct sway_container *con, struct sway_works
return;
}
- struct sway_container *parent = con->parent;
- struct sway_workspace *workspace = con->workspace;
+ struct sway_container *parent = con->pending.parent;
+ struct sway_workspace *workspace = con->pending.workspace;
// Clear the fullscreen mode when sending to the scratchpad
- if (con->fullscreen_mode != FULLSCREEN_NONE) {
+ if (con->pending.fullscreen_mode != FULLSCREEN_NONE) {
container_fullscreen_disable(con);
}
@@ -117,7 +117,7 @@ void root_scratchpad_show(struct sway_container *con) {
sway_log(SWAY_DEBUG, "No focused workspace to show scratchpad on");
return;
}
- struct sway_workspace *old_ws = con->workspace;
+ struct sway_workspace *old_ws = con->pending.workspace;
// If the current con or any of its parents are in fullscreen mode, we
// first need to disable it before showing the scratchpad con.
@@ -134,15 +134,15 @@ void root_scratchpad_show(struct sway_container *con) {
workspace_consider_destroy(old_ws);
} else {
// Act on the ancestor of scratchpad hidden split containers
- while (con->parent) {
- con = con->parent;
+ while (con->pending.parent) {
+ con = con->pending.parent;
}
}
workspace_add_floating(new_ws, con);
// Make sure the container's center point overlaps this workspace
- double center_lx = con->x + con->width / 2;
- double center_ly = con->y + con->height / 2;
+ double center_lx = con->pending.x + con->pending.width / 2;
+ double center_ly = con->pending.y + con->pending.height / 2;
struct wlr_box workspace_box;
workspace_get_box(new_ws, &workspace_box);
@@ -155,7 +155,7 @@ void root_scratchpad_show(struct sway_container *con) {
}
static void disable_fullscreen(struct sway_container *con, void *data) {
- if (con->fullscreen_mode != FULLSCREEN_NONE) {
+ if (con->pending.fullscreen_mode != FULLSCREEN_NONE) {
container_fullscreen_disable(con);
}
}
@@ -163,9 +163,9 @@ static void disable_fullscreen(struct sway_container *con, void *data) {
void root_scratchpad_hide(struct sway_container *con) {
struct sway_seat *seat = input_manager_current_seat();
struct sway_node *focus = seat_get_focus_inactive(seat, &root->node);
- struct sway_workspace *ws = con->workspace;
+ struct sway_workspace *ws = con->pending.workspace;
- if (con->fullscreen_mode == FULLSCREEN_GLOBAL && !con->workspace) {
+ if (con->pending.fullscreen_mode == FULLSCREEN_GLOBAL && !con->pending.workspace) {
// If the container was made fullscreen global while in the scratchpad,
// it should be shown until fullscreen has been disabled
return;
diff --git a/sway/tree/view.c b/sway/tree/view.c
index e62fd018..ad79b229 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -206,7 +206,7 @@ bool view_ancestor_is_only_visible(struct sway_view *view) {
} else {
only_visible = true;
}
- con = con->parent;
+ con = con->pending.parent;
}
return only_visible;
}
@@ -222,58 +222,58 @@ static bool view_is_only_visible(struct sway_view *view) {
}
}
- con = con->parent;
+ con = con->pending.parent;
}
return true;
}
static bool gaps_to_edge(struct sway_view *view) {
- struct side_gaps gaps = view->container->workspace->current_gaps;
+ struct side_gaps gaps = view->container->pending.workspace->current_gaps;
return gaps.top > 0 || gaps.right > 0 || gaps.bottom > 0 || gaps.left > 0;
}
void view_autoconfigure(struct sway_view *view) {
struct sway_container *con = view->container;
- struct sway_workspace *ws = con->workspace;
+ struct sway_workspace *ws = con->pending.workspace;
if (container_is_scratchpad_hidden(con) &&
- con->fullscreen_mode != FULLSCREEN_GLOBAL) {
+ con->pending.fullscreen_mode != FULLSCREEN_GLOBAL) {
return;
}
struct sway_output *output = ws ? ws->output : NULL;
- if (con->fullscreen_mode == FULLSCREEN_WORKSPACE) {
- con->content_x = output->lx;
- con->content_y = output->ly;
- con->content_width = output->width;
- con->content_height = output->height;
+ if (con->pending.fullscreen_mode == FULLSCREEN_WORKSPACE) {
+ con->pending.content_x = output->lx;
+ con->pending.content_y = output->ly;
+ con->pending.content_width = output->width;
+ con->pending.content_height = output->height;
return;
- } else if (con->fullscreen_mode == FULLSCREEN_GLOBAL) {
- con->content_x = root->x;
- con->content_y = root->y;
- con->content_width = root->width;
- con->content_height = root->height;
+ } else if (con->pending.fullscreen_mode == FULLSCREEN_GLOBAL) {
+ con->pending.content_x = root->x;
+ con->pending.content_y = root->y;
+ con->pending.content_width = root->width;
+ con->pending.content_height = root->height;
return;
}
- con->border_top = con->border_bottom = true;
- con->border_left = con->border_right = true;
+ con->pending.border_top = con->pending.border_bottom = true;
+ con->pending.border_left = con->pending.border_right = true;
double y_offset = 0;
if (!container_is_floating(con) && ws) {
if (config->hide_edge_borders == E_BOTH
|| config->hide_edge_borders == E_VERTICAL) {
- con->border_left = con->x != ws->x;
- int right_x = con->x + con->width;
- con->border_right = right_x != ws->x + ws->width;
+ con->pending.border_left = con->pending.x != ws->x;
+ int right_x = con->pending.x + con->pending.width;
+ con->pending.border_right = right_x != ws->x + ws->width;
}
if (config->hide_edge_borders == E_BOTH
|| config->hide_edge_borders == E_HORIZONTAL) {
- con->border_top = con->y != ws->y;
- int bottom_y = con->y + con->height;
- con->border_bottom = bottom_y != ws->y + ws->height;
+ con->pending.border_top = con->pending.y != ws->y;
+ int bottom_y = con->pending.y + con->pending.height;
+ con->pending.border_bottom = bottom_y != ws->y + ws->height;
}
bool smart = config->hide_edge_borders_smart == ESMART_ON ||
@@ -282,10 +282,10 @@ void view_autoconfigure(struct sway_view *view) {
if (smart) {
bool show_border = container_is_floating_or_child(con) ||
!view_is_only_visible(view);
- con->border_left &= show_border;
- con->border_right &= show_border;
- con->border_top &= show_border;
- con->border_bottom &= show_border;
+ con->pending.border_left &= show_border;
+ con->pending.border_right &= show_border;
+ con->pending.border_top &= show_border;
+ con->pending.border_bottom &= show_border;
}
// In a tabbed or stacked container, the container's y is the top of the
@@ -298,56 +298,56 @@ void view_autoconfigure(struct sway_view *view) {
enum sway_container_layout layout = container_parent_layout(con);
if (layout == L_TABBED) {
y_offset = container_titlebar_height();
- con->border_top = false;
+ con->pending.border_top = false;
} else if (layout == L_STACKED) {
y_offset = container_titlebar_height() * siblings->length;
- con->border_top = false;
+ con->pending.border_top = false;
}
}
}
double x, y, width, height;
- switch (con->border) {
+ switch (con->pending.border) {
default:
case B_CSD:
case B_NONE:
- x = con->x;
- y = con->y + y_offset;
- width = con->width;
- height = con->height - y_offset;
+ x = con->pending.x;
+ y = con->pending.y + y_offset;
+ width = con->pending.width;
+ height = con->pending.height - y_offset;
break;
case B_PIXEL:
- x = con->x + con->border_thickness * con->border_left;
- y = con->y + con->border_thickness * con->border_top + y_offset;
- width = con->width
- - con->border_thickness * con->border_left
- - con->border_thickness * con->border_right;
- height = con->height - y_offset
- - con->border_thickness * con->border_top
- - con->border_thickness * con->border_bottom;
+ x = con->pending.x + con->pending.border_thickness * con->pending.border_left;
+ y = con->pending.y + con->pending.border_thickness * con->pending.border_top + y_offset;
+ width = con->pending.width
+ - con->pending.border_thickness * con->pending.border_left
+ - con->pending.border_thickness * con->pending.border_right;
+ height = con->pending.height - y_offset
+ - con->pending.border_thickness * con->pending.border_top
+ - con->pending.border_thickness * con->pending.border_bottom;
break;
case B_NORMAL:
// Height is: 1px border + 3px pad + title height + 3px pad + 1px border
- x = con->x + con->border_thickness * con->border_left;
- width = con->width
- - con->border_thickness * con->border_left
- - con->border_thickness * con->border_right;
+ x = con->pending.x + con->pending.border_thickness * con->pending.border_left;
+ width = con->pending.width
+ - con->pending.border_thickness * con->pending.border_left
+ - con->pending.border_thickness * con->pending.border_right;
if (y_offset) {
- y = con->y + y_offset;
- height = con->height - y_offset
- - con->border_thickness * con->border_bottom;
+ y = con->pending.y + y_offset;
+ height = con->pending.height - y_offset
+ - con->pending.border_thickness * con->pending.border_bottom;
} else {
- y = con->y + container_titlebar_height();
- height = con->height - container_titlebar_height()
- - con->border_thickness * con->border_bottom;
+ y = con->pending.y + container_titlebar_height();
+ height = con->pending.height - container_titlebar_height()
+ - con->pending.border_thickness * con->pending.border_bottom;
}
break;
}
- con->content_x = x;
- con->content_y = y;
- con->content_width = width;
- con->content_height = height;
+ con->pending.content_x = x;
+ con->pending.content_y = y;
+ con->pending.content_width = width;
+ con->pending.content_height = height;
}
void view_set_activated(struct sway_view *view, bool activated) {
@@ -361,7 +361,7 @@ void view_set_activated(struct sway_view *view, bool activated) {
}
void view_request_activate(struct sway_view *view) {
- struct sway_workspace *ws = view->container->workspace;
+ struct sway_workspace *ws = view->container->pending.workspace;
if (!ws) { // hidden scratchpad container
return;
}
@@ -401,13 +401,13 @@ void view_set_csd_from_server(struct sway_view *view, bool enabled) {
void view_update_csd_from_client(struct sway_view *view, bool enabled) {
sway_log(SWAY_DEBUG, "View %p updated CSD to %i", view, enabled);
struct sway_container *con = view->container;
- if (enabled && con && con->border != B_CSD) {
- con->saved_border = con->border;
+ if (enabled && con && con->pending.border != B_CSD) {
+ con->saved_border = con->pending.border;
if (container_is_floating(con)) {
- con->border = B_CSD;
+ con->pending.border = B_CSD;
}
- } else if (!enabled && con && con->border == B_CSD) {
- con->border = con->saved_border;
+ } else if (!enabled && con && con->pending.border == B_CSD) {
+ con->pending.border = con->saved_border;
}
view->using_csd = enabled;
}
@@ -577,7 +577,7 @@ static struct sway_workspace *select_workspace(struct sway_view *view) {
if (node && node->type == N_WORKSPACE) {
return node->sway_workspace;
} else if (node && node->type == N_CONTAINER) {
- return node->sway_container->workspace;
+ return node->sway_container->pending.workspace;
}
// When there's no outputs connected, the above should match a workspace on
@@ -590,9 +590,9 @@ static bool should_focus(struct sway_view *view) {
struct sway_seat *seat = input_manager_current_seat();
struct sway_container *prev_con = seat_get_focused_container(seat);
struct sway_workspace *prev_ws = seat_get_focused_workspace(seat);
- struct sway_workspace *map_ws = view->container->workspace;
+ struct sway_workspace *map_ws = view->container->pending.workspace;
- if (view->container->fullscreen_mode == FULLSCREEN_GLOBAL) {
+ if (view->container->pending.fullscreen_mode == FULLSCREEN_GLOBAL) {
return true;
}
@@ -603,9 +603,9 @@ static bool should_focus(struct sway_view *view) {
// If the view is the only one in the focused workspace, it'll get focus
// regardless of any no_focus criteria.
- if (!view->container->parent && !prev_con) {
- size_t num_children = view->container->workspace->tiling->length +
- view->container->workspace->floating->length;
+ if (!view->container->pending.parent && !prev_con) {
+ size_t num_children = view->container->pending.workspace->tiling->length +
+ view->container->pending.workspace->floating->length;
if (num_children == 1) {
return true;
}
@@ -645,9 +645,9 @@ static void handle_foreign_fullscreen_request(
// Match fullscreen command behavior for scratchpad hidden views
struct sway_container *container = view->container;
- if (!container->workspace) {
- while (container->parent) {
- container = container->parent;
+ if (!container->pending.workspace) {
+ while (container->pending.parent) {
+ container = container->pending.parent;
}
}
@@ -668,10 +668,10 @@ static void handle_foreign_fullscreen_request(
if (event->fullscreen) {
arrange_root();
} else {
- if (container->parent) {
- arrange_container(container->parent);
- } else if (container->workspace) {
- arrange_workspace(container->workspace);
+ if (container->pending.parent) {
+ arrange_container(container->pending.parent);
+ } else if (container->pending.workspace) {
+ arrange_workspace(container->pending.workspace);
}
}
}
@@ -762,20 +762,20 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface,
}
if (view->impl->wants_floating && view->impl->wants_floating(view)) {
- view->container->border = config->floating_border;
- view->container->border_thickness = config->floating_border_thickness;
+ view->container->pending.border = config->floating_border;
+ view->container->pending.border_thickness = config->floating_border_thickness;
container_set_floating(view->container, true);
} else {
- view->container->border = config->border;
- view->container->border_thickness = config->border_thickness;
+ view->container->pending.border = config->border;
+ view->container->pending.border_thickness = config->border_thickness;
view_set_tiled(view, true);
}
if (config->popup_during_fullscreen == POPUP_LEAVE &&
- container->workspace &&
- container->workspace->fullscreen &&
- container->workspace->fullscreen->view) {
- struct sway_container *fs = container->workspace->fullscreen;
+ container->pending.workspace &&
+ container->pending.workspace->fullscreen &&
+ container->pending.workspace->fullscreen->view) {
+ struct sway_container *fs = container->pending.workspace->fullscreen;
if (view_is_transient_for(view, fs->view)) {
container_set_fullscreen(fs, false);
}
@@ -786,12 +786,12 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface,
if (fullscreen) {
container_set_fullscreen(view->container, true);
- arrange_workspace(view->container->workspace);
+ arrange_workspace(view->container->pending.workspace);
} else {
- if (container->parent) {
- arrange_container(container->parent);
- } else if (container->workspace) {
- arrange_workspace(container->workspace);
+ if (container->pending.parent) {
+ arrange_container(container->pending.parent);
+ } else if (container->pending.workspace) {
+ arrange_workspace(container->pending.workspace);
}
}
@@ -838,8 +838,8 @@ void view_unmap(struct sway_view *view) {
view->foreign_toplevel = NULL;
}
- struct sway_container *parent = view->container->parent;
- struct sway_workspace *ws = view->container->workspace;
+ struct sway_container *parent = view->container->pending.parent;
+ struct sway_workspace *ws = view->container->pending.workspace;
container_begin_destroy(view->container);
if (parent) {
container_reap_empty(parent);
@@ -874,8 +874,8 @@ void view_unmap(struct sway_view *view) {
void view_update_size(struct sway_view *view) {
struct sway_container *con = view->container;
- con->content_width = view->geometry.width;
- con->content_height = view->geometry.height;
+ con->pending.content_width = view->geometry.width;
+ con->pending.content_height = view->geometry.height;
container_set_geometry_from_content(con);
}
@@ -989,8 +989,8 @@ static void view_child_damage(struct sway_view_child *child, bool whole) {
int sx, sy;
child->impl->get_root_coords(child, &sx, &sy);
desktop_damage_surface(child->surface,
- child->view->container->content_x + sx,
- child->view->container->content_y + sy, whole);
+ child->view->container->pending.content_x + sx,
+ child->view->container->pending.content_y + sy, whole);
}
static void view_child_handle_surface_commit(struct wl_listener *listener,
@@ -1073,7 +1073,7 @@ void view_child_init(struct sway_view_child *child,
wl_signal_add(&view->events.unmap, &child->view_unmap);
child->view_unmap.notify = view_child_handle_view_unmap;
- struct sway_workspace *workspace = child->view->container->workspace;
+ struct sway_workspace *workspace = child->view->container->pending.workspace;
if (workspace) {
wlr_surface_send_enter(child->surface, workspace->output->wlr_output);
}
@@ -1256,15 +1256,15 @@ bool view_is_visible(struct sway_view *view) {
if (view->container->node.destroying) {
return false;
}
- struct sway_workspace *workspace = view->container->workspace;
- if (!workspace && view->container->fullscreen_mode != FULLSCREEN_GLOBAL) {
+ struct sway_workspace *workspace = view->container->pending.workspace;
+ if (!workspace && view->container->pending.fullscreen_mode != FULLSCREEN_GLOBAL) {
bool fs_global_descendant = false;
- struct sway_container *parent = view->container->parent;
+ struct sway_container *parent = view->container->pending.parent;
while (parent) {
- if (parent->fullscreen_mode == FULLSCREEN_GLOBAL) {
+ if (parent->pending.fullscreen_mode == FULLSCREEN_GLOBAL) {
fs_global_descendant = true;
}
- parent = parent->parent;
+ parent = parent->pending.parent;
}
if (!fs_global_descendant) {
return false;
@@ -1282,13 +1282,13 @@ bool view_is_visible(struct sway_view *view) {
enum sway_container_layout layout = container_parent_layout(con);
if ((layout == L_TABBED || layout == L_STACKED)
&& !container_is_floating(con)) {
- struct sway_node *parent = con->parent ?
- &con->parent->node : &con->workspace->node;
+ struct sway_node *parent = con->pending.parent ?
+ &con->pending.parent->node : &con->pending.workspace->node;
if (seat_get_active_tiling_child(seat, parent) != &con->node) {
return false;
}
}
- con = con->parent;
+ con = con->pending.parent;
}
// Check view isn't hidden by another fullscreen view
struct sway_container *fs = root->fullscreen_global ?
@@ -1322,7 +1322,7 @@ void view_set_urgent(struct sway_view *view, bool enable) {
ipc_event_window(view->container, "urgent");
if (!container_is_scratchpad_hidden(view->container)) {
- workspace_detect_urgent(view->container->workspace);
+ workspace_detect_urgent(view->container->pending.workspace);
}
}
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c
index 921b7d19..4e735064 100644
--- a/sway/tree/workspace.c
+++ b/sway/tree/workspace.c
@@ -48,7 +48,7 @@ struct sway_output *workspace_get_initial_output(const char *name) {
if (focus && focus->type == N_WORKSPACE) {
return focus->sway_workspace->output;
} else if (focus && focus->type == N_CONTAINER) {
- return focus->sway_container->workspace->output;
+ return focus->sway_container->pending.workspace->output;
}
// Fallback to the first output or noop output for headless
return root->outputs->length ? root->outputs->items[0] : root->noop_output;
@@ -569,7 +569,7 @@ bool workspace_switch(struct sway_workspace *workspace,
if (focus && focus->type == N_WORKSPACE) {
active_ws = focus->sway_workspace;
} else if (focus && focus->type == N_CONTAINER) {
- active_ws = focus->sway_container->workspace;
+ active_ws = focus->sway_container->pending.workspace;
}
if (!no_auto_back_and_forth && config->auto_back_and_forth && active_ws
@@ -736,13 +736,13 @@ struct sway_container *workspace_find_container(struct sway_workspace *ws,
}
static void set_workspace(struct sway_container *container, void *data) {
- container->workspace = container->parent->workspace;
+ container->pending.workspace = container->pending.parent->pending.workspace;
}
static void workspace_attach_tiling(struct sway_workspace *ws,
struct sway_container *con) {
list_add(ws->tiling, con);
- con->workspace = ws;
+ con->pending.workspace = ws;
container_for_each_child(con, set_workspace, NULL);
container_handle_fullscreen_reparent(con);
workspace_update_representation(ws);
@@ -753,7 +753,7 @@ static void workspace_attach_tiling(struct sway_workspace *ws,
struct sway_container *workspace_wrap_children(struct sway_workspace *ws) {
struct sway_container *fs = ws->fullscreen;
struct sway_container *middle = container_create(NULL);
- middle->layout = ws->layout;
+ middle->pending.layout = ws->layout;
while (ws->tiling->length) {
struct sway_container *child = ws->tiling->items[0];
container_detach(child);
@@ -771,9 +771,9 @@ void workspace_unwrap_children(struct sway_workspace *ws,
return;
}
- ws->layout = wrap->layout;
- while (wrap->children->length) {
- struct sway_container *child = wrap->children->items[0];
+ ws->layout = wrap->pending.layout;
+ while (wrap->pending.children->length) {
+ struct sway_container *child = wrap->pending.children->items[0];
container_detach(child);
workspace_add_tiling(ws, child);
}
@@ -793,14 +793,14 @@ void workspace_detach(struct sway_workspace *workspace) {
struct sway_container *workspace_add_tiling(struct sway_workspace *workspace,
struct sway_container *con) {
- if (con->workspace) {
+ if (con->pending.workspace) {
container_detach(con);
}
if (config->default_layout != L_NONE) {
con = container_split(con, config->default_layout);
}
list_add(workspace->tiling, con);
- con->workspace = workspace;
+ con->pending.workspace = workspace;
container_for_each_child(con, set_workspace, NULL);
container_handle_fullscreen_reparent(con);
workspace_update_representation(workspace);
@@ -811,11 +811,11 @@ struct sway_container *workspace_add_tiling(struct sway_workspace *workspace,
void workspace_add_floating(struct sway_workspace *workspace,
struct sway_container *con) {
- if (con->workspace) {
+ if (con->pending.workspace) {
container_detach(con);
}
list_add(workspace->floating, con);
- con->workspace = workspace;
+ con->pending.workspace = workspace;
container_for_each_child(con, set_workspace, NULL);
container_handle_fullscreen_reparent(con);
node_set_dirty(&workspace->node);
@@ -825,7 +825,7 @@ void workspace_add_floating(struct sway_workspace *workspace,
void workspace_insert_tiling_direct(struct sway_workspace *workspace,
struct sway_container *con, int index) {
list_insert(workspace->tiling, index, con);
- con->workspace = workspace;
+ con->pending.workspace = workspace;
container_for_each_child(con, set_workspace, NULL);
container_handle_fullscreen_reparent(con);
workspace_update_representation(workspace);
@@ -835,7 +835,7 @@ void workspace_insert_tiling_direct(struct sway_workspace *workspace,
struct sway_container *workspace_insert_tiling(struct sway_workspace *workspace,
struct sway_container *con, int index) {
- if (con->workspace) {
+ if (con->pending.workspace) {
container_detach(con);
}
if (config->default_layout != L_NONE) {
@@ -905,7 +905,7 @@ struct sway_container *workspace_split(struct sway_workspace *workspace,
enum sway_container_layout old_layout = workspace->layout;
struct sway_container *middle = workspace_wrap_children(workspace);
workspace->layout = layout;
- middle->layout = old_layout;
+ middle->pending.layout = old_layout;
struct sway_seat *seat;
wl_list_for_each(seat, &server.input->seats, link) {