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

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