aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-06-06 19:19:30 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-06-09 10:08:43 +1000
commitf9e6d703d298dbdee0770fd9e0c64ab2d7ac7deb (patch)
tree8c8ffd879e368aff3d749a637aabfa784800db5c
parentWIP: Atomic layout updates ground work (diff)
downloadsway-f9e6d703d298dbdee0770fd9e0c64ab2d7ac7deb.tar.gz
sway-f9e6d703d298dbdee0770fd9e0c64ab2d7ac7deb.tar.zst
sway-f9e6d703d298dbdee0770fd9e0c64ab2d7ac7deb.zip
Make main properties be the pending state
-rw-r--r--include/sway/tree/container.h4
-rw-r--r--sway/desktop/desktop.c3
-rw-r--r--sway/desktop/output.c28
-rw-r--r--sway/desktop/transaction.c49
-rw-r--r--sway/desktop/xwayland.c9
-rw-r--r--sway/tree/arrange.c107
-rw-r--r--sway/tree/layout.c4
-rw-r--r--sway/tree/view.c90
-rw-r--r--sway/tree/workspace.c6
9 files changed, 143 insertions, 157 deletions
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h
index dd5bd47c..a8efd893 100644
--- a/include/sway/tree/container.h
+++ b/include/sway/tree/container.h
@@ -91,7 +91,9 @@ struct sway_container {
91 */ 91 */
92 size_t id; 92 size_t id;
93 93
94 struct sway_container_state pending; 94 // The pending state is the main container properties, and the current state is in the below struct.
95 // This means most places of the code can refer to the main variables (pending state) and it'll just work.
96 struct sway_container_state current;
95 97
96 char *name; // The view's title (unformatted) 98 char *name; // The view's title (unformatted)
97 char *formatted_title; // The title displayed in the title bar 99 char *formatted_title; // The title displayed in the title bar
diff --git a/sway/desktop/desktop.c b/sway/desktop/desktop.c
index 66f33151..e495790c 100644
--- a/sway/desktop/desktop.c
+++ b/sway/desktop/desktop.c
@@ -7,7 +7,8 @@ void desktop_damage_surface(struct wlr_surface *surface, double lx, double ly,
7 for (int i = 0; i < root_container.children->length; ++i) { 7 for (int i = 0; i < root_container.children->length; ++i) {
8 struct sway_container *cont = root_container.children->items[i]; 8 struct sway_container *cont = root_container.children->items[i];
9 if (cont->type == C_OUTPUT) { 9 if (cont->type == C_OUTPUT) {
10 output_damage_surface(cont->sway_output, lx - cont->x, ly - cont->y, 10 output_damage_surface(cont->sway_output,
11 lx - cont->current.swayc_x, ly - cont->current.swayc_y,
11 surface, whole); 12 surface, whole);
12 } 13 }
13 } 14 }
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index c5d445a6..8af05bc3 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -774,9 +774,10 @@ static void render_container_stacked(struct sway_output *output,
774 marks_texture = view ? view->marks_unfocused : NULL; 774 marks_texture = view ? view->marks_unfocused : NULL;
775 } 775 }
776 776
777 int y = con->y + container_titlebar_height() * i; 777 int y = con->current.swayc_y + container_titlebar_height() * i;
778 render_titlebar(output, damage, child, child->x, y, child->width, 778 render_titlebar(output, damage, child, child->current.swayc_x, y,
779 colors, title_texture, marks_texture); 779 child->current.swayc_width, colors,
780 title_texture, marks_texture);
780 781
781 if (child == current) { 782 if (child == current) {
782 current_colors = colors; 783 current_colors = colors;
@@ -795,7 +796,7 @@ static void render_container_stacked(struct sway_output *output,
795static void render_container(struct sway_output *output, 796static void render_container(struct sway_output *output,
796 pixman_region32_t *damage, struct sway_container *con, 797 pixman_region32_t *damage, struct sway_container *con,
797 bool parent_focused) { 798 bool parent_focused) {
798 switch (con->layout) { 799 switch (con->current.layout) {
799 case L_NONE: 800 case L_NONE:
800 case L_HORIZ: 801 case L_HORIZ:
801 case L_VERT: 802 case L_VERT:
@@ -832,9 +833,10 @@ static void render_floating_container(struct sway_output *soutput,
832 marks_texture = view->marks_unfocused; 833 marks_texture = view->marks_unfocused;
833 } 834 }
834 835
835 if (con->sway_view->border == B_NORMAL) { 836 if (con->current.border == B_NORMAL) {
836 render_titlebar(soutput, damage, con, con->x, con->y, con->width, 837 render_titlebar(soutput, damage, con, con->current.swayc_x,
837 colors, title_texture, marks_texture); 838 con->current.swayc_y, con->current.swayc_width, colors,
839 title_texture, marks_texture);
838 } else { 840 } else {
839 render_top_border(soutput, damage, con, colors); 841 render_top_border(soutput, damage, con, colors);
840 } 842 }
@@ -1184,8 +1186,8 @@ void output_damage_from_view(struct sway_output *output,
1184void output_damage_box(struct sway_output *output, struct wlr_box *_box) { 1186void output_damage_box(struct sway_output *output, struct wlr_box *_box) {
1185 struct wlr_box box; 1187 struct wlr_box box;
1186 memcpy(&box, _box, sizeof(struct wlr_box)); 1188 memcpy(&box, _box, sizeof(struct wlr_box));
1187 box.x -= output->swayc->x; 1189 box.x -= output->swayc->current.swayc_x;
1188 box.y -= output->swayc->y; 1190 box.y -= output->swayc->current.swayc_y;
1189 scale_box(&box, output->wlr_output->scale); 1191 scale_box(&box, output->wlr_output->scale);
1190 wlr_output_damage_add_box(output->damage, &box); 1192 wlr_output_damage_add_box(output->damage, &box);
1191} 1193}
@@ -1204,10 +1206,10 @@ static void output_damage_whole_container_iterator(struct sway_container *con,
1204void output_damage_whole_container(struct sway_output *output, 1206void output_damage_whole_container(struct sway_output *output,
1205 struct sway_container *con) { 1207 struct sway_container *con) {
1206 struct wlr_box box = { 1208 struct wlr_box box = {
1207 .x = con->x - output->wlr_output->lx, 1209 .x = con->current.swayc_x - output->wlr_output->lx,
1208 .y = con->y - output->wlr_output->ly, 1210 .y = con->current.swayc_y - output->wlr_output->ly,
1209 .width = con->width, 1211 .width = con->current.swayc_width,
1210 .height = con->height, 1212 .height = con->current.swayc_height,
1211 }; 1213 };
1212 scale_box(&box, output->wlr_output->scale); 1214 scale_box(&box, output->wlr_output->scale);
1213 wlr_output_damage_add_box(output->damage, &box); 1215 wlr_output_damage_add_box(output->damage, &box);
diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c
index 69f97e3d..313e707b 100644
--- a/sway/desktop/transaction.c
+++ b/sway/desktop/transaction.c
@@ -67,8 +67,30 @@ void transaction_add_container(struct sway_transaction *transaction,
67 calloc(1, sizeof(struct sway_transaction_instruction)); 67 calloc(1, sizeof(struct sway_transaction_instruction));
68 instruction->transaction = transaction; 68 instruction->transaction = transaction;
69 instruction->container = container; 69 instruction->container = container;
70 memcpy(&instruction->state, &container->pending, 70
71 sizeof(struct sway_container_state)); 71 // Copy the container's main (pending) properties into the instruction state
72 struct sway_container_state *state = &instruction->state;
73 state->layout = container->layout;
74 state->swayc_x = container->x;
75 state->swayc_y = container->y;
76 state->swayc_width = container->width;
77 state->swayc_height = container->height;
78
79 if (container->type == C_VIEW) {
80 struct sway_view *view = container->sway_view;
81 state->view_x = view->x;
82 state->view_y = view->y;
83 state->view_width = view->width;
84 state->view_height = view->height;
85 state->is_fullscreen = view->is_fullscreen;
86 state->border = view->border;
87 state->border_thickness = view->border_thickness;
88 state->border_top = view->border_top;
89 state->border_left = view->border_left;
90 state->border_right = view->border_right;
91 state->border_bottom = view->border_bottom;
92 }
93
72 list_add(transaction->instructions, instruction); 94 list_add(transaction->instructions, instruction);
73} 95}
74 96
@@ -102,30 +124,13 @@ static void transaction_apply(struct sway_transaction *transaction) {
102 for (i = 0; i < transaction->instructions->length; ++i) { 124 for (i = 0; i < transaction->instructions->length; ++i) {
103 struct sway_transaction_instruction *instruction = 125 struct sway_transaction_instruction *instruction =
104 transaction->instructions->items[i]; 126 transaction->instructions->items[i];
105 struct sway_container_state *state = &instruction->state;
106 struct sway_container *container = instruction->container; 127 struct sway_container *container = instruction->container;
107 128
108 container->layout = state->layout; 129 memcpy(&instruction->container->current, &instruction->state,
109 container->x = state->swayc_x; 130 sizeof(struct sway_container_state));
110 container->y = state->swayc_y;
111 container->width = state->swayc_width;
112 container->height = state->swayc_height;
113 131
114 if (container->type == C_VIEW) { 132 if (container->type == C_VIEW) {
115 struct sway_view *view = container->sway_view; 133 remove_saved_view_texture(container->sway_view);
116 view->x = state->view_x;
117 view->y = state->view_y;
118 view->width = state->view_width;
119 view->height = state->view_height;
120 view->is_fullscreen = state->is_fullscreen;
121 view->border = state->border;
122 view->border_thickness = state->border_thickness;
123 view->border_top = state->border_top;
124 view->border_left = state->border_left;
125 view->border_right = state->border_right;
126 view->border_bottom = state->border_bottom;
127
128 remove_saved_view_texture(view);
129 } 134 }
130 } 135 }
131 136
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c
index 6a3c1b66..d8442530 100644
--- a/sway/desktop/xwayland.c
+++ b/sway/desktop/xwayland.c
@@ -257,11 +257,9 @@ static void handle_commit(struct wl_listener *listener, void *data) {
257 if (view->swayc && container_is_floating(view->swayc)) { 257 if (view->swayc && container_is_floating(view->swayc)) {
258 view_update_size(view, xsurface->width, xsurface->height); 258 view_update_size(view, xsurface->width, xsurface->height);
259 } else { 259 } else {
260 view_update_size(view, view->swayc->pending.swayc_width, 260 view_update_size(view, view->swayc->width, view->swayc->height);
261 view->swayc->pending.swayc_height);
262 } 261 }
263 view_update_position(view, 262 view_update_position(view, view->x, view->y);
264 view->swayc->pending.view_x, view->swayc->pending.view_y);
265 view_damage_from(view); 263 view_damage_from(view);
266 } 264 }
267} 265}
@@ -314,7 +312,8 @@ static void handle_request_configure(struct wl_listener *listener, void *data) {
314 return; 312 return;
315 } 313 }
316 // TODO: Let floating views do whatever 314 // TODO: Let floating views do whatever
317 configure(view, view->swayc->x, view->swayc->y, view->width, view->height); 315 configure(view, view->swayc->current.view_x, view->swayc->current.view_y,
316 view->swayc->current.view_width, view->swayc->current.view_height);
318} 317}
319 318
320static void handle_request_fullscreen(struct wl_listener *listener, void *data) { 319static void handle_request_fullscreen(struct wl_listener *listener, void *data) {
diff --git a/sway/tree/arrange.c b/sway/tree/arrange.c
index d8b3aec1..cf7ce61c 100644
--- a/sway/tree/arrange.c
+++ b/sway/tree/arrange.c
@@ -22,48 +22,46 @@ static void apply_horiz_layout(struct sway_container *parent) {
22 return; 22 return;
23 } 23 }
24 size_t parent_offset = 0; 24 size_t parent_offset = 0;
25 if (parent->parent->pending.layout == L_TABBED) { 25 if (parent->parent->layout == L_TABBED) {
26 parent_offset = container_titlebar_height(); 26 parent_offset = container_titlebar_height();
27 } else if (parent->parent->pending.layout == L_STACKED) { 27 } else if (parent->parent->layout == L_STACKED) {
28 parent_offset = container_titlebar_height() * 28 parent_offset = container_titlebar_height() *
29 parent->parent->children->length; 29 parent->parent->children->length;
30 } 30 }
31 size_t parent_height = parent->pending.swayc_height - parent_offset; 31 size_t parent_height = parent->height - parent_offset;
32 32
33 // Calculate total width of children 33 // Calculate total width of children
34 double total_width = 0; 34 double total_width = 0;
35 for (size_t i = 0; i < num_children; ++i) { 35 for (size_t i = 0; i < num_children; ++i) {
36 struct sway_container *child = parent->children->items[i]; 36 struct sway_container *child = parent->children->items[i];
37 if (child->pending.swayc_width <= 0) { 37 if (child->width <= 0) {
38 if (num_children > 1) { 38 if (num_children > 1) {
39 child->pending.swayc_width = 39 child->width = parent->width / (num_children - 1);
40 parent->pending.swayc_width / (num_children - 1);
41 } else { 40 } else {
42 child->pending.swayc_width = parent->pending.swayc_width; 41 child->width = parent->width;
43 } 42 }
44 } 43 }
45 total_width += child->pending.swayc_width; 44 total_width += child->width;
46 } 45 }
47 double scale = parent->pending.swayc_width / total_width; 46 double scale = parent->width / total_width;
48 47
49 // Resize windows 48 // Resize windows
50 wlr_log(L_DEBUG, "Arranging %p horizontally", parent); 49 wlr_log(L_DEBUG, "Arranging %p horizontally", parent);
51 double child_x = parent->pending.swayc_x; 50 double child_x = parent->x;
52 for (size_t i = 0; i < num_children; ++i) { 51 for (size_t i = 0; i < num_children; ++i) {
53 struct sway_container *child = parent->children->items[i]; 52 struct sway_container *child = parent->children->items[i];
54 wlr_log(L_DEBUG, 53 wlr_log(L_DEBUG,
55 "Calculating arrangement for %p:%d (will scale %f by %f)", 54 "Calculating arrangement for %p:%d (will scale %f by %f)",
56 child, child->type, child->pending.swayc_width, scale); 55 child, child->type, child->width, scale);
57 child->pending.swayc_x = child_x; 56 child->x = child_x;
58 child->pending.swayc_y = parent->pending.swayc_y + parent_offset; 57 child->y = parent->y + parent_offset;
59 child->pending.swayc_width = floor(child->pending.swayc_width * scale); 58 child->width = floor(child->width * scale);
60 child->pending.swayc_height = parent_height; 59 child->height = parent_height;
61 child_x += child->pending.swayc_width; 60 child_x += child->width;
62 61
63 // Make last child use remaining width of parent 62 // Make last child use remaining width of parent
64 if (i == num_children - 1) { 63 if (i == num_children - 1) {
65 child->pending.swayc_width = parent->pending.swayc_x + 64 child->width = parent->x + parent->width - child->x;
66 parent->pending.swayc_width - child->pending.swayc_x;
67 } 65 }
68 } 66 }
69} 67}
@@ -74,49 +72,47 @@ static void apply_vert_layout(struct sway_container *parent) {
74 return; 72 return;
75 } 73 }
76 size_t parent_offset = 0; 74 size_t parent_offset = 0;
77 if (parent->parent->pending.layout == L_TABBED) { 75 if (parent->parent->layout == L_TABBED) {
78 parent_offset = container_titlebar_height(); 76 parent_offset = container_titlebar_height();
79 } else if (parent->parent->pending.layout == L_STACKED) { 77 } else if (parent->parent->layout == L_STACKED) {
80 parent_offset = 78 parent_offset =
81 container_titlebar_height() * parent->parent->children->length; 79 container_titlebar_height() * parent->parent->children->length;
82 } 80 }
83 size_t parent_height = parent->pending.swayc_height - parent_offset; 81 size_t parent_height = parent->height - parent_offset;
84 82
85 // Calculate total height of children 83 // Calculate total height of children
86 double total_height = 0; 84 double total_height = 0;
87 for (size_t i = 0; i < num_children; ++i) { 85 for (size_t i = 0; i < num_children; ++i) {
88 struct sway_container *child = parent->children->items[i]; 86 struct sway_container *child = parent->children->items[i];
89 if (child->pending.swayc_height <= 0) { 87 if (child->height <= 0) {
90 if (num_children > 1) { 88 if (num_children > 1) {
91 child->pending.swayc_height = 89 child->height = parent_height / (num_children - 1);
92 parent_height / (num_children - 1);
93 } else { 90 } else {
94 child->pending.swayc_height = parent_height; 91 child->height = parent_height;
95 } 92 }
96 } 93 }
97 total_height += child->pending.swayc_height; 94 total_height += child->height;
98 } 95 }
99 double scale = parent_height / total_height; 96 double scale = parent_height / total_height;
100 97
101 // Resize 98 // Resize
102 wlr_log(L_DEBUG, "Arranging %p vertically", parent); 99 wlr_log(L_DEBUG, "Arranging %p vertically", parent);
103 double child_y = parent->pending.swayc_y + parent_offset; 100 double child_y = parent->y + parent_offset;
104 for (size_t i = 0; i < num_children; ++i) { 101 for (size_t i = 0; i < num_children; ++i) {
105 struct sway_container *child = parent->children->items[i]; 102 struct sway_container *child = parent->children->items[i];
106 wlr_log(L_DEBUG, 103 wlr_log(L_DEBUG,
107 "Calculating arrangement for %p:%d (will scale %f by %f)", 104 "Calculating arrangement for %p:%d (will scale %f by %f)",
108 child, child->type, child->pending.swayc_height, scale); 105 child, child->type, child->height, scale);
109 child->pending.swayc_x = parent->pending.swayc_x; 106 child->x = parent->x;
110 child->pending.swayc_y = child_y; 107 child->y = child_y;
111 child->pending.swayc_width = parent->pending.swayc_width; 108 child->width = parent->width;
112 child->pending.swayc_height = 109 child->height = floor(child->height * scale);
113 floor(child->pending.swayc_height * scale); 110 child_y += child->height;
114 child_y += child->pending.swayc_height;
115 111
116 // Make last child use remaining height of parent 112 // Make last child use remaining height of parent
117 if (i == num_children - 1) { 113 if (i == num_children - 1) {
118 child->pending.swayc_height = parent->pending.swayc_y + 114 child->height =
119 parent_offset + parent_height - child->pending.swayc_y; 115 parent->y + parent_offset + parent_height - child->y;
120 } 116 }
121 } 117 }
122} 118}
@@ -126,19 +122,19 @@ static void apply_tabbed_or_stacked_layout(struct sway_container *parent) {
126 return; 122 return;
127 } 123 }
128 size_t parent_offset = 0; 124 size_t parent_offset = 0;
129 if (parent->parent->pending.layout == L_TABBED) { 125 if (parent->parent->layout == L_TABBED) {
130 parent_offset = container_titlebar_height(); 126 parent_offset = container_titlebar_height();
131 } else if (parent->parent->pending.layout == L_STACKED) { 127 } else if (parent->parent->layout == L_STACKED) {
132 parent_offset = 128 parent_offset =
133 container_titlebar_height() * parent->parent->children->length; 129 container_titlebar_height() * parent->parent->children->length;
134 } 130 }
135 size_t parent_height = parent->pending.swayc_height - parent_offset; 131 size_t parent_height = parent->height - parent_offset;
136 for (int i = 0; i < parent->children->length; ++i) { 132 for (int i = 0; i < parent->children->length; ++i) {
137 struct sway_container *child = parent->children->items[i]; 133 struct sway_container *child = parent->children->items[i];
138 child->pending.swayc_x = parent->pending.swayc_x; 134 child->x = parent->x;
139 child->pending.swayc_y = parent->pending.swayc_y + parent_offset; 135 child->y = parent->y + parent_offset;
140 child->pending.swayc_width = parent->pending.swayc_width; 136 child->width = parent->width;
141 child->pending.swayc_height = parent_height; 137 child->height = parent_height;
142 } 138 }
143} 139}
144 140
@@ -148,11 +144,10 @@ static void _arrange_children_of(struct sway_container *parent,
148 return; 144 return;
149 } 145 }
150 wlr_log(L_DEBUG, "Arranging layout for %p %s %fx%f+%f,%f", parent, 146 wlr_log(L_DEBUG, "Arranging layout for %p %s %fx%f+%f,%f", parent,
151 parent->name, parent->pending.swayc_width, parent->pending.swayc_height, 147 parent->name, parent->width, parent->height, parent->x, parent->y);
152 parent->pending.swayc_x, parent->pending.swayc_y);
153 148
154 // Calculate x, y, width and height of children 149 // Calculate x, y, width and height of children
155 switch (parent->pending.layout) { 150 switch (parent->layout) {
156 case L_HORIZ: 151 case L_HORIZ:
157 apply_horiz_layout(parent); 152 apply_horiz_layout(parent);
158 break; 153 break;
@@ -191,13 +186,13 @@ static void _arrange_workspace(struct sway_container *workspace,
191 struct wlr_box *area = &output->sway_output->usable_area; 186 struct wlr_box *area = &output->sway_output->usable_area;
192 wlr_log(L_DEBUG, "Usable area for ws: %dx%d@%d,%d", 187 wlr_log(L_DEBUG, "Usable area for ws: %dx%d@%d,%d",
193 area->width, area->height, area->x, area->y); 188 area->width, area->height, area->x, area->y);
194 workspace->pending.swayc_width = area->width; 189 workspace->width = area->width;
195 workspace->pending.swayc_height = area->height; 190 workspace->height = area->height;
196 workspace->pending.swayc_x = output->x + area->x; 191 workspace->x = output->x + area->x;
197 workspace->pending.swayc_y = output->y + area->y; 192 workspace->y = output->y + area->y;
198 transaction_add_container(transaction, workspace); 193 transaction_add_container(transaction, workspace);
199 wlr_log(L_DEBUG, "Arranging workspace '%s' at %f, %f", workspace->name, 194 wlr_log(L_DEBUG, "Arranging workspace '%s' at %f, %f", workspace->name,
200 workspace->pending.swayc_x, workspace->pending.swayc_y); 195 workspace->x, workspace->y);
201 _arrange_children_of(workspace, transaction); 196 _arrange_children_of(workspace, transaction);
202} 197}
203 198
@@ -213,13 +208,9 @@ static void _arrange_output(struct sway_container *output,
213 output->y = output_box->y; 208 output->y = output_box->y;
214 output->width = output_box->width; 209 output->width = output_box->width;
215 output->height = output_box->height; 210 output->height = output_box->height;
216 output->pending.swayc_x = output_box->x;
217 output->pending.swayc_y = output_box->y;
218 output->pending.swayc_width = output_box->width;
219 output->pending.swayc_height = output_box->height;
220 transaction_add_container(transaction, output); 211 transaction_add_container(transaction, output);
221 wlr_log(L_DEBUG, "Arranging output '%s' at %f,%f", 212 wlr_log(L_DEBUG, "Arranging output '%s' at %f,%f",
222 output->name, output->pending.swayc_x, output->pending.swayc_y); 213 output->name, output->x, output->y);
223 for (int i = 0; i < output->children->length; ++i) { 214 for (int i = 0; i < output->children->length; ++i) {
224 struct sway_container *workspace = output->children->items[i]; 215 struct sway_container *workspace = output->children->items[i];
225 _arrange_workspace(workspace, transaction); 216 _arrange_workspace(workspace, transaction);
@@ -238,10 +229,6 @@ static void _arrange_root(struct sway_transaction *transaction) {
238 root_container.y = layout_box->y; 229 root_container.y = layout_box->y;
239 root_container.width = layout_box->width; 230 root_container.width = layout_box->width;
240 root_container.height = layout_box->height; 231 root_container.height = layout_box->height;
241 root_container.pending.swayc_x = layout_box->x;
242 root_container.pending.swayc_y = layout_box->y;
243 root_container.pending.swayc_width = layout_box->width;
244 root_container.pending.swayc_height = layout_box->height;
245 transaction_add_container(transaction, &root_container); 232 transaction_add_container(transaction, &root_container);
246 for (int i = 0; i < root_container.children->length; ++i) { 233 for (int i = 0; i < root_container.children->length; ++i) {
247 struct sway_container *output = root_container.children->items[i]; 234 struct sway_container *output = root_container.children->items[i];
diff --git a/sway/tree/layout.c b/sway/tree/layout.c
index 3bba049a..6d4cd088 100644
--- a/sway/tree/layout.c
+++ b/sway/tree/layout.c
@@ -915,10 +915,10 @@ void container_recursive_resize(struct sway_container *container,
915 bool layout_match = true; 915 bool layout_match = true;
916 wlr_log(L_DEBUG, "Resizing %p with amount: %f", container, amount); 916 wlr_log(L_DEBUG, "Resizing %p with amount: %f", container, amount);
917 if (edge == RESIZE_EDGE_LEFT || edge == RESIZE_EDGE_RIGHT) { 917 if (edge == RESIZE_EDGE_LEFT || edge == RESIZE_EDGE_RIGHT) {
918 container->pending.swayc_width += amount; 918 container->width += amount;
919 layout_match = container->layout == L_HORIZ; 919 layout_match = container->layout == L_HORIZ;
920 } else if (edge == RESIZE_EDGE_TOP || edge == RESIZE_EDGE_BOTTOM) { 920 } else if (edge == RESIZE_EDGE_TOP || edge == RESIZE_EDGE_BOTTOM) {
921 container->pending.swayc_height += amount; 921 container->height += amount;
922 layout_match = container->layout == L_VERT; 922 layout_match = container->layout == L_VERT;
923 } 923 }
924 if (container->children) { 924 if (container->children) {
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 40fe2740..dbf803c6 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -187,23 +187,23 @@ void view_autoconfigure(struct sway_view *view) {
187 } 187 }
188 } 188 }
189 189
190 struct sway_container_state *state = &view->swayc->pending; 190 struct sway_container *con = view->swayc;
191 191
192 state->border_top = state->border_bottom = true; 192 view->border_top = view->border_bottom = true;
193 state->border_left = state->border_right = true; 193 view->border_left = view->border_right = true;
194 if (config->hide_edge_borders == E_BOTH 194 if (config->hide_edge_borders == E_BOTH
195 || config->hide_edge_borders == E_VERTICAL 195 || config->hide_edge_borders == E_VERTICAL
196 || (config->hide_edge_borders == E_SMART && !other_views)) { 196 || (config->hide_edge_borders == E_SMART && !other_views)) {
197 state->border_left = state->swayc_x != ws->x; 197 view->border_left = con->x != ws->x;
198 int right_x = state->swayc_x + state->swayc_width; 198 int right_x = con->x + con->width;
199 state->border_right = right_x != ws->x + ws->width; 199 view->border_right = right_x != ws->x + ws->width;
200 } 200 }
201 if (config->hide_edge_borders == E_BOTH 201 if (config->hide_edge_borders == E_BOTH
202 || config->hide_edge_borders == E_HORIZONTAL 202 || config->hide_edge_borders == E_HORIZONTAL
203 || (config->hide_edge_borders == E_SMART && !other_views)) { 203 || (config->hide_edge_borders == E_SMART && !other_views)) {
204 state->border_top = state->swayc_y != ws->y; 204 view->border_top = con->y != ws->y;
205 int bottom_y = state->swayc_y + state->swayc_height; 205 int bottom_y = con->y + con->height;
206 state->border_bottom = bottom_y != ws->y + ws->height; 206 view->border_bottom = bottom_y != ws->y + ws->height;
207 } 207 }
208 208
209 double x, y, width, height; 209 double x, y, width, height;
@@ -213,54 +213,53 @@ void view_autoconfigure(struct sway_view *view) {
213 // In a tabbed or stacked container, the swayc's y is the top of the title 213 // In a tabbed or stacked container, the swayc's y is the top of the title
214 // area. We have to offset the surface y by the height of the title bar, and 214 // area. We have to offset the surface y by the height of the title bar, and
215 // disable any top border because we'll always have the title bar. 215 // disable any top border because we'll always have the title bar.
216 if (view->swayc->parent->pending.layout == L_TABBED) { 216 if (con->parent->layout == L_TABBED) {
217 y_offset = container_titlebar_height(); 217 y_offset = container_titlebar_height();
218 state->border_top = false; 218 view->border_top = false;
219 } else if (view->swayc->parent->pending.layout == L_STACKED) { 219 } else if (con->parent->layout == L_STACKED) {
220 y_offset = container_titlebar_height() 220 y_offset = container_titlebar_height() * con->parent->children->length;
221 * view->swayc->parent->children->length;
222 view->border_top = false; 221 view->border_top = false;
223 } 222 }
224 223
225 switch (state->border) { 224 switch (view->border) {
226 case B_NONE: 225 case B_NONE:
227 x = state->swayc_x; 226 x = con->x;
228 y = state->swayc_y + y_offset; 227 y = con->y + y_offset;
229 width = state->swayc_width; 228 width = con->width;
230 height = state->swayc_height - y_offset; 229 height = con->height - y_offset;
231 break; 230 break;
232 case B_PIXEL: 231 case B_PIXEL:
233 x = state->swayc_x + state->border_thickness * state->border_left; 232 x = con->x + view->border_thickness * view->border_left;
234 y = state->swayc_y + state->border_thickness * state->border_top + y_offset; 233 y = con->y + view->border_thickness * view->border_top + y_offset;
235 width = state->swayc_width 234 width = con->width
236 - state->border_thickness * state->border_left 235 - view->border_thickness * view->border_left
237 - state->border_thickness * state->border_right; 236 - view->border_thickness * view->border_right;
238 height = state->swayc_height - y_offset 237 height = con->height - y_offset
239 - state->border_thickness * state->border_top 238 - view->border_thickness * view->border_top
240 - state->border_thickness * state->border_bottom; 239 - view->border_thickness * view->border_bottom;
241 break; 240 break;
242 case B_NORMAL: 241 case B_NORMAL:
243 // Height is: 1px border + 3px pad + title height + 3px pad + 1px border 242 // Height is: 1px border + 3px pad + title height + 3px pad + 1px border
244 x = state->swayc_x + state->border_thickness * state->border_left; 243 x = con->x + view->border_thickness * view->border_left;
245 width = state->swayc_width 244 width = con->width
246 - state->border_thickness * state->border_left 245 - view->border_thickness * view->border_left
247 - state->border_thickness * state->border_right; 246 - view->border_thickness * view->border_right;
248 if (y_offset) { 247 if (y_offset) {
249 y = state->swayc_y + y_offset; 248 y = con->y + y_offset;
250 height = state->swayc_height - y_offset 249 height = con->height - y_offset
251 - state->border_thickness * state->border_bottom; 250 - view->border_thickness * view->border_bottom;
252 } else { 251 } else {
253 y = state->swayc_y + container_titlebar_height(); 252 y = con->y + container_titlebar_height();
254 height = state->swayc_height - container_titlebar_height() 253 height = con->height - container_titlebar_height()
255 - state->border_thickness * state->border_bottom; 254 - view->border_thickness * view->border_bottom;
256 } 255 }
257 break; 256 break;
258 } 257 }
259 258
260 state->view_x = x; 259 view->x = x;
261 state->view_y = y; 260 view->y = y;
262 state->view_width = width; 261 view->width = width;
263 state->view_height = height; 262 view->height = height;
264} 263}
265 264
266void view_set_activated(struct sway_view *view, bool activated) { 265void view_set_activated(struct sway_view *view, bool activated) {
@@ -319,9 +318,8 @@ void view_set_fullscreen_raw(struct sway_view *view, bool fullscreen) {
319 view_configure(view, view->saved_x, view->saved_y, 318 view_configure(view, view->saved_x, view->saved_y,
320 view->saved_width, view->saved_height); 319 view->saved_width, view->saved_height);
321 } else { 320 } else {
322 view->swayc->width = view->swayc->saved_width; 321 view->swayc->width = view->swayc->saved_width;
323 view->swayc->height = view->swayc->saved_height; 322 view->swayc->height = view->swayc->saved_height;
324 view_autoconfigure(view);
325 } 323 }
326 } 324 }
327} 325}
@@ -508,8 +506,6 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) {
508 view->swayc = cont; 506 view->swayc = cont;
509 view->border = config->border; 507 view->border = config->border;
510 view->border_thickness = config->border_thickness; 508 view->border_thickness = config->border_thickness;
511 view->swayc->pending.border = config->border;
512 view->swayc->pending.border_thickness = config->border_thickness;
513 509
514 view_init_subsurfaces(view, wlr_surface); 510 view_init_subsurfaces(view, wlr_surface);
515 wl_signal_add(&wlr_surface->events.new_subsurface, 511 wl_signal_add(&wlr_surface->events.new_subsurface,
@@ -977,7 +973,7 @@ bool view_is_visible(struct sway_view *view) {
977 } 973 }
978 // Check the workspace is visible 974 // Check the workspace is visible
979 if (!is_sticky) { 975 if (!is_sticky) {
980 return workspace_is_visible(workspace); 976 return workspace_is_visible(workspace);
981 } 977 }
982 return true; 978 return true;
983} 979}
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c
index ad581a96..9ba210fd 100644
--- a/sway/tree/workspace.c
+++ b/sway/tree/workspace.c
@@ -60,12 +60,6 @@ struct sway_container *workspace_create(struct sway_container *output,
60 workspace->prev_layout = L_NONE; 60 workspace->prev_layout = L_NONE;
61 workspace->layout = container_get_default_layout(output); 61 workspace->layout = container_get_default_layout(output);
62 62
63 workspace->pending.swayc_x = workspace->x;
64 workspace->pending.swayc_y = workspace->y;
65 workspace->pending.swayc_width = workspace->width;
66 workspace->pending.swayc_height = workspace->height;
67 workspace->pending.layout = workspace->layout;
68
69 struct sway_workspace *swayws = calloc(1, sizeof(struct sway_workspace)); 63 struct sway_workspace *swayws = calloc(1, sizeof(struct sway_workspace));
70 if (!swayws) { 64 if (!swayws) {
71 return NULL; 65 return NULL;