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.
master
Kenny Levinsen 4 years ago committed by Tudor Brindus
parent 28cadf5580
commit a047b5ee4a

@ -46,9 +46,9 @@ struct sway_container_state {
enum sway_fullscreen_mode fullscreen_mode;
struct sway_workspace *workspace;
struct sway_container *parent;
list_t *children;
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
struct sway_container *focused_inactive_child;
bool focused;
@ -60,6 +60,7 @@ struct sway_container_state {
bool border_left;
bool border_right;
// These are in layout coordinates.
double content_x, content_y;
double content_width, content_height;
};
@ -68,14 +69,12 @@ struct sway_container {
struct sway_node node;
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 pending;
char *title; // The view's title (unformatted)
char *formatted_title; // The title displayed in the title bar
enum sway_container_layout layout;
enum sway_container_layout prev_split_layout;
// Whether stickiness has been enabled on this container. Use
@ -86,11 +85,13 @@ struct sway_container {
// For C_ROOT, this has no meaning
// For other types, this is the position in layout coordinates
// Includes borders
double x, y;
double width, height;
double saved_x, saved_y;
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
double width_fraction;
double height_fraction;
@ -100,33 +101,11 @@ struct sway_container {
double child_total_width;
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
// refuses to resize to the content dimensions then it can be smaller.
// These are in layout coordinates.
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
list_t *outputs; // struct sway_output

@ -186,7 +186,7 @@ static void set_config_node(struct sway_node *node) {
switch (node->type) {
case N_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;
case N_WORKSPACE:
config->handler_context.workspace = node->sway_workspace;

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

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

@ -141,9 +141,9 @@ static struct sway_node *node_get_in_direction_tiling(
struct sway_container *wrap_candidate = NULL;
struct sway_container *current = container;
while (current) {
if (current->fullscreen_mode == FULLSCREEN_WORKSPACE) {
if (current->pending.fullscreen_mode == FULLSCREEN_WORKSPACE) {
// 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 =
output_get_in_direction(output, dir);
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);
}
if (current->fullscreen_mode == FULLSCREEN_GLOBAL) {
if (current->pending.fullscreen_mode == FULLSCREEN_GLOBAL) {
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
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);
if ((config->focus_wrapping != WRAP_WORKSPACE ||
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(
struct sway_container *con, struct sway_seat *seat,
enum wlr_direction dir) {
double ref_lx = con->x + con->width / 2;
double ref_ly = con->y + con->height / 2;
double ref_lx = con->pending.x + con->pending.width / 2;
double ref_ly = con->pending.y + con->pending.height / 2;
double closest_distance = DBL_MAX;
struct sway_container *closest_con = NULL;
if (!con->workspace) {
if (!con->pending.workspace) {
return NULL;
}
for (int i = 0; i < con->workspace->floating->length; i++) {
struct sway_container *floater = con->workspace->floating->items[i];
for (int i = 0; i < con->pending.workspace->floating->length; i++) {
struct sway_container *floater = con->pending.workspace->floating->items[i];
if (floater == con) {
continue;
}
float distance = dir == WLR_DIRECTION_LEFT || dir == WLR_DIRECTION_RIGHT
? (floater->x + floater->width / 2) - ref_lx
: (floater->y + floater->height / 2) - ref_ly;
? (floater->pending.x + floater->pending.width / 2) - ref_lx
: (floater->pending.y + floater->pending.height / 2) - ref_ly;
if (dir == WLR_DIRECTION_LEFT || dir == WLR_DIRECTION_UP) {
distance = -distance;
}
@ -334,7 +334,7 @@ static struct cmd_results *focus_output(struct sway_seat *seat,
static struct cmd_results *focus_parent(void) {
struct sway_seat *seat = config->handler_context.seat;
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);
}
struct sway_node *parent = node_get_parent(&con->node);

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

@ -133,7 +133,7 @@ struct cmd_results *cmd_layout(int argc, char **argv) {
// Operate on parent container, like i3.
if (container) {
container = container->parent;
container = container->pending.parent;
}
// 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 old_layout = L_NONE;
if (container) {
old_layout = container->layout;
old_layout = container->pending.layout;
new_layout = get_layout(argc, argv,
container->layout, container->prev_split_layout,
container->workspace->output);
container->pending.layout, container->prev_split_layout,
container->pending.workspace->output);
} else {
old_layout = workspace->layout;
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) {
container->prev_split_layout = old_layout;
}
container->layout = new_layout;
container->pending.layout = new_layout;
container_update_representation(container);
} else if (config->handler_context.container) {
// i3 avoids changing workspace layouts with a new container
// https://github.com/i3/i3/blob/3cd1c45eba6de073bc4300eebb4e1cc1a0c4479a/src/con.c#L1817
container = workspace_wrap_children(workspace);
container->layout = new_layout;
container->pending.layout = new_layout;
container_update_representation(container);
} else {
if (old_layout != L_TABBED && old_layout != L_STACKED) {

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

@ -57,7 +57,7 @@ struct sway_container *container_find_resize_parent(struct sway_container *con,
(allow_last || index < siblings->length - 1)) {
return con;
}
con = con->parent;
con = con->pending.parent;
}
return NULL;
@ -115,13 +115,13 @@ void container_resize_tiled(struct sway_container *con,
int sibling_amount = prev ? ceil((double)amount / 2.0) : amount;
if (is_horizontal(axis)) {
if (con->width + amount < MIN_SANE_W) {
if (con->pending.width + amount < MIN_SANE_W) {
return;
}
if (next->width - sibling_amount < MIN_SANE_W) {
if (next->pending.width - sibling_amount < MIN_SANE_W) {
return;
}
if (prev && prev->width - sibling_amount < MIN_SANE_W) {
if (prev && prev->pending.width - sibling_amount < MIN_SANE_W) {
return;
}
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);
for (int i = 0; i < siblings->length; ++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;
@ -146,13 +146,13 @@ void container_resize_tiled(struct sway_container *con,
prev->width_fraction -= sibling_amount_fraction;
}
} else {
if (con->height + amount < MIN_SANE_H) {
if (con->pending.height + amount < MIN_SANE_H) {
return;
}
if (next->height - sibling_amount < MIN_SANE_H) {
if (next->pending.height - sibling_amount < MIN_SANE_H) {
return;
}
if (prev && prev->height - sibling_amount < MIN_SANE_H) {
if (prev && prev->pending.height - sibling_amount < MIN_SANE_H) {
return;
}
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);
for (int i = 0; i < siblings->length; ++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;
@ -178,10 +178,10 @@ void container_resize_tiled(struct sway_container *con,
}
}
if (con->parent) {
arrange_container(con->parent);
if (con->pending.parent) {
arrange_container(con->pending.parent);
} 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;
floating_calculate_constraints(&min_width, &max_width,
&min_height, &max_height);
if (con->width + grow_width < min_width) {
grow_width = min_width - con->width;
} else if (con->width + grow_width > max_width) {
grow_width = max_width - con->width;
if (con->pending.width + grow_width < min_width) {
grow_width = min_width - con->pending.width;
} else if (con->pending.width + grow_width > max_width) {
grow_width = max_width - con->pending.width;
}
if (con->height + grow_height < min_height) {
grow_height = min_height - con->height;
} else if (con->height + grow_height > max_height) {
grow_height = max_height - con->height;
if (con->pending.height + grow_height < min_height) {
grow_height = min_height - con->pending.height;
} else if (con->pending.height + grow_height > max_height) {
grow_height = max_height - con->pending.height;
}
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) {
return cmd_results_new(CMD_INVALID, "Cannot resize any further");
}
con->x += grow_x;
con->y += grow_y;
con->width += grow_width;
con->height += grow_height;
con->pending.x += grow_x;
con->pending.y += grow_y;
con->pending.width += grow_width;
con->pending.height += grow_height;
con->content_x += grow_x;
con->content_y += grow_y;
con->content_width += grow_width;
con->content_height += grow_height;
con->pending.content_x += grow_x;
con->pending.content_y += grow_y;
con->pending.content_width += grow_width;
con->pending.content_height += grow_height;
arrange_container(con);
@ -256,9 +256,9 @@ static struct cmd_results *resize_adjust_tiled(uint32_t axis,
float pct = amount->amount / 100.0f;
if (is_horizontal(axis)) {
amount->amount = (float)current->width * pct;
amount->amount = (float)current->pending.width * pct;
} 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 ||
width->unit == MOVEMENT_UNIT_DEFAULT) {
// Convert to px
struct sway_container *parent = con->parent;
while (parent && parent->layout != L_HORIZ) {
parent = parent->parent;
struct sway_container *parent = con->pending.parent;
while (parent && parent->pending.layout != L_HORIZ) {
parent = parent->pending.parent;
}
if (parent) {
width->amount = parent->width * width->amount / 100;
width->amount = parent->pending.width * width->amount / 100;
} else {
width->amount = con->workspace->width * width->amount / 100;
width->amount = con->pending.workspace->width * width->amount / 100;
}
width->unit = MOVEMENT_UNIT_PX;
}
if (width->unit == MOVEMENT_UNIT_PX) {
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 ||
height->unit == MOVEMENT_UNIT_DEFAULT) {
// Convert to px
struct sway_container *parent = con->parent;
while (parent && parent->layout != L_VERT) {
parent = parent->parent;
struct sway_container *parent = con->pending.parent;
while (parent && parent->pending.layout != L_VERT) {
parent = parent->pending.parent;
}
if (parent) {
height->amount = parent->height * height->amount / 100;
height->amount = parent->pending.height * height->amount / 100;
} else {
height->amount = con->workspace->height * height->amount / 100;
height->amount = con->pending.workspace->height * height->amount / 100;
}
height->unit = MOVEMENT_UNIT_PX;
}
if (height->unit == MOVEMENT_UNIT_PX) {
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");
}
// 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;
// Falls through
case MOVEMENT_UNIT_PX:
case MOVEMENT_UNIT_DEFAULT:
width->amount = fmax(min_width, fmin(width->amount, max_width));
grow_width = width->amount - con->width;
con->x -= grow_width / 2;
con->width = width->amount;
grow_width = width->amount - con->pending.width;
con->pending.x -= grow_width / 2;
con->pending.width = width->amount;
break;
case MOVEMENT_UNIT_INVALID:
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");
}
// 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;
// Falls through
case MOVEMENT_UNIT_PX:
case MOVEMENT_UNIT_DEFAULT:
height->amount = fmax(min_height, fmin(height->amount, max_height));
grow_height = height->amount - con->height;
con->y -= grow_height / 2;
con->height = height->amount;
grow_height = height->amount - con->pending.height;
con->pending.y -= grow_height / 2;
con->pending.height = height->amount;
break;
case MOVEMENT_UNIT_INVALID:
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->content_y -= grow_height / 2;
con->content_width += grow_width;
con->content_height += grow_height;
con->pending.content_x -= grow_width / 2;
con->pending.content_y -= grow_height / 2;
con->pending.content_width += grow_width;
con->pending.content_height += grow_height;
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
struct sway_container *con = config->handler_context.container;
if (width.amount <= 0) {
width.amount = con->width;
width.amount = con->pending.width;
}
if (height.amount <= 0) {
height.amount = con->height;
height.amount = con->pending.height;
}
if (container_is_floating(con)) {

@ -21,8 +21,8 @@ static void scratchpad_toggle_auto(void) {
// If the focus is in a floating split container,
// operate on the split container instead of the child.
if (focus && container_is_floating_or_child(focus)) {
while (focus->parent) {
focus = focus->parent;
while (focus->pending.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.
for (int i = 0; i < root->scratchpad->length; ++i) {
struct sway_container *con = root->scratchpad->items[i];
if (con->parent) {
if (con->pending.parent) {
sway_log(SWAY_DEBUG,
"Moving a visible scratchpad window (%s) to this workspace",
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_workspace *ws = seat_get_focused_workspace(seat);
// 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);
return;
}
@ -111,8 +111,8 @@ struct cmd_results *cmd_scratchpad(int argc, char **argv) {
// If the container is in a floating split container,
// operate on the split container instead of the child.
if (container_is_floating_or_child(con)) {
while (con->parent) {
con = con->parent;
while (con->pending.parent) {
con = con->pending.parent;
}
}

@ -14,7 +14,7 @@ static struct cmd_results *do_split(int layout) {
struct sway_workspace *ws = config->handler_context.workspace;
if (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,
"Cannot split a hidden scratchpad container");
}

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

@ -16,46 +16,46 @@ static const char expected_syntax[] =
static void swap_places(struct sway_container *con1,
struct sway_container *con2) {
struct sway_container *temp = malloc(sizeof(struct sway_container));
temp->x = con1->x;
temp->y = con1->y;
temp->width = con1->width;
temp->height = con1->height;
temp->pending.x = con1->pending.x;
temp->pending.y = con1->pending.y;
temp->pending.width = con1->pending.width;
temp->pending.height = con1->pending.height;
temp->width_fraction = con1->width_fraction;
temp->height_fraction = con1->height_fraction;
temp->parent = con1->parent;
temp->workspace = con1->workspace;
temp->pending.parent = con1->pending.parent;
temp->pending.workspace = con1->pending.workspace;
bool temp_floating = container_is_floating(con1);
con1->x = con2->x;
con1->y = con2->y;
con1->width = con2->width;
con1->height = con2->height;
con1->pending.x = con2->pending.x;
con1->pending.y = con2->pending.y;
con1->pending.width = con2->pending.width;
con1->pending.height = con2->pending.height;
con1->width_fraction = con2->width_fraction;
con1->height_fraction = con2->height_fraction;
con2->x = temp->x;
con2->y = temp->y;
con2->width = temp->width;
con2->height = temp->height;
con2->pending.x = temp->pending.x;
con2->pending.y = temp->pending.y;
con2->pending.width = temp->pending.width;
con2->pending.height = temp->pending.height;
con2->width_fraction = temp->width_fraction;
con2->height_fraction = temp->height_fraction;
int temp_index = container_sibling_index(con1);
if (con2->parent) {
container_insert_child(con2->parent, con1,
if (con2->pending.parent) {
container_insert_child(con2->pending.parent, con1,
container_sibling_index(con2));
} else if (container_is_floating(con2)) {
workspace_add_floating(con2->workspace, con1);
workspace_add_floating(con2->pending.workspace, con1);
} else {
workspace_insert_tiling(con2->workspace, con1,
workspace_insert_tiling(con2->pending.workspace, con1,
container_sibling_index(con2));
}
if (temp->parent) {
container_insert_child(temp->parent, con2, temp_index);
if (temp->pending.parent) {
container_insert_child(temp->pending.parent, con2, temp_index);
} else if (temp_floating) {
workspace_add_floating(temp->workspace, con2);
workspace_add_floating(temp->pending.workspace, con2);
} else {
workspace_insert_tiling(temp->workspace, con2, temp_index);
workspace_insert_tiling(temp->pending.workspace, con2, temp_index);
}
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 *focus) {
if (focus == con1 || focus == con2) {
struct sway_workspace *ws1 = con1->workspace;
struct sway_workspace *ws2 = con2->workspace;
struct sway_workspace *ws1 = con1->pending.workspace;
struct sway_workspace *ws2 = con2->pending.workspace;
enum sway_container_layout layout1 = container_parent_layout(con1);
enum sway_container_layout layout2 = container_parent_layout(con2);
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);
}
enum sway_fullscreen_mode fs1 = con1->fullscreen_mode;
enum sway_fullscreen_mode fs2 = con2->fullscreen_mode;
enum sway_fullscreen_mode fs1 = con1->pending.fullscreen_mode;
enum sway_fullscreen_mode fs2 = con2->pending.fullscreen_mode;
if (fs1) {
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_container *focus = seat_get_focused_container(seat);
struct sway_workspace *vis1 =
output_get_active_workspace(con1->workspace->output);
output_get_active_workspace(con1->pending.workspace->output);
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"
"workspace. This should not happen")) {
return;

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

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

@ -128,8 +128,8 @@ static void copy_workspace_state(struct sway_workspace *ws,
// Set focused_inactive_child to the direct tiling child
struct sway_container *focus = seat_get_focus_inactive_tiling(seat, ws);
if (focus) {
while (focus->parent) {
focus = focus->parent;
while (focus->pending.parent) {
focus = focus->pending.parent;
}
}
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_container_state *state = &instruction->container_state;
state->layout = container->layout;
state->x = container->x;
state->y = container->y;
state->width = container->width;
state->height = container->height;
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 (state->children) {
list_free(state->children);
}
memcpy(state, &container->pending, sizeof(struct sway_container_state));
if (!container->view) {
if (state->children) {
state->children->length = 0;
} else {
state->children = create_list();
}
list_cat(state->children, container->children);
// We store a copy of the child list to avoid having it mutated after
// we copy the state.
state->children = create_list();
list_cat(state->children, container->pending.children);
} else {
state->children = NULL;
}
struct sway_seat *seat = input_manager_current_seat();

@ -70,13 +70,13 @@ static void popup_unconstrain(struct sway_xdg_popup *popup) {
struct sway_view *view = popup->child.view;
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
// of the popup
struct wlr_box output_toplevel_sx_box = {
.x = output->lx - view->container->content_x,
.y = output->ly - view->container->content_y,
.x = output->lx - view->container->pending.content_x,
.y = output->ly - view->container->pending.content_y,
.width = output->width,
.height = output->height,
};

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

@ -824,8 +824,8 @@ static void check_constraint_region(struct sway_cursor *cursor) {
struct sway_container *con = view->container;
double sx = cursor->cursor->x - con->content_x + view->geometry.x;
double sy = cursor->cursor->y - con->content_y + view->geometry.y;
double sx = cursor->cursor->x - con->pending.content_x + view->geometry.x;
double sy = cursor->cursor->y - con->pending.content_y + view->geometry.y;
if (!pixman_region32_contains_point(region,
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.;
wlr_cursor_warp_closest(cursor->cursor, NULL,
sx + con->content_x - view->geometry.x,
sy + con->content_y - view->geometry.y);
sx + con->pending.content_x - view->geometry.x,
sy + con->pending.content_y - view->geometry.y);
cursor_rebase(cursor);
}
@ -1157,8 +1157,8 @@ void cursor_warp_to_container(struct sway_cursor *cursor,
return;
}
double x = container->x + container->width / 2.0;
double y = container->y + container->height / 2.0;
double x = container->pending.x + container->pending.width / 2.0;
double y = container->pending.y + container->pending.height / 2.0;
wlr_cursor_warp(cursor->cursor, NULL, x, y);
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_container *con = view->container;
double lx = sx + con->content_x - view->geometry.x;
double ly = sy + con->content_y - view->geometry.y;
double lx = sx + con->pending.content_x - view->geometry.x;
double ly = sy + con->pending.content_y - view->geometry.y;
wlr_cursor_warp(cursor->cursor, NULL, lx, ly);

@ -309,8 +309,8 @@ static void handle_seat_node_destroy(struct wl_listener *listener, void *data) {
// Setting focus_inactive
focus = seat_get_focus_inactive(seat, &root->node);
seat_set_raw_focus(seat, next_focus);
if (focus->type == N_CONTAINER && focus->sway_container->workspace) {
seat_set_raw_focus(seat, &focus->sway_container->workspace->node);
if (focus->type == N_CONTAINER && focus->sway_container->pending.workspace) {
seat_set_raw_focus(seat, &focus->sway_container->pending.workspace->node);
}
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 ?
node->sway_workspace : node->sway_container->workspace;
node->sway_workspace : node->sway_container->pending.workspace;
struct sway_container *container = node->type == N_CONTAINER ?
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
// the focused container.
if (container) {
struct sway_container *parent = container->parent;
struct sway_container *parent = container->pending.parent;
while (parent) {
seat_set_raw_focus(seat, &parent->node);
parent = parent->parent;
parent = parent->pending.parent;
}
}
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;
if (node->type == N_CONTAINER &&
!container_is_floating_or_child(node->sway_container) &&
node->sway_container->workspace == workspace) {
node->sway_container->pending.workspace == workspace) {
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;
if (node->type == N_CONTAINER &&
container_is_floating_or_child(node->sway_container) &&
node->sway_container->workspace == workspace) {
node->sway_container->pending.workspace == workspace) {
return node->sway_container;
}
}
@ -1392,7 +1392,7 @@ struct sway_workspace *seat_get_focused_workspace(struct sway_seat *seat) {
return NULL;
}
if (focus->type == N_CONTAINER) {
return focus->sway_container->workspace;
return focus->sway_container->pending.workspace;
}
if (focus->type == N_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) {
struct sway_node *node = current->node;
if (node->type == N_CONTAINER &&
node->sway_container->workspace) {
return node->sway_container->workspace;
node->sway_container->pending.workspace) {
return node->sway_container->pending.workspace;
} else if (node->type == N_WORKSPACE) {
return node->sway_workspace;
}

@ -60,7 +60,7 @@ static bool edge_is_external(struct sway_container *cont, enum wlr_edges edge) {
return false;
}
}
cont = cont->parent;
cont = cont->pending.parent;
}
return true;
}
@ -70,25 +70,25 @@ static enum wlr_edges find_edge(struct sway_container *cont,
if (!cont->view || (surface && cont->view->surface != surface)) {
return WLR_EDGE_NONE;
}
if (cont->border == B_NONE || !cont->border_thickness ||
cont->border == B_CSD) {
if (cont->pending.border == B_NONE || !cont->pending.border_thickness ||
cont->pending.border == B_CSD) {
return WLR_EDGE_NONE;
}
if (cont->fullscreen_mode) {
if (cont->pending.fullscreen_mode) {
return WLR_EDGE_NONE;
}
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;
}
if (cursor->cursor->y < cont->y + cont->border_thickness) {
if (cursor->cursor->y < cont->pending.y + cont->pending.border_thickness) {
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;
}
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;
}
@ -251,7 +251,7 @@ static void handle_tablet_tool_tip(struct sway_seat *seat,
// Handle moving a tiling container
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);
return;
}
@ -386,7 +386,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
struct sway_container *cont_to_focus = cont;
enum sway_container_layout layout = container_parent_layout(cont);
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);
@ -402,9 +402,9 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
BTN_LEFT : BTN_RIGHT;
if (button == btn_resize) {
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;
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;
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) {
struct sway_container *floater = container_toplevel_ancestor(cont);
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;
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;
seatop_begin_resize_floating(seat, floater, edge);
return;
@ -463,7 +463,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
// Handle moving a tiling container
if (config->tiling_drag && (mod_pressed || on_titlebar) &&
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);
bool focused = focus == cont || container_has_ancestor(focus, cont);
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_titlebar = cont && !on_border && !surface;
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_workspace = node && node->type == N_WORKSPACE;
float scroll_factor =

@ -15,7 +15,7 @@ static void finalize_move(struct sway_seat *seat) {
// We "move" the container to its own location
// 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();
seatop_begin_default(seat);
@ -70,8 +70,8 @@ void seatop_begin_move_floating(struct sway_seat *seat,
return;
}
e->con = con;
e->dx = cursor->cursor->x - con->x;
e->dy = cursor->cursor->y - con->y;
e->dx = cursor->cursor->x - con->pending.x;
e->dy = cursor->cursor->y - con->pending.y;
seat->seatop_impl = &seatop_impl;
seat->seatop_data = e;

@ -120,8 +120,8 @@ static void handle_motion_postthreshold(struct sway_seat *seat) {
// Deny moving within own workspace if this is the only child
struct sway_container *con = node->sway_container;
if (workspace_num_tiling_views(e->con->workspace) == 1 &&
con->workspace == e->con->workspace) {
if (workspace_num_tiling_views(e->con->pending.workspace) == 1 &&
con->pending.workspace == e->con->pending.workspace) {
e->target_node = NULL;
e->target_edge = WLR_EDGE_NONE;
return;
@ -133,8 +133,8 @@ static void handle_motion_postthreshold(struct sway_seat *seat) {
enum wlr_edges edge = WLR_EDGE_NONE;
enum sway_container_layout layout = container_parent_layout(con);
struct wlr_box parent;
con->parent ? container_get_box(con->parent, &parent) :
workspace_get_box(con->workspace, &parent);
con->pending.parent ? container_get_box(con->pending.parent, &parent) :
workspace_get_box(con->pending.workspace, &parent);
if (layout == L_HORIZ || layout == L_TABBED) {
if (cursor->cursor->y < parent.y + DROP_LAYOUT_BORDER) {
edge = WLR_EDGE_TOP;
@ -161,7 +161,7 @@ static void handle_motion_postthreshold(struct sway_seat *seat) {
desktop_damage_box(&e->drop_box);
return;
}
con = con->parent;
con = con->pending.parent;
}
// 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
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 dist;
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;
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;
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;
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;
e->target_edge = WLR_EDGE_BOTTOM;
}
@ -200,10 +200,10 @@ static void handle_motion_postthreshold(struct sway_seat *seat) {
}
e->target_node = node;
e->drop_box.x = con->content_x;
e->drop_box.y = con->content_y;
e->drop_box.width = con->content_width;
e->drop_box.height = con->content_height;
e->drop_box.x = con->pending.content_x;
e->drop_box.y = con->pending.content_y;
e->drop_box.width = con->pending.content_width;
e->drop_box.height = con->pending.content_height;
resize_box(&e->drop_box, e->target_edge, thickness);
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 *old_parent = con->parent;
struct sway_workspace *old_ws = con->workspace;
struct sway_container *old_parent = con->pending.parent;
struct sway_workspace *old_ws = con->pending.workspace;
struct sway_node *target_node = e->target_node;
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;
int after = edge != WLR_EDGE_TOP && edge != WLR_EDGE_LEFT;
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);
struct sway_container *sibling = index == 0 ?
siblings->items[1] : siblings->items[index - 1];
con->width = sibling->width;
con->height = sibling->height;
con->pending.width = sibling->pending.width;
con->pending.height = sibling->pending.height;
con->width_fraction = sibling->width_fraction;
con->height_fraction = sibling->height_fraction;
}

@ -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
// size.
int relative_grow_width = width - con->width;
int relative_grow_height = height - con->height;
int relative_grow_x = (e->ref_con_lx + grow_x) - con->x;
int relative_grow_y = (e->ref_con_ly + grow_y) - con->y;
int relative_grow_width = width - con->pending.width;
int relative_grow_height = height - con->pending.height;
int relative_grow_x = (e->ref_con_lx + grow_x) - con->pending.x;
int relative_grow_y = (e->ref_con_ly + grow_y) - con->pending.y;
// Actually resize stuff
con->x += relative_grow_x;
con->y += relative_grow_y;
con->width += relative_grow_width;
con->height += relative_grow_height;
con->pending.x += relative_grow_x;
con->pending.y += relative_grow_y;
con->pending.width += relative_grow_width;
con->pending.height += relative_grow_height;
con->content_x += relative_grow_x;
con->content_y += relative_grow_y;
con->content_width += relative_grow_width;
con->content_height += relative_grow_height;
con->pending.content_x += relative_grow_x;
con->pending.content_y += relative_grow_y;
con->pending.content_width += relative_grow_width;
con->pending.content_height += relative_grow_height;
arrange_container(con);
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->ref_lx = seat->cursor->cursor->x;
e->ref_ly = seat->cursor->cursor->y;
e->ref_con_lx = con->x;
e->ref_con_ly = con->y;
e->ref_width = con->width;
e->ref_height = con->height;
e->ref_con_lx = con->pending.x;
e->ref_con_ly = con->pending.y;
e->ref_width = con->pending.width;
e->ref_height = con->pending.height;
seat->seatop_impl = &seatop_impl;
seat->seatop_data = e;

@ -53,19 +53,19 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
if (e->h_con) {
container_set_resizing(e->h_con, false);
container_set_resizing(e->h_sib, false);
if (e->h_con->parent) {
arrange_container(e->h_con->parent);
if (e->h_con->pending.parent) {
arrange_container(e->h_con->pending.parent);
} else {
arrange_workspace(e->h_con->workspace);
arrange_workspace(e->h_con->pending.workspace);
}
}
if (e->v_con) {
container_set_resizing(e->v_con, false);
container_set_resizing(e->v_sib, false);
if (e->v_con->parent) {
arrange_container(e->v_con->parent);
if (e->v_con->pending.parent) {
arrange_container(e->v_con->pending.parent);
} else {
arrange_workspace(e->v_con->workspace);
arrange_workspace(e->v_con->pending.workspace);
}
}
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->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) {
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->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) {
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) {
container_set_resizing(e->h_con, 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)) {
@ -154,7 +154,7 @@ void seatop_begin_resize_tiling(struct sway_seat *seat,
if (e->v_con) {
container_set_resizing(e->v_con, 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;
}
}

@ -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;
if (((!tab_or_stack || container_is_floating(c)) &&
c->current.border != B_NORMAL) ||
c->fullscreen_mode != FULLSCREEN_NONE ||
c->workspace == NULL) {
c->pending.fullscreen_mode != FULLSCREEN_NONE ||
c->pending.workspace == NULL) {
deco_rect->x = deco_rect->y = deco_rect->width = deco_rect->height = 0;
return;
}
if (c->parent) {
deco_rect->x = c->x - c->parent->x;
deco_rect->y = c->y - c->parent->y;
if (c->pending.parent) {
deco_rect->x = c->pending.x - c->pending.parent->pending.x;
deco_rect->y = c->pending.y - c->pending.parent->pending.y;
} else {
deco_rect->x = c->x - c->workspace->x;
deco_rect->y = c->y - c->workspace->y;
deco_rect->x = c->pending.x - c->pending.workspace->x;
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();
if (!container_is_floating(c)) {
if (parent_layout == L_TABBED) {
deco_rect->width = c->parent
? c->parent->width / c->parent->children->length
: c->workspace->width / c->workspace->tiling->length;
deco_rect->width = c->pending.parent
? c->pending.parent->pending.width / c->pending.parent->pending.children->length
: c->pending.workspace->width / c->pending.workspace->tiling->length;
deco_rect->x += deco_rect->width * container_sibling_index(c);
} else if (parent_layout == L_STACKED) {
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));
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->content_width,
c->content_height
c->pending.content_width,
c->pending.content_height
};
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_new_string(
ipc_json_layout_description(c->layout)));
ipc_json_layout_description(c->pending.layout)));
json_object_object_add(object, "orientation",
json_object_new_string(
ipc_json_orientation_description(c->layout)));
ipc_json_orientation_description(c->pending.layout)));
bool urgent = c->view ?
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, "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 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) {
double percent = ((double)c->width / parent_box.width)
* ((double)c->height / parent_box.height);
double percent = ((double)c->pending.width / parent_box.width)
* ((double)c->pending.height / parent_box.height);
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;
case N_CONTAINER:
if (node->sway_container->children) {
for (i = 0; i < node->sway_container->children->length; ++i) {
if (node->sway_container->pending.children) {
for (i = 0; i < node->sway_container->pending.children->length; ++i) {
struct sway_container *child =
node->sway_container->children->items[i];
node->sway_container->pending.children->items[i];
json_object_array_add(children,
ipc_json_describe_node_recursive(&child->node));
}

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

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

@ -75,7 +75,7 @@ void node_get_box(struct sway_node *node, struct wlr_box *box) {
struct sway_output *node_get_output(struct sway_node *node) {
switch (node->type) {
case N_CONTAINER: {
struct sway_workspace *ws = node->sway_container->workspace;
struct sway_workspace *ws = node->sway_container->pending.workspace;
return ws ? ws->output : NULL;
}
case N_WORKSPACE:
@ -91,7 +91,7 @@ struct sway_output *node_get_output(struct sway_node *node) {
enum sway_container_layout node_get_layout(struct sway_node *node) {
switch (node->type) {
case N_CONTAINER:
return node->sway_container->layout;
return node->sway_container->pending.layout;
case N_WORKSPACE:
return node->sway_workspace->layout;
case N_OUTPUT:
@ -105,11 +105,11 @@ struct sway_node *node_get_parent(struct sway_node *node) {
switch (node->type) {
case N_CONTAINER: {
struct sway_container *con = node->sway_container;
if (con->parent) {
return &con->parent->node;
if (con->pending.parent) {
return &con->pending.parent->node;
}
if (con->workspace) {
return &con->workspace->node;
if (con->pending.workspace) {
return &con->pending.workspace->node;
}
}
return NULL;
@ -131,7 +131,7 @@ struct sway_node *node_get_parent(struct sway_node *node) {
list_t *node_get_children(struct sway_node *node) {
switch (node->type) {
case N_CONTAINER:
return node->sway_container->children;
return node->sway_container->pending.children;
case N_WORKSPACE:
return node->sway_workspace->tiling;
case N_OUTPUT:
@ -143,7 +143,7 @@ list_t *node_get_children(struct sway_node *node) {
bool node_has_ancestor(struct sway_node *node, struct sway_node *ancestor) {
if (ancestor->type == N_ROOT && node->type == N_CONTAINER &&
node->sway_container->fullscreen_mode == FULLSCREEN_GLOBAL) {
node->sway_container->pending.fullscreen_mode == FULLSCREEN_GLOBAL) {
return true;
}
struct sway_node *parent = node_get_parent(node);
@ -152,7 +152,7 @@ bool node_has_ancestor(struct sway_node *node, struct sway_node *ancestor) {
return true;
}
if (ancestor->type == N_ROOT && parent->type == N_CONTAINER &&
parent->sway_container->fullscreen_mode == FULLSCREEN_GLOBAL) {
parent->sway_container->pending.fullscreen_mode == FULLSCREEN_GLOBAL) {
return true;
}
parent = node_get_parent(parent);

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

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

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

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

Loading…
Cancel
Save