aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop
diff options
context:
space:
mode:
authorLibravatar Kenny Levinsen <kl@kl.wtf>2021-02-12 23:22:51 +0100
committerLibravatar Tudor Brindus <me@tbrindus.ca>2021-02-16 22:05:00 -0500
commita047b5ee4a2a67d30d93641ff86531d54b8e0879 (patch)
tree271666c6254e4fabf943c1153224059411a5ce56 /sway/desktop
parentAdd missing transaction commits to seatop_default (diff)
downloadsway-a047b5ee4a2a67d30d93641ff86531d54b8e0879.tar.gz
sway-a047b5ee4a2a67d30d93641ff86531d54b8e0879.tar.zst
sway-a047b5ee4a2a67d30d93641ff86531d54b8e0879.zip
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.
Diffstat (limited to 'sway/desktop')
-rw-r--r--sway/desktop/render.c2
-rw-r--r--sway/desktop/transaction.c39
-rw-r--r--sway/desktop/xdg_shell.c6
-rw-r--r--sway/desktop/xwayland.c8
4 files changed, 21 insertions, 34 deletions
diff --git a/sway/desktop/render.c b/sway/desktop/render.c
index fee19a33..3343fb31 100644
--- a/sway/desktop/render.c
+++ b/sway/desktop/render.c
@@ -957,7 +957,7 @@ static void render_floating(struct sway_output *soutput,
957 } 957 }
958 for (int k = 0; k < ws->current.floating->length; ++k) { 958 for (int k = 0; k < ws->current.floating->length; ++k) {
959 struct sway_container *floater = ws->current.floating->items[k]; 959 struct sway_container *floater = ws->current.floating->items[k];
960 if (floater->fullscreen_mode != FULLSCREEN_NONE) { 960 if (floater->pending.fullscreen_mode != FULLSCREEN_NONE) {
961 continue; 961 continue;
962 } 962 }
963 render_floating_container(soutput, damage, floater); 963 render_floating_container(soutput, damage, floater);
diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c
index 9f488963..6c392bab 100644
--- a/sway/desktop/transaction.c
+++ b/sway/desktop/transaction.c
@@ -128,8 +128,8 @@ static void copy_workspace_state(struct sway_workspace *ws,
128 // Set focused_inactive_child to the direct tiling child 128 // Set focused_inactive_child to the direct tiling child
129 struct sway_container *focus = seat_get_focus_inactive_tiling(seat, ws); 129 struct sway_container *focus = seat_get_focus_inactive_tiling(seat, ws);
130 if (focus) { 130 if (focus) {
131 while (focus->parent) { 131 while (focus->pending.parent) {
132 focus = focus->parent; 132 focus = focus->pending.parent;
133 } 133 }
134 } 134 }
135 state->focused_inactive_child = focus; 135 state->focused_inactive_child = focus;
@@ -139,32 +139,19 @@ static void copy_container_state(struct sway_container *container,
139 struct sway_transaction_instruction *instruction) { 139 struct sway_transaction_instruction *instruction) {
140 struct sway_container_state *state = &instruction->container_state; 140 struct sway_container_state *state = &instruction->container_state;
141 141
142 state->layout = container->layout; 142 if (state->children) {
143 state->x = container->x; 143 list_free(state->children);
144 state->y = container->y; 144 }
145 state->width = container->width; 145
146 state->height = container->height; 146 memcpy(state, &container->pending, sizeof(struct sway_container_state));
147 state->fullscreen_mode = container->fullscreen_mode;
148 state->parent = container->parent;
149 state->workspace = container->workspace;
150 state->border = container->border;
151 state->border_thickness = container->border_thickness;
152 state->border_top = container->border_top;
153 state->border_left = container->border_left;
154 state->border_right = container->border_right;
155 state->border_bottom = container->border_bottom;
156 state->content_x = container->content_x;
157 state->content_y = container->content_y;
158 state->content_width = container->content_width;
159 state->content_height = container->content_height;
160 147
161 if (!container->view) { 148 if (!container->view) {
162 if (state->children) { 149 // We store a copy of the child list to avoid having it mutated after
163 state->children->length = 0; 150 // we copy the state.
164 } else { 151 state->children = create_list();
165 state->children = create_list(); 152 list_cat(state->children, container->pending.children);
166 } 153 } else {
167 list_cat(state->children, container->children); 154 state->children = NULL;
168 } 155 }
169 156
170 struct sway_seat *seat = input_manager_current_seat(); 157 struct sway_seat *seat = input_manager_current_seat();
diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c
index 14880dcd..4c13f91f 100644
--- a/sway/desktop/xdg_shell.c
+++ b/sway/desktop/xdg_shell.c
@@ -70,13 +70,13 @@ static void popup_unconstrain(struct sway_xdg_popup *popup) {
70 struct sway_view *view = popup->child.view; 70 struct sway_view *view = popup->child.view;
71 struct wlr_xdg_popup *wlr_popup = popup->wlr_xdg_surface->popup; 71 struct wlr_xdg_popup *wlr_popup = popup->wlr_xdg_surface->popup;
72 72
73 struct sway_output *output = view->container->workspace->output; 73 struct sway_output *output = view->container->pending.workspace->output;
74 74
75 // the output box expressed in the coordinate system of the toplevel parent 75 // the output box expressed in the coordinate system of the toplevel parent
76 // of the popup 76 // of the popup
77 struct wlr_box output_toplevel_sx_box = { 77 struct wlr_box output_toplevel_sx_box = {
78 .x = output->lx - view->container->content_x, 78 .x = output->lx - view->container->pending.content_x,
79 .y = output->ly - view->container->content_y, 79 .y = output->ly - view->container->pending.content_y,
80 .width = output->width, 80 .width = output->width,
81 .height = output->height, 81 .height = output->height,
82 }; 82 };
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c
index 4cd5f9d0..3ed65083 100644
--- a/sway/desktop/xwayland.c
+++ b/sway/desktop/xwayland.c
@@ -527,10 +527,10 @@ static void handle_request_configure(struct wl_listener *listener, void *data) {
527 view->natural_height = ev->height; 527 view->natural_height = ev->height;
528 container_floating_resize_and_center(view->container); 528 container_floating_resize_and_center(view->container);
529 529
530 configure(view, view->container->content_x, 530 configure(view, view->container->pending.content_x,
531 view->container->content_y, 531 view->container->pending.content_y,
532 view->container->content_width, 532 view->container->pending.content_width,
533 view->container->content_height); 533 view->container->pending.content_height);
534 node_set_dirty(&view->container->node); 534 node_set_dirty(&view->container->node);
535 } else { 535 } else {
536 configure(view, view->container->current.content_x, 536 configure(view, view->container->current.content_x,