aboutsummaryrefslogtreecommitdiff
path: root/sway/commands
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands')
-rw-r--r--sway/commands/border.c8
-rw-r--r--sway/commands/floating.c8
-rw-r--r--sway/commands/focus.c26
-rw-r--r--sway/commands/fullscreen.c10
-rw-r--r--sway/commands/layout.c12
-rw-r--r--sway/commands/move.c148
-rw-r--r--sway/commands/resize.c112
-rw-r--r--sway/commands/scratchpad.c12
-rw-r--r--sway/commands/split.c2
-rw-r--r--sway/commands/sticky.c6
-rw-r--r--sway/commands/swap.c56
11 files changed, 200 insertions, 200 deletions
diff --git a/sway/commands/border.c b/sway/commands/border.c
index 647663ac..7818fc96 100644
--- a/sway/commands/border.c
+++ b/sway/commands/border.c
@@ -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)) {
diff --git a/sway/commands/floating.c b/sway/commands/floating.c
index ce123345..74f6522c 100644
--- a/sway/commands/floating.c
+++ b/sway/commands/floating.c
@@ -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);
diff --git a/sway/commands/focus.c b/sway/commands/focus.c
index 79b7aed5..6b4f57c1 100644
--- a/sway/commands/focus.c
+++ b/sway/commands/focus.c
@@ -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);
diff --git a/sway/commands/fullscreen.c b/sway/commands/fullscreen.c
index 3392a7f7..a5d30d0e 100644
--- a/sway/commands/fullscreen.c
+++ b/sway/commands/fullscreen.c
@@ -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;
diff --git a/sway/commands/layout.c b/sway/commands/layout.c
index f2af183b..2ba61b38 100644
--- a/sway/commands/layout.c
+++ b/sway/commands/layout.c
@@ -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) {
diff --git a/sway/commands/move.c b/sway/commands/move.c
index f8f89f18..f2702fa1 100644
--- a/sway/commands/move.c
+++ b/sway/commands/move.c
@@ -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);
diff --git a/sway/commands/resize.c b/sway/commands/resize.c
index ca36e858..425069de 100644
--- a/sway/commands/resize.c
+++ b/sway/commands/resize.c
@@ -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)) {
diff --git a/sway/commands/scratchpad.c b/sway/commands/scratchpad.c
index 34871bc6..a1285df5 100644
--- a/sway/commands/scratchpad.c
+++ b/sway/commands/scratchpad.c
@@ -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;
}
}
diff --git a/sway/commands/split.c b/sway/commands/split.c
index 782bab02..3e25c6f7 100644
--- a/sway/commands/split.c
+++ b/sway/commands/split.c
@@ -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");
}
diff --git a/sway/commands/sticky.c b/sway/commands/sticky.c
index 3c93a276..9b09a0f9 100644
--- a/sway/commands/sticky.c
+++ b/sway/commands/sticky.c
@@ -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);
diff --git a/sway/commands/swap.c b/sway/commands/swap.c
index a7f9691b..ce5e5128 100644
--- a/sway/commands/swap.c
+++ b/sway/commands/swap.c
@@ -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;