From a047b5ee4a2a67d30d93641ff86531d54b8e0879 Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Fri, 12 Feb 2021 23:22:51 +0100 Subject: 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. --- sway/commands/focus.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'sway/commands/focus.c') 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); -- cgit v1.2.3