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.
This commit is contained in:
Kenny Levinsen 2021-02-12 23:22:51 +01:00 committed by Tudor Brindus
parent 28cadf5580
commit a047b5ee4a
33 changed files with 723 additions and 757 deletions

View file

@ -46,9 +46,9 @@ struct sway_container_state {
enum sway_fullscreen_mode fullscreen_mode; enum sway_fullscreen_mode fullscreen_mode;
struct sway_workspace *workspace; struct sway_workspace *workspace; // NULL when hidden in the scratchpad
struct sway_container *parent; struct sway_container *parent; // NULL if container in root of workspace
list_t *children; list_t *children; // struct sway_container
struct sway_container *focused_inactive_child; struct sway_container *focused_inactive_child;
bool focused; bool focused;
@ -60,6 +60,7 @@ struct sway_container_state {
bool border_left; bool border_left;
bool border_right; bool border_right;
// These are in layout coordinates.
double content_x, content_y; double content_x, content_y;
double content_width, content_height; double content_width, content_height;
}; };
@ -68,14 +69,12 @@ struct sway_container {
struct sway_node node; struct sway_node node;
struct sway_view *view; struct sway_view *view;
// The pending state is the main container properties, and the current state is in the below struct.
// This means most places of the code can refer to the main variables (pending state) and it'll just work.
struct sway_container_state current; struct sway_container_state current;
struct sway_container_state pending;
char *title; // The view's title (unformatted) char *title; // The view's title (unformatted)
char *formatted_title; // The title displayed in the title bar char *formatted_title; // The title displayed in the title bar
enum sway_container_layout layout;
enum sway_container_layout prev_split_layout; enum sway_container_layout prev_split_layout;
// Whether stickiness has been enabled on this container. Use // Whether stickiness has been enabled on this container. Use
@ -86,11 +85,13 @@ struct sway_container {
// For C_ROOT, this has no meaning // For C_ROOT, this has no meaning
// For other types, this is the position in layout coordinates // For other types, this is the position in layout coordinates
// Includes borders // Includes borders
double x, y;
double width, height;
double saved_x, saved_y; double saved_x, saved_y;
double saved_width, saved_height; double saved_width, saved_height;
// Used when the view changes to CSD unexpectedly. This will be a non-B_CSD
// border which we use to restore when the view returns to SSD.
enum sway_container_border saved_border;
// The share of the space of parent container this container occupies // The share of the space of parent container this container occupies
double width_fraction; double width_fraction;
double height_fraction; double height_fraction;
@ -100,33 +101,11 @@ struct sway_container {
double child_total_width; double child_total_width;
double child_total_height; double child_total_height;
// These are in layout coordinates.
double content_x, content_y;
int content_width, content_height;
// In most cases this is the same as the content x and y, but if the view // In most cases this is the same as the content x and y, but if the view
// refuses to resize to the content dimensions then it can be smaller. // refuses to resize to the content dimensions then it can be smaller.
// These are in layout coordinates. // These are in layout coordinates.
double surface_x, surface_y; double surface_x, surface_y;
enum sway_fullscreen_mode fullscreen_mode;
enum sway_container_border border;
// Used when the view changes to CSD unexpectedly. This will be a non-B_CSD
// border which we use to restore when the view returns to SSD.
enum sway_container_border saved_border;
int border_thickness;
bool border_top;
bool border_bottom;
bool border_left;
bool border_right;
struct sway_workspace *workspace; // NULL when hidden in the scratchpad
struct sway_container *parent; // NULL if container in root of workspace
list_t *children; // struct sway_container
// Outputs currently being intersected // Outputs currently being intersected
list_t *outputs; // struct sway_output list_t *outputs; // struct sway_output

View file

@ -186,7 +186,7 @@ static void set_config_node(struct sway_node *node) {
switch (node->type) { switch (node->type) {
case N_CONTAINER: case N_CONTAINER:
config->handler_context.container = node->sway_container; config->handler_context.container = node->sway_container;
config->handler_context.workspace = node->sway_container->workspace; config->handler_context.workspace = node->sway_container->pending.workspace;
break; break;
case N_WORKSPACE: case N_WORKSPACE:
config->handler_context.workspace = node->sway_workspace; config->handler_context.workspace = node->sway_workspace;

View file

@ -19,11 +19,11 @@ static void set_border(struct sway_container *con,
view_set_csd_from_server(con->view, false); view_set_csd_from_server(con->view, false);
} else if (!con->view->using_csd && new_border == B_CSD) { } else if (!con->view->using_csd && new_border == B_CSD) {
view_set_csd_from_server(con->view, true); view_set_csd_from_server(con->view, true);
con->saved_border = con->border; con->saved_border = con->pending.border;
} }
} }
if (new_border != B_CSD || container_is_floating(con)) { if (new_border != B_CSD || container_is_floating(con)) {
con->border = new_border; con->pending.border = new_border;
} }
if (con->view) { if (con->view) {
con->view->using_csd = new_border == B_CSD; con->view->using_csd = new_border == B_CSD;
@ -35,7 +35,7 @@ static void border_toggle(struct sway_container *con) {
set_border(con, B_NONE); set_border(con, B_NONE);
return; return;
} }
switch (con->border) { switch (con->pending.border) {
case B_NONE: case B_NONE:
set_border(con, B_PIXEL); set_border(con, B_PIXEL);
break; break;
@ -88,7 +88,7 @@ struct cmd_results *cmd_border(int argc, char **argv) {
"or 'border pixel <px>'"); "or 'border pixel <px>'");
} }
if (argc == 2) { if (argc == 2) {
container->border_thickness = atoi(argv[1]); container->pending.border_thickness = atoi(argv[1]);
} }
if (container_is_floating(container)) { if (container_is_floating(container)) {

View file

@ -40,8 +40,8 @@ struct cmd_results *cmd_floating(int argc, char **argv) {
// If the container is in a floating split container, // If the container is in a floating split container,
// operate on the split container instead of the child. // operate on the split container instead of the child.
if (container_is_floating_or_child(container)) { if (container_is_floating_or_child(container)) {
while (container->parent) { while (container->pending.parent) {
container = container->parent; container = container->pending.parent;
} }
} }
@ -51,8 +51,8 @@ struct cmd_results *cmd_floating(int argc, char **argv) {
container_set_floating(container, wants_floating); container_set_floating(container, wants_floating);
// Floating containers in the scratchpad should be ignored // Floating containers in the scratchpad should be ignored
if (container->workspace) { if (container->pending.workspace) {
arrange_workspace(container->workspace); arrange_workspace(container->pending.workspace);
} }
return cmd_results_new(CMD_SUCCESS, NULL); return cmd_results_new(CMD_SUCCESS, NULL);

View file

@ -141,9 +141,9 @@ static struct sway_node *node_get_in_direction_tiling(
struct sway_container *wrap_candidate = NULL; struct sway_container *wrap_candidate = NULL;
struct sway_container *current = container; struct sway_container *current = container;
while (current) { while (current) {
if (current->fullscreen_mode == FULLSCREEN_WORKSPACE) { if (current->pending.fullscreen_mode == FULLSCREEN_WORKSPACE) {
// Fullscreen container with a direction - go straight to outputs // Fullscreen container with a direction - go straight to outputs
struct sway_output *output = current->workspace->output; struct sway_output *output = current->pending.workspace->output;
struct sway_output *new_output = struct sway_output *new_output =
output_get_in_direction(output, dir); output_get_in_direction(output, dir);
if (!new_output) { if (!new_output) {
@ -151,7 +151,7 @@ static struct sway_node *node_get_in_direction_tiling(
} }
return get_node_in_output_direction(new_output, dir); return get_node_in_output_direction(new_output, dir);
} }
if (current->fullscreen_mode == FULLSCREEN_GLOBAL) { if (current->pending.fullscreen_mode == FULLSCREEN_GLOBAL) {
return NULL; return NULL;
} }
@ -202,11 +202,11 @@ static struct sway_node *node_get_in_direction_tiling(
} }
} }
current = current->parent; current = current->pending.parent;
} }
// Check a different output // Check a different output
struct sway_output *output = container->workspace->output; struct sway_output *output = container->pending.workspace->output;
struct sway_output *new_output = output_get_in_direction(output, dir); struct sway_output *new_output = output_get_in_direction(output, dir);
if ((config->focus_wrapping != WRAP_WORKSPACE || if ((config->focus_wrapping != WRAP_WORKSPACE ||
container->node.type == N_WORKSPACE) && new_output) { container->node.type == N_WORKSPACE) && new_output) {
@ -226,23 +226,23 @@ static struct sway_node *node_get_in_direction_tiling(
static struct sway_node *node_get_in_direction_floating( static struct sway_node *node_get_in_direction_floating(
struct sway_container *con, struct sway_seat *seat, struct sway_container *con, struct sway_seat *seat,
enum wlr_direction dir) { enum wlr_direction dir) {
double ref_lx = con->x + con->width / 2; double ref_lx = con->pending.x + con->pending.width / 2;
double ref_ly = con->y + con->height / 2; double ref_ly = con->pending.y + con->pending.height / 2;
double closest_distance = DBL_MAX; double closest_distance = DBL_MAX;
struct sway_container *closest_con = NULL; struct sway_container *closest_con = NULL;
if (!con->workspace) { if (!con->pending.workspace) {
return NULL; return NULL;
} }
for (int i = 0; i < con->workspace->floating->length; i++) { for (int i = 0; i < con->pending.workspace->floating->length; i++) {
struct sway_container *floater = con->workspace->floating->items[i]; struct sway_container *floater = con->pending.workspace->floating->items[i];
if (floater == con) { if (floater == con) {
continue; continue;
} }
float distance = dir == WLR_DIRECTION_LEFT || dir == WLR_DIRECTION_RIGHT float distance = dir == WLR_DIRECTION_LEFT || dir == WLR_DIRECTION_RIGHT
? (floater->x + floater->width / 2) - ref_lx ? (floater->pending.x + floater->pending.width / 2) - ref_lx
: (floater->y + floater->height / 2) - ref_ly; : (floater->pending.y + floater->pending.height / 2) - ref_ly;
if (dir == WLR_DIRECTION_LEFT || dir == WLR_DIRECTION_UP) { if (dir == WLR_DIRECTION_LEFT || dir == WLR_DIRECTION_UP) {
distance = -distance; distance = -distance;
} }
@ -334,7 +334,7 @@ static struct cmd_results *focus_output(struct sway_seat *seat,
static struct cmd_results *focus_parent(void) { static struct cmd_results *focus_parent(void) {
struct sway_seat *seat = config->handler_context.seat; struct sway_seat *seat = config->handler_context.seat;
struct sway_container *con = config->handler_context.container; struct sway_container *con = config->handler_context.container;
if (!con || con->fullscreen_mode) { if (!con || con->pending.fullscreen_mode) {
return cmd_results_new(CMD_SUCCESS, NULL); return cmd_results_new(CMD_SUCCESS, NULL);
} }
struct sway_node *parent = node_get_parent(&con->node); struct sway_node *parent = node_get_parent(&con->node);

View file

@ -27,15 +27,15 @@ struct cmd_results *cmd_fullscreen(int argc, char **argv) {
} }
// If in the scratchpad, operate on the highest container // If in the scratchpad, operate on the highest container
if (container && !container->workspace) { if (container && !container->pending.workspace) {
while (container->parent) { while (container->pending.parent) {
container = container->parent; container = container->pending.parent;
} }
} }
bool is_fullscreen = false; bool is_fullscreen = false;
for (struct sway_container *curr = container; curr; curr = curr->parent) { for (struct sway_container *curr = container; curr; curr = curr->pending.parent) {
if (curr->fullscreen_mode != FULLSCREEN_NONE) { if (curr->pending.fullscreen_mode != FULLSCREEN_NONE) {
container = curr; container = curr;
is_fullscreen = true; is_fullscreen = true;
break; break;

View file

@ -133,7 +133,7 @@ struct cmd_results *cmd_layout(int argc, char **argv) {
// Operate on parent container, like i3. // Operate on parent container, like i3.
if (container) { if (container) {
container = container->parent; container = container->pending.parent;
} }
// We could be working with a container OR a workspace. These are different // We could be working with a container OR a workspace. These are different
@ -142,10 +142,10 @@ struct cmd_results *cmd_layout(int argc, char **argv) {
enum sway_container_layout new_layout = L_NONE; enum sway_container_layout new_layout = L_NONE;
enum sway_container_layout old_layout = L_NONE; enum sway_container_layout old_layout = L_NONE;
if (container) { if (container) {
old_layout = container->layout; old_layout = container->pending.layout;
new_layout = get_layout(argc, argv, new_layout = get_layout(argc, argv,
container->layout, container->prev_split_layout, container->pending.layout, container->prev_split_layout,
container->workspace->output); container->pending.workspace->output);
} else { } else {
old_layout = workspace->layout; old_layout = workspace->layout;
new_layout = get_layout(argc, argv, new_layout = get_layout(argc, argv,
@ -160,13 +160,13 @@ struct cmd_results *cmd_layout(int argc, char **argv) {
if (old_layout != L_TABBED && old_layout != L_STACKED) { if (old_layout != L_TABBED && old_layout != L_STACKED) {
container->prev_split_layout = old_layout; container->prev_split_layout = old_layout;
} }
container->layout = new_layout; container->pending.layout = new_layout;
container_update_representation(container); container_update_representation(container);
} else if (config->handler_context.container) { } else if (config->handler_context.container) {
// i3 avoids changing workspace layouts with a new container // i3 avoids changing workspace layouts with a new container
// https://github.com/i3/i3/blob/3cd1c45eba6de073bc4300eebb4e1cc1a0c4479a/src/con.c#L1817 // https://github.com/i3/i3/blob/3cd1c45eba6de073bc4300eebb4e1cc1a0c4479a/src/con.c#L1817
container = workspace_wrap_children(workspace); container = workspace_wrap_children(workspace);
container->layout = new_layout; container->pending.layout = new_layout;
container_update_representation(container); container_update_representation(container);
} else { } else {
if (old_layout != L_TABBED && old_layout != L_STACKED) { if (old_layout != L_TABBED && old_layout != L_STACKED) {

View file

@ -113,8 +113,8 @@ static void container_move_to_container_from_direction(
struct sway_container *container, struct sway_container *destination, struct sway_container *container, struct sway_container *destination,
enum wlr_direction move_dir) { enum wlr_direction move_dir) {
if (destination->view) { if (destination->view) {
if (destination->parent == container->parent && if (destination->pending.parent == container->pending.parent &&
destination->workspace == container->workspace) { destination->pending.workspace == container->pending.workspace) {
sway_log(SWAY_DEBUG, "Swapping siblings"); sway_log(SWAY_DEBUG, "Swapping siblings");
list_t *siblings = container_get_siblings(container); list_t *siblings = container_get_siblings(container);
int container_index = list_find(siblings, container); int container_index = list_find(siblings, container);
@ -126,28 +126,28 @@ static void container_move_to_container_from_direction(
int offset = int offset =
move_dir == WLR_DIRECTION_LEFT || move_dir == WLR_DIRECTION_UP; move_dir == WLR_DIRECTION_LEFT || move_dir == WLR_DIRECTION_UP;
int index = container_sibling_index(destination) + offset; int index = container_sibling_index(destination) + offset;
if (destination->parent) { if (destination->pending.parent) {
container_insert_child(destination->parent, container, index); container_insert_child(destination->pending.parent, container, index);
} else { } else {
workspace_insert_tiling(destination->workspace, workspace_insert_tiling(destination->pending.workspace,
container, index); container, index);
} }
container->width = container->height = 0; container->pending.width = container->pending.height = 0;
container->width_fraction = container->height_fraction = 0; container->width_fraction = container->height_fraction = 0;
workspace_squash(destination->workspace); workspace_squash(destination->pending.workspace);
} }
return; return;
} }
if (is_parallel(destination->layout, move_dir)) { if (is_parallel(destination->pending.layout, move_dir)) {
sway_log(SWAY_DEBUG, "Reparenting container (parallel)"); sway_log(SWAY_DEBUG, "Reparenting container (parallel)");
int index = int index =
move_dir == WLR_DIRECTION_RIGHT || move_dir == WLR_DIRECTION_DOWN ? move_dir == WLR_DIRECTION_RIGHT || move_dir == WLR_DIRECTION_DOWN ?
0 : destination->children->length; 0 : destination->pending.children->length;
container_insert_child(destination, container, index); container_insert_child(destination, container, index);
container->width = container->height = 0; container->pending.width = container->pending.height = 0;
container->width_fraction = container->height_fraction = 0; container->width_fraction = container->height_fraction = 0;
workspace_squash(destination->workspace); workspace_squash(destination->pending.workspace);
return; return;
} }
@ -168,7 +168,7 @@ static void container_move_to_container_from_direction(
static void container_move_to_workspace_from_direction( static void container_move_to_workspace_from_direction(
struct sway_container *container, struct sway_workspace *workspace, struct sway_container *container, struct sway_workspace *workspace,
enum wlr_direction move_dir) { enum wlr_direction move_dir) {
container->width = container->height = 0; container->pending.width = container->pending.height = 0;
container->width_fraction = container->height_fraction = 0; container->width_fraction = container->height_fraction = 0;
if (is_parallel(workspace->layout, move_dir)) { if (is_parallel(workspace->layout, move_dir)) {
@ -188,8 +188,8 @@ static void container_move_to_workspace_from_direction(
workspace_add_tiling(workspace, container); workspace_add_tiling(workspace, container);
return; return;
} }
while (focus_inactive->parent) { while (focus_inactive->pending.parent) {
focus_inactive = focus_inactive->parent; focus_inactive = focus_inactive->pending.parent;
} }
container_move_to_container_from_direction(container, focus_inactive, container_move_to_container_from_direction(container, focus_inactive,
move_dir); move_dir);
@ -197,25 +197,25 @@ static void container_move_to_workspace_from_direction(
static void container_move_to_workspace(struct sway_container *container, static void container_move_to_workspace(struct sway_container *container,
struct sway_workspace *workspace) { struct sway_workspace *workspace) {
if (container->workspace == workspace) { if (container->pending.workspace == workspace) {
return; return;
} }
struct sway_workspace *old_workspace = container->workspace; struct sway_workspace *old_workspace = container->pending.workspace;
if (container_is_floating(container)) { if (container_is_floating(container)) {
struct sway_output *old_output = container->workspace->output; struct sway_output *old_output = container->pending.workspace->output;
container_detach(container); container_detach(container);
workspace_add_floating(workspace, container); workspace_add_floating(workspace, container);
container_handle_fullscreen_reparent(container); container_handle_fullscreen_reparent(container);
// If changing output, center it within the workspace // If changing output, center it within the workspace
if (old_output != workspace->output && !container->fullscreen_mode) { if (old_output != workspace->output && !container->pending.fullscreen_mode) {
container_floating_move_to_center(container); container_floating_move_to_center(container);
} }
} else { } else {
container_detach(container); container_detach(container);
if (workspace_is_empty(workspace) && container->children) { if (workspace_is_empty(workspace) && container->pending.children) {
workspace_unwrap_children(workspace, container); workspace_unwrap_children(workspace, container);
} else { } else {
container->width = container->height = 0; container->pending.width = container->pending.height = 0;
container->width_fraction = container->height_fraction = 0; container->width_fraction = container->height_fraction = 0;
workspace_add_tiling(workspace, container); workspace_add_tiling(workspace, container);
} }
@ -237,13 +237,13 @@ static void container_move_to_container(struct sway_container *container,
return; return;
} }
if (container_is_floating(container)) { if (container_is_floating(container)) {
container_move_to_workspace(container, destination->workspace); container_move_to_workspace(container, destination->pending.workspace);
return; return;
} }
struct sway_workspace *old_workspace = container->workspace; struct sway_workspace *old_workspace = container->pending.workspace;
container_detach(container); container_detach(container);
container->width = container->height = 0; container->pending.width = container->pending.height = 0;
container->width_fraction = container->height_fraction = 0; container->width_fraction = container->height_fraction = 0;
if (destination->view) { if (destination->view) {
@ -256,12 +256,12 @@ static void container_move_to_container(struct sway_container *container,
ipc_event_window(container, "move"); ipc_event_window(container, "move");
} }
if (destination->workspace) { if (destination->pending.workspace) {
workspace_focus_fullscreen(destination->workspace); workspace_focus_fullscreen(destination->pending.workspace);
workspace_detect_urgent(destination->workspace); workspace_detect_urgent(destination->pending.workspace);
} }
if (old_workspace && old_workspace != destination->workspace) { if (old_workspace && old_workspace != destination->pending.workspace) {
workspace_detect_urgent(old_workspace); workspace_detect_urgent(old_workspace);
} }
} }
@ -275,7 +275,7 @@ static bool container_move_to_next_output(struct sway_container *container,
if (!sway_assert(ws, "Expected output to have a workspace")) { if (!sway_assert(ws, "Expected output to have a workspace")) {
return false; return false;
} }
switch (container->fullscreen_mode) { switch (container->pending.fullscreen_mode) {
case FULLSCREEN_NONE: case FULLSCREEN_NONE:
container_move_to_workspace_from_direction(container, ws, move_dir); container_move_to_workspace_from_direction(container, ws, move_dir);
return true; return true;
@ -293,12 +293,12 @@ static bool container_move_to_next_output(struct sway_container *container,
static bool container_move_in_direction(struct sway_container *container, static bool container_move_in_direction(struct sway_container *container,
enum wlr_direction move_dir) { enum wlr_direction move_dir) {
// If moving a fullscreen view, only consider outputs // If moving a fullscreen view, only consider outputs
switch (container->fullscreen_mode) { switch (container->pending.fullscreen_mode) {
case FULLSCREEN_NONE: case FULLSCREEN_NONE:
break; break;
case FULLSCREEN_WORKSPACE: case FULLSCREEN_WORKSPACE:
return container_move_to_next_output(container, return container_move_to_next_output(container,
container->workspace->output, move_dir); container->pending.workspace->output, move_dir);
case FULLSCREEN_GLOBAL: case FULLSCREEN_GLOBAL:
return false; return false;
} }
@ -317,26 +317,26 @@ static bool container_move_in_direction(struct sway_container *container,
while (!ancestor) { while (!ancestor) {
// Don't allow containers to move out of their // Don't allow containers to move out of their
// fullscreen or floating parent // fullscreen or floating parent
if (current->fullscreen_mode || container_is_floating(current)) { if (current->pending.fullscreen_mode || container_is_floating(current)) {
return false; return false;
} }
enum sway_container_layout parent_layout = container_parent_layout(current); enum sway_container_layout parent_layout = container_parent_layout(current);
if (!is_parallel(parent_layout, move_dir)) { if (!is_parallel(parent_layout, move_dir)) {
if (!current->parent) { if (!current->pending.parent) {
// No parallel parent, so we reorient the workspace // No parallel parent, so we reorient the workspace
current = workspace_wrap_children(current->workspace); current = workspace_wrap_children(current->pending.workspace);
current->workspace->layout = current->pending.workspace->layout =
move_dir == WLR_DIRECTION_LEFT || move_dir == WLR_DIRECTION_LEFT ||
move_dir == WLR_DIRECTION_RIGHT ? move_dir == WLR_DIRECTION_RIGHT ?
L_HORIZ : L_VERT; L_HORIZ : L_VERT;
container->height = container->width = 0; container->pending.height = container->pending.width = 0;
container->height_fraction = container->width_fraction = 0; container->height_fraction = container->width_fraction = 0;
workspace_update_representation(current->workspace); workspace_update_representation(current->pending.workspace);
wrapped = true; wrapped = true;
} else { } else {
// Keep looking for a parallel parent // Keep looking for a parallel parent
current = current->parent; current = current->pending.parent;
} }
continue; continue;
} }
@ -356,14 +356,14 @@ static bool container_move_in_direction(struct sway_container *container,
container_move_to_container_from_direction(container, container_move_to_container_from_direction(container,
target, move_dir); target, move_dir);
return true; return true;
} else if (!container->parent) { } else if (!container->pending.parent) {
// Container is at workspace level so we move it to the // Container is at workspace level so we move it to the
// next workspace if possible // next workspace if possible
return container_move_to_next_output(container, return container_move_to_next_output(container,
current->workspace->output, move_dir); current->pending.workspace->output, move_dir);
} else { } else {
// Container has escaped its immediate parallel parent // Container has escaped its immediate parallel parent
current = current->parent; current = current->pending.parent;
continue; continue;
} }
} }
@ -377,31 +377,31 @@ static bool container_move_in_direction(struct sway_container *container,
container_move_to_container_from_direction(container, container_move_to_container_from_direction(container,
target, move_dir); target, move_dir);
return true; return true;
} else if (!wrapped && !container->parent->parent && } else if (!wrapped && !container->pending.parent->pending.parent &&
container->parent->children->length == 1) { container->pending.parent->pending.children->length == 1) {
// Treat singleton children as if they are at workspace level like i3 // Treat singleton children as if they are at workspace level like i3
// https://github.com/i3/i3/blob/1d9160f2d247dbaa83fb62f02fd7041dec767fc2/src/move.c#L367 // https://github.com/i3/i3/blob/1d9160f2d247dbaa83fb62f02fd7041dec767fc2/src/move.c#L367
return container_move_to_next_output(container, return container_move_to_next_output(container,
ancestor->workspace->output, move_dir); ancestor->pending.workspace->output, move_dir);
} else { } else {
// Container will be promoted // Container will be promoted
struct sway_container *old_parent = container->parent; struct sway_container *old_parent = container->pending.parent;
if (ancestor->parent) { if (ancestor->pending.parent) {
// Container will move in with its parent // Container will move in with its parent
container_insert_child(ancestor->parent, container, container_insert_child(ancestor->pending.parent, container,
index + (offs < 0 ? 0 : 1)); index + (offs < 0 ? 0 : 1));
} else { } else {
// Container will move to workspace level, // Container will move to workspace level,
// may be re-split by workspace_layout // may be re-split by workspace_layout
workspace_insert_tiling(ancestor->workspace, container, workspace_insert_tiling(ancestor->pending.workspace, container,
index + (offs < 0 ? 0 : 1)); index + (offs < 0 ? 0 : 1));
} }
ancestor->height = ancestor->width = 0; ancestor->pending.height = ancestor->pending.width = 0;
ancestor->height_fraction = ancestor->width_fraction = 0; ancestor->height_fraction = ancestor->width_fraction = 0;
if (old_parent) { if (old_parent) {
container_reap_empty(old_parent); container_reap_empty(old_parent);
} }
workspace_squash(container->workspace); workspace_squash(container->pending.workspace);
return true; return true;
} }
} }
@ -427,14 +427,14 @@ static struct cmd_results *cmd_move_container(bool no_auto_back_and_forth,
container = workspace_wrap_children(workspace); container = workspace_wrap_children(workspace);
} }
if (container->fullscreen_mode == FULLSCREEN_GLOBAL) { if (container->pending.fullscreen_mode == FULLSCREEN_GLOBAL) {
return cmd_results_new(CMD_FAILURE, return cmd_results_new(CMD_FAILURE,
"Can't move fullscreen global container"); "Can't move fullscreen global container");
} }
struct sway_seat *seat = config->handler_context.seat; struct sway_seat *seat = config->handler_context.seat;
struct sway_container *old_parent = container->parent; struct sway_container *old_parent = container->pending.parent;
struct sway_workspace *old_ws = container->workspace; struct sway_workspace *old_ws = container->pending.workspace;
struct sway_output *old_output = old_ws ? old_ws->output : NULL; struct sway_output *old_output = old_ws ? old_ws->output : NULL;
struct sway_node *destination = NULL; struct sway_node *destination = NULL;
@ -508,7 +508,7 @@ static struct cmd_results *cmd_move_container(bool no_auto_back_and_forth,
destination = dst ? &dst->node : &ws->node; destination = dst ? &dst->node : &ws->node;
} else if (strcasecmp(argv[0], "output") == 0) { } else if (strcasecmp(argv[0], "output") == 0) {
struct sway_output *new_output = output_in_direction(argv[1], struct sway_output *new_output = output_in_direction(argv[1],
old_output, container->x, container->y); old_output, container->pending.x, container->pending.y);
if (!new_output) { if (!new_output) {
return cmd_results_new(CMD_FAILURE, return cmd_results_new(CMD_FAILURE,
"Can't find output with name/direction '%s'", argv[1]); "Can't find output with name/direction '%s'", argv[1]);
@ -706,12 +706,12 @@ static struct cmd_results *cmd_move_in_direction(
"Cannot move workspaces in a direction"); "Cannot move workspaces in a direction");
} }
if (container_is_floating(container)) { if (container_is_floating(container)) {
if (container->fullscreen_mode) { if (container->pending.fullscreen_mode) {
return cmd_results_new(CMD_FAILURE, return cmd_results_new(CMD_FAILURE,
"Cannot move fullscreen floating container"); "Cannot move fullscreen floating container");
} }
double lx = container->x; double lx = container->pending.x;
double ly = container->y; double ly = container->pending.y;
switch (direction) { switch (direction) {
case WLR_DIRECTION_LEFT: case WLR_DIRECTION_LEFT:
lx -= move_amt; lx -= move_amt;
@ -729,8 +729,8 @@ static struct cmd_results *cmd_move_in_direction(
container_floating_move_to(container, lx, ly); container_floating_move_to(container, lx, ly);
return cmd_results_new(CMD_SUCCESS, NULL); return cmd_results_new(CMD_SUCCESS, NULL);
} }
struct sway_workspace *old_ws = container->workspace; struct sway_workspace *old_ws = container->pending.workspace;
struct sway_container *old_parent = container->parent; struct sway_container *old_parent = container->pending.parent;
if (!container_move_in_direction(container, direction)) { if (!container_move_in_direction(container, direction)) {
// Container didn't move // Container didn't move
@ -744,7 +744,7 @@ static struct cmd_results *cmd_move_in_direction(
workspace_consider_destroy(old_ws); workspace_consider_destroy(old_ws);
} }
struct sway_workspace *new_ws = container->workspace; struct sway_workspace *new_ws = container->pending.workspace;
if (root->fullscreen_global) { if (root->fullscreen_global) {
arrange_root(); arrange_root();
@ -781,8 +781,8 @@ static struct cmd_results *cmd_move_to_position_pointer(
} }
struct wlr_cursor *cursor = seat->cursor->cursor; struct wlr_cursor *cursor = seat->cursor->cursor;
/* Determine where to put the window. */ /* Determine where to put the window. */
double lx = cursor->x - container->width / 2; double lx = cursor->x - container->pending.width / 2;
double ly = cursor->y - container->height / 2; double ly = cursor->y - container->pending.height / 2;
/* Correct target coordinates to be in bounds (on screen). */ /* Correct target coordinates to be in bounds (on screen). */
struct wlr_output *output = wlr_output_layout_output_at( struct wlr_output *output = wlr_output_layout_output_at(
@ -792,11 +792,11 @@ static struct cmd_results *cmd_move_to_position_pointer(
wlr_output_layout_get_box(root->output_layout, output); wlr_output_layout_get_box(root->output_layout, output);
lx = fmax(lx, box->x); lx = fmax(lx, box->x);
ly = fmax(ly, box->y); ly = fmax(ly, box->y);
if (lx + container->width > box->x + box->width) { if (lx + container->pending.width > box->x + box->width) {
lx = box->x + box->width - container->width; lx = box->x + box->width - container->pending.width;
} }
if (ly + container->height > box->y + box->height) { if (ly + container->pending.height > box->y + box->height) {
ly = box->y + box->height - container->height; ly = box->y + box->height - container->pending.height;
} }
} }
@ -846,16 +846,16 @@ static struct cmd_results *cmd_move_to_position(int argc, char **argv) {
} else if (strcmp(argv[0], "center") == 0) { } else if (strcmp(argv[0], "center") == 0) {
double lx, ly; double lx, ly;
if (absolute) { if (absolute) {
lx = root->x + (root->width - container->width) / 2; lx = root->x + (root->width - container->pending.width) / 2;
ly = root->y + (root->height - container->height) / 2; ly = root->y + (root->height - container->pending.height) / 2;
} else { } else {
struct sway_workspace *ws = container->workspace; struct sway_workspace *ws = container->pending.workspace;
if (!ws) { if (!ws) {
struct sway_seat *seat = config->handler_context.seat; struct sway_seat *seat = config->handler_context.seat;
ws = seat_get_focused_workspace(seat); ws = seat_get_focused_workspace(seat);
} }
lx = ws->x + (ws->width - container->width) / 2; lx = ws->x + (ws->width - container->pending.width) / 2;
ly = ws->y + (ws->height - container->height) / 2; ly = ws->y + (ws->height - container->pending.height) / 2;
} }
container_floating_move_to(container, lx, ly); container_floating_move_to(container, lx, ly);
return cmd_results_new(CMD_SUCCESS, NULL); return cmd_results_new(CMD_SUCCESS, NULL);
@ -886,7 +886,7 @@ static struct cmd_results *cmd_move_to_position(int argc, char **argv) {
return cmd_results_new(CMD_INVALID, "Invalid y position specified"); return cmd_results_new(CMD_INVALID, "Invalid y position specified");
} }
struct sway_workspace *ws = container->workspace; struct sway_workspace *ws = container->pending.workspace;
if (!ws) { if (!ws) {
struct sway_seat *seat = config->handler_context.seat; struct sway_seat *seat = config->handler_context.seat;
ws = seat_get_focused_workspace(seat); ws = seat_get_focused_workspace(seat);
@ -960,14 +960,14 @@ static struct cmd_results *cmd_move_to_scratchpad(void) {
// If the container is in a floating split container, // If the container is in a floating split container,
// operate on the split container instead of the child. // operate on the split container instead of the child.
if (container_is_floating_or_child(con)) { if (container_is_floating_or_child(con)) {
while (con->parent) { while (con->pending.parent) {
con = con->parent; con = con->pending.parent;
} }
} }
if (!con->scratchpad) { if (!con->scratchpad) {
root_scratchpad_add_container(con, NULL); root_scratchpad_add_container(con, NULL);
} else if (con->workspace) { } else if (con->pending.workspace) {
root_scratchpad_hide(con); root_scratchpad_hide(con);
} }
return cmd_results_new(CMD_SUCCESS, NULL); return cmd_results_new(CMD_SUCCESS, NULL);

View file

@ -57,7 +57,7 @@ struct sway_container *container_find_resize_parent(struct sway_container *con,
(allow_last || index < siblings->length - 1)) { (allow_last || index < siblings->length - 1)) {
return con; return con;
} }
con = con->parent; con = con->pending.parent;
} }
return NULL; return NULL;
@ -115,13 +115,13 @@ void container_resize_tiled(struct sway_container *con,
int sibling_amount = prev ? ceil((double)amount / 2.0) : amount; int sibling_amount = prev ? ceil((double)amount / 2.0) : amount;
if (is_horizontal(axis)) { if (is_horizontal(axis)) {
if (con->width + amount < MIN_SANE_W) { if (con->pending.width + amount < MIN_SANE_W) {
return; return;
} }
if (next->width - sibling_amount < MIN_SANE_W) { if (next->pending.width - sibling_amount < MIN_SANE_W) {
return; return;
} }
if (prev && prev->width - sibling_amount < MIN_SANE_W) { if (prev && prev->pending.width - sibling_amount < MIN_SANE_W) {
return; return;
} }
if (con->child_total_width <= 0) { if (con->child_total_width <= 0) {
@ -133,7 +133,7 @@ void container_resize_tiled(struct sway_container *con,
list_t *siblings = container_get_siblings(con); list_t *siblings = container_get_siblings(con);
for (int i = 0; i < siblings->length; ++i) { for (int i = 0; i < siblings->length; ++i) {
struct sway_container *con = siblings->items[i]; struct sway_container *con = siblings->items[i];
con->width_fraction = con->width / con->child_total_width; con->width_fraction = con->pending.width / con->child_total_width;
} }
double amount_fraction = (double)amount / con->child_total_width; double amount_fraction = (double)amount / con->child_total_width;
@ -146,13 +146,13 @@ void container_resize_tiled(struct sway_container *con,
prev->width_fraction -= sibling_amount_fraction; prev->width_fraction -= sibling_amount_fraction;
} }
} else { } else {
if (con->height + amount < MIN_SANE_H) { if (con->pending.height + amount < MIN_SANE_H) {
return; return;
} }
if (next->height - sibling_amount < MIN_SANE_H) { if (next->pending.height - sibling_amount < MIN_SANE_H) {
return; return;
} }
if (prev && prev->height - sibling_amount < MIN_SANE_H) { if (prev && prev->pending.height - sibling_amount < MIN_SANE_H) {
return; return;
} }
if (con->child_total_height <= 0) { if (con->child_total_height <= 0) {
@ -164,7 +164,7 @@ void container_resize_tiled(struct sway_container *con,
list_t *siblings = container_get_siblings(con); list_t *siblings = container_get_siblings(con);
for (int i = 0; i < siblings->length; ++i) { for (int i = 0; i < siblings->length; ++i) {
struct sway_container *con = siblings->items[i]; struct sway_container *con = siblings->items[i];
con->height_fraction = con->height / con->child_total_height; con->height_fraction = con->pending.height / con->child_total_height;
} }
double amount_fraction = (double)amount / con->child_total_height; double amount_fraction = (double)amount / con->child_total_height;
@ -178,10 +178,10 @@ void container_resize_tiled(struct sway_container *con,
} }
} }
if (con->parent) { if (con->pending.parent) {
arrange_container(con->parent); arrange_container(con->pending.parent);
} else { } else {
arrange_workspace(con->workspace); arrange_workspace(con->pending.workspace);
} }
} }
@ -203,15 +203,15 @@ static struct cmd_results *resize_adjust_floating(uint32_t axis,
int min_width, max_width, min_height, max_height; int min_width, max_width, min_height, max_height;
floating_calculate_constraints(&min_width, &max_width, floating_calculate_constraints(&min_width, &max_width,
&min_height, &max_height); &min_height, &max_height);
if (con->width + grow_width < min_width) { if (con->pending.width + grow_width < min_width) {
grow_width = min_width - con->width; grow_width = min_width - con->pending.width;
} else if (con->width + grow_width > max_width) { } else if (con->pending.width + grow_width > max_width) {
grow_width = max_width - con->width; grow_width = max_width - con->pending.width;
} }
if (con->height + grow_height < min_height) { if (con->pending.height + grow_height < min_height) {
grow_height = min_height - con->height; grow_height = min_height - con->pending.height;
} else if (con->height + grow_height > max_height) { } else if (con->pending.height + grow_height > max_height) {
grow_height = max_height - con->height; grow_height = max_height - con->pending.height;
} }
int grow_x = 0, grow_y = 0; int grow_x = 0, grow_y = 0;
@ -227,15 +227,15 @@ static struct cmd_results *resize_adjust_floating(uint32_t axis,
if (grow_width == 0 && grow_height == 0) { if (grow_width == 0 && grow_height == 0) {
return cmd_results_new(CMD_INVALID, "Cannot resize any further"); return cmd_results_new(CMD_INVALID, "Cannot resize any further");
} }
con->x += grow_x; con->pending.x += grow_x;
con->y += grow_y; con->pending.y += grow_y;
con->width += grow_width; con->pending.width += grow_width;
con->height += grow_height; con->pending.height += grow_height;
con->content_x += grow_x; con->pending.content_x += grow_x;
con->content_y += grow_y; con->pending.content_y += grow_y;
con->content_width += grow_width; con->pending.content_width += grow_width;
con->content_height += grow_height; con->pending.content_height += grow_height;
arrange_container(con); arrange_container(con);
@ -256,9 +256,9 @@ static struct cmd_results *resize_adjust_tiled(uint32_t axis,
float pct = amount->amount / 100.0f; float pct = amount->amount / 100.0f;
if (is_horizontal(axis)) { if (is_horizontal(axis)) {
amount->amount = (float)current->width * pct; amount->amount = (float)current->pending.width * pct;
} else { } else {
amount->amount = (float)current->height * pct; amount->amount = (float)current->pending.height * pct;
} }
} }
@ -281,20 +281,20 @@ static struct cmd_results *resize_set_tiled(struct sway_container *con,
if (width->unit == MOVEMENT_UNIT_PPT || if (width->unit == MOVEMENT_UNIT_PPT ||
width->unit == MOVEMENT_UNIT_DEFAULT) { width->unit == MOVEMENT_UNIT_DEFAULT) {
// Convert to px // Convert to px
struct sway_container *parent = con->parent; struct sway_container *parent = con->pending.parent;
while (parent && parent->layout != L_HORIZ) { while (parent && parent->pending.layout != L_HORIZ) {
parent = parent->parent; parent = parent->pending.parent;
} }
if (parent) { if (parent) {
width->amount = parent->width * width->amount / 100; width->amount = parent->pending.width * width->amount / 100;
} else { } else {
width->amount = con->workspace->width * width->amount / 100; width->amount = con->pending.workspace->width * width->amount / 100;
} }
width->unit = MOVEMENT_UNIT_PX; width->unit = MOVEMENT_UNIT_PX;
} }
if (width->unit == MOVEMENT_UNIT_PX) { if (width->unit == MOVEMENT_UNIT_PX) {
container_resize_tiled(con, AXIS_HORIZONTAL, container_resize_tiled(con, AXIS_HORIZONTAL,
width->amount - con->width); width->amount - con->pending.width);
} }
} }
@ -302,20 +302,20 @@ static struct cmd_results *resize_set_tiled(struct sway_container *con,
if (height->unit == MOVEMENT_UNIT_PPT || if (height->unit == MOVEMENT_UNIT_PPT ||
height->unit == MOVEMENT_UNIT_DEFAULT) { height->unit == MOVEMENT_UNIT_DEFAULT) {
// Convert to px // Convert to px
struct sway_container *parent = con->parent; struct sway_container *parent = con->pending.parent;
while (parent && parent->layout != L_VERT) { while (parent && parent->pending.layout != L_VERT) {
parent = parent->parent; parent = parent->pending.parent;
} }
if (parent) { if (parent) {
height->amount = parent->height * height->amount / 100; height->amount = parent->pending.height * height->amount / 100;
} else { } else {
height->amount = con->workspace->height * height->amount / 100; height->amount = con->pending.workspace->height * height->amount / 100;
} }
height->unit = MOVEMENT_UNIT_PX; height->unit = MOVEMENT_UNIT_PX;
} }
if (height->unit == MOVEMENT_UNIT_PX) { if (height->unit == MOVEMENT_UNIT_PX) {
container_resize_tiled(con, AXIS_VERTICAL, container_resize_tiled(con, AXIS_VERTICAL,
height->amount - con->height); height->amount - con->pending.height);
} }
} }
@ -339,15 +339,15 @@ static struct cmd_results *resize_set_floating(struct sway_container *con,
"Cannot resize a hidden scratchpad container by ppt"); "Cannot resize a hidden scratchpad container by ppt");
} }
// Convert to px // Convert to px
width->amount = con->workspace->width * width->amount / 100; width->amount = con->pending.workspace->width * width->amount / 100;
width->unit = MOVEMENT_UNIT_PX; width->unit = MOVEMENT_UNIT_PX;
// Falls through // Falls through
case MOVEMENT_UNIT_PX: case MOVEMENT_UNIT_PX:
case MOVEMENT_UNIT_DEFAULT: case MOVEMENT_UNIT_DEFAULT:
width->amount = fmax(min_width, fmin(width->amount, max_width)); width->amount = fmax(min_width, fmin(width->amount, max_width));
grow_width = width->amount - con->width; grow_width = width->amount - con->pending.width;
con->x -= grow_width / 2; con->pending.x -= grow_width / 2;
con->width = width->amount; con->pending.width = width->amount;
break; break;
case MOVEMENT_UNIT_INVALID: case MOVEMENT_UNIT_INVALID:
sway_assert(false, "invalid width unit"); sway_assert(false, "invalid width unit");
@ -363,15 +363,15 @@ static struct cmd_results *resize_set_floating(struct sway_container *con,
"Cannot resize a hidden scratchpad container by ppt"); "Cannot resize a hidden scratchpad container by ppt");
} }
// Convert to px // Convert to px
height->amount = con->workspace->height * height->amount / 100; height->amount = con->pending.workspace->height * height->amount / 100;
height->unit = MOVEMENT_UNIT_PX; height->unit = MOVEMENT_UNIT_PX;
// Falls through // Falls through
case MOVEMENT_UNIT_PX: case MOVEMENT_UNIT_PX:
case MOVEMENT_UNIT_DEFAULT: case MOVEMENT_UNIT_DEFAULT:
height->amount = fmax(min_height, fmin(height->amount, max_height)); height->amount = fmax(min_height, fmin(height->amount, max_height));
grow_height = height->amount - con->height; grow_height = height->amount - con->pending.height;
con->y -= grow_height / 2; con->pending.y -= grow_height / 2;
con->height = height->amount; con->pending.height = height->amount;
break; break;
case MOVEMENT_UNIT_INVALID: case MOVEMENT_UNIT_INVALID:
sway_assert(false, "invalid height unit"); sway_assert(false, "invalid height unit");
@ -379,10 +379,10 @@ static struct cmd_results *resize_set_floating(struct sway_container *con,
} }
} }
con->content_x -= grow_width / 2; con->pending.content_x -= grow_width / 2;
con->content_y -= grow_height / 2; con->pending.content_y -= grow_height / 2;
con->content_width += grow_width; con->pending.content_width += grow_width;
con->content_height += grow_height; con->pending.content_height += grow_height;
arrange_container(con); arrange_container(con);
@ -437,10 +437,10 @@ static struct cmd_results *cmd_resize_set(int argc, char **argv) {
// If 0, don't resize that dimension // If 0, don't resize that dimension
struct sway_container *con = config->handler_context.container; struct sway_container *con = config->handler_context.container;
if (width.amount <= 0) { if (width.amount <= 0) {
width.amount = con->width; width.amount = con->pending.width;
} }
if (height.amount <= 0) { if (height.amount <= 0) {
height.amount = con->height; height.amount = con->pending.height;
} }
if (container_is_floating(con)) { if (container_is_floating(con)) {

View file

@ -21,8 +21,8 @@ static void scratchpad_toggle_auto(void) {
// If the focus is in a floating split container, // If the focus is in a floating split container,
// operate on the split container instead of the child. // operate on the split container instead of the child.
if (focus && container_is_floating_or_child(focus)) { if (focus && container_is_floating_or_child(focus)) {
while (focus->parent) { while (focus->pending.parent) {
focus = focus->parent; focus = focus->pending.parent;
} }
} }
@ -52,7 +52,7 @@ static void scratchpad_toggle_auto(void) {
// In this case we move it to the current workspace. // In this case we move it to the current workspace.
for (int i = 0; i < root->scratchpad->length; ++i) { for (int i = 0; i < root->scratchpad->length; ++i) {
struct sway_container *con = root->scratchpad->items[i]; struct sway_container *con = root->scratchpad->items[i];
if (con->parent) { if (con->pending.parent) {
sway_log(SWAY_DEBUG, sway_log(SWAY_DEBUG,
"Moving a visible scratchpad window (%s) to this workspace", "Moving a visible scratchpad window (%s) to this workspace",
con->title); con->title);
@ -80,7 +80,7 @@ static void scratchpad_toggle_container(struct sway_container *con) {
struct sway_seat *seat = input_manager_current_seat(); struct sway_seat *seat = input_manager_current_seat();
struct sway_workspace *ws = seat_get_focused_workspace(seat); struct sway_workspace *ws = seat_get_focused_workspace(seat);
// Check if it matches a currently visible scratchpad window and hide it. // Check if it matches a currently visible scratchpad window and hide it.
if (con->workspace && ws == con->workspace) { if (con->pending.workspace && ws == con->pending.workspace) {
root_scratchpad_hide(con); root_scratchpad_hide(con);
return; return;
} }
@ -111,8 +111,8 @@ struct cmd_results *cmd_scratchpad(int argc, char **argv) {
// If the container is in a floating split container, // If the container is in a floating split container,
// operate on the split container instead of the child. // operate on the split container instead of the child.
if (container_is_floating_or_child(con)) { if (container_is_floating_or_child(con)) {
while (con->parent) { while (con->pending.parent) {
con = con->parent; con = con->pending.parent;
} }
} }

View file

@ -14,7 +14,7 @@ static struct cmd_results *do_split(int layout) {
struct sway_workspace *ws = config->handler_context.workspace; struct sway_workspace *ws = config->handler_context.workspace;
if (con) { if (con) {
if (container_is_scratchpad_hidden_or_child(con) && if (container_is_scratchpad_hidden_or_child(con) &&
con->fullscreen_mode != FULLSCREEN_GLOBAL) { con->pending.fullscreen_mode != FULLSCREEN_GLOBAL) {
return cmd_results_new(CMD_FAILURE, return cmd_results_new(CMD_FAILURE,
"Cannot split a hidden scratchpad container"); "Cannot split a hidden scratchpad container");
} }

View file

@ -29,14 +29,14 @@ struct cmd_results *cmd_sticky(int argc, char **argv) {
!container_is_scratchpad_hidden(container)) { !container_is_scratchpad_hidden(container)) {
// move container to active workspace // move container to active workspace
struct sway_workspace *active_workspace = struct sway_workspace *active_workspace =
output_get_active_workspace(container->workspace->output); output_get_active_workspace(container->pending.workspace->output);
if (!sway_assert(active_workspace, if (!sway_assert(active_workspace,
"Expected output to have a workspace")) { "Expected output to have a workspace")) {
return cmd_results_new(CMD_FAILURE, return cmd_results_new(CMD_FAILURE,
"Expected output to have a workspace"); "Expected output to have a workspace");
} }
if (container->workspace != active_workspace) { if (container->pending.workspace != active_workspace) {
struct sway_workspace *old_workspace = container->workspace; struct sway_workspace *old_workspace = container->pending.workspace;
container_detach(container); container_detach(container);
workspace_add_floating(active_workspace, container); workspace_add_floating(active_workspace, container);
container_handle_fullscreen_reparent(container); container_handle_fullscreen_reparent(container);

View file

@ -16,46 +16,46 @@ static const char expected_syntax[] =
static void swap_places(struct sway_container *con1, static void swap_places(struct sway_container *con1,
struct sway_container *con2) { struct sway_container *con2) {
struct sway_container *temp = malloc(sizeof(struct sway_container)); struct sway_container *temp = malloc(sizeof(struct sway_container));
temp->x = con1->x; temp->pending.x = con1->pending.x;
temp->y = con1->y; temp->pending.y = con1->pending.y;
temp->width = con1->width; temp->pending.width = con1->pending.width;
temp->height = con1->height; temp->pending.height = con1->pending.height;
temp->width_fraction = con1->width_fraction; temp->width_fraction = con1->width_fraction;
temp->height_fraction = con1->height_fraction; temp->height_fraction = con1->height_fraction;
temp->parent = con1->parent; temp->pending.parent = con1->pending.parent;
temp->workspace = con1->workspace; temp->pending.workspace = con1->pending.workspace;
bool temp_floating = container_is_floating(con1); bool temp_floating = container_is_floating(con1);
con1->x = con2->x; con1->pending.x = con2->pending.x;
con1->y = con2->y; con1->pending.y = con2->pending.y;
con1->width = con2->width; con1->pending.width = con2->pending.width;
con1->height = con2->height; con1->pending.height = con2->pending.height;
con1->width_fraction = con2->width_fraction; con1->width_fraction = con2->width_fraction;
con1->height_fraction = con2->height_fraction; con1->height_fraction = con2->height_fraction;
con2->x = temp->x; con2->pending.x = temp->pending.x;
con2->y = temp->y; con2->pending.y = temp->pending.y;
con2->width = temp->width; con2->pending.width = temp->pending.width;
con2->height = temp->height; con2->pending.height = temp->pending.height;
con2->width_fraction = temp->width_fraction; con2->width_fraction = temp->width_fraction;
con2->height_fraction = temp->height_fraction; con2->height_fraction = temp->height_fraction;
int temp_index = container_sibling_index(con1); int temp_index = container_sibling_index(con1);
if (con2->parent) { if (con2->pending.parent) {
container_insert_child(con2->parent, con1, container_insert_child(con2->pending.parent, con1,
container_sibling_index(con2)); container_sibling_index(con2));
} else if (container_is_floating(con2)) { } else if (container_is_floating(con2)) {
workspace_add_floating(con2->workspace, con1); workspace_add_floating(con2->pending.workspace, con1);
} else { } else {
workspace_insert_tiling(con2->workspace, con1, workspace_insert_tiling(con2->pending.workspace, con1,
container_sibling_index(con2)); container_sibling_index(con2));
} }
if (temp->parent) { if (temp->pending.parent) {
container_insert_child(temp->parent, con2, temp_index); container_insert_child(temp->pending.parent, con2, temp_index);
} else if (temp_floating) { } else if (temp_floating) {
workspace_add_floating(temp->workspace, con2); workspace_add_floating(temp->pending.workspace, con2);
} else { } else {
workspace_insert_tiling(temp->workspace, con2, temp_index); workspace_insert_tiling(temp->pending.workspace, con2, temp_index);
} }
free(temp); free(temp);
@ -65,8 +65,8 @@ static void swap_focus(struct sway_container *con1,
struct sway_container *con2, struct sway_seat *seat, struct sway_container *con2, struct sway_seat *seat,
struct sway_container *focus) { struct sway_container *focus) {
if (focus == con1 || focus == con2) { if (focus == con1 || focus == con2) {
struct sway_workspace *ws1 = con1->workspace; struct sway_workspace *ws1 = con1->pending.workspace;
struct sway_workspace *ws2 = con2->workspace; struct sway_workspace *ws2 = con2->pending.workspace;
enum sway_container_layout layout1 = container_parent_layout(con1); enum sway_container_layout layout1 = container_parent_layout(con1);
enum sway_container_layout layout2 = container_parent_layout(con2); enum sway_container_layout layout2 = container_parent_layout(con2);
if (focus == con1 && (layout2 == L_TABBED || layout2 == L_STACKED)) { if (focus == con1 && (layout2 == L_TABBED || layout2 == L_STACKED)) {
@ -125,8 +125,8 @@ void container_swap(struct sway_container *con1, struct sway_container *con2) {
root_scratchpad_remove_container(con2); root_scratchpad_remove_container(con2);
} }
enum sway_fullscreen_mode fs1 = con1->fullscreen_mode; enum sway_fullscreen_mode fs1 = con1->pending.fullscreen_mode;
enum sway_fullscreen_mode fs2 = con2->fullscreen_mode; enum sway_fullscreen_mode fs2 = con2->pending.fullscreen_mode;
if (fs1) { if (fs1) {
container_fullscreen_disable(con1); container_fullscreen_disable(con1);
} }
@ -137,9 +137,9 @@ void container_swap(struct sway_container *con1, struct sway_container *con2) {
struct sway_seat *seat = config->handler_context.seat; struct sway_seat *seat = config->handler_context.seat;
struct sway_container *focus = seat_get_focused_container(seat); struct sway_container *focus = seat_get_focused_container(seat);
struct sway_workspace *vis1 = struct sway_workspace *vis1 =
output_get_active_workspace(con1->workspace->output); output_get_active_workspace(con1->pending.workspace->output);
struct sway_workspace *vis2 = struct sway_workspace *vis2 =
output_get_active_workspace(con2->workspace->output); output_get_active_workspace(con2->pending.workspace->output);
if (!sway_assert(vis1 && vis2, "con1 or con2 are on an output without a" if (!sway_assert(vis1 && vis2, "con1 or con2 are on an output without a"
"workspace. This should not happen")) { "workspace. This should not happen")) {
return; return;

View file

@ -351,7 +351,7 @@ static bool criteria_matches_view(struct criteria *criteria,
} }
if (criteria->workspace) { if (criteria->workspace) {
struct sway_workspace *ws = view->container->workspace; struct sway_workspace *ws = view->container->pending.workspace;
if (!ws) { if (!ws) {
return false; return false;
} }
@ -359,7 +359,7 @@ static bool criteria_matches_view(struct criteria *criteria,
switch (criteria->workspace->match_type) { switch (criteria->workspace->match_type) {
case PATTERN_FOCUSED: case PATTERN_FOCUSED:
if (focused && if (focused &&
strcmp(ws->name, focused->container->workspace->name)) { strcmp(ws->name, focused->container->pending.workspace->name)) {
return false; return false;
} }
break; break;

View file

@ -957,7 +957,7 @@ static void render_floating(struct sway_output *soutput,
} }
for (int k = 0; k < ws->current.floating->length; ++k) { for (int k = 0; k < ws->current.floating->length; ++k) {
struct sway_container *floater = ws->current.floating->items[k]; struct sway_container *floater = ws->current.floating->items[k];
if (floater->fullscreen_mode != FULLSCREEN_NONE) { if (floater->pending.fullscreen_mode != FULLSCREEN_NONE) {
continue; continue;
} }
render_floating_container(soutput, damage, floater); render_floating_container(soutput, damage, floater);

View file

@ -128,8 +128,8 @@ static void copy_workspace_state(struct sway_workspace *ws,
// Set focused_inactive_child to the direct tiling child // Set focused_inactive_child to the direct tiling child
struct sway_container *focus = seat_get_focus_inactive_tiling(seat, ws); struct sway_container *focus = seat_get_focus_inactive_tiling(seat, ws);
if (focus) { if (focus) {
while (focus->parent) { while (focus->pending.parent) {
focus = focus->parent; focus = focus->pending.parent;
} }
} }
state->focused_inactive_child = focus; state->focused_inactive_child = focus;
@ -139,32 +139,19 @@ static void copy_container_state(struct sway_container *container,
struct sway_transaction_instruction *instruction) { struct sway_transaction_instruction *instruction) {
struct sway_container_state *state = &instruction->container_state; struct sway_container_state *state = &instruction->container_state;
state->layout = container->layout; if (state->children) {
state->x = container->x; list_free(state->children);
state->y = container->y; }
state->width = container->width;
state->height = container->height; memcpy(state, &container->pending, sizeof(struct sway_container_state));
state->fullscreen_mode = container->fullscreen_mode;
state->parent = container->parent;
state->workspace = container->workspace;
state->border = container->border;
state->border_thickness = container->border_thickness;
state->border_top = container->border_top;
state->border_left = container->border_left;
state->border_right = container->border_right;
state->border_bottom = container->border_bottom;
state->content_x = container->content_x;
state->content_y = container->content_y;
state->content_width = container->content_width;
state->content_height = container->content_height;
if (!container->view) { if (!container->view) {
if (state->children) { // We store a copy of the child list to avoid having it mutated after
state->children->length = 0; // we copy the state.
} else {
state->children = create_list(); state->children = create_list();
} list_cat(state->children, container->pending.children);
list_cat(state->children, container->children); } else {
state->children = NULL;
} }
struct sway_seat *seat = input_manager_current_seat(); struct sway_seat *seat = input_manager_current_seat();

View file

@ -70,13 +70,13 @@ static void popup_unconstrain(struct sway_xdg_popup *popup) {
struct sway_view *view = popup->child.view; struct sway_view *view = popup->child.view;
struct wlr_xdg_popup *wlr_popup = popup->wlr_xdg_surface->popup; struct wlr_xdg_popup *wlr_popup = popup->wlr_xdg_surface->popup;
struct sway_output *output = view->container->workspace->output; struct sway_output *output = view->container->pending.workspace->output;
// the output box expressed in the coordinate system of the toplevel parent // the output box expressed in the coordinate system of the toplevel parent
// of the popup // of the popup
struct wlr_box output_toplevel_sx_box = { struct wlr_box output_toplevel_sx_box = {
.x = output->lx - view->container->content_x, .x = output->lx - view->container->pending.content_x,
.y = output->ly - view->container->content_y, .y = output->ly - view->container->pending.content_y,
.width = output->width, .width = output->width,
.height = output->height, .height = output->height,
}; };

View file

@ -527,10 +527,10 @@ static void handle_request_configure(struct wl_listener *listener, void *data) {
view->natural_height = ev->height; view->natural_height = ev->height;
container_floating_resize_and_center(view->container); container_floating_resize_and_center(view->container);
configure(view, view->container->content_x, configure(view, view->container->pending.content_x,
view->container->content_y, view->container->pending.content_y,
view->container->content_width, view->container->pending.content_width,
view->container->content_height); view->container->pending.content_height);
node_set_dirty(&view->container->node); node_set_dirty(&view->container->node);
} else { } else {
configure(view, view->container->current.content_x, configure(view, view->container->current.content_x,

View file

@ -824,8 +824,8 @@ static void check_constraint_region(struct sway_cursor *cursor) {
struct sway_container *con = view->container; struct sway_container *con = view->container;
double sx = cursor->cursor->x - con->content_x + view->geometry.x; double sx = cursor->cursor->x - con->pending.content_x + view->geometry.x;
double sy = cursor->cursor->y - con->content_y + view->geometry.y; double sy = cursor->cursor->y - con->pending.content_y + view->geometry.y;
if (!pixman_region32_contains_point(region, if (!pixman_region32_contains_point(region,
floor(sx), floor(sy), NULL)) { floor(sx), floor(sy), NULL)) {
@ -836,8 +836,8 @@ static void check_constraint_region(struct sway_cursor *cursor) {
double sy = (boxes[0].y1 + boxes[0].y2) / 2.; double sy = (boxes[0].y1 + boxes[0].y2) / 2.;
wlr_cursor_warp_closest(cursor->cursor, NULL, wlr_cursor_warp_closest(cursor->cursor, NULL,
sx + con->content_x - view->geometry.x, sx + con->pending.content_x - view->geometry.x,
sy + con->content_y - view->geometry.y); sy + con->pending.content_y - view->geometry.y);
cursor_rebase(cursor); cursor_rebase(cursor);
} }
@ -1157,8 +1157,8 @@ void cursor_warp_to_container(struct sway_cursor *cursor,
return; return;
} }
double x = container->x + container->width / 2.0; double x = container->pending.x + container->pending.width / 2.0;
double y = container->y + container->height / 2.0; double y = container->pending.y + container->pending.height / 2.0;
wlr_cursor_warp(cursor->cursor, NULL, x, y); wlr_cursor_warp(cursor->cursor, NULL, x, y);
cursor_unhide(cursor); cursor_unhide(cursor);
@ -1271,8 +1271,8 @@ static void warp_to_constraint_cursor_hint(struct sway_cursor *cursor) {
struct sway_view *view = view_from_wlr_surface(constraint->surface); struct sway_view *view = view_from_wlr_surface(constraint->surface);
struct sway_container *con = view->container; struct sway_container *con = view->container;
double lx = sx + con->content_x - view->geometry.x; double lx = sx + con->pending.content_x - view->geometry.x;
double ly = sy + con->content_y - view->geometry.y; double ly = sy + con->pending.content_y - view->geometry.y;
wlr_cursor_warp(cursor->cursor, NULL, lx, ly); wlr_cursor_warp(cursor->cursor, NULL, lx, ly);

View file

@ -309,8 +309,8 @@ static void handle_seat_node_destroy(struct wl_listener *listener, void *data) {
// Setting focus_inactive // Setting focus_inactive
focus = seat_get_focus_inactive(seat, &root->node); focus = seat_get_focus_inactive(seat, &root->node);
seat_set_raw_focus(seat, next_focus); seat_set_raw_focus(seat, next_focus);
if (focus->type == N_CONTAINER && focus->sway_container->workspace) { if (focus->type == N_CONTAINER && focus->sway_container->pending.workspace) {
seat_set_raw_focus(seat, &focus->sway_container->workspace->node); seat_set_raw_focus(seat, &focus->sway_container->pending.workspace->node);
} }
seat_set_raw_focus(seat, focus); seat_set_raw_focus(seat, focus);
} }
@ -1086,7 +1086,7 @@ void seat_set_focus(struct sway_seat *seat, struct sway_node *node) {
} }
struct sway_workspace *new_workspace = node->type == N_WORKSPACE ? struct sway_workspace *new_workspace = node->type == N_WORKSPACE ?
node->sway_workspace : node->sway_container->workspace; node->sway_workspace : node->sway_container->pending.workspace;
struct sway_container *container = node->type == N_CONTAINER ? struct sway_container *container = node->type == N_CONTAINER ?
node->sway_container : NULL; node->sway_container : NULL;
@ -1135,10 +1135,10 @@ void seat_set_focus(struct sway_seat *seat, struct sway_node *node) {
// Put the container parents on the focus stack, then the workspace, then // Put the container parents on the focus stack, then the workspace, then
// the focused container. // the focused container.
if (container) { if (container) {
struct sway_container *parent = container->parent; struct sway_container *parent = container->pending.parent;
while (parent) { while (parent) {
seat_set_raw_focus(seat, &parent->node); seat_set_raw_focus(seat, &parent->node);
parent = parent->parent; parent = parent->pending.parent;
} }
} }
if (new_workspace) { if (new_workspace) {
@ -1327,7 +1327,7 @@ struct sway_container *seat_get_focus_inactive_tiling(struct sway_seat *seat,
struct sway_node *node = current->node; struct sway_node *node = current->node;
if (node->type == N_CONTAINER && if (node->type == N_CONTAINER &&
!container_is_floating_or_child(node->sway_container) && !container_is_floating_or_child(node->sway_container) &&
node->sway_container->workspace == workspace) { node->sway_container->pending.workspace == workspace) {
return node->sway_container; return node->sway_container;
} }
} }
@ -1344,7 +1344,7 @@ struct sway_container *seat_get_focus_inactive_floating(struct sway_seat *seat,
struct sway_node *node = current->node; struct sway_node *node = current->node;
if (node->type == N_CONTAINER && if (node->type == N_CONTAINER &&
container_is_floating_or_child(node->sway_container) && container_is_floating_or_child(node->sway_container) &&
node->sway_container->workspace == workspace) { node->sway_container->pending.workspace == workspace) {
return node->sway_container; return node->sway_container;
} }
} }
@ -1392,7 +1392,7 @@ struct sway_workspace *seat_get_focused_workspace(struct sway_seat *seat) {
return NULL; return NULL;
} }
if (focus->type == N_CONTAINER) { if (focus->type == N_CONTAINER) {
return focus->sway_container->workspace; return focus->sway_container->pending.workspace;
} }
if (focus->type == N_WORKSPACE) { if (focus->type == N_WORKSPACE) {
return focus->sway_workspace; return focus->sway_workspace;
@ -1405,8 +1405,8 @@ struct sway_workspace *seat_get_last_known_workspace(struct sway_seat *seat) {
wl_list_for_each(current, &seat->focus_stack, link) { wl_list_for_each(current, &seat->focus_stack, link) {
struct sway_node *node = current->node; struct sway_node *node = current->node;
if (node->type == N_CONTAINER && if (node->type == N_CONTAINER &&
node->sway_container->workspace) { node->sway_container->pending.workspace) {
return node->sway_container->workspace; return node->sway_container->pending.workspace;
} else if (node->type == N_WORKSPACE) { } else if (node->type == N_WORKSPACE) {
return node->sway_workspace; return node->sway_workspace;
} }

View file

@ -60,7 +60,7 @@ static bool edge_is_external(struct sway_container *cont, enum wlr_edges edge) {
return false; return false;
} }
} }
cont = cont->parent; cont = cont->pending.parent;
} }
return true; return true;
} }
@ -70,25 +70,25 @@ static enum wlr_edges find_edge(struct sway_container *cont,
if (!cont->view || (surface && cont->view->surface != surface)) { if (!cont->view || (surface && cont->view->surface != surface)) {
return WLR_EDGE_NONE; return WLR_EDGE_NONE;
} }
if (cont->border == B_NONE || !cont->border_thickness || if (cont->pending.border == B_NONE || !cont->pending.border_thickness ||
cont->border == B_CSD) { cont->pending.border == B_CSD) {
return WLR_EDGE_NONE; return WLR_EDGE_NONE;
} }
if (cont->fullscreen_mode) { if (cont->pending.fullscreen_mode) {
return WLR_EDGE_NONE; return WLR_EDGE_NONE;
} }
enum wlr_edges edge = 0; enum wlr_edges edge = 0;
if (cursor->cursor->x < cont->x + cont->border_thickness) { if (cursor->cursor->x < cont->pending.x + cont->pending.border_thickness) {
edge |= WLR_EDGE_LEFT; edge |= WLR_EDGE_LEFT;
} }
if (cursor->cursor->y < cont->y + cont->border_thickness) { if (cursor->cursor->y < cont->pending.y + cont->pending.border_thickness) {
edge |= WLR_EDGE_TOP; edge |= WLR_EDGE_TOP;
} }
if (cursor->cursor->x >= cont->x + cont->width - cont->border_thickness) { if (cursor->cursor->x >= cont->pending.x + cont->pending.width - cont->pending.border_thickness) {
edge |= WLR_EDGE_RIGHT; edge |= WLR_EDGE_RIGHT;
} }
if (cursor->cursor->y >= cont->y + cont->height - cont->border_thickness) { if (cursor->cursor->y >= cont->pending.y + cont->pending.height - cont->pending.border_thickness) {
edge |= WLR_EDGE_BOTTOM; edge |= WLR_EDGE_BOTTOM;
} }
@ -251,7 +251,7 @@ static void handle_tablet_tool_tip(struct sway_seat *seat,
// Handle moving a tiling container // Handle moving a tiling container
if (config->tiling_drag && mod_pressed && !is_floating_or_child && if (config->tiling_drag && mod_pressed && !is_floating_or_child &&
cont->fullscreen_mode == FULLSCREEN_NONE) { cont->pending.fullscreen_mode == FULLSCREEN_NONE) {
seatop_begin_move_tiling(seat, cont); seatop_begin_move_tiling(seat, cont);
return; return;
} }
@ -386,7 +386,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
struct sway_container *cont_to_focus = cont; struct sway_container *cont_to_focus = cont;
enum sway_container_layout layout = container_parent_layout(cont); enum sway_container_layout layout = container_parent_layout(cont);
if (layout == L_TABBED || layout == L_STACKED) { if (layout == L_TABBED || layout == L_STACKED) {
cont_to_focus = seat_get_focus_inactive_view(seat, &cont->parent->node); cont_to_focus = seat_get_focus_inactive_view(seat, &cont->pending.parent->node);
} }
seat_set_focus_container(seat, cont_to_focus); seat_set_focus_container(seat, cont_to_focus);
@ -402,9 +402,9 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
BTN_LEFT : BTN_RIGHT; BTN_LEFT : BTN_RIGHT;
if (button == btn_resize) { if (button == btn_resize) {
edge = 0; edge = 0;
edge |= cursor->cursor->x > cont->x + cont->width / 2 ? edge |= cursor->cursor->x > cont->pending.x + cont->pending.width / 2 ?
WLR_EDGE_RIGHT : WLR_EDGE_LEFT; WLR_EDGE_RIGHT : WLR_EDGE_LEFT;
edge |= cursor->cursor->y > cont->y + cont->height / 2 ? edge |= cursor->cursor->y > cont->pending.y + cont->pending.height / 2 ?
WLR_EDGE_BOTTOM : WLR_EDGE_TOP; WLR_EDGE_BOTTOM : WLR_EDGE_TOP;
const char *image = NULL; const char *image = NULL;
@ -451,9 +451,9 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
if (mod_pressed && button == btn_resize) { if (mod_pressed && button == btn_resize) {
struct sway_container *floater = container_toplevel_ancestor(cont); struct sway_container *floater = container_toplevel_ancestor(cont);
edge = 0; edge = 0;
edge |= cursor->cursor->x > floater->x + floater->width / 2 ? edge |= cursor->cursor->x > floater->pending.x + floater->pending.width / 2 ?
WLR_EDGE_RIGHT : WLR_EDGE_LEFT; WLR_EDGE_RIGHT : WLR_EDGE_LEFT;
edge |= cursor->cursor->y > floater->y + floater->height / 2 ? edge |= cursor->cursor->y > floater->pending.y + floater->pending.height / 2 ?
WLR_EDGE_BOTTOM : WLR_EDGE_TOP; WLR_EDGE_BOTTOM : WLR_EDGE_TOP;
seatop_begin_resize_floating(seat, floater, edge); seatop_begin_resize_floating(seat, floater, edge);
return; return;
@ -463,7 +463,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
// Handle moving a tiling container // Handle moving a tiling container
if (config->tiling_drag && (mod_pressed || on_titlebar) && if (config->tiling_drag && (mod_pressed || on_titlebar) &&
state == WLR_BUTTON_PRESSED && !is_floating_or_child && state == WLR_BUTTON_PRESSED && !is_floating_or_child &&
cont && cont->fullscreen_mode == FULLSCREEN_NONE) { cont && cont->pending.fullscreen_mode == FULLSCREEN_NONE) {
struct sway_container *focus = seat_get_focused_container(seat); struct sway_container *focus = seat_get_focused_container(seat);
bool focused = focus == cont || container_has_ancestor(focus, cont); bool focused = focus == cont || container_has_ancestor(focus, cont);
if (on_titlebar && !focused) { if (on_titlebar && !focused) {
@ -674,7 +674,7 @@ static void handle_pointer_axis(struct sway_seat *seat,
bool on_border = edge != WLR_EDGE_NONE; bool on_border = edge != WLR_EDGE_NONE;
bool on_titlebar = cont && !on_border && !surface; bool on_titlebar = cont && !on_border && !surface;
bool on_titlebar_border = cont && on_border && bool on_titlebar_border = cont && on_border &&
cursor->cursor->y < cont->content_y; cursor->cursor->y < cont->pending.content_y;
bool on_contents = cont && !on_border && surface; bool on_contents = cont && !on_border && surface;
bool on_workspace = node && node->type == N_WORKSPACE; bool on_workspace = node && node->type == N_WORKSPACE;
float scroll_factor = float scroll_factor =

View file

@ -15,7 +15,7 @@ static void finalize_move(struct sway_seat *seat) {
// We "move" the container to its own location // We "move" the container to its own location
// so it discovers its output again. // so it discovers its output again.
container_floating_move_to(e->con, e->con->x, e->con->y); container_floating_move_to(e->con, e->con->pending.x, e->con->pending.y);
transaction_commit_dirty(); transaction_commit_dirty();
seatop_begin_default(seat); seatop_begin_default(seat);
@ -70,8 +70,8 @@ void seatop_begin_move_floating(struct sway_seat *seat,
return; return;
} }
e->con = con; e->con = con;
e->dx = cursor->cursor->x - con->x; e->dx = cursor->cursor->x - con->pending.x;
e->dy = cursor->cursor->y - con->y; e->dy = cursor->cursor->y - con->pending.y;
seat->seatop_impl = &seatop_impl; seat->seatop_impl = &seatop_impl;
seat->seatop_data = e; seat->seatop_data = e;

View file

@ -120,8 +120,8 @@ static void handle_motion_postthreshold(struct sway_seat *seat) {
// Deny moving within own workspace if this is the only child // Deny moving within own workspace if this is the only child
struct sway_container *con = node->sway_container; struct sway_container *con = node->sway_container;
if (workspace_num_tiling_views(e->con->workspace) == 1 && if (workspace_num_tiling_views(e->con->pending.workspace) == 1 &&
con->workspace == e->con->workspace) { con->pending.workspace == e->con->pending.workspace) {
e->target_node = NULL; e->target_node = NULL;
e->target_edge = WLR_EDGE_NONE; e->target_edge = WLR_EDGE_NONE;
return; return;
@ -133,8 +133,8 @@ static void handle_motion_postthreshold(struct sway_seat *seat) {
enum wlr_edges edge = WLR_EDGE_NONE; enum wlr_edges edge = WLR_EDGE_NONE;
enum sway_container_layout layout = container_parent_layout(con); enum sway_container_layout layout = container_parent_layout(con);
struct wlr_box parent; struct wlr_box parent;
con->parent ? container_get_box(con->parent, &parent) : con->pending.parent ? container_get_box(con->pending.parent, &parent) :
workspace_get_box(con->workspace, &parent); workspace_get_box(con->pending.workspace, &parent);
if (layout == L_HORIZ || layout == L_TABBED) { if (layout == L_HORIZ || layout == L_TABBED) {
if (cursor->cursor->y < parent.y + DROP_LAYOUT_BORDER) { if (cursor->cursor->y < parent.y + DROP_LAYOUT_BORDER) {
edge = WLR_EDGE_TOP; edge = WLR_EDGE_TOP;
@ -161,7 +161,7 @@ static void handle_motion_postthreshold(struct sway_seat *seat) {
desktop_damage_box(&e->drop_box); desktop_damage_box(&e->drop_box);
return; return;
} }
con = con->parent; con = con->pending.parent;
} }
// Use the hovered view - but we must be over the actual surface // Use the hovered view - but we must be over the actual surface
@ -174,23 +174,23 @@ static void handle_motion_postthreshold(struct sway_seat *seat) {
} }
// Find the closest edge // Find the closest edge
size_t thickness = fmin(con->content_width, con->content_height) * 0.3; size_t thickness = fmin(con->pending.content_width, con->pending.content_height) * 0.3;
size_t closest_dist = INT_MAX; size_t closest_dist = INT_MAX;
size_t dist; size_t dist;
e->target_edge = WLR_EDGE_NONE; e->target_edge = WLR_EDGE_NONE;
if ((dist = cursor->cursor->y - con->y) < closest_dist) { if ((dist = cursor->cursor->y - con->pending.y) < closest_dist) {
closest_dist = dist; closest_dist = dist;
e->target_edge = WLR_EDGE_TOP; e->target_edge = WLR_EDGE_TOP;
} }
if ((dist = cursor->cursor->x - con->x) < closest_dist) { if ((dist = cursor->cursor->x - con->pending.x) < closest_dist) {
closest_dist = dist; closest_dist = dist;
e->target_edge = WLR_EDGE_LEFT; e->target_edge = WLR_EDGE_LEFT;
} }
if ((dist = con->x + con->width - cursor->cursor->x) < closest_dist) { if ((dist = con->pending.x + con->pending.width - cursor->cursor->x) < closest_dist) {
closest_dist = dist; closest_dist = dist;
e->target_edge = WLR_EDGE_RIGHT; e->target_edge = WLR_EDGE_RIGHT;
} }
if ((dist = con->y + con->height - cursor->cursor->y) < closest_dist) { if ((dist = con->pending.y + con->pending.height - cursor->cursor->y) < closest_dist) {
closest_dist = dist; closest_dist = dist;
e->target_edge = WLR_EDGE_BOTTOM; e->target_edge = WLR_EDGE_BOTTOM;
} }
@ -200,10 +200,10 @@ static void handle_motion_postthreshold(struct sway_seat *seat) {
} }
e->target_node = node; e->target_node = node;
e->drop_box.x = con->content_x; e->drop_box.x = con->pending.content_x;
e->drop_box.y = con->content_y; e->drop_box.y = con->pending.content_y;
e->drop_box.width = con->content_width; e->drop_box.width = con->pending.content_width;
e->drop_box.height = con->content_height; e->drop_box.height = con->pending.content_height;
resize_box(&e->drop_box, e->target_edge, thickness); resize_box(&e->drop_box, e->target_edge, thickness);
desktop_damage_box(&e->drop_box); desktop_damage_box(&e->drop_box);
} }
@ -234,11 +234,11 @@ static void finalize_move(struct sway_seat *seat) {
} }
struct sway_container *con = e->con; struct sway_container *con = e->con;
struct sway_container *old_parent = con->parent; struct sway_container *old_parent = con->pending.parent;
struct sway_workspace *old_ws = con->workspace; struct sway_workspace *old_ws = con->pending.workspace;
struct sway_node *target_node = e->target_node; struct sway_node *target_node = e->target_node;
struct sway_workspace *new_ws = target_node->type == N_WORKSPACE ? struct sway_workspace *new_ws = target_node->type == N_WORKSPACE ?
target_node->sway_workspace : target_node->sway_container->workspace; target_node->sway_workspace : target_node->sway_container->pending.workspace;
enum wlr_edges edge = e->target_edge; enum wlr_edges edge = e->target_edge;
int after = edge != WLR_EDGE_TOP && edge != WLR_EDGE_LEFT; int after = edge != WLR_EDGE_TOP && edge != WLR_EDGE_LEFT;
bool swap = edge == WLR_EDGE_NONE && target_node->type == N_CONTAINER; bool swap = edge == WLR_EDGE_NONE && target_node->type == N_CONTAINER;
@ -285,8 +285,8 @@ static void finalize_move(struct sway_seat *seat) {
int index = list_find(siblings, con); int index = list_find(siblings, con);
struct sway_container *sibling = index == 0 ? struct sway_container *sibling = index == 0 ?
siblings->items[1] : siblings->items[index - 1]; siblings->items[1] : siblings->items[index - 1];
con->width = sibling->width; con->pending.width = sibling->pending.width;
con->height = sibling->height; con->pending.height = sibling->pending.height;
con->width_fraction = sibling->width_fraction; con->width_fraction = sibling->width_fraction;
con->height_fraction = sibling->height_fraction; con->height_fraction = sibling->height_fraction;
} }

View file

@ -118,21 +118,21 @@ static void handle_pointer_motion(struct sway_seat *seat, uint32_t time_msec) {
// Determine the amounts we need to bump everything relative to the current // Determine the amounts we need to bump everything relative to the current
// size. // size.
int relative_grow_width = width - con->width; int relative_grow_width = width - con->pending.width;
int relative_grow_height = height - con->height; int relative_grow_height = height - con->pending.height;
int relative_grow_x = (e->ref_con_lx + grow_x) - con->x; int relative_grow_x = (e->ref_con_lx + grow_x) - con->pending.x;
int relative_grow_y = (e->ref_con_ly + grow_y) - con->y; int relative_grow_y = (e->ref_con_ly + grow_y) - con->pending.y;
// Actually resize stuff // Actually resize stuff
con->x += relative_grow_x; con->pending.x += relative_grow_x;
con->y += relative_grow_y; con->pending.y += relative_grow_y;
con->width += relative_grow_width; con->pending.width += relative_grow_width;
con->height += relative_grow_height; con->pending.height += relative_grow_height;
con->content_x += relative_grow_x; con->pending.content_x += relative_grow_x;
con->content_y += relative_grow_y; con->pending.content_y += relative_grow_y;
con->content_width += relative_grow_width; con->pending.content_width += relative_grow_width;
con->content_height += relative_grow_height; con->pending.content_height += relative_grow_height;
arrange_container(con); arrange_container(con);
transaction_commit_dirty(); transaction_commit_dirty();
@ -169,10 +169,10 @@ void seatop_begin_resize_floating(struct sway_seat *seat,
e->edge = edge == WLR_EDGE_NONE ? WLR_EDGE_BOTTOM | WLR_EDGE_RIGHT : edge; e->edge = edge == WLR_EDGE_NONE ? WLR_EDGE_BOTTOM | WLR_EDGE_RIGHT : edge;
e->ref_lx = seat->cursor->cursor->x; e->ref_lx = seat->cursor->cursor->x;
e->ref_ly = seat->cursor->cursor->y; e->ref_ly = seat->cursor->cursor->y;
e->ref_con_lx = con->x; e->ref_con_lx = con->pending.x;
e->ref_con_ly = con->y; e->ref_con_ly = con->pending.y;
e->ref_width = con->width; e->ref_width = con->pending.width;
e->ref_height = con->height; e->ref_height = con->pending.height;
seat->seatop_impl = &seatop_impl; seat->seatop_impl = &seatop_impl;
seat->seatop_data = e; seat->seatop_data = e;

View file

@ -53,19 +53,19 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
if (e->h_con) { if (e->h_con) {
container_set_resizing(e->h_con, false); container_set_resizing(e->h_con, false);
container_set_resizing(e->h_sib, false); container_set_resizing(e->h_sib, false);
if (e->h_con->parent) { if (e->h_con->pending.parent) {
arrange_container(e->h_con->parent); arrange_container(e->h_con->pending.parent);
} else { } else {
arrange_workspace(e->h_con->workspace); arrange_workspace(e->h_con->pending.workspace);
} }
} }
if (e->v_con) { if (e->v_con) {
container_set_resizing(e->v_con, false); container_set_resizing(e->v_con, false);
container_set_resizing(e->v_sib, false); container_set_resizing(e->v_sib, false);
if (e->v_con->parent) { if (e->v_con->pending.parent) {
arrange_container(e->v_con->parent); arrange_container(e->v_con->pending.parent);
} else { } else {
arrange_workspace(e->v_con->workspace); arrange_workspace(e->v_con->pending.workspace);
} }
} }
transaction_commit_dirty(); transaction_commit_dirty();
@ -82,16 +82,16 @@ static void handle_pointer_motion(struct sway_seat *seat, uint32_t time_msec) {
if (e->h_con) { if (e->h_con) {
if (e->edge & WLR_EDGE_LEFT) { if (e->edge & WLR_EDGE_LEFT) {
amount_x = (e->h_con_orig_width - moved_x) - e->h_con->width; amount_x = (e->h_con_orig_width - moved_x) - e->h_con->pending.width;
} else if (e->edge & WLR_EDGE_RIGHT) { } else if (e->edge & WLR_EDGE_RIGHT) {
amount_x = (e->h_con_orig_width + moved_x) - e->h_con->width; amount_x = (e->h_con_orig_width + moved_x) - e->h_con->pending.width;
} }
} }
if (e->v_con) { if (e->v_con) {
if (e->edge & WLR_EDGE_TOP) { if (e->edge & WLR_EDGE_TOP) {
amount_y = (e->v_con_orig_height - moved_y) - e->v_con->height; amount_y = (e->v_con_orig_height - moved_y) - e->v_con->pending.height;
} else if (e->edge & WLR_EDGE_BOTTOM) { } else if (e->edge & WLR_EDGE_BOTTOM) {
amount_y = (e->v_con_orig_height + moved_y) - e->v_con->height; amount_y = (e->v_con_orig_height + moved_y) - e->v_con->pending.height;
} }
} }
@ -143,7 +143,7 @@ void seatop_begin_resize_tiling(struct sway_seat *seat,
if (e->h_con) { if (e->h_con) {
container_set_resizing(e->h_con, true); container_set_resizing(e->h_con, true);
container_set_resizing(e->h_sib, true); container_set_resizing(e->h_sib, true);
e->h_con_orig_width = e->h_con->width; e->h_con_orig_width = e->h_con->pending.width;
} }
} }
if (edge & (WLR_EDGE_TOP | WLR_EDGE_BOTTOM)) { if (edge & (WLR_EDGE_TOP | WLR_EDGE_BOTTOM)) {
@ -154,7 +154,7 @@ void seatop_begin_resize_tiling(struct sway_seat *seat,
if (e->v_con) { if (e->v_con) {
container_set_resizing(e->v_con, true); container_set_resizing(e->v_con, true);
container_set_resizing(e->v_sib, true); container_set_resizing(e->v_sib, true);
e->v_con_orig_height = e->v_con->height; e->v_con_orig_height = e->v_con->pending.height;
} }
} }

View file

@ -456,27 +456,27 @@ static void get_deco_rect(struct sway_container *c, struct wlr_box *deco_rect) {
bool tab_or_stack = parent_layout == L_TABBED || parent_layout == L_STACKED; bool tab_or_stack = parent_layout == L_TABBED || parent_layout == L_STACKED;
if (((!tab_or_stack || container_is_floating(c)) && if (((!tab_or_stack || container_is_floating(c)) &&
c->current.border != B_NORMAL) || c->current.border != B_NORMAL) ||
c->fullscreen_mode != FULLSCREEN_NONE || c->pending.fullscreen_mode != FULLSCREEN_NONE ||
c->workspace == NULL) { c->pending.workspace == NULL) {
deco_rect->x = deco_rect->y = deco_rect->width = deco_rect->height = 0; deco_rect->x = deco_rect->y = deco_rect->width = deco_rect->height = 0;
return; return;
} }
if (c->parent) { if (c->pending.parent) {
deco_rect->x = c->x - c->parent->x; deco_rect->x = c->pending.x - c->pending.parent->pending.x;
deco_rect->y = c->y - c->parent->y; deco_rect->y = c->pending.y - c->pending.parent->pending.y;
} else { } else {
deco_rect->x = c->x - c->workspace->x; deco_rect->x = c->pending.x - c->pending.workspace->x;
deco_rect->y = c->y - c->workspace->y; deco_rect->y = c->pending.y - c->pending.workspace->y;
} }
deco_rect->width = c->width; deco_rect->width = c->pending.width;
deco_rect->height = container_titlebar_height(); deco_rect->height = container_titlebar_height();
if (!container_is_floating(c)) { if (!container_is_floating(c)) {
if (parent_layout == L_TABBED) { if (parent_layout == L_TABBED) {
deco_rect->width = c->parent deco_rect->width = c->pending.parent
? c->parent->width / c->parent->children->length ? c->pending.parent->pending.width / c->pending.parent->pending.children->length
: c->workspace->width / c->workspace->tiling->length; : c->pending.workspace->width / c->pending.workspace->tiling->length;
deco_rect->x += deco_rect->width * container_sibling_index(c); deco_rect->x += deco_rect->width * container_sibling_index(c);
} else if (parent_layout == L_STACKED) { } else if (parent_layout == L_STACKED) {
if (!c->view) { if (!c->view) {
@ -499,10 +499,10 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object
json_object_object_add(object, "visible", json_object_new_boolean(visible)); json_object_object_add(object, "visible", json_object_new_boolean(visible));
struct wlr_box window_box = { struct wlr_box window_box = {
c->content_x - c->x, c->pending.content_x - c->pending.x,
(c->current.border == B_PIXEL) ? c->current.border_thickness : 0, (c->current.border == B_PIXEL) ? c->current.border_thickness : 0,
c->content_width, c->pending.content_width,
c->content_height c->pending.content_height
}; };
json_object_object_add(object, "window_rect", ipc_json_create_rect(&window_box)); json_object_object_add(object, "window_rect", ipc_json_create_rect(&window_box));
@ -595,11 +595,11 @@ static void ipc_json_describe_container(struct sway_container *c, json_object *o
json_object_object_add(object, "layout", json_object_object_add(object, "layout",
json_object_new_string( json_object_new_string(
ipc_json_layout_description(c->layout))); ipc_json_layout_description(c->pending.layout)));
json_object_object_add(object, "orientation", json_object_object_add(object, "orientation",
json_object_new_string( json_object_new_string(
ipc_json_orientation_description(c->layout))); ipc_json_orientation_description(c->pending.layout)));
bool urgent = c->view ? bool urgent = c->view ?
view_is_urgent(c->view) : container_has_urgent_child(c); view_is_urgent(c->view) : container_has_urgent_child(c);
@ -607,7 +607,7 @@ static void ipc_json_describe_container(struct sway_container *c, json_object *o
json_object_object_add(object, "sticky", json_object_new_boolean(c->is_sticky)); json_object_object_add(object, "sticky", json_object_new_boolean(c->is_sticky));
json_object_object_add(object, "fullscreen_mode", json_object_object_add(object, "fullscreen_mode",
json_object_new_int(c->fullscreen_mode)); json_object_new_int(c->pending.fullscreen_mode));
struct sway_node *parent = node_get_parent(&c->node); struct sway_node *parent = node_get_parent(&c->node);
struct wlr_box parent_box = {0, 0, 0, 0}; struct wlr_box parent_box = {0, 0, 0, 0};
@ -617,8 +617,8 @@ static void ipc_json_describe_container(struct sway_container *c, json_object *o
} }
if (parent_box.width != 0 && parent_box.height != 0) { if (parent_box.width != 0 && parent_box.height != 0) {
double percent = ((double)c->width / parent_box.width) double percent = ((double)c->pending.width / parent_box.width)
* ((double)c->height / parent_box.height); * ((double)c->pending.height / parent_box.height);
json_object_object_add(object, "percent", json_object_new_double(percent)); json_object_object_add(object, "percent", json_object_new_double(percent));
} }
@ -749,10 +749,10 @@ json_object *ipc_json_describe_node_recursive(struct sway_node *node) {
} }
break; break;
case N_CONTAINER: case N_CONTAINER:
if (node->sway_container->children) { if (node->sway_container->pending.children) {
for (i = 0; i < node->sway_container->children->length; ++i) { for (i = 0; i < node->sway_container->pending.children->length; ++i) {
struct sway_container *child = struct sway_container *child =
node->sway_container->children->items[i]; node->sway_container->pending.children->items[i];
json_object_array_add(children, json_object_array_add(children,
ipc_json_describe_node_recursive(&child->node)); ipc_json_describe_node_recursive(&child->node));
} }

View file

@ -55,7 +55,7 @@ static void apply_horiz_layout(list_t *children, struct wlr_box *parent) {
// Calculate gap size // Calculate gap size
double inner_gap = 0; double inner_gap = 0;
struct sway_container *child = children->items[0]; struct sway_container *child = children->items[0];
struct sway_workspace *ws = child->workspace; struct sway_workspace *ws = child->pending.workspace;
if (ws) { if (ws) {
inner_gap = ws->gaps_inner; 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) { if (layout == L_TABBED || layout == L_STACKED) {
inner_gap = 0; inner_gap = 0;
} }
temp = temp->parent; temp = temp->pending.parent;
} }
double total_gap = fmin(inner_gap * (children->length - 1), double total_gap = fmin(inner_gap * (children->length - 1),
fmax(0, parent->width - MIN_SANE_W * children->length)); 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) { for (int i = 0; i < children->length; ++i) {
struct sway_container *child = children->items[i]; struct sway_container *child = children->items[i];
child->child_total_width = child_total_width; child->child_total_width = child_total_width;
child->x = child_x; child->pending.x = child_x;
child->y = parent->y; child->pending.y = parent->y;
child->width = round(child->width_fraction * child_total_width); child->pending.width = round(child->width_fraction * child_total_width);
child->height = parent->height; child->pending.height = parent->height;
child_x += child->width + inner_gap; child_x += child->pending.width + inner_gap;
// Make last child use remaining width of parent // Make last child use remaining width of parent
if (i == children->length - 1) { 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 // Calculate gap size
double inner_gap = 0; double inner_gap = 0;
struct sway_container *child = children->items[0]; struct sway_container *child = children->items[0];
struct sway_workspace *ws = child->workspace; struct sway_workspace *ws = child->pending.workspace;
if (ws) { if (ws) {
inner_gap = ws->gaps_inner; 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) { if (layout == L_TABBED || layout == L_STACKED) {
inner_gap = 0; inner_gap = 0;
} }
temp = temp->parent; temp = temp->pending.parent;
} }
double total_gap = fmin(inner_gap * (children->length - 1), double total_gap = fmin(inner_gap * (children->length - 1),
fmax(0, parent->height - MIN_SANE_H * children->length)); 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) { for (int i = 0; i < children->length; ++i) {
struct sway_container *child = children->items[i]; struct sway_container *child = children->items[i];
child->child_total_height = child_total_height; child->child_total_height = child_total_height;
child->x = parent->x; child->pending.x = parent->x;
child->y = child_y; child->pending.y = child_y;
child->width = parent->width; child->pending.width = parent->width;
child->height = round(child->height_fraction * child_total_height); child->pending.height = round(child->height_fraction * child_total_height);
child_y += child->height + inner_gap; child_y += child->pending.height + inner_gap;
// Make last child use remaining height of parent // Make last child use remaining height of parent
if (i == children->length - 1) { 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) { for (int i = 0; i < children->length; ++i) {
struct sway_container *child = children->items[i]; struct sway_container *child = children->items[i];
int parent_offset = child->view ? 0 : container_titlebar_height(); int parent_offset = child->view ? 0 : container_titlebar_height();
child->x = parent->x; child->pending.x = parent->x;
child->y = parent->y + parent_offset; child->pending.y = parent->y + parent_offset;
child->width = parent->width; child->pending.width = parent->width;
child->height = parent->height - parent_offset; 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]; struct sway_container *child = children->items[i];
int parent_offset = child->view ? 0 : int parent_offset = child->view ? 0 :
container_titlebar_height() * children->length; container_titlebar_height() * children->length;
child->x = parent->x; child->pending.x = parent->x;
child->y = parent->y + parent_offset; child->pending.y = parent->y + parent_offset;
child->width = parent->width; child->pending.width = parent->width;
child->height = parent->height - parent_offset; child->pending.height = parent->height - parent_offset;
} }
} }
@ -246,7 +246,7 @@ void arrange_container(struct sway_container *container) {
} }
struct wlr_box box; struct wlr_box box;
container_get_box(container, &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); 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) { for (int i = 0; i < workspace->floating->length; ++i) {
struct sway_container *floater = workspace->floating->items[i]; struct sway_container *floater = workspace->floating->items[i];
container_floating_translate(floater, diff_x, diff_y); container_floating_translate(floater, diff_x, diff_y);
double center_x = floater->x + floater->width / 2; double center_x = floater->pending.x + floater->pending.width / 2;
double center_y = floater->y + floater->height / 2; double center_y = floater->pending.y + floater->pending.height / 2;
struct wlr_box workspace_box; struct wlr_box workspace_box;
workspace_get_box(workspace, &workspace_box); workspace_get_box(workspace, &workspace_box);
if (!wlr_box_contains_point(&workspace_box, center_x, center_y)) { 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); workspace->x, workspace->y);
if (workspace->fullscreen) { if (workspace->fullscreen) {
struct sway_container *fs = workspace->fullscreen; struct sway_container *fs = workspace->fullscreen;
fs->x = output->lx; fs->pending.x = output->lx;
fs->y = output->ly; fs->pending.y = output->ly;
fs->width = output->width; fs->pending.width = output->width;
fs->height = output->height; fs->pending.height = output->height;
arrange_container(fs); arrange_container(fs);
} else { } else {
struct wlr_box box; struct wlr_box box;
@ -337,10 +337,10 @@ void arrange_root(void) {
if (root->fullscreen_global) { if (root->fullscreen_global) {
struct sway_container *fs = root->fullscreen_global; struct sway_container *fs = root->fullscreen_global;
fs->x = root->x; fs->pending.x = root->x;
fs->y = root->y; fs->pending.y = root->y;
fs->width = root->width; fs->pending.width = root->width;
fs->height = root->height; fs->pending.height = root->height;
arrange_container(fs); arrange_container(fs);
} else { } else {
for (int i = 0; i < root->outputs->length; ++i) { for (int i = 0; i < root->outputs->length; ++i) {

View file

@ -30,12 +30,12 @@ struct sway_container *container_create(struct sway_view *view) {
return NULL; return NULL;
} }
node_init(&c->node, N_CONTAINER, c); node_init(&c->node, N_CONTAINER, c);
c->layout = L_NONE; c->pending.layout = L_NONE;
c->view = view; c->view = view;
c->alpha = 1.0f; c->alpha = 1.0f;
if (!view) { if (!view) {
c->children = create_list(); c->pending.children = create_list();
c->current.children = create_list(); c->current.children = create_list();
} }
c->marks = 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_focused_inactive);
wlr_texture_destroy(con->title_unfocused); wlr_texture_destroy(con->title_unfocused);
wlr_texture_destroy(con->title_urgent); wlr_texture_destroy(con->title_urgent);
list_free(con->children); list_free(con->pending.children);
list_free(con->current.children); list_free(con->current.children);
list_free(con->outputs); 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 // The workspace must have the fullscreen pointer cleared so that the
// seat code can find an appropriate new focus. // seat code can find an appropriate new focus.
if (con->fullscreen_mode == FULLSCREEN_WORKSPACE && con->workspace) { if (con->pending.fullscreen_mode == FULLSCREEN_WORKSPACE && con->pending.workspace) {
con->workspace->fullscreen = NULL; 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); container_fullscreen_disable(con);
} }
@ -108,11 +108,11 @@ void container_begin_destroy(struct sway_container *con) {
root_scratchpad_remove_container(con); root_scratchpad_remove_container(con);
} }
if (con->fullscreen_mode == FULLSCREEN_GLOBAL) { if (con->pending.fullscreen_mode == FULLSCREEN_GLOBAL) {
container_fullscreen_disable(con); container_fullscreen_disable(con);
} }
if (con->parent || con->workspace) { if (con->pending.parent || con->pending.workspace) {
container_detach(con); container_detach(con);
} }
} }
@ -121,12 +121,12 @@ void container_reap_empty(struct sway_container *con) {
if (con->view) { if (con->view) {
return; return;
} }
struct sway_workspace *ws = con->workspace; struct sway_workspace *ws = con->pending.workspace;
while (con) { while (con) {
if (con->children->length) { if (con->pending.children->length) {
return; return;
} }
struct sway_container *parent = con->parent; struct sway_container *parent = con->pending.parent;
container_begin_destroy(con); container_begin_destroy(con);
con = parent; con = parent;
} }
@ -139,9 +139,9 @@ struct sway_container *container_flatten(struct sway_container *container) {
if (container->view) { if (container->view) {
return NULL; return NULL;
} }
while (container && container->children->length == 1) { while (container && container->pending.children->length == 1) {
struct sway_container *child = container->children->items[0]; struct sway_container *child = container->pending.children->items[0];
struct sway_container *parent = container->parent; struct sway_container *parent = container->pending.parent;
container_replace(container, child); container_replace(container, child);
container_begin_destroy(container); container_begin_destroy(container);
container = parent; 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, struct sway_container *container_find_child(struct sway_container *container,
bool (*test)(struct sway_container *con, void *data), void *data) { bool (*test)(struct sway_container *con, void *data), void *data) {
if (!container->children) { if (!container->pending.children) {
return NULL; return NULL;
} }
for (int i = 0; i < container->children->length; ++i) { for (int i = 0; i < container->pending.children->length; ++i) {
struct sway_container *child = container->children->items[i]; struct sway_container *child = container->pending.children->items[i];
if (test(child, data)) { if (test(child, data)) {
return child; return child;
} }
@ -319,10 +319,10 @@ struct sway_container *view_container_at(struct sway_node *parent,
struct sway_container *container = parent->sway_container; struct sway_container *container = parent->sway_container;
struct wlr_box box = { struct wlr_box box = {
.x = container->x, .x = container->pending.x,
.y = container->y, .y = container->pending.y,
.width = container->width, .width = container->pending.width,
.height = container->height, .height = container->pending.height,
}; };
if (wlr_box_contains_point(&box, lx, ly)) { 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 container_for_each_child(struct sway_container *container,
void (*f)(struct sway_container *container, void *data), void (*f)(struct sway_container *container, void *data),
void *data) { void *data) {
if (container->children) { if (container->pending.children) {
for (int i = 0; i < container->children->length; ++i) { for (int i = 0; i < container->pending.children->length; ++i) {
struct sway_container *child = container->children->items[i]; struct sway_container *child = container->pending.children->items[i];
f(child, data); f(child, data);
container_for_each_child(child, f, 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, bool container_has_ancestor(struct sway_container *descendant,
struct sway_container *ancestor) { struct sway_container *ancestor) {
while (descendant) { while (descendant) {
descendant = descendant->parent; descendant = descendant->pending.parent;
if (descendant == ancestor) { if (descendant == ancestor) {
return true; return true;
} }
@ -596,23 +596,23 @@ size_t container_build_representation(enum sway_container_layout layout,
void container_update_representation(struct sway_container *con) { void container_update_representation(struct sway_container *con) {
if (!con->view) { if (!con->view) {
size_t len = container_build_representation(con->layout, size_t len = container_build_representation(con->pending.layout,
con->children, NULL); con->pending.children, NULL);
free(con->formatted_title); free(con->formatted_title);
con->formatted_title = calloc(len + 1, sizeof(char)); con->formatted_title = calloc(len + 1, sizeof(char));
if (!sway_assert(con->formatted_title, if (!sway_assert(con->formatted_title,
"Unable to allocate title string")) { "Unable to allocate title string")) {
return; return;
} }
container_build_representation(con->layout, con->children, container_build_representation(con->pending.layout, con->pending.children,
con->formatted_title); con->formatted_title);
container_calculate_title_height(con); container_calculate_title_height(con);
container_update_title_textures(con); container_update_title_textures(con);
} }
if (con->parent) { if (con->pending.parent) {
container_update_representation(con->parent); container_update_representation(con->pending.parent);
} else if (con->workspace) { } else if (con->pending.workspace) {
workspace_update_representation(con->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, floating_calculate_constraints(&min_width, &max_width,
&min_height, &max_height); &min_height, &max_height);
if (!con->view) { if (!con->view) {
con->width = fmax(min_width, fmin(con->width, max_width)); con->pending.width = fmax(min_width, fmin(con->pending.width, max_width));
con->height = fmax(min_height, fmin(con->height, max_height)); con->pending.height = fmax(min_height, fmin(con->pending.height, max_height));
} else { } else {
struct sway_view *view = con->view; struct sway_view *view = con->view;
con->content_width = con->pending.content_width =
fmax(min_width, fmin(view->natural_width, max_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)); fmax(min_height, fmin(view->natural_height, max_height));
container_set_geometry_from_content(con); container_set_geometry_from_content(con);
} }
} }
void container_floating_resize_and_center(struct sway_container *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) { if (!ws) {
// On scratchpad, just resize // On scratchpad, just resize
floating_natural_resize(con); floating_natural_resize(con);
@ -687,42 +687,42 @@ void container_floating_resize_and_center(struct sway_container *con) {
ws->output->wlr_output); ws->output->wlr_output);
if (!ob) { if (!ob) {
// On NOOP output. Will be called again when moved to an output // On NOOP output. Will be called again when moved to an output
con->x = 0; con->pending.x = 0;
con->y = 0; con->pending.y = 0;
con->width = 0; con->pending.width = 0;
con->height = 0; con->pending.height = 0;
return; return;
} }
floating_natural_resize(con); floating_natural_resize(con);
if (!con->view) { if (!con->view) {
if (con->width > ws->width || con->height > ws->height) { if (con->pending.width > ws->width || con->pending.height > ws->height) {
con->x = ob->x + (ob->width - con->width) / 2; con->pending.x = ob->x + (ob->width - con->pending.width) / 2;
con->y = ob->y + (ob->height - con->height) / 2; con->pending.y = ob->y + (ob->height - con->pending.height) / 2;
} else { } else {
con->x = ws->x + (ws->width - con->width) / 2; con->pending.x = ws->x + (ws->width - con->pending.width) / 2;
con->y = ws->y + (ws->height - con->height) / 2; con->pending.y = ws->y + (ws->height - con->pending.height) / 2;
} }
} else { } else {
if (con->content_width > ws->width if (con->pending.content_width > ws->width
|| con->content_height > ws->height) { || con->pending.content_height > ws->height) {
con->content_x = ob->x + (ob->width - con->content_width) / 2; con->pending.content_x = ob->x + (ob->width - con->pending.content_width) / 2;
con->content_y = ob->y + (ob->height - con->content_height) / 2; con->pending.content_y = ob->y + (ob->height - con->pending.content_height) / 2;
} else { } else {
con->content_x = ws->x + (ws->width - con->content_width) / 2; con->pending.content_x = ws->x + (ws->width - con->pending.content_width) / 2;
con->content_y = ws->y + (ws->height - con->content_height) / 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. // If the view's border is B_NONE then these properties are ignored.
con->border_top = con->border_bottom = true; con->pending.border_top = con->pending.border_bottom = true;
con->border_left = con->border_right = true; con->pending.border_left = con->pending.border_right = true;
container_set_geometry_from_content(con); container_set_geometry_from_content(con);
} }
} }
void container_floating_set_default_size(struct sway_container *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; return;
} }
@ -730,16 +730,16 @@ void container_floating_set_default_size(struct sway_container *con) {
floating_calculate_constraints(&min_width, &max_width, floating_calculate_constraints(&min_width, &max_width,
&min_height, &max_height); &min_height, &max_height);
struct wlr_box *box = calloc(1, sizeof(struct wlr_box)); 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 width = fmax(min_width, fmin(box->width * 0.5, max_width));
double height = fmax(min_height, fmin(box->height * 0.75, max_height)); double height = fmax(min_height, fmin(box->height * 0.75, max_height));
if (!con->view) { if (!con->view) {
con->width = width; con->pending.width = width;
con->height = height; con->pending.height = height;
} else { } else {
con->content_width = width; con->pending.content_width = width;
con->content_height = height; con->pending.content_height = height;
container_set_geometry_from_content(con); 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); con->view->impl->set_resizing(con->view, resizing);
} }
} else { } else {
for (int i = 0; i < con->children->length; ++i ) { for (int i = 0; i < con->pending.children->length; ++i ) {
struct sway_container *child = con->children->items[i]; struct sway_container *child = con->pending.children->items[i];
container_set_resizing(child, resizing); 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_seat *seat = input_manager_current_seat();
struct sway_workspace *workspace = container->workspace; struct sway_workspace *workspace = container->pending.workspace;
if (enable) { if (enable) {
struct sway_container *old_parent = container->parent; struct sway_container *old_parent = container->pending.parent;
container_detach(container); container_detach(container);
workspace_add_floating(workspace, container); workspace_add_floating(workspace, container);
if (container->view) { if (container->view) {
view_set_tiled(container->view, false); view_set_tiled(container->view, false);
if (container->view->using_csd) { if (container->view->using_csd) {
container->border = B_CSD; container->pending.border = B_CSD;
} }
} }
container_floating_set_default_size(container); 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); seat_get_focus_inactive_tiling(seat, workspace);
if (reference) { if (reference) {
container_add_sibling(reference, container, 1); container_add_sibling(reference, container, 1);
container->width = reference->width; container->pending.width = reference->pending.width;
container->height = reference->height; container->pending.height = reference->pending.height;
} else { } else {
struct sway_container *other = struct sway_container *other =
workspace_add_tiling(workspace, container); workspace_add_tiling(workspace, container);
other->width = workspace->width; other->pending.width = workspace->width;
other->height = workspace->height; other->pending.height = workspace->height;
} }
if (container->view) { if (container->view) {
view_set_tiled(container->view, true); view_set_tiled(container->view, true);
if (container->view->using_csd) { if (container->view->using_csd) {
container->border = container->saved_border; container->pending.border = container->saved_border;
} }
} }
container->width_fraction = 0; 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 border_width = 0;
size_t top = 0; size_t top = 0;
if (con->border != B_CSD) { if (con->pending.border != B_CSD) {
border_width = con->border_thickness * (con->border != B_NONE); border_width = con->pending.border_thickness * (con->pending.border != B_NONE);
top = con->border == B_NORMAL ? top = con->pending.border == B_NORMAL ?
container_titlebar_height() : border_width; container_titlebar_height() : border_width;
} }
con->x = con->content_x - border_width; con->pending.x = con->pending.content_x - border_width;
con->y = con->content_y - top; con->pending.y = con->pending.content_y - top;
con->width = con->content_width + border_width * 2; con->pending.width = con->pending.content_width + border_width * 2;
con->height = top + con->content_height + border_width; con->pending.height = top + con->pending.content_height + border_width;
node_set_dirty(&con->node); node_set_dirty(&con->node);
} }
bool container_is_floating(struct sway_container *container) { bool container_is_floating(struct sway_container *container) {
if (!container->parent && container->workspace && if (!container->pending.parent && container->pending.workspace &&
list_find(container->workspace->floating, container) != -1) { list_find(container->pending.workspace->floating, container) != -1) {
return true; return true;
} }
if (container->scratchpad) { 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) { void container_get_box(struct sway_container *container, struct wlr_box *box) {
box->x = container->x; box->x = container->pending.x;
box->y = container->y; box->y = container->pending.y;
box->width = container->width; box->width = container->pending.width;
box->height = container->height; 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, void container_floating_translate(struct sway_container *con,
double x_amount, double y_amount) { double x_amount, double y_amount) {
con->x += x_amount; con->pending.x += x_amount;
con->y += y_amount; con->pending.y += y_amount;
con->content_x += x_amount; con->pending.content_x += x_amount;
con->content_y += y_amount; con->pending.content_y += y_amount;
if (con->children) { if (con->pending.children) {
for (int i = 0; i < con->children->length; ++i) { for (int i = 0; i < con->pending.children->length; ++i) {
struct sway_container *child = con->children->items[i]; struct sway_container *child = con->pending.children->items[i];
container_floating_translate(child, x_amount, y_amount); container_floating_translate(child, x_amount, y_amount);
} }
} }
@ -893,8 +893,8 @@ void container_floating_translate(struct sway_container *con,
* center. * center.
*/ */
struct sway_output *container_floating_find_output(struct sway_container *con) { struct sway_output *container_floating_find_output(struct sway_container *con) {
double center_x = con->x + con->width / 2; double center_x = con->pending.x + con->pending.width / 2;
double center_y = con->y + con->height / 2; double center_y = con->pending.y + con->pending.height / 2;
struct sway_output *closest_output = NULL; struct sway_output *closest_output = NULL;
double closest_distance = DBL_MAX; double closest_distance = DBL_MAX;
for (int i = 0; i < root->outputs->length; ++i) { 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")) { "Expected a floating container")) {
return; 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)) { if (container_is_scratchpad_hidden(con)) {
return; 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); struct sway_output *new_output = container_floating_find_output(con);
if (!sway_assert(new_output, "Unable to find any output")) { if (!sway_assert(new_output, "Unable to find any output")) {
return; return;
@ -951,10 +951,10 @@ void container_floating_move_to_center(struct sway_container *con) {
"Expected a floating container")) { "Expected a floating container")) {
return; return;
} }
struct sway_workspace *ws = con->workspace; struct sway_workspace *ws = con->pending.workspace;
double new_lx = ws->x + (ws->width - con->width) / 2; double new_lx = ws->x + (ws->width - con->pending.width) / 2;
double new_ly = ws->y + (ws->height - con->height) / 2; double new_ly = ws->y + (ws->height - con->pending.height) / 2;
container_floating_translate(con, new_lx - con->x, new_ly - con->y); 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) { 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) { 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")) { "Expected a non-fullscreen container")) {
return; return;
} }
bool enable = true; bool enable = true;
set_fullscreen_iterator(con, &enable); set_fullscreen_iterator(con, &enable);
container_for_each_child(con, set_fullscreen_iterator, &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_x = con->pending.x;
con->saved_y = con->y; con->saved_y = con->pending.y;
con->saved_width = con->width; con->saved_width = con->pending.width;
con->saved_height = con->height; con->saved_height = con->pending.height;
if (con->workspace) { if (con->pending.workspace) {
con->workspace->fullscreen = con; con->pending.workspace->fullscreen = con;
struct sway_seat *seat; struct sway_seat *seat;
struct sway_workspace *focus_ws; struct sway_workspace *focus_ws;
wl_list_for_each(seat, &server.input->seats, link) { wl_list_for_each(seat, &server.input->seats, link) {
focus_ws = seat_get_focused_workspace(seat); focus_ws = seat_get_focused_workspace(seat);
if (focus_ws == con->workspace) { if (focus_ws == con->pending.workspace) {
seat_set_focus_container(seat, con); seat_set_focus_container(seat, con);
} else { } else {
struct sway_node *focus = 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) { 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")) { "Expected a non-fullscreen container")) {
return; return;
} }
@ -1032,10 +1032,10 @@ static void container_fullscreen_global(struct sway_container *con) {
container_for_each_child(con, set_fullscreen_iterator, &enable); container_for_each_child(con, set_fullscreen_iterator, &enable);
root->fullscreen_global = con; root->fullscreen_global = con;
con->saved_x = con->x; con->saved_x = con->pending.x;
con->saved_y = con->y; con->saved_y = con->pending.y;
con->saved_width = con->width; con->saved_width = con->pending.width;
con->saved_height = con->height; con->saved_height = con->pending.height;
struct sway_seat *seat; struct sway_seat *seat;
wl_list_for_each(seat, &server.input->seats, link) { 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); container_end_mouse_operation(con);
ipc_event_window(con, "fullscreen_mode"); ipc_event_window(con, "fullscreen_mode");
} }
void container_fullscreen_disable(struct sway_container *con) { 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")) { "Expected a fullscreen container")) {
return; return;
} }
@ -1060,19 +1060,19 @@ void container_fullscreen_disable(struct sway_container *con) {
container_for_each_child(con, set_fullscreen_iterator, &enable); container_for_each_child(con, set_fullscreen_iterator, &enable);
if (container_is_floating(con)) { if (container_is_floating(con)) {
con->x = con->saved_x; con->pending.x = con->saved_x;
con->y = con->saved_y; con->pending.y = con->saved_y;
con->width = con->saved_width; con->pending.width = con->saved_width;
con->height = con->saved_height; con->pending.height = con->saved_height;
} }
if (con->fullscreen_mode == FULLSCREEN_WORKSPACE) { if (con->pending.fullscreen_mode == FULLSCREEN_WORKSPACE) {
if (con->workspace) { if (con->pending.workspace) {
con->workspace->fullscreen = NULL; con->pending.workspace->fullscreen = NULL;
if (container_is_floating(con)) { if (container_is_floating(con)) {
struct sway_output *output = struct sway_output *output =
container_floating_find_output(con); container_floating_find_output(con);
if (con->workspace->output != output) { if (con->pending.workspace->output != output) {
container_floating_move_to_center(con); 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 // If the container was mapped as fullscreen and set as floating by
// criteria, it needs to be reinitialized as floating to get the proper // criteria, it needs to be reinitialized as floating to get the proper
// size and location // 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); container_floating_resize_and_center(con);
} }
con->fullscreen_mode = FULLSCREEN_NONE; con->pending.fullscreen_mode = FULLSCREEN_NONE;
container_end_mouse_operation(con); container_end_mouse_operation(con);
ipc_event_window(con, "fullscreen_mode"); 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, void container_set_fullscreen(struct sway_container *con,
enum sway_fullscreen_mode mode) { enum sway_fullscreen_mode mode) {
if (con->fullscreen_mode == mode) { if (con->pending.fullscreen_mode == mode) {
return; return;
} }
@ -1118,8 +1118,8 @@ void container_set_fullscreen(struct sway_container *con,
if (root->fullscreen_global) { if (root->fullscreen_global) {
container_fullscreen_disable(root->fullscreen_global); container_fullscreen_disable(root->fullscreen_global);
} }
if (con->workspace && con->workspace->fullscreen) { if (con->pending.workspace && con->pending.workspace->fullscreen) {
container_fullscreen_disable(con->workspace->fullscreen); container_fullscreen_disable(con->pending.workspace->fullscreen);
} }
container_fullscreen_workspace(con); container_fullscreen_workspace(con);
break; break;
@ -1127,7 +1127,7 @@ void container_set_fullscreen(struct sway_container *con,
if (root->fullscreen_global) { if (root->fullscreen_global) {
container_fullscreen_disable(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_disable(con);
} }
container_fullscreen_global(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_toplevel_ancestor(
struct sway_container *container) { struct sway_container *container) {
while (container->parent) { while (container->pending.parent) {
container = container->parent; container = container->pending.parent;
} }
return container; 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) { bool container_is_fullscreen_or_child(struct sway_container *container) {
do { do {
if (container->fullscreen_mode) { if (container->pending.fullscreen_mode) {
return true; return true;
} }
container = container->parent; container = container->pending.parent;
} while (container); } while (container);
return false; 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) { enum sway_container_layout container_parent_layout(struct sway_container *con) {
if (con->parent) { if (con->pending.parent) {
return con->parent->layout; return con->pending.parent->pending.layout;
} }
if (con->workspace) { if (con->pending.workspace) {
return con->workspace->layout; return con->pending.workspace->layout;
} }
return L_NONE; return L_NONE;
} }
@ -1244,16 +1244,16 @@ enum sway_container_layout container_current_parent_layout(
} }
list_t *container_get_siblings(struct sway_container *container) { list_t *container_get_siblings(struct sway_container *container) {
if (container->parent) { if (container->pending.parent) {
return container->parent->children; return container->pending.parent->pending.children;
} }
if (container_is_scratchpad_hidden(container)) { if (container_is_scratchpad_hidden(container)) {
return NULL; return NULL;
} }
if (list_find(container->workspace->tiling, container) != -1) { if (list_find(container->pending.workspace->tiling, container) != -1) {
return container->workspace->tiling; return container->pending.workspace->tiling;
} }
return container->workspace->floating; return container->pending.workspace->floating;
} }
int container_sibling_index(struct sway_container *child) { 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) { void container_handle_fullscreen_reparent(struct sway_container *con) {
if (con->fullscreen_mode != FULLSCREEN_WORKSPACE || !con->workspace || if (con->pending.fullscreen_mode != FULLSCREEN_WORKSPACE || !con->pending.workspace ||
con->workspace->fullscreen == con) { con->pending.workspace->fullscreen == con) {
return; return;
} }
if (con->workspace->fullscreen) { if (con->pending.workspace->fullscreen) {
container_fullscreen_disable(con->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) { 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, void container_insert_child(struct sway_container *parent,
struct sway_container *child, int i) { struct sway_container *child, int i) {
if (child->workspace) { if (child->pending.workspace) {
container_detach(child); container_detach(child);
} }
list_insert(parent->children, i, child); list_insert(parent->pending.children, i, child);
child->parent = parent; child->pending.parent = parent;
child->workspace = parent->workspace; child->pending.workspace = parent->pending.workspace;
container_for_each_child(child, set_workspace, NULL); container_for_each_child(child, set_workspace, NULL);
container_handle_fullscreen_reparent(child); container_handle_fullscreen_reparent(child);
container_update_representation(parent); container_update_representation(parent);
@ -1299,14 +1299,14 @@ void container_insert_child(struct sway_container *parent,
void container_add_sibling(struct sway_container *fixed, void container_add_sibling(struct sway_container *fixed,
struct sway_container *active, bool after) { struct sway_container *active, bool after) {
if (active->workspace) { if (active->pending.workspace) {
container_detach(active); container_detach(active);
} }
list_t *siblings = container_get_siblings(fixed); list_t *siblings = container_get_siblings(fixed);
int index = list_find(siblings, fixed); int index = list_find(siblings, fixed);
list_insert(siblings, index + after, active); list_insert(siblings, index + after, active);
active->parent = fixed->parent; active->pending.parent = fixed->pending.parent;
active->workspace = fixed->workspace; active->pending.workspace = fixed->pending.workspace;
container_for_each_child(active, set_workspace, NULL); container_for_each_child(active, set_workspace, NULL);
container_handle_fullscreen_reparent(active); container_handle_fullscreen_reparent(active);
container_update_representation(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, void container_add_child(struct sway_container *parent,
struct sway_container *child) { struct sway_container *child) {
if (child->workspace) { if (child->pending.workspace) {
container_detach(child); container_detach(child);
} }
list_add(parent->children, child); list_add(parent->pending.children, child);
child->parent = parent; child->pending.parent = parent;
child->workspace = parent->workspace; child->pending.workspace = parent->pending.workspace;
container_for_each_child(child, set_workspace, NULL); container_for_each_child(child, set_workspace, NULL);
bool fullscreen = child->fullscreen_mode != FULLSCREEN_NONE || bool fullscreen = child->pending.fullscreen_mode != FULLSCREEN_NONE ||
parent->fullscreen_mode != FULLSCREEN_NONE; parent->pending.fullscreen_mode != FULLSCREEN_NONE;
set_fullscreen_iterator(child, &fullscreen); set_fullscreen_iterator(child, &fullscreen);
container_for_each_child(child, set_fullscreen_iterator, &fullscreen); container_for_each_child(child, set_fullscreen_iterator, &fullscreen);
container_handle_fullscreen_reparent(child); container_handle_fullscreen_reparent(child);
@ -1332,15 +1332,15 @@ void container_add_child(struct sway_container *parent,
} }
void container_detach(struct sway_container *child) { void container_detach(struct sway_container *child) {
if (child->fullscreen_mode == FULLSCREEN_WORKSPACE) { if (child->pending.fullscreen_mode == FULLSCREEN_WORKSPACE) {
child->workspace->fullscreen = NULL; child->pending.workspace->fullscreen = NULL;
} }
if (child->fullscreen_mode == FULLSCREEN_GLOBAL) { if (child->pending.fullscreen_mode == FULLSCREEN_GLOBAL) {
root->fullscreen_global = NULL; root->fullscreen_global = NULL;
} }
struct sway_container *old_parent = child->parent; struct sway_container *old_parent = child->pending.parent;
struct sway_workspace *old_workspace = child->workspace; struct sway_workspace *old_workspace = child->pending.workspace;
list_t *siblings = container_get_siblings(child); list_t *siblings = container_get_siblings(child);
if (siblings) { if (siblings) {
int index = list_find(siblings, child); int index = list_find(siblings, child);
@ -1348,8 +1348,8 @@ void container_detach(struct sway_container *child) {
list_del(siblings, index); list_del(siblings, index);
} }
} }
child->parent = NULL; child->pending.parent = NULL;
child->workspace = NULL; child->pending.workspace = NULL;
container_for_each_child(child, set_workspace, NULL); container_for_each_child(child, set_workspace, NULL);
if (old_parent) { if (old_parent) {
@ -1364,18 +1364,18 @@ void container_detach(struct sway_container *child) {
void container_replace(struct sway_container *container, void container_replace(struct sway_container *container,
struct sway_container *replacement) { 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; bool scratchpad = container->scratchpad;
struct sway_workspace *ws = NULL; struct sway_workspace *ws = NULL;
if (fullscreen != FULLSCREEN_NONE) { if (fullscreen != FULLSCREEN_NONE) {
container_fullscreen_disable(container); container_fullscreen_disable(container);
} }
if (scratchpad) { if (scratchpad) {
ws = container->workspace; ws = container->pending.workspace;
root_scratchpad_show(container); root_scratchpad_show(container);
root_scratchpad_remove_container(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 width_fraction = container->width_fraction;
float height_fraction = container->height_fraction; float height_fraction = container->height_fraction;
container_add_sibling(container, replacement, 1); container_add_sibling(container, replacement, 1);
@ -1403,7 +1403,7 @@ struct sway_container *container_split(struct sway_container *child,
enum sway_container_layout layout) { enum sway_container_layout layout) {
// i3 doesn't split singleton H/V containers // i3 doesn't split singleton H/V containers
// https://github.com/i3/i3/blob/3cd1c45eba6de073bc4300eebb4e1cc1a0c4479a/src/tree.c#L354 // 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); list_t *siblings = container_get_siblings(child);
if (siblings->length == 1) { if (siblings->length == 1) {
enum sway_container_layout current = container_parent_layout(child); 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; current = L_NONE;
} }
if (current == L_HORIZ || current == L_VERT) { if (current == L_HORIZ || current == L_VERT) {
if (child->parent) { if (child->pending.parent) {
child->parent->layout = layout; child->pending.parent->pending.layout = layout;
container_update_representation(child->parent); container_update_representation(child->pending.parent);
} else { } else {
child->workspace->layout = layout; child->pending.workspace->layout = layout;
workspace_update_representation(child->workspace); workspace_update_representation(child->pending.workspace);
} }
return child; return child;
} }
@ -1429,25 +1429,25 @@ struct sway_container *container_split(struct sway_container *child,
if (container_is_floating(child) && child->view) { if (container_is_floating(child) && child->view) {
view_set_tiled(child->view, true); view_set_tiled(child->view, true);
if (child->view->using_csd) { if (child->view->using_csd) {
child->border = child->saved_border; child->pending.border = child->saved_border;
} }
} }
struct sway_container *cont = container_create(NULL); struct sway_container *cont = container_create(NULL);
cont->width = child->width; cont->pending.width = child->pending.width;
cont->height = child->height; cont->pending.height = child->pending.height;
cont->width_fraction = child->width_fraction; cont->width_fraction = child->width_fraction;
cont->height_fraction = child->height_fraction; cont->height_fraction = child->height_fraction;
cont->x = child->x; cont->pending.x = child->pending.x;
cont->y = child->y; cont->pending.y = child->pending.y;
cont->layout = layout; cont->pending.layout = layout;
container_replace(child, cont); container_replace(child, cont);
container_add_child(cont, child); container_add_child(cont, child);
if (set_focus) { if (set_focus) {
seat_set_raw_focus(seat, &cont->node); 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); seat_set_focus(seat, &child->node);
} else { } else {
seat_set_raw_focus(seat, &child->node); 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) { void container_raise_floating(struct sway_container *con) {
// Bring container to front by putting it at the end of the floating list. // Bring container to front by putting it at the end of the floating list.
struct sway_container *floater = container_toplevel_ancestor(con); struct sway_container *floater = container_toplevel_ancestor(con);
if (container_is_floating(floater) && floater->workspace) { if (container_is_floating(floater) && floater->pending.workspace) {
list_move_to_end(floater->workspace->floating, floater); list_move_to_end(floater->pending.workspace->floating, floater);
node_set_dirty(&floater->workspace->node); node_set_dirty(&floater->pending.workspace->node);
} }
} }
bool container_is_scratchpad_hidden(struct sway_container *con) { 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) { bool container_is_scratchpad_hidden_or_child(struct sway_container *con) {
con = container_toplevel_ancestor(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) { 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, static bool container_is_squashable(struct sway_container *con,
struct sway_container *child) { struct sway_container *child) {
enum sway_container_layout gp_layout = container_parent_layout(con); enum sway_container_layout gp_layout = container_parent_layout(con);
return (con->layout == L_HORIZ || con->layout == L_VERT) && return (con->pending.layout == L_HORIZ || con->pending.layout == L_VERT) &&
(child->layout == L_HORIZ || child->layout == L_VERT) && (child->pending.layout == L_HORIZ || child->pending.layout == L_VERT) &&
!is_parallel(con->layout, child->layout) && !is_parallel(con->pending.layout, child->pending.layout) &&
is_parallel(gp_layout, child->layout); is_parallel(gp_layout, child->pending.layout);
} }
static void container_squash_children(struct sway_container *con) { static void container_squash_children(struct sway_container *con) {
for (int i = 0; i < con->children->length; i++) { for (int i = 0; i < con->pending.children->length; i++) {
struct sway_container *child = con->children->items[i]; struct sway_container *child = con->pending.children->items[i];
i += container_squash(child); i += container_squash(child);
} }
} }
int container_squash(struct sway_container *con) { int container_squash(struct sway_container *con) {
if (!con->children) { if (!con->pending.children) {
return 0; return 0;
} }
if (con->children->length != 1) { if (con->pending.children->length != 1) {
container_squash_children(con); container_squash_children(con);
return 0; 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 idx = container_sibling_index(con);
int change = 0; int change = 0;
if (container_is_squashable(con, child)) { if (container_is_squashable(con, child)) {
// con and child are a redundant H/V pair. Destroy them. // con and child are a redundant H/V pair. Destroy them.
while (child->children->length) { while (child->pending.children->length) {
struct sway_container *current = child->children->items[0]; struct sway_container *current = child->pending.children->items[0];
container_detach(current); container_detach(current);
if (con->parent) { if (con->pending.parent) {
container_insert_child(con->parent, current, idx); container_insert_child(con->pending.parent, current, idx);
} else { } else {
workspace_insert_tiling_direct(con->workspace, current, idx); workspace_insert_tiling_direct(con->pending.workspace, current, idx);
} }
change++; change++;
} }

View file

@ -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) { struct sway_output *node_get_output(struct sway_node *node) {
switch (node->type) { switch (node->type) {
case N_CONTAINER: { 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; return ws ? ws->output : NULL;
} }
case N_WORKSPACE: 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) { enum sway_container_layout node_get_layout(struct sway_node *node) {
switch (node->type) { switch (node->type) {
case N_CONTAINER: case N_CONTAINER:
return node->sway_container->layout; return node->sway_container->pending.layout;
case N_WORKSPACE: case N_WORKSPACE:
return node->sway_workspace->layout; return node->sway_workspace->layout;
case N_OUTPUT: case N_OUTPUT:
@ -105,11 +105,11 @@ struct sway_node *node_get_parent(struct sway_node *node) {
switch (node->type) { switch (node->type) {
case N_CONTAINER: { case N_CONTAINER: {
struct sway_container *con = node->sway_container; struct sway_container *con = node->sway_container;
if (con->parent) { if (con->pending.parent) {
return &con->parent->node; return &con->pending.parent->node;
} }
if (con->workspace) { if (con->pending.workspace) {
return &con->workspace->node; return &con->pending.workspace->node;
} }
} }
return NULL; 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) { list_t *node_get_children(struct sway_node *node) {
switch (node->type) { switch (node->type) {
case N_CONTAINER: case N_CONTAINER:
return node->sway_container->children; return node->sway_container->pending.children;
case N_WORKSPACE: case N_WORKSPACE:
return node->sway_workspace->tiling; return node->sway_workspace->tiling;
case N_OUTPUT: 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) { bool node_has_ancestor(struct sway_node *node, struct sway_node *ancestor) {
if (ancestor->type == N_ROOT && node->type == N_CONTAINER && 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; return true;
} }
struct sway_node *parent = node_get_parent(node); 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; return true;
} }
if (ancestor->type == N_ROOT && parent->type == N_CONTAINER && 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; return true;
} }
parent = node_get_parent(parent); parent = node_get_parent(parent);

View file

@ -70,13 +70,13 @@ static void restore_workspaces(struct sway_output *output) {
// floater re-centered // floater re-centered
for (int i = 0; i < ws->floating->length; i++) { for (int i = 0; i < ws->floating->length; i++) {
struct sway_container *floater = ws->floating->items[i]; struct sway_container *floater = ws->floating->items[i];
if (floater->width == 0 || floater->height == 0 || if (floater->pending.width == 0 || floater->pending.height == 0 ||
floater->width > output->width || floater->pending.width > output->width ||
floater->height > output->height || floater->pending.height > output->height ||
floater->x > output->lx + output->width || floater->pending.x > output->lx + output->width ||
floater->y > output->ly + output->height || floater->pending.y > output->ly + output->height ||
floater->x + floater->width < output->lx || floater->pending.x + floater->pending.width < output->lx ||
floater->y + floater->height < output->ly) { floater->pending.y + floater->pending.height < output->ly) {
container_floating_resize_and_center(floater); container_floating_resize_and_center(floater);
} }
} }

View file

@ -59,11 +59,11 @@ void root_scratchpad_add_container(struct sway_container *con, struct sway_works
return; return;
} }
struct sway_container *parent = con->parent; struct sway_container *parent = con->pending.parent;
struct sway_workspace *workspace = con->workspace; struct sway_workspace *workspace = con->pending.workspace;
// Clear the fullscreen mode when sending to the scratchpad // 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); 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"); sway_log(SWAY_DEBUG, "No focused workspace to show scratchpad on");
return; 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 // If the current con or any of its parents are in fullscreen mode, we
// first need to disable it before showing the scratchpad con. // 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); workspace_consider_destroy(old_ws);
} else { } else {
// Act on the ancestor of scratchpad hidden split containers // Act on the ancestor of scratchpad hidden split containers
while (con->parent) { while (con->pending.parent) {
con = con->parent; con = con->pending.parent;
} }
} }
workspace_add_floating(new_ws, con); workspace_add_floating(new_ws, con);
// Make sure the container's center point overlaps this workspace // Make sure the container's center point overlaps this workspace
double center_lx = con->x + con->width / 2; double center_lx = con->pending.x + con->pending.width / 2;
double center_ly = con->y + con->height / 2; double center_ly = con->pending.y + con->pending.height / 2;
struct wlr_box workspace_box; struct wlr_box workspace_box;
workspace_get_box(new_ws, &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) { 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); 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) { void root_scratchpad_hide(struct sway_container *con) {
struct sway_seat *seat = input_manager_current_seat(); struct sway_seat *seat = input_manager_current_seat();
struct sway_node *focus = seat_get_focus_inactive(seat, &root->node); 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, // If the container was made fullscreen global while in the scratchpad,
// it should be shown until fullscreen has been disabled // it should be shown until fullscreen has been disabled
return; return;

View file

@ -206,7 +206,7 @@ bool view_ancestor_is_only_visible(struct sway_view *view) {
} else { } else {
only_visible = true; only_visible = true;
} }
con = con->parent; con = con->pending.parent;
} }
return only_visible; 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; return true;
} }
static bool gaps_to_edge(struct sway_view *view) { 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; return gaps.top > 0 || gaps.right > 0 || gaps.bottom > 0 || gaps.left > 0;
} }
void view_autoconfigure(struct sway_view *view) { void view_autoconfigure(struct sway_view *view) {
struct sway_container *con = view->container; 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) && if (container_is_scratchpad_hidden(con) &&
con->fullscreen_mode != FULLSCREEN_GLOBAL) { con->pending.fullscreen_mode != FULLSCREEN_GLOBAL) {
return; return;
} }
struct sway_output *output = ws ? ws->output : NULL; struct sway_output *output = ws ? ws->output : NULL;
if (con->fullscreen_mode == FULLSCREEN_WORKSPACE) { if (con->pending.fullscreen_mode == FULLSCREEN_WORKSPACE) {
con->content_x = output->lx; con->pending.content_x = output->lx;
con->content_y = output->ly; con->pending.content_y = output->ly;
con->content_width = output->width; con->pending.content_width = output->width;
con->content_height = output->height; con->pending.content_height = output->height;
return; return;
} else if (con->fullscreen_mode == FULLSCREEN_GLOBAL) { } else if (con->pending.fullscreen_mode == FULLSCREEN_GLOBAL) {
con->content_x = root->x; con->pending.content_x = root->x;
con->content_y = root->y; con->pending.content_y = root->y;
con->content_width = root->width; con->pending.content_width = root->width;
con->content_height = root->height; con->pending.content_height = root->height;
return; return;
} }
con->border_top = con->border_bottom = true; con->pending.border_top = con->pending.border_bottom = true;
con->border_left = con->border_right = true; con->pending.border_left = con->pending.border_right = true;
double y_offset = 0; double y_offset = 0;
if (!container_is_floating(con) && ws) { if (!container_is_floating(con) && ws) {
if (config->hide_edge_borders == E_BOTH if (config->hide_edge_borders == E_BOTH
|| config->hide_edge_borders == E_VERTICAL) { || config->hide_edge_borders == E_VERTICAL) {
con->border_left = con->x != ws->x; con->pending.border_left = con->pending.x != ws->x;
int right_x = con->x + con->width; int right_x = con->pending.x + con->pending.width;
con->border_right = right_x != ws->x + ws->width; con->pending.border_right = right_x != ws->x + ws->width;
} }
if (config->hide_edge_borders == E_BOTH if (config->hide_edge_borders == E_BOTH
|| config->hide_edge_borders == E_HORIZONTAL) { || config->hide_edge_borders == E_HORIZONTAL) {
con->border_top = con->y != ws->y; con->pending.border_top = con->pending.y != ws->y;
int bottom_y = con->y + con->height; int bottom_y = con->pending.y + con->pending.height;
con->border_bottom = bottom_y != ws->y + ws->height; con->pending.border_bottom = bottom_y != ws->y + ws->height;
} }
bool smart = config->hide_edge_borders_smart == ESMART_ON || bool smart = config->hide_edge_borders_smart == ESMART_ON ||
@ -282,10 +282,10 @@ void view_autoconfigure(struct sway_view *view) {
if (smart) { if (smart) {
bool show_border = container_is_floating_or_child(con) || bool show_border = container_is_floating_or_child(con) ||
!view_is_only_visible(view); !view_is_only_visible(view);
con->border_left &= show_border; con->pending.border_left &= show_border;
con->border_right &= show_border; con->pending.border_right &= show_border;
con->border_top &= show_border; con->pending.border_top &= show_border;
con->border_bottom &= show_border; con->pending.border_bottom &= show_border;
} }
// In a tabbed or stacked container, the container's y is the top of the // 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); enum sway_container_layout layout = container_parent_layout(con);
if (layout == L_TABBED) { if (layout == L_TABBED) {
y_offset = container_titlebar_height(); y_offset = container_titlebar_height();
con->border_top = false; con->pending.border_top = false;
} else if (layout == L_STACKED) { } else if (layout == L_STACKED) {
y_offset = container_titlebar_height() * siblings->length; y_offset = container_titlebar_height() * siblings->length;
con->border_top = false; con->pending.border_top = false;
} }
} }
} }
double x, y, width, height; double x, y, width, height;
switch (con->border) { switch (con->pending.border) {
default: default:
case B_CSD: case B_CSD:
case B_NONE: case B_NONE:
x = con->x; x = con->pending.x;
y = con->y + y_offset; y = con->pending.y + y_offset;
width = con->width; width = con->pending.width;
height = con->height - y_offset; height = con->pending.height - y_offset;
break; break;
case B_PIXEL: case B_PIXEL:
x = con->x + con->border_thickness * con->border_left; x = con->pending.x + con->pending.border_thickness * con->pending.border_left;
y = con->y + con->border_thickness * con->border_top + y_offset; y = con->pending.y + con->pending.border_thickness * con->pending.border_top + y_offset;
width = con->width width = con->pending.width
- con->border_thickness * con->border_left - con->pending.border_thickness * con->pending.border_left
- con->border_thickness * con->border_right; - con->pending.border_thickness * con->pending.border_right;
height = con->height - y_offset height = con->pending.height - y_offset
- con->border_thickness * con->border_top - con->pending.border_thickness * con->pending.border_top
- con->border_thickness * con->border_bottom; - con->pending.border_thickness * con->pending.border_bottom;
break; break;
case B_NORMAL: case B_NORMAL:
// Height is: 1px border + 3px pad + title height + 3px pad + 1px border // Height is: 1px border + 3px pad + title height + 3px pad + 1px border
x = con->x + con->border_thickness * con->border_left; x = con->pending.x + con->pending.border_thickness * con->pending.border_left;
width = con->width width = con->pending.width
- con->border_thickness * con->border_left - con->pending.border_thickness * con->pending.border_left
- con->border_thickness * con->border_right; - con->pending.border_thickness * con->pending.border_right;
if (y_offset) { if (y_offset) {
y = con->y + y_offset; y = con->pending.y + y_offset;
height = con->height - y_offset height = con->pending.height - y_offset
- con->border_thickness * con->border_bottom; - con->pending.border_thickness * con->pending.border_bottom;
} else { } else {
y = con->y + container_titlebar_height(); y = con->pending.y + container_titlebar_height();
height = con->height - container_titlebar_height() height = con->pending.height - container_titlebar_height()
- con->border_thickness * con->border_bottom; - con->pending.border_thickness * con->pending.border_bottom;
} }
break; break;
} }
con->content_x = x; con->pending.content_x = x;
con->content_y = y; con->pending.content_y = y;
con->content_width = width; con->pending.content_width = width;
con->content_height = height; con->pending.content_height = height;
} }
void view_set_activated(struct sway_view *view, bool activated) { 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) { 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 if (!ws) { // hidden scratchpad container
return; 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) { void view_update_csd_from_client(struct sway_view *view, bool enabled) {
sway_log(SWAY_DEBUG, "View %p updated CSD to %i", view, enabled); sway_log(SWAY_DEBUG, "View %p updated CSD to %i", view, enabled);
struct sway_container *con = view->container; struct sway_container *con = view->container;
if (enabled && con && con->border != B_CSD) { if (enabled && con && con->pending.border != B_CSD) {
con->saved_border = con->border; con->saved_border = con->pending.border;
if (container_is_floating(con)) { if (container_is_floating(con)) {
con->border = B_CSD; con->pending.border = B_CSD;
} }
} else if (!enabled && con && con->border == B_CSD) { } else if (!enabled && con && con->pending.border == B_CSD) {
con->border = con->saved_border; con->pending.border = con->saved_border;
} }
view->using_csd = enabled; view->using_csd = enabled;
} }
@ -577,7 +577,7 @@ static struct sway_workspace *select_workspace(struct sway_view *view) {
if (node && node->type == N_WORKSPACE) { if (node && node->type == N_WORKSPACE) {
return node->sway_workspace; return node->sway_workspace;
} else if (node && node->type == N_CONTAINER) { } 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 // 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_seat *seat = input_manager_current_seat();
struct sway_container *prev_con = seat_get_focused_container(seat); struct sway_container *prev_con = seat_get_focused_container(seat);
struct sway_workspace *prev_ws = seat_get_focused_workspace(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; 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 // If the view is the only one in the focused workspace, it'll get focus
// regardless of any no_focus criteria. // regardless of any no_focus criteria.
if (!view->container->parent && !prev_con) { if (!view->container->pending.parent && !prev_con) {
size_t num_children = view->container->workspace->tiling->length + size_t num_children = view->container->pending.workspace->tiling->length +
view->container->workspace->floating->length; view->container->pending.workspace->floating->length;
if (num_children == 1) { if (num_children == 1) {
return true; return true;
} }
@ -645,9 +645,9 @@ static void handle_foreign_fullscreen_request(
// Match fullscreen command behavior for scratchpad hidden views // Match fullscreen command behavior for scratchpad hidden views
struct sway_container *container = view->container; struct sway_container *container = view->container;
if (!container->workspace) { if (!container->pending.workspace) {
while (container->parent) { while (container->pending.parent) {
container = container->parent; container = container->pending.parent;
} }
} }
@ -668,10 +668,10 @@ static void handle_foreign_fullscreen_request(
if (event->fullscreen) { if (event->fullscreen) {
arrange_root(); arrange_root();
} else { } else {
if (container->parent) { if (container->pending.parent) {
arrange_container(container->parent); arrange_container(container->pending.parent);
} else if (container->workspace) { } else if (container->pending.workspace) {
arrange_workspace(container->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)) { if (view->impl->wants_floating && view->impl->wants_floating(view)) {
view->container->border = config->floating_border; view->container->pending.border = config->floating_border;
view->container->border_thickness = config->floating_border_thickness; view->container->pending.border_thickness = config->floating_border_thickness;
container_set_floating(view->container, true); container_set_floating(view->container, true);
} else { } else {
view->container->border = config->border; view->container->pending.border = config->border;
view->container->border_thickness = config->border_thickness; view->container->pending.border_thickness = config->border_thickness;
view_set_tiled(view, true); view_set_tiled(view, true);
} }
if (config->popup_during_fullscreen == POPUP_LEAVE && if (config->popup_during_fullscreen == POPUP_LEAVE &&
container->workspace && container->pending.workspace &&
container->workspace->fullscreen && container->pending.workspace->fullscreen &&
container->workspace->fullscreen->view) { container->pending.workspace->fullscreen->view) {
struct sway_container *fs = container->workspace->fullscreen; struct sway_container *fs = container->pending.workspace->fullscreen;
if (view_is_transient_for(view, fs->view)) { if (view_is_transient_for(view, fs->view)) {
container_set_fullscreen(fs, false); container_set_fullscreen(fs, false);
} }
@ -786,12 +786,12 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface,
if (fullscreen) { if (fullscreen) {
container_set_fullscreen(view->container, true); container_set_fullscreen(view->container, true);
arrange_workspace(view->container->workspace); arrange_workspace(view->container->pending.workspace);
} else { } else {
if (container->parent) { if (container->pending.parent) {
arrange_container(container->parent); arrange_container(container->pending.parent);
} else if (container->workspace) { } else if (container->pending.workspace) {
arrange_workspace(container->workspace); arrange_workspace(container->pending.workspace);
} }
} }
@ -838,8 +838,8 @@ void view_unmap(struct sway_view *view) {
view->foreign_toplevel = NULL; view->foreign_toplevel = NULL;
} }
struct sway_container *parent = view->container->parent; struct sway_container *parent = view->container->pending.parent;
struct sway_workspace *ws = view->container->workspace; struct sway_workspace *ws = view->container->pending.workspace;
container_begin_destroy(view->container); container_begin_destroy(view->container);
if (parent) { if (parent) {
container_reap_empty(parent); container_reap_empty(parent);
@ -874,8 +874,8 @@ void view_unmap(struct sway_view *view) {
void view_update_size(struct sway_view *view) { void view_update_size(struct sway_view *view) {
struct sway_container *con = view->container; struct sway_container *con = view->container;
con->content_width = view->geometry.width; con->pending.content_width = view->geometry.width;
con->content_height = view->geometry.height; con->pending.content_height = view->geometry.height;
container_set_geometry_from_content(con); 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; int sx, sy;
child->impl->get_root_coords(child, &sx, &sy); child->impl->get_root_coords(child, &sx, &sy);
desktop_damage_surface(child->surface, desktop_damage_surface(child->surface,
child->view->container->content_x + sx, child->view->container->pending.content_x + sx,
child->view->container->content_y + sy, whole); child->view->container->pending.content_y + sy, whole);
} }
static void view_child_handle_surface_commit(struct wl_listener *listener, 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); wl_signal_add(&view->events.unmap, &child->view_unmap);
child->view_unmap.notify = view_child_handle_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) { if (workspace) {
wlr_surface_send_enter(child->surface, workspace->output->wlr_output); 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) { if (view->container->node.destroying) {
return false; return false;
} }
struct sway_workspace *workspace = view->container->workspace; struct sway_workspace *workspace = view->container->pending.workspace;
if (!workspace && view->container->fullscreen_mode != FULLSCREEN_GLOBAL) { if (!workspace && view->container->pending.fullscreen_mode != FULLSCREEN_GLOBAL) {
bool fs_global_descendant = false; bool fs_global_descendant = false;
struct sway_container *parent = view->container->parent; struct sway_container *parent = view->container->pending.parent;
while (parent) { while (parent) {
if (parent->fullscreen_mode == FULLSCREEN_GLOBAL) { if (parent->pending.fullscreen_mode == FULLSCREEN_GLOBAL) {
fs_global_descendant = true; fs_global_descendant = true;
} }
parent = parent->parent; parent = parent->pending.parent;
} }
if (!fs_global_descendant) { if (!fs_global_descendant) {
return false; return false;
@ -1282,13 +1282,13 @@ bool view_is_visible(struct sway_view *view) {
enum sway_container_layout layout = container_parent_layout(con); enum sway_container_layout layout = container_parent_layout(con);
if ((layout == L_TABBED || layout == L_STACKED) if ((layout == L_TABBED || layout == L_STACKED)
&& !container_is_floating(con)) { && !container_is_floating(con)) {
struct sway_node *parent = con->parent ? struct sway_node *parent = con->pending.parent ?
&con->parent->node : &con->workspace->node; &con->pending.parent->node : &con->pending.workspace->node;
if (seat_get_active_tiling_child(seat, parent) != &con->node) { if (seat_get_active_tiling_child(seat, parent) != &con->node) {
return false; return false;
} }
} }
con = con->parent; con = con->pending.parent;
} }
// Check view isn't hidden by another fullscreen view // Check view isn't hidden by another fullscreen view
struct sway_container *fs = root->fullscreen_global ? 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"); ipc_event_window(view->container, "urgent");
if (!container_is_scratchpad_hidden(view->container)) { if (!container_is_scratchpad_hidden(view->container)) {
workspace_detect_urgent(view->container->workspace); workspace_detect_urgent(view->container->pending.workspace);
} }
} }

View file

@ -48,7 +48,7 @@ struct sway_output *workspace_get_initial_output(const char *name) {
if (focus && focus->type == N_WORKSPACE) { if (focus && focus->type == N_WORKSPACE) {
return focus->sway_workspace->output; return focus->sway_workspace->output;
} else if (focus && focus->type == N_CONTAINER) { } 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 // Fallback to the first output or noop output for headless
return root->outputs->length ? root->outputs->items[0] : root->noop_output; 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) { if (focus && focus->type == N_WORKSPACE) {
active_ws = focus->sway_workspace; active_ws = focus->sway_workspace;
} else if (focus && focus->type == N_CONTAINER) { } 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 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) { 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, static void workspace_attach_tiling(struct sway_workspace *ws,
struct sway_container *con) { struct sway_container *con) {
list_add(ws->tiling, con); list_add(ws->tiling, con);
con->workspace = ws; con->pending.workspace = ws;
container_for_each_child(con, set_workspace, NULL); container_for_each_child(con, set_workspace, NULL);
container_handle_fullscreen_reparent(con); container_handle_fullscreen_reparent(con);
workspace_update_representation(ws); 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 *workspace_wrap_children(struct sway_workspace *ws) {
struct sway_container *fs = ws->fullscreen; struct sway_container *fs = ws->fullscreen;
struct sway_container *middle = container_create(NULL); struct sway_container *middle = container_create(NULL);
middle->layout = ws->layout; middle->pending.layout = ws->layout;
while (ws->tiling->length) { while (ws->tiling->length) {
struct sway_container *child = ws->tiling->items[0]; struct sway_container *child = ws->tiling->items[0];
container_detach(child); container_detach(child);
@ -771,9 +771,9 @@ void workspace_unwrap_children(struct sway_workspace *ws,
return; return;
} }
ws->layout = wrap->layout; ws->layout = wrap->pending.layout;
while (wrap->children->length) { while (wrap->pending.children->length) {
struct sway_container *child = wrap->children->items[0]; struct sway_container *child = wrap->pending.children->items[0];
container_detach(child); container_detach(child);
workspace_add_tiling(ws, 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 *workspace_add_tiling(struct sway_workspace *workspace,
struct sway_container *con) { struct sway_container *con) {
if (con->workspace) { if (con->pending.workspace) {
container_detach(con); container_detach(con);
} }
if (config->default_layout != L_NONE) { if (config->default_layout != L_NONE) {
con = container_split(con, config->default_layout); con = container_split(con, config->default_layout);
} }
list_add(workspace->tiling, con); list_add(workspace->tiling, con);
con->workspace = workspace; con->pending.workspace = workspace;
container_for_each_child(con, set_workspace, NULL); container_for_each_child(con, set_workspace, NULL);
container_handle_fullscreen_reparent(con); container_handle_fullscreen_reparent(con);
workspace_update_representation(workspace); 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, void workspace_add_floating(struct sway_workspace *workspace,
struct sway_container *con) { struct sway_container *con) {
if (con->workspace) { if (con->pending.workspace) {
container_detach(con); container_detach(con);
} }
list_add(workspace->floating, con); list_add(workspace->floating, con);
con->workspace = workspace; con->pending.workspace = workspace;
container_for_each_child(con, set_workspace, NULL); container_for_each_child(con, set_workspace, NULL);
container_handle_fullscreen_reparent(con); container_handle_fullscreen_reparent(con);
node_set_dirty(&workspace->node); 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, void workspace_insert_tiling_direct(struct sway_workspace *workspace,
struct sway_container *con, int index) { struct sway_container *con, int index) {
list_insert(workspace->tiling, index, con); list_insert(workspace->tiling, index, con);
con->workspace = workspace; con->pending.workspace = workspace;
container_for_each_child(con, set_workspace, NULL); container_for_each_child(con, set_workspace, NULL);
container_handle_fullscreen_reparent(con); container_handle_fullscreen_reparent(con);
workspace_update_representation(workspace); 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 *workspace_insert_tiling(struct sway_workspace *workspace,
struct sway_container *con, int index) { struct sway_container *con, int index) {
if (con->workspace) { if (con->pending.workspace) {
container_detach(con); container_detach(con);
} }
if (config->default_layout != L_NONE) { 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; enum sway_container_layout old_layout = workspace->layout;
struct sway_container *middle = workspace_wrap_children(workspace); struct sway_container *middle = workspace_wrap_children(workspace);
workspace->layout = layout; workspace->layout = layout;
middle->layout = old_layout; middle->pending.layout = old_layout;
struct sway_seat *seat; struct sway_seat *seat;
wl_list_for_each(seat, &server.input->seats, link) { wl_list_for_each(seat, &server.input->seats, link) {