container: Move pending state to state struct

Pending state is currently inlined directly in the container struct,
while the current state is in a state struct. A side-effect of this is
that it is not immediately obvious that pending double-buffered state is
accessed, nor is it obvious what state is double-buffered.

Instead, use the state struct for both current and pending.
This commit is contained in:
Kenny Levinsen 2021-02-12 23:22:51 +01:00 committed by Tudor Brindus
parent 28cadf5580
commit a047b5ee4a
33 changed files with 723 additions and 757 deletions

View file

@ -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);

View file

@ -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();

View file

@ -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,
};

View file

@ -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,