summaryrefslogtreecommitdiffstats
path: root/sway/desktop
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 /sway/desktop
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.
Diffstat (limited to 'sway/desktop')
-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
7 files changed, 84 insertions, 80 deletions
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