aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-11-17 18:32:03 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-11-17 21:29:42 +1000
commitbe9348d25c9556bdabb83d964a8761f920fc4a11 (patch)
treec06bde3d10e9bfea04acdd9b055cd596f13d4522
parentMerge pull request #3132 from emersion/dispatch-cursor-btn-segfault (diff)
downloadsway-be9348d25c9556bdabb83d964a8761f920fc4a11.tar.gz
sway-be9348d25c9556bdabb83d964a8761f920fc4a11.tar.zst
sway-be9348d25c9556bdabb83d964a8761f920fc4a11.zip
Move view {x,y,width,height} into container struct
This renames/moves the following properties: * sway_view.{x,y,width,height} -> sway_container.content_{x,y,width,height} * This is required to support placeholder containers as they don't have a view. * sway_container_state.view_{x,y,width,height} -> sway_container_state.content_{x,y,width,height} * To remain consistent with the above. * sway_container_state.con_{x,y,width,height} -> sway_container_state.{x,y,width,height} * The con prefix was there to give it contrast from the view properties, and is no longer useful. The function container_set_geometry_from_floating_view has also been renamed to container_set_geometry_from_content.
-rw-r--r--include/sway/tree/container.h14
-rw-r--r--include/sway/tree/view.h4
-rw-r--r--sway/commands/border.c2
-rw-r--r--sway/commands/resize.c22
-rw-r--r--sway/desktop/desktop.c4
-rw-r--r--sway/desktop/output.c24
-rw-r--r--sway/desktop/render.c50
-rw-r--r--sway/desktop/transaction.c48
-rw-r--r--sway/desktop/xdg_shell.c10
-rw-r--r--sway/desktop/xdg_shell_v6.c10
-rw-r--r--sway/desktop/xwayland.c18
-rw-r--r--sway/input/cursor.c21
-rw-r--r--sway/ipc-json.c8
-rw-r--r--sway/tree/container.c44
-rw-r--r--sway/tree/view.c37
15 files changed, 156 insertions, 160 deletions
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h
index d3155eb3..f907aad2 100644
--- a/include/sway/tree/container.h
+++ b/include/sway/tree/container.h
@@ -41,8 +41,8 @@ enum wlr_direction;
41struct sway_container_state { 41struct sway_container_state {
42 // Container properties 42 // Container properties
43 enum sway_container_layout layout; 43 enum sway_container_layout layout;
44 double con_x, con_y; 44 double x, y;
45 double con_width, con_height; 45 double width, height;
46 46
47 bool is_fullscreen; 47 bool is_fullscreen;
48 48
@@ -60,9 +60,8 @@ struct sway_container_state {
60 bool border_left; 60 bool border_left;
61 bool border_right; 61 bool border_right;
62 62
63 // View properties 63 double content_x, content_y;
64 double view_x, view_y; 64 double content_width, content_height;
65 double view_width, view_height;
66}; 65};
67 66
68struct sway_container { 67struct sway_container {
@@ -89,6 +88,9 @@ struct sway_container {
89 double saved_x, saved_y; 88 double saved_x, saved_y;
90 double saved_width, saved_height; 89 double saved_width, saved_height;
91 90
91 double content_x, content_y;
92 int content_width, content_height;
93
92 bool is_fullscreen; 94 bool is_fullscreen;
93 95
94 enum sway_container_border border; 96 enum sway_container_border border;
@@ -210,7 +212,7 @@ void container_init_floating(struct sway_container *container);
210 212
211void container_set_floating(struct sway_container *container, bool enable); 213void container_set_floating(struct sway_container *container, bool enable);
212 214
213void container_set_geometry_from_floating_view(struct sway_container *con); 215void container_set_geometry_from_content(struct sway_container *con);
214 216
215/** 217/**
216 * Determine if the given container is itself floating. 218 * Determine if the given container is itself floating.
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h
index 4a8c3cb1..8f045c6a 100644
--- a/include/sway/tree/view.h
+++ b/include/sway/tree/view.h
@@ -67,10 +67,6 @@ struct sway_view {
67 67
68 pid_t pid; 68 pid_t pid;
69 69
70 // Geometry of the view itself (excludes borders) in layout coordinates
71 double x, y;
72 int width, height;
73
74 double saved_x, saved_y; 70 double saved_x, saved_y;
75 int saved_width, saved_height; 71 int saved_width, saved_height;
76 72
diff --git a/sway/commands/border.c b/sway/commands/border.c
index b6eab550..d51741d2 100644
--- a/sway/commands/border.c
+++ b/sway/commands/border.c
@@ -93,7 +93,7 @@ struct cmd_results *cmd_border(int argc, char **argv) {
93 } 93 }
94 94
95 if (container_is_floating(container)) { 95 if (container_is_floating(container)) {
96 container_set_geometry_from_floating_view(container); 96 container_set_geometry_from_content(container);
97 } 97 }
98 98
99 arrange_container(container); 99 arrange_container(container);
diff --git a/sway/commands/resize.c b/sway/commands/resize.c
index 94ffbbe1..e876f48a 100644
--- a/sway/commands/resize.c
+++ b/sway/commands/resize.c
@@ -404,13 +404,10 @@ static struct cmd_results *resize_adjust_floating(enum resize_axis axis,
404 con->width += grow_width; 404 con->width += grow_width;
405 con->height += grow_height; 405 con->height += grow_height;
406 406
407 if (con->view) { 407 con->content_x += grow_x;
408 struct sway_view *view = con->view; 408 con->content_y += grow_y;
409 view->x += grow_x; 409 con->content_width += grow_width;
410 view->y += grow_y; 410 con->content_height += grow_height;
411 view->width += grow_width;
412 view->height += grow_height;
413 }
414 411
415 arrange_container(con); 412 arrange_container(con);
416 413
@@ -546,13 +543,10 @@ static struct cmd_results *resize_set_floating(struct sway_container *con,
546 } 543 }
547 } 544 }
548 545
549 if (con->view) { 546 con->content_x -= grow_width / 2;
550 struct sway_view *view = con->view; 547 con->content_y -= grow_height / 2;
551 view->x -= grow_width / 2; 548 con->content_width += grow_width;
552 view->y -= grow_height / 2; 549 con->content_height += grow_height;
553 view->width += grow_width;
554 view->height += grow_height;
555 }
556 550
557 arrange_container(con); 551 arrange_container(con);
558 552
diff --git a/sway/desktop/desktop.c b/sway/desktop/desktop.c
index 771b58fe..d8dd0240 100644
--- a/sway/desktop/desktop.c
+++ b/sway/desktop/desktop.c
@@ -28,8 +28,8 @@ void desktop_damage_box(struct wlr_box *box) {
28void desktop_damage_view(struct sway_view *view) { 28void desktop_damage_view(struct sway_view *view) {
29 desktop_damage_whole_container(view->container); 29 desktop_damage_whole_container(view->container);
30 struct wlr_box box = { 30 struct wlr_box box = {
31 .x = view->container->current.view_x - view->geometry.x, 31 .x = view->container->current.content_x - view->geometry.x,
32 .y = view->container->current.view_y - view->geometry.y, 32 .y = view->container->current.content_y - view->geometry.y,
33 .width = view->surface->current.width, 33 .width = view->surface->current.width,
34 .height = view->surface->current.height, 34 .height = view->surface->current.height,
35 }; 35 };
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index c53a9c73..e8112bd9 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -160,12 +160,12 @@ void output_view_for_each_surface(struct sway_output *output,
160 .user_iterator = iterator, 160 .user_iterator = iterator,
161 .user_data = user_data, 161 .user_data = user_data,
162 .output = output, 162 .output = output,
163 .ox = view->container->current.view_x - output->wlr_output->lx 163 .ox = view->container->current.content_x - output->wlr_output->lx
164 - view->geometry.x, 164 - view->geometry.x,
165 .oy = view->container->current.view_y - output->wlr_output->ly 165 .oy = view->container->current.content_y - output->wlr_output->ly
166 - view->geometry.y, 166 - view->geometry.y,
167 .width = view->container->current.view_width, 167 .width = view->container->current.content_width,
168 .height = view->container->current.view_height, 168 .height = view->container->current.content_height,
169 .rotation = 0, // TODO 169 .rotation = 0, // TODO
170 }; 170 };
171 171
@@ -179,12 +179,12 @@ void output_view_for_each_popup(struct sway_output *output,
179 .user_iterator = iterator, 179 .user_iterator = iterator,
180 .user_data = user_data, 180 .user_data = user_data,
181 .output = output, 181 .output = output,
182 .ox = view->container->current.view_x - output->wlr_output->lx 182 .ox = view->container->current.content_x - output->wlr_output->lx
183 - view->geometry.x, 183 - view->geometry.x,
184 .oy = view->container->current.view_y - output->wlr_output->ly 184 .oy = view->container->current.content_y - output->wlr_output->ly
185 - view->geometry.y, 185 - view->geometry.y,
186 .width = view->container->current.view_width, 186 .width = view->container->current.content_width,
187 .height = view->container->current.view_height, 187 .height = view->container->current.content_height,
188 .rotation = 0, // TODO 188 .rotation = 0, // TODO
189 }; 189 };
190 190
@@ -473,10 +473,10 @@ void output_damage_whole_container(struct sway_output *output,
473 struct sway_container *con) { 473 struct sway_container *con) {
474 // Pad the box by 1px, because the width is a double and might be a fraction 474 // Pad the box by 1px, because the width is a double and might be a fraction
475 struct wlr_box box = { 475 struct wlr_box box = {
476 .x = con->current.con_x - output->wlr_output->lx - 1, 476 .x = con->current.x - output->wlr_output->lx - 1,
477 .y = con->current.con_y - output->wlr_output->ly - 1, 477 .y = con->current.y - output->wlr_output->ly - 1,
478 .width = con->current.con_width + 2, 478 .width = con->current.width + 2,
479 .height = con->current.con_height + 2, 479 .height = con->current.height + 2,
480 }; 480 };
481 scale_box(&box, output->wlr_output->scale); 481 scale_box(&box, output->wlr_output->scale);
482 wlr_output_damage_add_box(output->damage, &box); 482 wlr_output_damage_add_box(output->damage, &box);
diff --git a/sway/desktop/render.c b/sway/desktop/render.c
index 1b3b29e7..93e196bb 100644
--- a/sway/desktop/render.c
+++ b/sway/desktop/render.c
@@ -211,9 +211,9 @@ static void render_view_toplevels(struct sway_view *view,
211 .alpha = alpha, 211 .alpha = alpha,
212 }; 212 };
213 // Render all toplevels without descending into popups 213 // Render all toplevels without descending into popups
214 double ox = view->container->current.view_x - 214 double ox = view->container->current.content_x -
215 output->wlr_output->lx - view->geometry.x; 215 output->wlr_output->lx - view->geometry.x;
216 double oy = view->container->current.view_y - 216 double oy = view->container->current.content_y -
217 output->wlr_output->ly - view->geometry.y; 217 output->wlr_output->ly - view->geometry.y;
218 output_surface_for_each_surface(output, view->surface, ox, oy, 218 output_surface_for_each_surface(output, view->surface, ox, oy,
219 render_surface_iterator, &data); 219 render_surface_iterator, &data);
@@ -247,9 +247,9 @@ static void render_saved_view(struct sway_view *view,
247 return; 247 return;
248 } 248 }
249 struct wlr_box box = { 249 struct wlr_box box = {
250 .x = view->container->current.view_x - output->wlr_output->lx - 250 .x = view->container->current.content_x - output->wlr_output->lx -
251 view->saved_geometry.x, 251 view->saved_geometry.x,
252 .y = view->container->current.view_y - output->wlr_output->ly - 252 .y = view->container->current.content_y - output->wlr_output->ly -
253 view->saved_geometry.y, 253 view->saved_geometry.y,
254 .width = view->saved_buffer_width, 254 .width = view->saved_buffer_width,
255 .height = view->saved_buffer_height, 255 .height = view->saved_buffer_height,
@@ -300,10 +300,10 @@ static void render_view(struct sway_output *output, pixman_region32_t *damage,
300 if (state->border_left) { 300 if (state->border_left) {
301 memcpy(&color, colors->child_border, sizeof(float) * 4); 301 memcpy(&color, colors->child_border, sizeof(float) * 4);
302 premultiply_alpha(color, con->alpha); 302 premultiply_alpha(color, con->alpha);
303 box.x = state->con_x; 303 box.x = state->x;
304 box.y = state->view_y; 304 box.y = state->content_y;
305 box.width = state->border_thickness; 305 box.width = state->border_thickness;
306 box.height = state->view_height; 306 box.height = state->content_height;
307 scale_box(&box, output_scale); 307 scale_box(&box, output_scale);
308 render_rect(output->wlr_output, damage, &box, color); 308 render_rect(output->wlr_output, damage, &box, color);
309 } 309 }
@@ -319,10 +319,10 @@ static void render_view(struct sway_output *output, pixman_region32_t *damage,
319 memcpy(&color, colors->child_border, sizeof(float) * 4); 319 memcpy(&color, colors->child_border, sizeof(float) * 4);
320 } 320 }
321 premultiply_alpha(color, con->alpha); 321 premultiply_alpha(color, con->alpha);
322 box.x = state->view_x + state->view_width; 322 box.x = state->content_x + state->content_width;
323 box.y = state->view_y; 323 box.y = state->content_y;
324 box.width = state->border_thickness; 324 box.width = state->border_thickness;
325 box.height = state->view_height; 325 box.height = state->content_height;
326 scale_box(&box, output_scale); 326 scale_box(&box, output_scale);
327 render_rect(output->wlr_output, damage, &box, color); 327 render_rect(output->wlr_output, damage, &box, color);
328 } 328 }
@@ -334,9 +334,9 @@ static void render_view(struct sway_output *output, pixman_region32_t *damage,
334 memcpy(&color, colors->child_border, sizeof(float) * 4); 334 memcpy(&color, colors->child_border, sizeof(float) * 4);
335 } 335 }
336 premultiply_alpha(color, con->alpha); 336 premultiply_alpha(color, con->alpha);
337 box.x = state->con_x; 337 box.x = state->x;
338 box.y = state->view_y + state->view_height; 338 box.y = state->content_y + state->content_height;
339 box.width = state->con_width; 339 box.width = state->width;
340 box.height = state->border_thickness; 340 box.height = state->border_thickness;
341 scale_box(&box, output_scale); 341 scale_box(&box, output_scale);
342 render_rect(output->wlr_output, damage, &box, color); 342 render_rect(output->wlr_output, damage, &box, color);
@@ -585,9 +585,9 @@ static void render_top_border(struct sway_output *output,
585 // Child border - top edge 585 // Child border - top edge
586 memcpy(&color, colors->child_border, sizeof(float) * 4); 586 memcpy(&color, colors->child_border, sizeof(float) * 4);
587 premultiply_alpha(color, con->alpha); 587 premultiply_alpha(color, con->alpha);
588 box.x = state->con_x; 588 box.x = state->x;
589 box.y = state->con_y; 589 box.y = state->y;
590 box.width = state->con_width; 590 box.width = state->width;
591 box.height = state->border_thickness; 591 box.height = state->border_thickness;
592 scale_box(&box, output_scale); 592 scale_box(&box, output_scale);
593 render_rect(output->wlr_output, output_damage, &box, color); 593 render_rect(output->wlr_output, output_damage, &box, color);
@@ -641,8 +641,8 @@ static void render_containers_linear(struct sway_output *output,
641 } 641 }
642 642
643 if (state->border == B_NORMAL) { 643 if (state->border == B_NORMAL) {
644 render_titlebar(output, damage, child, state->con_x, 644 render_titlebar(output, damage, child, state->x,
645 state->con_y, state->con_width, colors, 645 state->y, state->width, colors,
646 title_texture, marks_texture); 646 title_texture, marks_texture);
647 } else if (state->border == B_PIXEL) { 647 } else if (state->border == B_PIXEL) {
648 render_top_border(output, damage, child, colors); 648 render_top_border(output, damage, child, colors);
@@ -696,7 +696,7 @@ static void render_containers_tabbed(struct sway_output *output,
696 marks_texture = child->marks_unfocused; 696 marks_texture = child->marks_unfocused;
697 } 697 }
698 698
699 int x = cstate->con_x + tab_width * i; 699 int x = cstate->x + tab_width * i;
700 700
701 // Make last tab use the remaining width of the parent 701 // Make last tab use the remaining width of the parent
702 if (i == parent->children->length - 1) { 702 if (i == parent->children->length - 1) {
@@ -801,10 +801,10 @@ static void render_container(struct sway_output *output,
801 struct parent_data data = { 801 struct parent_data data = {
802 .layout = con->current.layout, 802 .layout = con->current.layout,
803 .box = { 803 .box = {
804 .x = con->current.con_x, 804 .x = con->current.x,
805 .y = con->current.con_y, 805 .y = con->current.y,
806 .width = con->current.con_width, 806 .width = con->current.width,
807 .height = con->current.con_height, 807 .height = con->current.height,
808 }, 808 },
809 .children = con->current.children, 809 .children = con->current.children,
810 .focused = focused, 810 .focused = focused,
@@ -853,8 +853,8 @@ static void render_floating_container(struct sway_output *soutput,
853 } 853 }
854 854
855 if (con->current.border == B_NORMAL) { 855 if (con->current.border == B_NORMAL) {
856 render_titlebar(soutput, damage, con, con->current.con_x, 856 render_titlebar(soutput, damage, con, con->current.x,
857 con->current.con_y, con->current.con_width, colors, 857 con->current.y, con->current.width, colors,
858 title_texture, marks_texture); 858 title_texture, marks_texture);
859 } else if (con->current.border == B_PIXEL) { 859 } else if (con->current.border == B_PIXEL) {
860 render_top_border(soutput, damage, con, colors); 860 render_top_border(soutput, damage, con, colors);
diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c
index 44156d41..39cb641f 100644
--- a/sway/desktop/transaction.c
+++ b/sway/desktop/transaction.c
@@ -130,10 +130,10 @@ static void copy_container_state(struct sway_container *container,
130 struct sway_container_state *state = &instruction->container_state; 130 struct sway_container_state *state = &instruction->container_state;
131 131
132 state->layout = container->layout; 132 state->layout = container->layout;
133 state->con_x = container->x; 133 state->x = container->x;
134 state->con_y = container->y; 134 state->y = container->y;
135 state->con_width = container->width; 135 state->width = container->width;
136 state->con_height = container->height; 136 state->height = container->height;
137 state->is_fullscreen = container->is_fullscreen; 137 state->is_fullscreen = container->is_fullscreen;
138 state->parent = container->parent; 138 state->parent = container->parent;
139 state->workspace = container->workspace; 139 state->workspace = container->workspace;
@@ -143,14 +143,12 @@ static void copy_container_state(struct sway_container *container,
143 state->border_left = container->border_left; 143 state->border_left = container->border_left;
144 state->border_right = container->border_right; 144 state->border_right = container->border_right;
145 state->border_bottom = container->border_bottom; 145 state->border_bottom = container->border_bottom;
146 state->content_x = container->content_x;
147 state->content_y = container->content_y;
148 state->content_width = container->content_width;
149 state->content_height = container->content_height;
146 150
147 if (container->view) { 151 if (!container->view) {
148 struct sway_view *view = container->view;
149 state->view_x = view->x;
150 state->view_y = view->y;
151 state->view_width = view->width;
152 state->view_height = view->height;
153 } else {
154 state->children = create_list(); 152 state->children = create_list();
155 list_cat(state->children, container->children); 153 list_cat(state->children, container->children);
156 } 154 }
@@ -217,8 +215,8 @@ static void apply_container_state(struct sway_container *container,
217 desktop_damage_whole_container(container); 215 desktop_damage_whole_container(container);
218 if (view && view->saved_buffer) { 216 if (view && view->saved_buffer) {
219 struct wlr_box box = { 217 struct wlr_box box = {
220 .x = container->current.view_x - view->saved_geometry.x, 218 .x = container->current.content_x - view->saved_geometry.x,
221 .y = container->current.view_y - view->saved_geometry.y, 219 .y = container->current.content_y - view->saved_geometry.y,
222 .width = view->saved_buffer_width, 220 .width = view->saved_buffer_width,
223 .height = view->saved_buffer_height, 221 .height = view->saved_buffer_height,
224 }; 222 };
@@ -245,8 +243,8 @@ static void apply_container_state(struct sway_container *container,
245 if (view && view->surface) { 243 if (view && view->surface) {
246 struct wlr_surface *surface = view->surface; 244 struct wlr_surface *surface = view->surface;
247 struct wlr_box box = { 245 struct wlr_box box = {
248 .x = container->current.view_x - view->geometry.x, 246 .x = container->current.content_x - view->geometry.x,
249 .y = container->current.view_y - view->geometry.y, 247 .y = container->current.content_y - view->geometry.y,
250 .width = surface->current.width, 248 .width = surface->current.width,
251 .height = surface->current.height, 249 .height = surface->current.height,
252 }; 250 };
@@ -386,14 +384,14 @@ static bool should_configure(struct sway_node *node,
386 // Xwayland views are position-aware and need to be reconfigured 384 // Xwayland views are position-aware and need to be reconfigured
387 // when their position changes. 385 // when their position changes.
388 if (node->sway_container->view->type == SWAY_VIEW_XWAYLAND) { 386 if (node->sway_container->view->type == SWAY_VIEW_XWAYLAND) {
389 if (cstate->view_x != istate->view_x || 387 if (cstate->content_x != istate->content_x ||
390 cstate->view_y != istate->view_y) { 388 cstate->content_y != istate->content_y) {
391 return true; 389 return true;
392 } 390 }
393 } 391 }
394#endif 392#endif
395 if (cstate->view_width == istate->view_width && 393 if (cstate->content_width == istate->content_width &&
396 cstate->view_height == istate->view_height) { 394 cstate->content_height == istate->content_height) {
397 return false; 395 return false;
398 } 396 }
399 return true; 397 return true;
@@ -409,10 +407,10 @@ static void transaction_commit(struct sway_transaction *transaction) {
409 struct sway_node *node = instruction->node; 407 struct sway_node *node = instruction->node;
410 if (should_configure(node, instruction)) { 408 if (should_configure(node, instruction)) {
411 instruction->serial = view_configure(node->sway_container->view, 409 instruction->serial = view_configure(node->sway_container->view,
412 instruction->container_state.view_x, 410 instruction->container_state.content_x,
413 instruction->container_state.view_y, 411 instruction->container_state.content_y,
414 instruction->container_state.view_width, 412 instruction->container_state.content_width,
415 instruction->container_state.view_height); 413 instruction->container_state.content_height);
416 ++transaction->num_waiting; 414 ++transaction->num_waiting;
417 415
418 // From here on we are rendering a saved buffer of the view, which 416 // From here on we are rendering a saved buffer of the view, which
@@ -504,8 +502,8 @@ void transaction_notify_view_ready_by_size(struct sway_view *view,
504 int width, int height) { 502 int width, int height) {
505 struct sway_transaction_instruction *instruction = 503 struct sway_transaction_instruction *instruction =
506 view->container->node.instruction; 504 view->container->node.instruction;
507 if (instruction->container_state.view_width == width && 505 if (instruction->container_state.content_width == width &&
508 instruction->container_state.view_height == height) { 506 instruction->container_state.content_height == height) {
509 set_instruction_ready(instruction); 507 set_instruction_ready(instruction);
510 } 508 }
511} 509}
diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c
index 0b2ebc96..801dcee0 100644
--- a/sway/desktop/xdg_shell.c
+++ b/sway/desktop/xdg_shell.c
@@ -75,8 +75,8 @@ static void popup_unconstrain(struct sway_xdg_popup *popup) {
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->x, 78 .x = output->lx - view->container->content_x,
79 .y = output->ly - view->y, 79 .y = output->ly - view->container->content_y,
80 .width = output->width, 80 .width = output->width,
81 .height = output->height, 81 .height = output->height,
82 }; 82 };
@@ -286,9 +286,11 @@ static void handle_commit(struct wl_listener *listener, void *data) {
286 } else { 286 } else {
287 struct wlr_box new_geo; 287 struct wlr_box new_geo;
288 wlr_xdg_surface_get_geometry(xdg_surface, &new_geo); 288 wlr_xdg_surface_get_geometry(xdg_surface, &new_geo);
289 struct sway_container *con = view->container;
289 290
290 if ((new_geo.width != view->width || new_geo.height != view->height) && 291 if ((new_geo.width != con->content_width ||
291 container_is_floating(view->container)) { 292 new_geo.height != con->content_height) &&
293 container_is_floating(con)) {
292 // A floating view has unexpectedly sent a new size 294 // A floating view has unexpectedly sent a new size
293 desktop_damage_view(view); 295 desktop_damage_view(view);
294 view_update_size(view, new_geo.width, new_geo.height); 296 view_update_size(view, new_geo.width, new_geo.height);
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c
index 692cfbf5..4bc83b8e 100644
--- a/sway/desktop/xdg_shell_v6.c
+++ b/sway/desktop/xdg_shell_v6.c
@@ -74,8 +74,8 @@ static void popup_unconstrain(struct sway_xdg_popup_v6 *popup) {
74 // the output box expressed in the coordinate system of the toplevel parent 74 // the output box expressed in the coordinate system of the toplevel parent
75 // of the popup 75 // of the popup
76 struct wlr_box output_toplevel_sx_box = { 76 struct wlr_box output_toplevel_sx_box = {
77 .x = output->lx - view->x, 77 .x = output->lx - view->container->content_x,
78 .y = output->ly - view->y, 78 .y = output->ly - view->container->content_y,
79 .width = output->width, 79 .width = output->width,
80 .height = output->height, 80 .height = output->height,
81 }; 81 };
@@ -283,9 +283,11 @@ static void handle_commit(struct wl_listener *listener, void *data) {
283 } else { 283 } else {
284 struct wlr_box new_geo; 284 struct wlr_box new_geo;
285 wlr_xdg_surface_v6_get_geometry(xdg_surface_v6, &new_geo); 285 wlr_xdg_surface_v6_get_geometry(xdg_surface_v6, &new_geo);
286 struct sway_container *con = view->container;
286 287
287 if ((new_geo.width != view->width || new_geo.height != view->height) && 288 if ((new_geo.width != con->content_width ||
288 container_is_floating(view->container)) { 289 new_geo.height != con->content_height) &&
290 container_is_floating(con)) {
289 // A floating view has unexpectedly sent a new size 291 // A floating view has unexpectedly sent a new size
290 desktop_damage_view(view); 292 desktop_damage_view(view);
291 view_update_size(view, new_geo.width, new_geo.height); 293 view_update_size(view, new_geo.width, new_geo.height);
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c
index 0c41d960..1838ad32 100644
--- a/sway/desktop/xwayland.c
+++ b/sway/desktop/xwayland.c
@@ -332,9 +332,11 @@ static void handle_commit(struct wl_listener *listener, void *data) {
332 } else { 332 } else {
333 struct wlr_box new_geo; 333 struct wlr_box new_geo;
334 get_geometry(view, &new_geo); 334 get_geometry(view, &new_geo);
335 struct sway_container *con = view->container;
335 336
336 if ((new_geo.width != view->width || new_geo.height != view->height) && 337 if ((new_geo.width != con->content_width ||
337 container_is_floating(view->container)) { 338 new_geo.height != con->content_height) &&
339 container_is_floating(con)) {
338 // A floating view has unexpectedly sent a new size 340 // A floating view has unexpectedly sent a new size
339 // eg. The Firefox "Save As" dialog when downloading a file 341 // eg. The Firefox "Save As" dialog when downloading a file
340 desktop_damage_view(view); 342 desktop_damage_view(view);
@@ -432,13 +434,13 @@ static void handle_request_configure(struct wl_listener *listener, void *data) {
432 return; 434 return;
433 } 435 }
434 if (container_is_floating(view->container)) { 436 if (container_is_floating(view->container)) {
435 configure(view, view->container->current.view_x, 437 configure(view, view->container->current.content_x,
436 view->container->current.view_y, ev->width, ev->height); 438 view->container->current.content_y, ev->width, ev->height);
437 } else { 439 } else {
438 configure(view, view->container->current.view_x, 440 configure(view, view->container->current.content_x,
439 view->container->current.view_y, 441 view->container->current.content_y,
440 view->container->current.view_width, 442 view->container->current.content_width,
441 view->container->current.view_height); 443 view->container->current.content_height);
442 } 444 }
443} 445}
444 446
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 81b82abc..c81e9ab1 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -348,7 +348,7 @@ static void handle_move_tiling_motion(struct sway_seat *seat,
348 } 348 }
349 349
350 // Find the closest edge 350 // Find the closest edge
351 size_t thickness = fmin(con->view->width, con->view->height) * 0.3; 351 size_t thickness = fmin(con->content_width, con->content_height) * 0.3;
352 size_t closest_dist = INT_MAX; 352 size_t closest_dist = INT_MAX;
353 size_t dist; 353 size_t dist;
354 seat->op_target_edge = WLR_EDGE_NONE; 354 seat->op_target_edge = WLR_EDGE_NONE;
@@ -374,10 +374,10 @@ static void handle_move_tiling_motion(struct sway_seat *seat,
374 } 374 }
375 375
376 seat->op_target_node = node; 376 seat->op_target_node = node;
377 seat->op_drop_box.x = con->view->x; 377 seat->op_drop_box.x = con->content_x;
378 seat->op_drop_box.y = con->view->y; 378 seat->op_drop_box.y = con->content_y;
379 seat->op_drop_box.width = con->view->width; 379 seat->op_drop_box.width = con->content_width;
380 seat->op_drop_box.height = con->view->height; 380 seat->op_drop_box.height = con->content_height;
381 resize_box(&seat->op_drop_box, seat->op_target_edge, thickness); 381 resize_box(&seat->op_drop_box, seat->op_target_edge, thickness);
382 desktop_damage_box(&seat->op_drop_box); 382 desktop_damage_box(&seat->op_drop_box);
383} 383}
@@ -498,13 +498,10 @@ static void handle_resize_floating_motion(struct sway_seat *seat,
498 con->width += relative_grow_width; 498 con->width += relative_grow_width;
499 con->height += relative_grow_height; 499 con->height += relative_grow_height;
500 500
501 if (con->view) { 501 con->content_x += relative_grow_x;
502 struct sway_view *view = con->view; 502 con->content_y += relative_grow_y;
503 view->x += relative_grow_x; 503 con->content_width += relative_grow_width;
504 view->y += relative_grow_y; 504 con->content_height += relative_grow_height;
505 view->width += relative_grow_width;
506 view->height += relative_grow_height;
507 }
508 505
509 arrange_container(con); 506 arrange_container(con);
510} 507}
diff --git a/sway/ipc-json.c b/sway/ipc-json.c
index 4d9a87d8..110b958a 100644
--- a/sway/ipc-json.c
+++ b/sway/ipc-json.c
@@ -246,10 +246,10 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object
246 json_object_object_add(object, "marks", marks); 246 json_object_object_add(object, "marks", marks);
247 247
248 struct wlr_box window_box = { 248 struct wlr_box window_box = {
249 c->view->x - c->x, 249 c->content_x - c->x,
250 (c->current.border == B_PIXEL) ? c->current.border_thickness : 0, 250 (c->current.border == B_PIXEL) ? c->current.border_thickness : 0,
251 c->view->width, 251 c->content_width,
252 c->view->height 252 c->content_height
253 }; 253 };
254 254
255 json_object_object_add(object, "window_rect", ipc_json_create_rect(&window_box)); 255 json_object_object_add(object, "window_rect", ipc_json_create_rect(&window_box));
@@ -258,7 +258,7 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object
258 258
259 if (c->current.border == B_NORMAL) { 259 if (c->current.border == B_NORMAL) {
260 deco_box.width = c->width; 260 deco_box.width = c->width;
261 deco_box.height = c->view->y - c->y; 261 deco_box.height = c->content_y - c->y;
262 } 262 }
263 263
264 json_object_object_add(object, "deco_rect", ipc_json_create_rect(&deco_box)); 264 json_object_object_add(object, "deco_rect", ipc_json_create_rect(&deco_box));
diff --git a/sway/tree/container.c b/sway/tree/container.c
index 3740cb53..89d80e51 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -165,8 +165,8 @@ static struct sway_container *surface_at_view(struct sway_container *con, double
165 return NULL; 165 return NULL;
166 } 166 }
167 struct sway_view *view = con->view; 167 struct sway_view *view = con->view;
168 double view_sx = lx - view->x + view->geometry.x; 168 double view_sx = lx - con->content_x + view->geometry.x;
169 double view_sy = ly - view->y + view->geometry.y; 169 double view_sy = ly - con->content_y + view->geometry.y;
170 170
171 double _sx, _sy; 171 double _sx, _sy;
172 struct wlr_surface *_surface = NULL; 172 struct wlr_surface *_surface = NULL;
@@ -641,16 +641,18 @@ void container_init_floating(struct sway_container *con) {
641 con->y = ws->y + (ws->height - con->height) / 2; 641 con->y = ws->y + (ws->height - con->height) / 2;
642 } else { 642 } else {
643 struct sway_view *view = con->view; 643 struct sway_view *view = con->view;
644 view->width = fmax(min_width, fmin(view->natural_width, max_width)); 644 con->content_width =
645 view->height = fmax(min_height, fmin(view->natural_height, max_height)); 645 fmax(min_width, fmin(view->natural_width, max_width));
646 view->x = ws->x + (ws->width - view->width) / 2; 646 con->content_height =
647 view->y = ws->y + (ws->height - view->height) / 2; 647 fmax(min_height, fmin(view->natural_height, max_height));
648 con->content_x = ws->x + (ws->width - con->content_width) / 2;
649 con->content_y = ws->y + (ws->height - con->content_height) / 2;
648 650
649 // If the view's border is B_NONE then these properties are ignored. 651 // If the view's border is B_NONE then these properties are ignored.
650 con->border_top = con->border_bottom = true; 652 con->border_top = con->border_bottom = true;
651 con->border_left = con->border_right = true; 653 con->border_left = con->border_right = true;
652 654
653 container_set_geometry_from_floating_view(con); 655 container_set_geometry_from_content(con);
654 } 656 }
655} 657}
656 658
@@ -707,14 +709,13 @@ void container_set_floating(struct sway_container *container, bool enable) {
707 ipc_event_window(container, "floating"); 709 ipc_event_window(container, "floating");
708} 710}
709 711
710void container_set_geometry_from_floating_view(struct sway_container *con) { 712void container_set_geometry_from_content(struct sway_container *con) {
711 if (!sway_assert(con->view, "Expected a view")) { 713 if (!sway_assert(con->view, "Expected a view")) {
712 return; 714 return;
713 } 715 }
714 if (!sway_assert(container_is_floating(con), "Expected a floating view")) { 716 if (!sway_assert(container_is_floating(con), "Expected a floating view")) {
715 return; 717 return;
716 } 718 }
717 struct sway_view *view = con->view;
718 size_t border_width = 0; 719 size_t border_width = 0;
719 size_t top = 0; 720 size_t top = 0;
720 721
@@ -724,10 +725,10 @@ void container_set_geometry_from_floating_view(struct sway_container *con) {
724 container_titlebar_height() : border_width; 725 container_titlebar_height() : border_width;
725 } 726 }
726 727
727 con->x = view->x - border_width; 728 con->x = con->content_x - border_width;
728 con->y = view->y - top; 729 con->y = con->content_y - top;
729 con->width = view->width + border_width * 2; 730 con->width = con->content_width + border_width * 2;
730 con->height = top + view->height + border_width; 731 con->height = top + con->content_height + border_width;
731 node_set_dirty(&con->node); 732 node_set_dirty(&con->node);
732} 733}
733 734
@@ -756,15 +757,16 @@ void container_floating_translate(struct sway_container *con,
756 double x_amount, double y_amount) { 757 double x_amount, double y_amount) {
757 con->x += x_amount; 758 con->x += x_amount;
758 con->y += y_amount; 759 con->y += y_amount;
759 if (con->view) { 760 con->content_x += x_amount;
760 con->view->x += x_amount; 761 con->content_y += y_amount;
761 con->view->y += y_amount; 762
762 } else { 763 if (con->children) {
763 for (int i = 0; i < con->children->length; ++i) { 764 for (int i = 0; i < con->children->length; ++i) {
764 struct sway_container *child = con->children->items[i]; 765 struct sway_container *child = con->children->items[i];
765 container_floating_translate(child, x_amount, y_amount); 766 container_floating_translate(child, x_amount, y_amount);
766 } 767 }
767 } 768 }
769
768 node_set_dirty(&con->node); 770 node_set_dirty(&con->node);
769} 771}
770 772
@@ -964,10 +966,10 @@ static void surface_send_leave_iterator(struct wlr_surface *surface,
964 966
965void container_discover_outputs(struct sway_container *con) { 967void container_discover_outputs(struct sway_container *con) {
966 struct wlr_box con_box = { 968 struct wlr_box con_box = {
967 .x = con->current.con_x, 969 .x = con->current.x,
968 .y = con->current.con_y, 970 .y = con->current.y,
969 .width = con->current.con_width, 971 .width = con->current.width,
970 .height = con->current.con_height, 972 .height = con->current.height,
971 }; 973 };
972 struct sway_output *old_output = container_get_effective_output(con); 974 struct sway_output *old_output = container_get_effective_output(con);
973 975
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 21b32649..18195467 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -196,22 +196,22 @@ static bool gaps_to_edge(struct sway_view *view) {
196} 196}
197 197
198void view_autoconfigure(struct sway_view *view) { 198void view_autoconfigure(struct sway_view *view) {
199 if (!view->container->workspace) { 199 struct sway_container *con = view->container;
200 if (!con->workspace) {
200 // Hidden in the scratchpad 201 // Hidden in the scratchpad
201 return; 202 return;
202 } 203 }
203 struct sway_output *output = view->container->workspace->output; 204 struct sway_output *output = con->workspace->output;
204 205
205 if (view->container->is_fullscreen) { 206 if (con->is_fullscreen) {
206 view->x = output->lx; 207 con->content_x = output->lx;
207 view->y = output->ly; 208 con->content_y = output->ly;
208 view->width = output->width; 209 con->content_width = output->width;
209 view->height = output->height; 210 con->content_height = output->height;
210 return; 211 return;
211 } 212 }
212 213
213 struct sway_workspace *ws = view->container->workspace; 214 struct sway_workspace *ws = view->container->workspace;
214 struct sway_container *con = view->container;
215 215
216 bool smart = config->hide_edge_borders == E_SMART || 216 bool smart = config->hide_edge_borders == E_SMART ||
217 config->hide_edge_borders == E_SMART_NO_GAPS; 217 config->hide_edge_borders == E_SMART_NO_GAPS;
@@ -289,10 +289,10 @@ void view_autoconfigure(struct sway_view *view) {
289 break; 289 break;
290 } 290 }
291 291
292 view->x = x; 292 con->content_x = x;
293 view->y = y; 293 con->content_y = y;
294 view->width = width; 294 con->content_width = width;
295 view->height = height; 295 con->content_height = height;
296} 296}
297 297
298void view_set_activated(struct sway_view *view, bool activated) { 298void view_set_activated(struct sway_view *view, bool activated) {
@@ -667,11 +667,11 @@ void view_update_size(struct sway_view *view, int width, int height) {
667 "Expected a floating container")) { 667 "Expected a floating container")) {
668 return; 668 return;
669 } 669 }
670 view->width = width; 670 view->container->content_width = width;
671 view->height = height; 671 view->container->content_height = height;
672 view->container->current.view_width = width; 672 view->container->current.content_width = width;
673 view->container->current.view_height = height; 673 view->container->current.content_height = height;
674 container_set_geometry_from_floating_view(view->container); 674 container_set_geometry_from_content(view->container);
675} 675}
676 676
677static void subsurface_get_root_coords(struct sway_view_child *child, 677static void subsurface_get_root_coords(struct sway_view_child *child,
@@ -707,7 +707,8 @@ static void view_child_damage(struct sway_view_child *child, bool whole) {
707 int sx, sy; 707 int sx, sy;
708 child->impl->get_root_coords(child, &sx, &sy); 708 child->impl->get_root_coords(child, &sx, &sy);
709 desktop_damage_surface(child->surface, 709 desktop_damage_surface(child->surface,
710 child->view->x + sx, child->view->y + sy, whole); 710 child->view->container->content_x + sx,
711 child->view->container->content_y + sy, whole);
711} 712}
712 713
713static void view_child_handle_surface_commit(struct wl_listener *listener, 714static void view_child_handle_surface_commit(struct wl_listener *listener,