diff options
Diffstat (limited to 'sway/tree/container.c')
-rw-r--r-- | sway/tree/container.c | 622 |
1 files changed, 329 insertions, 293 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c index 6a9ce1c4..6a01eab3 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -1,12 +1,13 @@ | |||
1 | #define _POSIX_C_SOURCE 200809L | 1 | #define _POSIX_C_SOURCE 200809L |
2 | #include <assert.h> | 2 | #include <assert.h> |
3 | #include <drm_fourcc.h> | ||
3 | #include <stdint.h> | 4 | #include <stdint.h> |
4 | #include <stdlib.h> | 5 | #include <stdlib.h> |
5 | #include <string.h> | 6 | #include <string.h> |
6 | #include <strings.h> | 7 | #include <strings.h> |
7 | #include <wayland-server-core.h> | 8 | #include <wayland-server-core.h> |
8 | #include <wlr/types/wlr_output_layout.h> | 9 | #include <wlr/types/wlr_output_layout.h> |
9 | #include "cairo.h" | 10 | #include "cairo_util.h" |
10 | #include "pango.h" | 11 | #include "pango.h" |
11 | #include "sway/config.h" | 12 | #include "sway/config.h" |
12 | #include "sway/desktop.h" | 13 | #include "sway/desktop.h" |
@@ -19,6 +20,7 @@ | |||
19 | #include "sway/tree/arrange.h" | 20 | #include "sway/tree/arrange.h" |
20 | #include "sway/tree/view.h" | 21 | #include "sway/tree/view.h" |
21 | #include "sway/tree/workspace.h" | 22 | #include "sway/tree/workspace.h" |
23 | #include "sway/xdg_decoration.h" | ||
22 | #include "list.h" | 24 | #include "list.h" |
23 | #include "log.h" | 25 | #include "log.h" |
24 | #include "stringop.h" | 26 | #include "stringop.h" |
@@ -30,12 +32,12 @@ struct sway_container *container_create(struct sway_view *view) { | |||
30 | return NULL; | 32 | return NULL; |
31 | } | 33 | } |
32 | node_init(&c->node, N_CONTAINER, c); | 34 | node_init(&c->node, N_CONTAINER, c); |
33 | c->layout = L_NONE; | 35 | c->pending.layout = L_NONE; |
34 | c->view = view; | 36 | c->view = view; |
35 | c->alpha = 1.0f; | 37 | c->alpha = 1.0f; |
36 | 38 | ||
37 | if (!view) { | 39 | if (!view) { |
38 | c->children = create_list(); | 40 | c->pending.children = create_list(); |
39 | c->current.children = create_list(); | 41 | c->current.children = create_list(); |
40 | } | 42 | } |
41 | c->marks = create_list(); | 43 | c->marks = create_list(); |
@@ -62,7 +64,7 @@ void container_destroy(struct sway_container *con) { | |||
62 | wlr_texture_destroy(con->title_focused_inactive); | 64 | wlr_texture_destroy(con->title_focused_inactive); |
63 | wlr_texture_destroy(con->title_unfocused); | 65 | wlr_texture_destroy(con->title_unfocused); |
64 | wlr_texture_destroy(con->title_urgent); | 66 | wlr_texture_destroy(con->title_urgent); |
65 | list_free(con->children); | 67 | list_free(con->pending.children); |
66 | list_free(con->current.children); | 68 | list_free(con->current.children); |
67 | list_free(con->outputs); | 69 | list_free(con->outputs); |
68 | 70 | ||
@@ -90,10 +92,10 @@ void container_begin_destroy(struct sway_container *con) { | |||
90 | } | 92 | } |
91 | // The workspace must have the fullscreen pointer cleared so that the | 93 | // The workspace must have the fullscreen pointer cleared so that the |
92 | // seat code can find an appropriate new focus. | 94 | // seat code can find an appropriate new focus. |
93 | if (con->fullscreen_mode == FULLSCREEN_WORKSPACE && con->workspace) { | 95 | if (con->pending.fullscreen_mode == FULLSCREEN_WORKSPACE && con->pending.workspace) { |
94 | con->workspace->fullscreen = NULL; | 96 | con->pending.workspace->fullscreen = NULL; |
95 | } | 97 | } |
96 | if (con->scratchpad && con->fullscreen_mode == FULLSCREEN_GLOBAL) { | 98 | if (con->scratchpad && con->pending.fullscreen_mode == FULLSCREEN_GLOBAL) { |
97 | container_fullscreen_disable(con); | 99 | container_fullscreen_disable(con); |
98 | } | 100 | } |
99 | 101 | ||
@@ -108,11 +110,11 @@ void container_begin_destroy(struct sway_container *con) { | |||
108 | root_scratchpad_remove_container(con); | 110 | root_scratchpad_remove_container(con); |
109 | } | 111 | } |
110 | 112 | ||
111 | if (con->fullscreen_mode == FULLSCREEN_GLOBAL) { | 113 | if (con->pending.fullscreen_mode == FULLSCREEN_GLOBAL) { |
112 | container_fullscreen_disable(con); | 114 | container_fullscreen_disable(con); |
113 | } | 115 | } |
114 | 116 | ||
115 | if (con->parent || con->workspace) { | 117 | if (con->pending.parent || con->pending.workspace) { |
116 | container_detach(con); | 118 | container_detach(con); |
117 | } | 119 | } |
118 | } | 120 | } |
@@ -121,12 +123,12 @@ void container_reap_empty(struct sway_container *con) { | |||
121 | if (con->view) { | 123 | if (con->view) { |
122 | return; | 124 | return; |
123 | } | 125 | } |
124 | struct sway_workspace *ws = con->workspace; | 126 | struct sway_workspace *ws = con->pending.workspace; |
125 | while (con) { | 127 | while (con) { |
126 | if (con->children->length) { | 128 | if (con->pending.children->length) { |
127 | return; | 129 | return; |
128 | } | 130 | } |
129 | struct sway_container *parent = con->parent; | 131 | struct sway_container *parent = con->pending.parent; |
130 | container_begin_destroy(con); | 132 | container_begin_destroy(con); |
131 | con = parent; | 133 | con = parent; |
132 | } | 134 | } |
@@ -139,9 +141,9 @@ struct sway_container *container_flatten(struct sway_container *container) { | |||
139 | if (container->view) { | 141 | if (container->view) { |
140 | return NULL; | 142 | return NULL; |
141 | } | 143 | } |
142 | while (container && container->children->length == 1) { | 144 | while (container && container->pending.children->length == 1) { |
143 | struct sway_container *child = container->children->items[0]; | 145 | struct sway_container *child = container->pending.children->items[0]; |
144 | struct sway_container *parent = container->parent; | 146 | struct sway_container *parent = container->pending.parent; |
145 | container_replace(container, child); | 147 | container_replace(container, child); |
146 | container_begin_destroy(container); | 148 | container_begin_destroy(container); |
147 | container = parent; | 149 | container = parent; |
@@ -151,11 +153,11 @@ struct sway_container *container_flatten(struct sway_container *container) { | |||
151 | 153 | ||
152 | struct sway_container *container_find_child(struct sway_container *container, | 154 | struct sway_container *container_find_child(struct sway_container *container, |
153 | bool (*test)(struct sway_container *con, void *data), void *data) { | 155 | bool (*test)(struct sway_container *con, void *data), void *data) { |
154 | if (!container->children) { | 156 | if (!container->pending.children) { |
155 | return NULL; | 157 | return NULL; |
156 | } | 158 | } |
157 | for (int i = 0; i < container->children->length; ++i) { | 159 | for (int i = 0; i < container->pending.children->length; ++i) { |
158 | struct sway_container *child = container->children->items[i]; | 160 | struct sway_container *child = container->pending.children->items[i]; |
159 | if (test(child, data)) { | 161 | if (test(child, data)) { |
160 | return child; | 162 | return child; |
161 | } | 163 | } |
@@ -310,7 +312,7 @@ static struct sway_container *floating_container_at(double lx, double ly, | |||
310 | return NULL; | 312 | return NULL; |
311 | } | 313 | } |
312 | 314 | ||
313 | struct sway_container *view_container_at(struct sway_node *parent, | 315 | static struct sway_container *view_container_content_at(struct sway_node *parent, |
314 | double lx, double ly, | 316 | double lx, double ly, |
315 | struct wlr_surface **surface, double *sx, double *sy) { | 317 | struct wlr_surface **surface, double *sx, double *sy) { |
316 | if (!sway_assert(node_is_view(parent), "Expected a view")) { | 318 | if (!sway_assert(node_is_view(parent), "Expected a view")) { |
@@ -319,10 +321,33 @@ struct sway_container *view_container_at(struct sway_node *parent, | |||
319 | 321 | ||
320 | struct sway_container *container = parent->sway_container; | 322 | struct sway_container *container = parent->sway_container; |
321 | struct wlr_box box = { | 323 | struct wlr_box box = { |
322 | .x = container->x, | 324 | .x = container->pending.content_x, |
323 | .y = container->y, | 325 | .y = container->pending.content_y, |
324 | .width = container->width, | 326 | .width = container->pending.content_width, |
325 | .height = container->height, | 327 | .height = container->pending.content_height, |
328 | }; | ||
329 | |||
330 | if (wlr_box_contains_point(&box, lx, ly)) { | ||
331 | surface_at_view(parent->sway_container, lx, ly, surface, sx, sy); | ||
332 | return container; | ||
333 | } | ||
334 | |||
335 | return NULL; | ||
336 | } | ||
337 | |||
338 | static struct sway_container *view_container_at(struct sway_node *parent, | ||
339 | double lx, double ly, | ||
340 | struct wlr_surface **surface, double *sx, double *sy) { | ||
341 | if (!sway_assert(node_is_view(parent), "Expected a view")) { | ||
342 | return NULL; | ||
343 | } | ||
344 | |||
345 | struct sway_container *container = parent->sway_container; | ||
346 | struct wlr_box box = { | ||
347 | .x = container->pending.x, | ||
348 | .y = container->pending.y, | ||
349 | .width = container->pending.width, | ||
350 | .height = container->pending.height, | ||
326 | }; | 351 | }; |
327 | 352 | ||
328 | if (wlr_box_contains_point(&box, lx, ly)) { | 353 | if (wlr_box_contains_point(&box, lx, ly)) { |
@@ -394,7 +419,7 @@ struct sway_container *container_at(struct sway_workspace *workspace, | |||
394 | } | 419 | } |
395 | // Tiling (focused) | 420 | // Tiling (focused) |
396 | if (focus && focus->view && !is_floating) { | 421 | if (focus && focus->view && !is_floating) { |
397 | if ((c = surface_at_view(focus, lx, ly, surface, sx, sy))) { | 422 | if ((c = view_container_content_at(&focus->node, lx, ly, surface, sx, sy))) { |
398 | return c; | 423 | return c; |
399 | } | 424 | } |
400 | } | 425 | } |
@@ -408,19 +433,41 @@ struct sway_container *container_at(struct sway_workspace *workspace, | |||
408 | void container_for_each_child(struct sway_container *container, | 433 | void container_for_each_child(struct sway_container *container, |
409 | void (*f)(struct sway_container *container, void *data), | 434 | void (*f)(struct sway_container *container, void *data), |
410 | void *data) { | 435 | void *data) { |
411 | if (container->children) { | 436 | if (container->pending.children) { |
412 | for (int i = 0; i < container->children->length; ++i) { | 437 | for (int i = 0; i < container->pending.children->length; ++i) { |
413 | struct sway_container *child = container->children->items[i]; | 438 | struct sway_container *child = container->pending.children->items[i]; |
414 | f(child, data); | 439 | f(child, data); |
415 | container_for_each_child(child, f, data); | 440 | container_for_each_child(child, f, data); |
416 | } | 441 | } |
417 | } | 442 | } |
418 | } | 443 | } |
419 | 444 | ||
445 | struct sway_container *container_obstructing_fullscreen_container(struct sway_container *container) | ||
446 | { | ||
447 | struct sway_workspace *workspace = container->pending.workspace; | ||
448 | |||
449 | if (workspace && workspace->fullscreen && !container_is_fullscreen_or_child(container)) { | ||
450 | if (container_is_transient_for(container, workspace->fullscreen)) { | ||
451 | return NULL; | ||
452 | } | ||
453 | return workspace->fullscreen; | ||
454 | } | ||
455 | |||
456 | struct sway_container *fullscreen_global = root->fullscreen_global; | ||
457 | if (fullscreen_global && container != fullscreen_global && !container_has_ancestor(container, fullscreen_global)) { | ||
458 | if (container_is_transient_for(container, fullscreen_global)) { | ||
459 | return NULL; | ||
460 | } | ||
461 | return fullscreen_global; | ||
462 | } | ||
463 | |||
464 | return NULL; | ||
465 | } | ||
466 | |||
420 | bool container_has_ancestor(struct sway_container *descendant, | 467 | bool container_has_ancestor(struct sway_container *descendant, |
421 | struct sway_container *ancestor) { | 468 | struct sway_container *ancestor) { |
422 | while (descendant) { | 469 | while (descendant) { |
423 | descendant = descendant->parent; | 470 | descendant = descendant->pending.parent; |
424 | if (descendant == ancestor) { | 471 | if (descendant == ancestor) { |
425 | return true; | 472 | return true; |
426 | } | 473 | } |
@@ -446,23 +493,13 @@ struct sway_output *container_get_effective_output(struct sway_container *con) { | |||
446 | return con->outputs->items[con->outputs->length - 1]; | 493 | return con->outputs->items[con->outputs->length - 1]; |
447 | } | 494 | } |
448 | 495 | ||
449 | static void update_title_texture(struct sway_container *con, | 496 | static void render_titlebar_text_texture(struct sway_output *output, |
450 | struct wlr_texture **texture, struct border_colors *class) { | 497 | struct sway_container *con, struct wlr_texture **texture, |
451 | struct sway_output *output = container_get_effective_output(con); | 498 | struct border_colors *class, bool pango_markup, char *text) { |
452 | if (!output) { | ||
453 | return; | ||
454 | } | ||
455 | if (*texture) { | ||
456 | wlr_texture_destroy(*texture); | ||
457 | *texture = NULL; | ||
458 | } | ||
459 | if (!con->formatted_title) { | ||
460 | return; | ||
461 | } | ||
462 | |||
463 | double scale = output->wlr_output->scale; | 499 | double scale = output->wlr_output->scale; |
464 | int width = 0; | 500 | int width = 0; |
465 | int height = con->title_height * scale; | 501 | int height = config->font_height * scale; |
502 | int baseline; | ||
466 | 503 | ||
467 | // We must use a non-nil cairo_t for cairo_set_font_options to work. | 504 | // We must use a non-nil cairo_t for cairo_set_font_options to work. |
468 | // Therefore, we cannot use cairo_create(NULL). | 505 | // Therefore, we cannot use cairo_create(NULL). |
@@ -480,11 +517,19 @@ static void update_title_texture(struct sway_container *con, | |||
480 | to_cairo_subpixel_order(output->wlr_output->subpixel)); | 517 | to_cairo_subpixel_order(output->wlr_output->subpixel)); |
481 | } | 518 | } |
482 | cairo_set_font_options(c, fo); | 519 | cairo_set_font_options(c, fo); |
483 | get_text_size(c, config->font, &width, NULL, NULL, scale, | 520 | get_text_size(c, config->font, &width, NULL, &baseline, scale, |
484 | config->pango_markup, "%s", con->formatted_title); | 521 | config->pango_markup, "%s", text); |
485 | cairo_surface_destroy(dummy_surface); | 522 | cairo_surface_destroy(dummy_surface); |
486 | cairo_destroy(c); | 523 | cairo_destroy(c); |
487 | 524 | ||
525 | if (width == 0 || height == 0) { | ||
526 | return; | ||
527 | } | ||
528 | |||
529 | if (height > config->font_height * scale) { | ||
530 | height = config->font_height * scale; | ||
531 | } | ||
532 | |||
488 | cairo_surface_t *surface = cairo_image_surface_create( | 533 | cairo_surface_t *surface = cairo_image_surface_create( |
489 | CAIRO_FORMAT_ARGB32, width, height); | 534 | CAIRO_FORMAT_ARGB32, width, height); |
490 | cairo_t *cairo = cairo_create(surface); | 535 | cairo_t *cairo = cairo_create(surface); |
@@ -497,23 +542,40 @@ static void update_title_texture(struct sway_container *con, | |||
497 | PangoContext *pango = pango_cairo_create_context(cairo); | 542 | PangoContext *pango = pango_cairo_create_context(cairo); |
498 | cairo_set_source_rgba(cairo, class->text[0], class->text[1], | 543 | cairo_set_source_rgba(cairo, class->text[0], class->text[1], |
499 | class->text[2], class->text[3]); | 544 | class->text[2], class->text[3]); |
500 | cairo_move_to(cairo, 0, 0); | 545 | cairo_move_to(cairo, 0, config->font_baseline * scale - baseline); |
501 | 546 | ||
502 | pango_printf(cairo, config->font, scale, config->pango_markup, | 547 | render_text(cairo, config->font, scale, pango_markup, "%s", text); |
503 | "%s", con->formatted_title); | ||
504 | 548 | ||
505 | cairo_surface_flush(surface); | 549 | cairo_surface_flush(surface); |
506 | unsigned char *data = cairo_image_surface_get_data(surface); | 550 | unsigned char *data = cairo_image_surface_get_data(surface); |
507 | int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width); | 551 | int stride = cairo_image_surface_get_stride(surface); |
508 | struct wlr_renderer *renderer = wlr_backend_get_renderer( | 552 | struct wlr_renderer *renderer = wlr_backend_get_renderer( |
509 | output->wlr_output->backend); | 553 | output->wlr_output->backend); |
510 | *texture = wlr_texture_from_pixels( | 554 | *texture = wlr_texture_from_pixels( |
511 | renderer, WL_SHM_FORMAT_ARGB8888, stride, width, height, data); | 555 | renderer, DRM_FORMAT_ARGB8888, stride, width, height, data); |
512 | cairo_surface_destroy(surface); | 556 | cairo_surface_destroy(surface); |
513 | g_object_unref(pango); | 557 | g_object_unref(pango); |
514 | cairo_destroy(cairo); | 558 | cairo_destroy(cairo); |
515 | } | 559 | } |
516 | 560 | ||
561 | static void update_title_texture(struct sway_container *con, | ||
562 | struct wlr_texture **texture, struct border_colors *class) { | ||
563 | struct sway_output *output = container_get_effective_output(con); | ||
564 | if (!output) { | ||
565 | return; | ||
566 | } | ||
567 | if (*texture) { | ||
568 | wlr_texture_destroy(*texture); | ||
569 | *texture = NULL; | ||
570 | } | ||
571 | if (!con->formatted_title) { | ||
572 | return; | ||
573 | } | ||
574 | |||
575 | render_titlebar_text_texture(output, con, texture, class, | ||
576 | config->pango_markup, con->formatted_title); | ||
577 | } | ||
578 | |||
517 | void container_update_title_textures(struct sway_container *container) { | 579 | void container_update_title_textures(struct sway_container *container) { |
518 | update_title_texture(container, &container->title_focused, | 580 | update_title_texture(container, &container->title_focused, |
519 | &config->border_colors.focused); | 581 | &config->border_colors.focused); |
@@ -526,21 +588,6 @@ void container_update_title_textures(struct sway_container *container) { | |||
526 | container_damage_whole(container); | 588 | container_damage_whole(container); |
527 | } | 589 | } |
528 | 590 | ||
529 | void container_calculate_title_height(struct sway_container *container) { | ||
530 | if (!container->formatted_title) { | ||
531 | container->title_height = 0; | ||
532 | return; | ||
533 | } | ||
534 | cairo_t *cairo = cairo_create(NULL); | ||
535 | int height; | ||
536 | int baseline; | ||
537 | get_text_size(cairo, config->font, NULL, &height, &baseline, 1, | ||
538 | config->pango_markup, "%s", container->formatted_title); | ||
539 | cairo_destroy(cairo); | ||
540 | container->title_height = height; | ||
541 | container->title_baseline = baseline; | ||
542 | } | ||
543 | |||
544 | /** | 591 | /** |
545 | * Calculate and return the length of the tree representation. | 592 | * Calculate and return the length of the tree representation. |
546 | * An example tree representation is: V[Terminal, Firefox] | 593 | * An example tree representation is: V[Terminal, Firefox] |
@@ -596,23 +643,22 @@ size_t container_build_representation(enum sway_container_layout layout, | |||
596 | 643 | ||
597 | void container_update_representation(struct sway_container *con) { | 644 | void container_update_representation(struct sway_container *con) { |
598 | if (!con->view) { | 645 | if (!con->view) { |
599 | size_t len = container_build_representation(con->layout, | 646 | size_t len = container_build_representation(con->pending.layout, |
600 | con->children, NULL); | 647 | con->pending.children, NULL); |
601 | free(con->formatted_title); | 648 | free(con->formatted_title); |
602 | con->formatted_title = calloc(len + 1, sizeof(char)); | 649 | con->formatted_title = calloc(len + 1, sizeof(char)); |
603 | if (!sway_assert(con->formatted_title, | 650 | if (!sway_assert(con->formatted_title, |
604 | "Unable to allocate title string")) { | 651 | "Unable to allocate title string")) { |
605 | return; | 652 | return; |
606 | } | 653 | } |
607 | container_build_representation(con->layout, con->children, | 654 | container_build_representation(con->pending.layout, con->pending.children, |
608 | con->formatted_title); | 655 | con->formatted_title); |
609 | container_calculate_title_height(con); | ||
610 | container_update_title_textures(con); | 656 | container_update_title_textures(con); |
611 | } | 657 | } |
612 | if (con->parent) { | 658 | if (con->pending.parent) { |
613 | container_update_representation(con->parent); | 659 | container_update_representation(con->pending.parent); |
614 | } else if (con->workspace) { | 660 | } else if (con->pending.workspace) { |
615 | workspace_update_representation(con->workspace); | 661 | workspace_update_representation(con->pending.workspace); |
616 | } | 662 | } |
617 | } | 663 | } |
618 | 664 | ||
@@ -663,20 +709,20 @@ static void floating_natural_resize(struct sway_container *con) { | |||
663 | floating_calculate_constraints(&min_width, &max_width, | 709 | floating_calculate_constraints(&min_width, &max_width, |
664 | &min_height, &max_height); | 710 | &min_height, &max_height); |
665 | if (!con->view) { | 711 | if (!con->view) { |
666 | con->width = fmax(min_width, fmin(con->width, max_width)); | 712 | con->pending.width = fmax(min_width, fmin(con->pending.width, max_width)); |
667 | con->height = fmax(min_height, fmin(con->height, max_height)); | 713 | con->pending.height = fmax(min_height, fmin(con->pending.height, max_height)); |
668 | } else { | 714 | } else { |
669 | struct sway_view *view = con->view; | 715 | struct sway_view *view = con->view; |
670 | con->content_width = | 716 | con->pending.content_width = |
671 | fmax(min_width, fmin(view->natural_width, max_width)); | 717 | fmax(min_width, fmin(view->natural_width, max_width)); |
672 | con->content_height = | 718 | con->pending.content_height = |
673 | fmax(min_height, fmin(view->natural_height, max_height)); | 719 | fmax(min_height, fmin(view->natural_height, max_height)); |
674 | container_set_geometry_from_content(con); | 720 | container_set_geometry_from_content(con); |
675 | } | 721 | } |
676 | } | 722 | } |
677 | 723 | ||
678 | void container_floating_resize_and_center(struct sway_container *con) { | 724 | void container_floating_resize_and_center(struct sway_container *con) { |
679 | struct sway_workspace *ws = con->workspace; | 725 | struct sway_workspace *ws = con->pending.workspace; |
680 | if (!ws) { | 726 | if (!ws) { |
681 | // On scratchpad, just resize | 727 | // On scratchpad, just resize |
682 | floating_natural_resize(con); | 728 | floating_natural_resize(con); |
@@ -687,42 +733,42 @@ void container_floating_resize_and_center(struct sway_container *con) { | |||
687 | ws->output->wlr_output); | 733 | ws->output->wlr_output); |
688 | if (!ob) { | 734 | if (!ob) { |
689 | // On NOOP output. Will be called again when moved to an output | 735 | // On NOOP output. Will be called again when moved to an output |
690 | con->x = 0; | 736 | con->pending.x = 0; |
691 | con->y = 0; | 737 | con->pending.y = 0; |
692 | con->width = 0; | 738 | con->pending.width = 0; |
693 | con->height = 0; | 739 | con->pending.height = 0; |
694 | return; | 740 | return; |
695 | } | 741 | } |
696 | 742 | ||
697 | floating_natural_resize(con); | 743 | floating_natural_resize(con); |
698 | if (!con->view) { | 744 | if (!con->view) { |
699 | if (con->width > ws->width || con->height > ws->height) { | 745 | if (con->pending.width > ws->width || con->pending.height > ws->height) { |
700 | con->x = ob->x + (ob->width - con->width) / 2; | 746 | con->pending.x = ob->x + (ob->width - con->pending.width) / 2; |
701 | con->y = ob->y + (ob->height - con->height) / 2; | 747 | con->pending.y = ob->y + (ob->height - con->pending.height) / 2; |
702 | } else { | 748 | } else { |
703 | con->x = ws->x + (ws->width - con->width) / 2; | 749 | con->pending.x = ws->x + (ws->width - con->pending.width) / 2; |
704 | con->y = ws->y + (ws->height - con->height) / 2; | 750 | con->pending.y = ws->y + (ws->height - con->pending.height) / 2; |
705 | } | 751 | } |
706 | } else { | 752 | } else { |
707 | if (con->content_width > ws->width | 753 | if (con->pending.content_width > ws->width |
708 | || con->content_height > ws->height) { | 754 | || con->pending.content_height > ws->height) { |
709 | con->content_x = ob->x + (ob->width - con->content_width) / 2; | 755 | con->pending.content_x = ob->x + (ob->width - con->pending.content_width) / 2; |
710 | con->content_y = ob->y + (ob->height - con->content_height) / 2; | 756 | con->pending.content_y = ob->y + (ob->height - con->pending.content_height) / 2; |
711 | } else { | 757 | } else { |
712 | con->content_x = ws->x + (ws->width - con->content_width) / 2; | 758 | con->pending.content_x = ws->x + (ws->width - con->pending.content_width) / 2; |
713 | con->content_y = ws->y + (ws->height - con->content_height) / 2; | 759 | con->pending.content_y = ws->y + (ws->height - con->pending.content_height) / 2; |
714 | } | 760 | } |
715 | 761 | ||
716 | // If the view's border is B_NONE then these properties are ignored. | 762 | // If the view's border is B_NONE then these properties are ignored. |
717 | con->border_top = con->border_bottom = true; | 763 | con->pending.border_top = con->pending.border_bottom = true; |
718 | con->border_left = con->border_right = true; | 764 | con->pending.border_left = con->pending.border_right = true; |
719 | 765 | ||
720 | container_set_geometry_from_content(con); | 766 | container_set_geometry_from_content(con); |
721 | } | 767 | } |
722 | } | 768 | } |
723 | 769 | ||
724 | void container_floating_set_default_size(struct sway_container *con) { | 770 | void container_floating_set_default_size(struct sway_container *con) { |
725 | if (!sway_assert(con->workspace, "Expected a container on a workspace")) { | 771 | if (!sway_assert(con->pending.workspace, "Expected a container on a workspace")) { |
726 | return; | 772 | return; |
727 | } | 773 | } |
728 | 774 | ||
@@ -730,16 +776,16 @@ void container_floating_set_default_size(struct sway_container *con) { | |||
730 | floating_calculate_constraints(&min_width, &max_width, | 776 | floating_calculate_constraints(&min_width, &max_width, |
731 | &min_height, &max_height); | 777 | &min_height, &max_height); |
732 | struct wlr_box *box = calloc(1, sizeof(struct wlr_box)); | 778 | struct wlr_box *box = calloc(1, sizeof(struct wlr_box)); |
733 | workspace_get_box(con->workspace, box); | 779 | workspace_get_box(con->pending.workspace, box); |
734 | 780 | ||
735 | double width = fmax(min_width, fmin(box->width * 0.5, max_width)); | 781 | double width = fmax(min_width, fmin(box->width * 0.5, max_width)); |
736 | double height = fmax(min_height, fmin(box->height * 0.75, max_height)); | 782 | double height = fmax(min_height, fmin(box->height * 0.75, max_height)); |
737 | if (!con->view) { | 783 | if (!con->view) { |
738 | con->width = width; | 784 | con->pending.width = width; |
739 | con->height = height; | 785 | con->pending.height = height; |
740 | } else { | 786 | } else { |
741 | con->content_width = width; | 787 | con->pending.content_width = width; |
742 | con->content_height = height; | 788 | con->pending.content_height = height; |
743 | container_set_geometry_from_content(con); | 789 | container_set_geometry_from_content(con); |
744 | } | 790 | } |
745 | 791 | ||
@@ -761,8 +807,8 @@ void container_set_resizing(struct sway_container *con, bool resizing) { | |||
761 | con->view->impl->set_resizing(con->view, resizing); | 807 | con->view->impl->set_resizing(con->view, resizing); |
762 | } | 808 | } |
763 | } else { | 809 | } else { |
764 | for (int i = 0; i < con->children->length; ++i ) { | 810 | for (int i = 0; i < con->pending.children->length; ++i ) { |
765 | struct sway_container *child = con->children->items[i]; | 811 | struct sway_container *child = con->pending.children->items[i]; |
766 | container_set_resizing(child, resizing); | 812 | container_set_resizing(child, resizing); |
767 | } | 813 | } |
768 | } | 814 | } |
@@ -774,21 +820,33 @@ void container_set_floating(struct sway_container *container, bool enable) { | |||
774 | } | 820 | } |
775 | 821 | ||
776 | struct sway_seat *seat = input_manager_current_seat(); | 822 | struct sway_seat *seat = input_manager_current_seat(); |
777 | struct sway_workspace *workspace = container->workspace; | 823 | struct sway_workspace *workspace = container->pending.workspace; |
824 | struct sway_container *focus = seat_get_focused_container(seat); | ||
825 | bool set_focus = focus == container; | ||
778 | 826 | ||
779 | if (enable) { | 827 | if (enable) { |
780 | struct sway_container *old_parent = container->parent; | 828 | struct sway_container *old_parent = container->pending.parent; |
781 | container_detach(container); | 829 | container_detach(container); |
782 | workspace_add_floating(workspace, container); | 830 | workspace_add_floating(workspace, container); |
783 | if (container->view) { | 831 | if (container->view) { |
784 | view_set_tiled(container->view, false); | 832 | view_set_tiled(container->view, false); |
785 | if (container->view->using_csd) { | 833 | if (container->view->using_csd) { |
786 | container->border = B_CSD; | 834 | container->saved_border = container->pending.border; |
835 | container->pending.border = B_CSD; | ||
836 | if (container->view->xdg_decoration) { | ||
837 | struct sway_xdg_decoration *deco = container->view->xdg_decoration; | ||
838 | wlr_xdg_toplevel_decoration_v1_set_mode(deco->wlr_xdg_decoration, | ||
839 | WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE); | ||
840 | } | ||
787 | } | 841 | } |
788 | } | 842 | } |
789 | container_floating_set_default_size(container); | 843 | container_floating_set_default_size(container); |
790 | container_floating_resize_and_center(container); | 844 | container_floating_resize_and_center(container); |
791 | if (old_parent) { | 845 | if (old_parent) { |
846 | if (set_focus) { | ||
847 | seat_set_raw_focus(seat, &old_parent->node); | ||
848 | seat_set_raw_focus(seat, &container->node); | ||
849 | } | ||
792 | container_reap_empty(old_parent); | 850 | container_reap_empty(old_parent); |
793 | } | 851 | } |
794 | } else { | 852 | } else { |
@@ -800,19 +858,28 @@ void container_set_floating(struct sway_container *container, bool enable) { | |||
800 | struct sway_container *reference = | 858 | struct sway_container *reference = |
801 | seat_get_focus_inactive_tiling(seat, workspace); | 859 | seat_get_focus_inactive_tiling(seat, workspace); |
802 | if (reference) { | 860 | if (reference) { |
803 | container_add_sibling(reference, container, 1); | 861 | if (reference->view) { |
804 | container->width = reference->width; | 862 | container_add_sibling(reference, container, 1); |
805 | container->height = reference->height; | 863 | } else { |
864 | container_add_child(reference, container); | ||
865 | } | ||
866 | container->pending.width = reference->pending.width; | ||
867 | container->pending.height = reference->pending.height; | ||
806 | } else { | 868 | } else { |
807 | struct sway_container *other = | 869 | struct sway_container *other = |
808 | workspace_add_tiling(workspace, container); | 870 | workspace_add_tiling(workspace, container); |
809 | other->width = workspace->width; | 871 | other->pending.width = workspace->width; |
810 | other->height = workspace->height; | 872 | other->pending.height = workspace->height; |
811 | } | 873 | } |
812 | if (container->view) { | 874 | if (container->view) { |
813 | view_set_tiled(container->view, true); | 875 | view_set_tiled(container->view, true); |
814 | if (container->view->using_csd) { | 876 | if (container->view->using_csd) { |
815 | container->border = container->saved_border; | 877 | container->pending.border = container->saved_border; |
878 | if (container->view->xdg_decoration) { | ||
879 | struct sway_xdg_decoration *deco = container->view->xdg_decoration; | ||
880 | wlr_xdg_toplevel_decoration_v1_set_mode(deco->wlr_xdg_decoration, | ||
881 | WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE); | ||
882 | } | ||
816 | } | 883 | } |
817 | } | 884 | } |
818 | container->width_fraction = 0; | 885 | container->width_fraction = 0; |
@@ -834,22 +901,33 @@ void container_set_geometry_from_content(struct sway_container *con) { | |||
834 | size_t border_width = 0; | 901 | size_t border_width = 0; |
835 | size_t top = 0; | 902 | size_t top = 0; |
836 | 903 | ||
837 | if (con->border != B_CSD) { | 904 | if (con->pending.border != B_CSD && !con->pending.fullscreen_mode) { |
838 | border_width = con->border_thickness * (con->border != B_NONE); | 905 | border_width = con->pending.border_thickness * (con->pending.border != B_NONE); |
839 | top = con->border == B_NORMAL ? | 906 | top = con->pending.border == B_NORMAL ? |
840 | container_titlebar_height() : border_width; | 907 | container_titlebar_height() : border_width; |
841 | } | 908 | } |
842 | 909 | ||
843 | con->x = con->content_x - border_width; | 910 | con->pending.x = con->pending.content_x - border_width; |
844 | con->y = con->content_y - top; | 911 | con->pending.y = con->pending.content_y - top; |
845 | con->width = con->content_width + border_width * 2; | 912 | con->pending.width = con->pending.content_width + border_width * 2; |
846 | con->height = top + con->content_height + border_width; | 913 | con->pending.height = top + con->pending.content_height + border_width; |
847 | node_set_dirty(&con->node); | 914 | node_set_dirty(&con->node); |
848 | } | 915 | } |
849 | 916 | ||
850 | bool container_is_floating(struct sway_container *container) { | 917 | bool container_is_floating(struct sway_container *container) { |
851 | if (!container->parent && container->workspace && | 918 | if (!container->pending.parent && container->pending.workspace && |
852 | list_find(container->workspace->floating, container) != -1) { | 919 | list_find(container->pending.workspace->floating, container) != -1) { |
920 | return true; | ||
921 | } | ||
922 | if (container->scratchpad) { | ||
923 | return true; | ||
924 | } | ||
925 | return false; | ||
926 | } | ||
927 | |||
928 | bool container_is_current_floating(struct sway_container *container) { | ||
929 | if (!container->current.parent && container->current.workspace && | ||
930 | list_find(container->current.workspace->floating, container) != -1) { | ||
853 | return true; | 931 | return true; |
854 | } | 932 | } |
855 | if (container->scratchpad) { | 933 | if (container->scratchpad) { |
@@ -859,10 +937,10 @@ bool container_is_floating(struct sway_container *container) { | |||
859 | } | 937 | } |
860 | 938 | ||
861 | void container_get_box(struct sway_container *container, struct wlr_box *box) { | 939 | void container_get_box(struct sway_container *container, struct wlr_box *box) { |
862 | box->x = container->x; | 940 | box->x = container->pending.x; |
863 | box->y = container->y; | 941 | box->y = container->pending.y; |
864 | box->width = container->width; | 942 | box->width = container->pending.width; |
865 | box->height = container->height; | 943 | box->height = container->pending.height; |
866 | } | 944 | } |
867 | 945 | ||
868 | /** | 946 | /** |
@@ -870,14 +948,14 @@ void container_get_box(struct sway_container *container, struct wlr_box *box) { | |||
870 | */ | 948 | */ |
871 | void container_floating_translate(struct sway_container *con, | 949 | void container_floating_translate(struct sway_container *con, |
872 | double x_amount, double y_amount) { | 950 | double x_amount, double y_amount) { |
873 | con->x += x_amount; | 951 | con->pending.x += x_amount; |
874 | con->y += y_amount; | 952 | con->pending.y += y_amount; |
875 | con->content_x += x_amount; | 953 | con->pending.content_x += x_amount; |
876 | con->content_y += y_amount; | 954 | con->pending.content_y += y_amount; |
877 | 955 | ||
878 | if (con->children) { | 956 | if (con->pending.children) { |
879 | for (int i = 0; i < con->children->length; ++i) { | 957 | for (int i = 0; i < con->pending.children->length; ++i) { |
880 | struct sway_container *child = con->children->items[i]; | 958 | struct sway_container *child = con->pending.children->items[i]; |
881 | container_floating_translate(child, x_amount, y_amount); | 959 | container_floating_translate(child, x_amount, y_amount); |
882 | } | 960 | } |
883 | } | 961 | } |
@@ -893,8 +971,8 @@ void container_floating_translate(struct sway_container *con, | |||
893 | * center. | 971 | * center. |
894 | */ | 972 | */ |
895 | struct sway_output *container_floating_find_output(struct sway_container *con) { | 973 | struct sway_output *container_floating_find_output(struct sway_container *con) { |
896 | double center_x = con->x + con->width / 2; | 974 | double center_x = con->pending.x + con->pending.width / 2; |
897 | double center_y = con->y + con->height / 2; | 975 | double center_y = con->pending.y + con->pending.height / 2; |
898 | struct sway_output *closest_output = NULL; | 976 | struct sway_output *closest_output = NULL; |
899 | double closest_distance = DBL_MAX; | 977 | double closest_distance = DBL_MAX; |
900 | for (int i = 0; i < root->outputs->length; ++i) { | 978 | for (int i = 0; i < root->outputs->length; ++i) { |
@@ -925,11 +1003,11 @@ void container_floating_move_to(struct sway_container *con, | |||
925 | "Expected a floating container")) { | 1003 | "Expected a floating container")) { |
926 | return; | 1004 | return; |
927 | } | 1005 | } |
928 | container_floating_translate(con, lx - con->x, ly - con->y); | 1006 | container_floating_translate(con, lx - con->pending.x, ly - con->pending.y); |
929 | if (container_is_scratchpad_hidden(con)) { | 1007 | if (container_is_scratchpad_hidden(con)) { |
930 | return; | 1008 | return; |
931 | } | 1009 | } |
932 | struct sway_workspace *old_workspace = con->workspace; | 1010 | struct sway_workspace *old_workspace = con->pending.workspace; |
933 | struct sway_output *new_output = container_floating_find_output(con); | 1011 | struct sway_output *new_output = container_floating_find_output(con); |
934 | if (!sway_assert(new_output, "Unable to find any output")) { | 1012 | if (!sway_assert(new_output, "Unable to find any output")) { |
935 | return; | 1013 | return; |
@@ -951,10 +1029,10 @@ void container_floating_move_to_center(struct sway_container *con) { | |||
951 | "Expected a floating container")) { | 1029 | "Expected a floating container")) { |
952 | return; | 1030 | return; |
953 | } | 1031 | } |
954 | struct sway_workspace *ws = con->workspace; | 1032 | struct sway_workspace *ws = con->pending.workspace; |
955 | double new_lx = ws->x + (ws->width - con->width) / 2; | 1033 | double new_lx = ws->x + (ws->width - con->pending.width) / 2; |
956 | double new_ly = ws->y + (ws->height - con->height) / 2; | 1034 | double new_ly = ws->y + (ws->height - con->pending.height) / 2; |
957 | container_floating_translate(con, new_lx - con->x, new_ly - con->y); | 1035 | container_floating_translate(con, new_lx - con->pending.x, new_ly - con->pending.y); |
958 | } | 1036 | } |
959 | 1037 | ||
960 | static bool find_urgent_iterator(struct sway_container *con, void *data) { | 1038 | static bool find_urgent_iterator(struct sway_container *con, void *data) { |
@@ -972,42 +1050,39 @@ void container_end_mouse_operation(struct sway_container *container) { | |||
972 | } | 1050 | } |
973 | } | 1051 | } |
974 | 1052 | ||
975 | static void set_fullscreen_iterator(struct sway_container *con, void *data) { | 1053 | static void set_fullscreen(struct sway_container *con, bool enable) { |
976 | if (!con->view) { | 1054 | if (!con->view) { |
977 | return; | 1055 | return; |
978 | } | 1056 | } |
979 | if (con->view->impl->set_fullscreen) { | 1057 | if (con->view->impl->set_fullscreen) { |
980 | bool *enable = data; | 1058 | con->view->impl->set_fullscreen(con->view, enable); |
981 | con->view->impl->set_fullscreen(con->view, *enable); | ||
982 | if (con->view->foreign_toplevel) { | 1059 | if (con->view->foreign_toplevel) { |
983 | wlr_foreign_toplevel_handle_v1_set_fullscreen( | 1060 | wlr_foreign_toplevel_handle_v1_set_fullscreen( |
984 | con->view->foreign_toplevel, *enable); | 1061 | con->view->foreign_toplevel, enable); |
985 | } | 1062 | } |
986 | } | 1063 | } |
987 | } | 1064 | } |
988 | 1065 | ||
989 | static void container_fullscreen_workspace(struct sway_container *con) { | 1066 | static void container_fullscreen_workspace(struct sway_container *con) { |
990 | if (!sway_assert(con->fullscreen_mode == FULLSCREEN_NONE, | 1067 | if (!sway_assert(con->pending.fullscreen_mode == FULLSCREEN_NONE, |
991 | "Expected a non-fullscreen container")) { | 1068 | "Expected a non-fullscreen container")) { |
992 | return; | 1069 | return; |
993 | } | 1070 | } |
994 | bool enable = true; | 1071 | set_fullscreen(con, true); |
995 | set_fullscreen_iterator(con, &enable); | 1072 | con->pending.fullscreen_mode = FULLSCREEN_WORKSPACE; |
996 | container_for_each_child(con, set_fullscreen_iterator, &enable); | ||
997 | con->fullscreen_mode = FULLSCREEN_WORKSPACE; | ||
998 | 1073 | ||
999 | con->saved_x = con->x; | 1074 | con->saved_x = con->pending.x; |
1000 | con->saved_y = con->y; | 1075 | con->saved_y = con->pending.y; |
1001 | con->saved_width = con->width; | 1076 | con->saved_width = con->pending.width; |
1002 | con->saved_height = con->height; | 1077 | con->saved_height = con->pending.height; |
1003 | 1078 | ||
1004 | if (con->workspace) { | 1079 | if (con->pending.workspace) { |
1005 | con->workspace->fullscreen = con; | 1080 | con->pending.workspace->fullscreen = con; |
1006 | struct sway_seat *seat; | 1081 | struct sway_seat *seat; |
1007 | struct sway_workspace *focus_ws; | 1082 | struct sway_workspace *focus_ws; |
1008 | wl_list_for_each(seat, &server.input->seats, link) { | 1083 | wl_list_for_each(seat, &server.input->seats, link) { |
1009 | focus_ws = seat_get_focused_workspace(seat); | 1084 | focus_ws = seat_get_focused_workspace(seat); |
1010 | if (focus_ws == con->workspace) { | 1085 | if (focus_ws == con->pending.workspace) { |
1011 | seat_set_focus_container(seat, con); | 1086 | seat_set_focus_container(seat, con); |
1012 | } else { | 1087 | } else { |
1013 | struct sway_node *focus = | 1088 | struct sway_node *focus = |
@@ -1023,19 +1098,17 @@ static void container_fullscreen_workspace(struct sway_container *con) { | |||
1023 | } | 1098 | } |
1024 | 1099 | ||
1025 | static void container_fullscreen_global(struct sway_container *con) { | 1100 | static void container_fullscreen_global(struct sway_container *con) { |
1026 | if (!sway_assert(con->fullscreen_mode == FULLSCREEN_NONE, | 1101 | if (!sway_assert(con->pending.fullscreen_mode == FULLSCREEN_NONE, |
1027 | "Expected a non-fullscreen container")) { | 1102 | "Expected a non-fullscreen container")) { |
1028 | return; | 1103 | return; |
1029 | } | 1104 | } |
1030 | bool enable = true; | 1105 | set_fullscreen(con, true); |
1031 | set_fullscreen_iterator(con, &enable); | ||
1032 | container_for_each_child(con, set_fullscreen_iterator, &enable); | ||
1033 | 1106 | ||
1034 | root->fullscreen_global = con; | 1107 | root->fullscreen_global = con; |
1035 | con->saved_x = con->x; | 1108 | con->saved_x = con->pending.x; |
1036 | con->saved_y = con->y; | 1109 | con->saved_y = con->pending.y; |
1037 | con->saved_width = con->width; | 1110 | con->saved_width = con->pending.width; |
1038 | con->saved_height = con->height; | 1111 | con->saved_height = con->pending.height; |
1039 | 1112 | ||
1040 | struct sway_seat *seat; | 1113 | struct sway_seat *seat; |
1041 | wl_list_for_each(seat, &server.input->seats, link) { | 1114 | wl_list_for_each(seat, &server.input->seats, link) { |
@@ -1045,34 +1118,32 @@ static void container_fullscreen_global(struct sway_container *con) { | |||
1045 | } | 1118 | } |
1046 | } | 1119 | } |
1047 | 1120 | ||
1048 | con->fullscreen_mode = FULLSCREEN_GLOBAL; | 1121 | con->pending.fullscreen_mode = FULLSCREEN_GLOBAL; |
1049 | container_end_mouse_operation(con); | 1122 | container_end_mouse_operation(con); |
1050 | ipc_event_window(con, "fullscreen_mode"); | 1123 | ipc_event_window(con, "fullscreen_mode"); |
1051 | } | 1124 | } |
1052 | 1125 | ||
1053 | void container_fullscreen_disable(struct sway_container *con) { | 1126 | void container_fullscreen_disable(struct sway_container *con) { |
1054 | if (!sway_assert(con->fullscreen_mode != FULLSCREEN_NONE, | 1127 | if (!sway_assert(con->pending.fullscreen_mode != FULLSCREEN_NONE, |
1055 | "Expected a fullscreen container")) { | 1128 | "Expected a fullscreen container")) { |
1056 | return; | 1129 | return; |
1057 | } | 1130 | } |
1058 | bool enable = false; | 1131 | set_fullscreen(con, false); |
1059 | set_fullscreen_iterator(con, &enable); | ||
1060 | container_for_each_child(con, set_fullscreen_iterator, &enable); | ||
1061 | 1132 | ||
1062 | if (container_is_floating(con)) { | 1133 | if (container_is_floating(con)) { |
1063 | con->x = con->saved_x; | 1134 | con->pending.x = con->saved_x; |
1064 | con->y = con->saved_y; | 1135 | con->pending.y = con->saved_y; |
1065 | con->width = con->saved_width; | 1136 | con->pending.width = con->saved_width; |
1066 | con->height = con->saved_height; | 1137 | con->pending.height = con->saved_height; |
1067 | } | 1138 | } |
1068 | 1139 | ||
1069 | if (con->fullscreen_mode == FULLSCREEN_WORKSPACE) { | 1140 | if (con->pending.fullscreen_mode == FULLSCREEN_WORKSPACE) { |
1070 | if (con->workspace) { | 1141 | if (con->pending.workspace) { |
1071 | con->workspace->fullscreen = NULL; | 1142 | con->pending.workspace->fullscreen = NULL; |
1072 | if (container_is_floating(con)) { | 1143 | if (container_is_floating(con)) { |
1073 | struct sway_output *output = | 1144 | struct sway_output *output = |
1074 | container_floating_find_output(con); | 1145 | container_floating_find_output(con); |
1075 | if (con->workspace->output != output) { | 1146 | if (con->pending.workspace->output != output) { |
1076 | container_floating_move_to_center(con); | 1147 | container_floating_move_to_center(con); |
1077 | } | 1148 | } |
1078 | } | 1149 | } |
@@ -1084,11 +1155,11 @@ void container_fullscreen_disable(struct sway_container *con) { | |||
1084 | // If the container was mapped as fullscreen and set as floating by | 1155 | // If the container was mapped as fullscreen and set as floating by |
1085 | // criteria, it needs to be reinitialized as floating to get the proper | 1156 | // criteria, it needs to be reinitialized as floating to get the proper |
1086 | // size and location | 1157 | // size and location |
1087 | if (container_is_floating(con) && (con->width == 0 || con->height == 0)) { | 1158 | if (container_is_floating(con) && (con->pending.width == 0 || con->pending.height == 0)) { |
1088 | container_floating_resize_and_center(con); | 1159 | container_floating_resize_and_center(con); |
1089 | } | 1160 | } |
1090 | 1161 | ||
1091 | con->fullscreen_mode = FULLSCREEN_NONE; | 1162 | con->pending.fullscreen_mode = FULLSCREEN_NONE; |
1092 | container_end_mouse_operation(con); | 1163 | container_end_mouse_operation(con); |
1093 | ipc_event_window(con, "fullscreen_mode"); | 1164 | ipc_event_window(con, "fullscreen_mode"); |
1094 | 1165 | ||
@@ -1106,7 +1177,7 @@ void container_fullscreen_disable(struct sway_container *con) { | |||
1106 | 1177 | ||
1107 | void container_set_fullscreen(struct sway_container *con, | 1178 | void container_set_fullscreen(struct sway_container *con, |
1108 | enum sway_fullscreen_mode mode) { | 1179 | enum sway_fullscreen_mode mode) { |
1109 | if (con->fullscreen_mode == mode) { | 1180 | if (con->pending.fullscreen_mode == mode) { |
1110 | return; | 1181 | return; |
1111 | } | 1182 | } |
1112 | 1183 | ||
@@ -1118,8 +1189,8 @@ void container_set_fullscreen(struct sway_container *con, | |||
1118 | if (root->fullscreen_global) { | 1189 | if (root->fullscreen_global) { |
1119 | container_fullscreen_disable(root->fullscreen_global); | 1190 | container_fullscreen_disable(root->fullscreen_global); |
1120 | } | 1191 | } |
1121 | if (con->workspace && con->workspace->fullscreen) { | 1192 | if (con->pending.workspace && con->pending.workspace->fullscreen) { |
1122 | container_fullscreen_disable(con->workspace->fullscreen); | 1193 | container_fullscreen_disable(con->pending.workspace->fullscreen); |
1123 | } | 1194 | } |
1124 | container_fullscreen_workspace(con); | 1195 | container_fullscreen_workspace(con); |
1125 | break; | 1196 | break; |
@@ -1127,7 +1198,7 @@ void container_set_fullscreen(struct sway_container *con, | |||
1127 | if (root->fullscreen_global) { | 1198 | if (root->fullscreen_global) { |
1128 | container_fullscreen_disable(root->fullscreen_global); | 1199 | container_fullscreen_disable(root->fullscreen_global); |
1129 | } | 1200 | } |
1130 | if (con->fullscreen_mode == FULLSCREEN_WORKSPACE) { | 1201 | if (con->pending.fullscreen_mode == FULLSCREEN_WORKSPACE) { |
1131 | container_fullscreen_disable(con); | 1202 | container_fullscreen_disable(con); |
1132 | } | 1203 | } |
1133 | container_fullscreen_global(con); | 1204 | container_fullscreen_global(con); |
@@ -1137,8 +1208,8 @@ void container_set_fullscreen(struct sway_container *con, | |||
1137 | 1208 | ||
1138 | struct sway_container *container_toplevel_ancestor( | 1209 | struct sway_container *container_toplevel_ancestor( |
1139 | struct sway_container *container) { | 1210 | struct sway_container *container) { |
1140 | while (container->parent) { | 1211 | while (container->pending.parent) { |
1141 | container = container->parent; | 1212 | container = container->pending.parent; |
1142 | } | 1213 | } |
1143 | 1214 | ||
1144 | return container; | 1215 | return container; |
@@ -1150,10 +1221,10 @@ bool container_is_floating_or_child(struct sway_container *container) { | |||
1150 | 1221 | ||
1151 | bool container_is_fullscreen_or_child(struct sway_container *container) { | 1222 | bool container_is_fullscreen_or_child(struct sway_container *container) { |
1152 | do { | 1223 | do { |
1153 | if (container->fullscreen_mode) { | 1224 | if (container->pending.fullscreen_mode) { |
1154 | return true; | 1225 | return true; |
1155 | } | 1226 | } |
1156 | container = container->parent; | 1227 | container = container->pending.parent; |
1157 | } while (container); | 1228 | } while (container); |
1158 | 1229 | ||
1159 | return false; | 1230 | return false; |
@@ -1226,11 +1297,11 @@ void container_discover_outputs(struct sway_container *con) { | |||
1226 | } | 1297 | } |
1227 | 1298 | ||
1228 | enum sway_container_layout container_parent_layout(struct sway_container *con) { | 1299 | enum sway_container_layout container_parent_layout(struct sway_container *con) { |
1229 | if (con->parent) { | 1300 | if (con->pending.parent) { |
1230 | return con->parent->layout; | 1301 | return con->pending.parent->pending.layout; |
1231 | } | 1302 | } |
1232 | if (con->workspace) { | 1303 | if (con->pending.workspace) { |
1233 | return con->workspace->layout; | 1304 | return con->pending.workspace->layout; |
1234 | } | 1305 | } |
1235 | return L_NONE; | 1306 | return L_NONE; |
1236 | } | 1307 | } |
@@ -1244,16 +1315,16 @@ enum sway_container_layout container_current_parent_layout( | |||
1244 | } | 1315 | } |
1245 | 1316 | ||
1246 | list_t *container_get_siblings(struct sway_container *container) { | 1317 | list_t *container_get_siblings(struct sway_container *container) { |
1247 | if (container->parent) { | 1318 | if (container->pending.parent) { |
1248 | return container->parent->children; | 1319 | return container->pending.parent->pending.children; |
1249 | } | 1320 | } |
1250 | if (container_is_scratchpad_hidden(container)) { | 1321 | if (container_is_scratchpad_hidden(container)) { |
1251 | return NULL; | 1322 | return NULL; |
1252 | } | 1323 | } |
1253 | if (list_find(container->workspace->tiling, container) != -1) { | 1324 | if (list_find(container->pending.workspace->tiling, container) != -1) { |
1254 | return container->workspace->tiling; | 1325 | return container->pending.workspace->tiling; |
1255 | } | 1326 | } |
1256 | return container->workspace->floating; | 1327 | return container->pending.workspace->floating; |
1257 | } | 1328 | } |
1258 | 1329 | ||
1259 | int container_sibling_index(struct sway_container *child) { | 1330 | int container_sibling_index(struct sway_container *child) { |
@@ -1268,30 +1339,30 @@ list_t *container_get_current_siblings(struct sway_container *container) { | |||
1268 | } | 1339 | } |
1269 | 1340 | ||
1270 | void container_handle_fullscreen_reparent(struct sway_container *con) { | 1341 | void container_handle_fullscreen_reparent(struct sway_container *con) { |
1271 | if (con->fullscreen_mode != FULLSCREEN_WORKSPACE || !con->workspace || | 1342 | if (con->pending.fullscreen_mode != FULLSCREEN_WORKSPACE || !con->pending.workspace || |
1272 | con->workspace->fullscreen == con) { | 1343 | con->pending.workspace->fullscreen == con) { |
1273 | return; | 1344 | return; |
1274 | } | 1345 | } |
1275 | if (con->workspace->fullscreen) { | 1346 | if (con->pending.workspace->fullscreen) { |
1276 | container_fullscreen_disable(con->workspace->fullscreen); | 1347 | container_fullscreen_disable(con->pending.workspace->fullscreen); |
1277 | } | 1348 | } |
1278 | con->workspace->fullscreen = con; | 1349 | con->pending.workspace->fullscreen = con; |
1279 | 1350 | ||
1280 | arrange_workspace(con->workspace); | 1351 | arrange_workspace(con->pending.workspace); |
1281 | } | 1352 | } |
1282 | 1353 | ||
1283 | static void set_workspace(struct sway_container *container, void *data) { | 1354 | static void set_workspace(struct sway_container *container, void *data) { |
1284 | container->workspace = container->parent->workspace; | 1355 | container->pending.workspace = container->pending.parent->pending.workspace; |
1285 | } | 1356 | } |
1286 | 1357 | ||
1287 | void container_insert_child(struct sway_container *parent, | 1358 | void container_insert_child(struct sway_container *parent, |
1288 | struct sway_container *child, int i) { | 1359 | struct sway_container *child, int i) { |
1289 | if (child->workspace) { | 1360 | if (child->pending.workspace) { |
1290 | container_detach(child); | 1361 | container_detach(child); |
1291 | } | 1362 | } |
1292 | list_insert(parent->children, i, child); | 1363 | list_insert(parent->pending.children, i, child); |
1293 | child->parent = parent; | 1364 | child->pending.parent = parent; |
1294 | child->workspace = parent->workspace; | 1365 | child->pending.workspace = parent->pending.workspace; |
1295 | container_for_each_child(child, set_workspace, NULL); | 1366 | container_for_each_child(child, set_workspace, NULL); |
1296 | container_handle_fullscreen_reparent(child); | 1367 | container_handle_fullscreen_reparent(child); |
1297 | container_update_representation(parent); | 1368 | container_update_representation(parent); |
@@ -1299,14 +1370,14 @@ void container_insert_child(struct sway_container *parent, | |||
1299 | 1370 | ||
1300 | void container_add_sibling(struct sway_container *fixed, | 1371 | void container_add_sibling(struct sway_container *fixed, |
1301 | struct sway_container *active, bool after) { | 1372 | struct sway_container *active, bool after) { |
1302 | if (active->workspace) { | 1373 | if (active->pending.workspace) { |
1303 | container_detach(active); | 1374 | container_detach(active); |
1304 | } | 1375 | } |
1305 | list_t *siblings = container_get_siblings(fixed); | 1376 | list_t *siblings = container_get_siblings(fixed); |
1306 | int index = list_find(siblings, fixed); | 1377 | int index = list_find(siblings, fixed); |
1307 | list_insert(siblings, index + after, active); | 1378 | list_insert(siblings, index + after, active); |
1308 | active->parent = fixed->parent; | 1379 | active->pending.parent = fixed->pending.parent; |
1309 | active->workspace = fixed->workspace; | 1380 | active->pending.workspace = fixed->pending.workspace; |
1310 | container_for_each_child(active, set_workspace, NULL); | 1381 | container_for_each_child(active, set_workspace, NULL); |
1311 | container_handle_fullscreen_reparent(active); | 1382 | container_handle_fullscreen_reparent(active); |
1312 | container_update_representation(active); | 1383 | container_update_representation(active); |
@@ -1314,17 +1385,13 @@ void container_add_sibling(struct sway_container *fixed, | |||
1314 | 1385 | ||
1315 | void container_add_child(struct sway_container *parent, | 1386 | void container_add_child(struct sway_container *parent, |
1316 | struct sway_container *child) { | 1387 | struct sway_container *child) { |
1317 | if (child->workspace) { | 1388 | if (child->pending.workspace) { |
1318 | container_detach(child); | 1389 | container_detach(child); |
1319 | } | 1390 | } |
1320 | list_add(parent->children, child); | 1391 | list_add(parent->pending.children, child); |
1321 | child->parent = parent; | 1392 | child->pending.parent = parent; |
1322 | child->workspace = parent->workspace; | 1393 | child->pending.workspace = parent->pending.workspace; |
1323 | container_for_each_child(child, set_workspace, NULL); | 1394 | container_for_each_child(child, set_workspace, NULL); |
1324 | bool fullscreen = child->fullscreen_mode != FULLSCREEN_NONE || | ||
1325 | parent->fullscreen_mode != FULLSCREEN_NONE; | ||
1326 | set_fullscreen_iterator(child, &fullscreen); | ||
1327 | container_for_each_child(child, set_fullscreen_iterator, &fullscreen); | ||
1328 | container_handle_fullscreen_reparent(child); | 1395 | container_handle_fullscreen_reparent(child); |
1329 | container_update_representation(parent); | 1396 | container_update_representation(parent); |
1330 | node_set_dirty(&child->node); | 1397 | node_set_dirty(&child->node); |
@@ -1332,15 +1399,15 @@ void container_add_child(struct sway_container *parent, | |||
1332 | } | 1399 | } |
1333 | 1400 | ||
1334 | void container_detach(struct sway_container *child) { | 1401 | void container_detach(struct sway_container *child) { |
1335 | if (child->fullscreen_mode == FULLSCREEN_WORKSPACE) { | 1402 | if (child->pending.fullscreen_mode == FULLSCREEN_WORKSPACE) { |
1336 | child->workspace->fullscreen = NULL; | 1403 | child->pending.workspace->fullscreen = NULL; |
1337 | } | 1404 | } |
1338 | if (child->fullscreen_mode == FULLSCREEN_GLOBAL) { | 1405 | if (child->pending.fullscreen_mode == FULLSCREEN_GLOBAL) { |
1339 | root->fullscreen_global = NULL; | 1406 | root->fullscreen_global = NULL; |
1340 | } | 1407 | } |
1341 | 1408 | ||
1342 | struct sway_container *old_parent = child->parent; | 1409 | struct sway_container *old_parent = child->pending.parent; |
1343 | struct sway_workspace *old_workspace = child->workspace; | 1410 | struct sway_workspace *old_workspace = child->pending.workspace; |
1344 | list_t *siblings = container_get_siblings(child); | 1411 | list_t *siblings = container_get_siblings(child); |
1345 | if (siblings) { | 1412 | if (siblings) { |
1346 | int index = list_find(siblings, child); | 1413 | int index = list_find(siblings, child); |
@@ -1348,8 +1415,8 @@ void container_detach(struct sway_container *child) { | |||
1348 | list_del(siblings, index); | 1415 | list_del(siblings, index); |
1349 | } | 1416 | } |
1350 | } | 1417 | } |
1351 | child->parent = NULL; | 1418 | child->pending.parent = NULL; |
1352 | child->workspace = NULL; | 1419 | child->pending.workspace = NULL; |
1353 | container_for_each_child(child, set_workspace, NULL); | 1420 | container_for_each_child(child, set_workspace, NULL); |
1354 | 1421 | ||
1355 | if (old_parent) { | 1422 | if (old_parent) { |
@@ -1364,18 +1431,18 @@ void container_detach(struct sway_container *child) { | |||
1364 | 1431 | ||
1365 | void container_replace(struct sway_container *container, | 1432 | void container_replace(struct sway_container *container, |
1366 | struct sway_container *replacement) { | 1433 | struct sway_container *replacement) { |
1367 | enum sway_fullscreen_mode fullscreen = container->fullscreen_mode; | 1434 | enum sway_fullscreen_mode fullscreen = container->pending.fullscreen_mode; |
1368 | bool scratchpad = container->scratchpad; | 1435 | bool scratchpad = container->scratchpad; |
1369 | struct sway_workspace *ws = NULL; | 1436 | struct sway_workspace *ws = NULL; |
1370 | if (fullscreen != FULLSCREEN_NONE) { | 1437 | if (fullscreen != FULLSCREEN_NONE) { |
1371 | container_fullscreen_disable(container); | 1438 | container_fullscreen_disable(container); |
1372 | } | 1439 | } |
1373 | if (scratchpad) { | 1440 | if (scratchpad) { |
1374 | ws = container->workspace; | 1441 | ws = container->pending.workspace; |
1375 | root_scratchpad_show(container); | 1442 | root_scratchpad_show(container); |
1376 | root_scratchpad_remove_container(container); | 1443 | root_scratchpad_remove_container(container); |
1377 | } | 1444 | } |
1378 | if (container->parent || container->workspace) { | 1445 | if (container->pending.parent || container->pending.workspace) { |
1379 | float width_fraction = container->width_fraction; | 1446 | float width_fraction = container->width_fraction; |
1380 | float height_fraction = container->height_fraction; | 1447 | float height_fraction = container->height_fraction; |
1381 | container_add_sibling(container, replacement, 1); | 1448 | container_add_sibling(container, replacement, 1); |
@@ -1403,7 +1470,7 @@ struct sway_container *container_split(struct sway_container *child, | |||
1403 | enum sway_container_layout layout) { | 1470 | enum sway_container_layout layout) { |
1404 | // i3 doesn't split singleton H/V containers | 1471 | // i3 doesn't split singleton H/V containers |
1405 | // https://github.com/i3/i3/blob/3cd1c45eba6de073bc4300eebb4e1cc1a0c4479a/src/tree.c#L354 | 1472 | // https://github.com/i3/i3/blob/3cd1c45eba6de073bc4300eebb4e1cc1a0c4479a/src/tree.c#L354 |
1406 | if (child->parent || child->workspace) { | 1473 | if (child->pending.parent || child->pending.workspace) { |
1407 | list_t *siblings = container_get_siblings(child); | 1474 | list_t *siblings = container_get_siblings(child); |
1408 | if (siblings->length == 1) { | 1475 | if (siblings->length == 1) { |
1409 | enum sway_container_layout current = container_parent_layout(child); | 1476 | enum sway_container_layout current = container_parent_layout(child); |
@@ -1411,12 +1478,12 @@ struct sway_container *container_split(struct sway_container *child, | |||
1411 | current = L_NONE; | 1478 | current = L_NONE; |
1412 | } | 1479 | } |
1413 | if (current == L_HORIZ || current == L_VERT) { | 1480 | if (current == L_HORIZ || current == L_VERT) { |
1414 | if (child->parent) { | 1481 | if (child->pending.parent) { |
1415 | child->parent->layout = layout; | 1482 | child->pending.parent->pending.layout = layout; |
1416 | container_update_representation(child->parent); | 1483 | container_update_representation(child->pending.parent); |
1417 | } else { | 1484 | } else { |
1418 | child->workspace->layout = layout; | 1485 | child->pending.workspace->layout = layout; |
1419 | workspace_update_representation(child->workspace); | 1486 | workspace_update_representation(child->pending.workspace); |
1420 | } | 1487 | } |
1421 | return child; | 1488 | return child; |
1422 | } | 1489 | } |
@@ -1429,25 +1496,25 @@ struct sway_container *container_split(struct sway_container *child, | |||
1429 | if (container_is_floating(child) && child->view) { | 1496 | if (container_is_floating(child) && child->view) { |
1430 | view_set_tiled(child->view, true); | 1497 | view_set_tiled(child->view, true); |
1431 | if (child->view->using_csd) { | 1498 | if (child->view->using_csd) { |
1432 | child->border = child->saved_border; | 1499 | child->pending.border = child->saved_border; |
1433 | } | 1500 | } |
1434 | } | 1501 | } |
1435 | 1502 | ||
1436 | struct sway_container *cont = container_create(NULL); | 1503 | struct sway_container *cont = container_create(NULL); |
1437 | cont->width = child->width; | 1504 | cont->pending.width = child->pending.width; |
1438 | cont->height = child->height; | 1505 | cont->pending.height = child->pending.height; |
1439 | cont->width_fraction = child->width_fraction; | 1506 | cont->width_fraction = child->width_fraction; |
1440 | cont->height_fraction = child->height_fraction; | 1507 | cont->height_fraction = child->height_fraction; |
1441 | cont->x = child->x; | 1508 | cont->pending.x = child->pending.x; |
1442 | cont->y = child->y; | 1509 | cont->pending.y = child->pending.y; |
1443 | cont->layout = layout; | 1510 | cont->pending.layout = layout; |
1444 | 1511 | ||
1445 | container_replace(child, cont); | 1512 | container_replace(child, cont); |
1446 | container_add_child(cont, child); | 1513 | container_add_child(cont, child); |
1447 | 1514 | ||
1448 | if (set_focus) { | 1515 | if (set_focus) { |
1449 | seat_set_raw_focus(seat, &cont->node); | 1516 | seat_set_raw_focus(seat, &cont->node); |
1450 | if (cont->fullscreen_mode == FULLSCREEN_GLOBAL) { | 1517 | if (cont->pending.fullscreen_mode == FULLSCREEN_GLOBAL) { |
1451 | seat_set_focus(seat, &child->node); | 1518 | seat_set_focus(seat, &child->node); |
1452 | } else { | 1519 | } else { |
1453 | seat_set_raw_focus(seat, &child->node); | 1520 | seat_set_raw_focus(seat, &child->node); |
@@ -1554,39 +1621,8 @@ static void update_marks_texture(struct sway_container *con, | |||
1554 | } | 1621 | } |
1555 | free(part); | 1622 | free(part); |
1556 | 1623 | ||
1557 | double scale = output->wlr_output->scale; | 1624 | render_titlebar_text_texture(output, con, texture, class, false, buffer); |
1558 | int width = 0; | ||
1559 | int height = con->title_height * scale; | ||
1560 | |||
1561 | cairo_t *c = cairo_create(NULL); | ||
1562 | get_text_size(c, config->font, &width, NULL, NULL, scale, false, | ||
1563 | "%s", buffer); | ||
1564 | cairo_destroy(c); | ||
1565 | 1625 | ||
1566 | cairo_surface_t *surface = cairo_image_surface_create( | ||
1567 | CAIRO_FORMAT_ARGB32, width, height); | ||
1568 | cairo_t *cairo = cairo_create(surface); | ||
1569 | cairo_set_source_rgba(cairo, class->background[0], class->background[1], | ||
1570 | class->background[2], class->background[3]); | ||
1571 | cairo_paint(cairo); | ||
1572 | PangoContext *pango = pango_cairo_create_context(cairo); | ||
1573 | cairo_set_antialias(cairo, CAIRO_ANTIALIAS_BEST); | ||
1574 | cairo_set_source_rgba(cairo, class->text[0], class->text[1], | ||
1575 | class->text[2], class->text[3]); | ||
1576 | cairo_move_to(cairo, 0, 0); | ||
1577 | |||
1578 | pango_printf(cairo, config->font, scale, false, "%s", buffer); | ||
1579 | |||
1580 | cairo_surface_flush(surface); | ||
1581 | unsigned char *data = cairo_image_surface_get_data(surface); | ||
1582 | int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width); | ||
1583 | struct wlr_renderer *renderer = wlr_backend_get_renderer( | ||
1584 | output->wlr_output->backend); | ||
1585 | *texture = wlr_texture_from_pixels( | ||
1586 | renderer, WL_SHM_FORMAT_ARGB8888, stride, width, height, data); | ||
1587 | cairo_surface_destroy(surface); | ||
1588 | g_object_unref(pango); | ||
1589 | cairo_destroy(cairo); | ||
1590 | free(buffer); | 1626 | free(buffer); |
1591 | } | 1627 | } |
1592 | 1628 | ||
@@ -1608,19 +1644,19 @@ void container_update_marks_textures(struct sway_container *con) { | |||
1608 | void container_raise_floating(struct sway_container *con) { | 1644 | void container_raise_floating(struct sway_container *con) { |
1609 | // Bring container to front by putting it at the end of the floating list. | 1645 | // Bring container to front by putting it at the end of the floating list. |
1610 | struct sway_container *floater = container_toplevel_ancestor(con); | 1646 | struct sway_container *floater = container_toplevel_ancestor(con); |
1611 | if (container_is_floating(floater) && floater->workspace) { | 1647 | if (container_is_floating(floater) && floater->pending.workspace) { |
1612 | list_move_to_end(floater->workspace->floating, floater); | 1648 | list_move_to_end(floater->pending.workspace->floating, floater); |
1613 | node_set_dirty(&floater->workspace->node); | 1649 | node_set_dirty(&floater->pending.workspace->node); |
1614 | } | 1650 | } |
1615 | } | 1651 | } |
1616 | 1652 | ||
1617 | bool container_is_scratchpad_hidden(struct sway_container *con) { | 1653 | bool container_is_scratchpad_hidden(struct sway_container *con) { |
1618 | return con->scratchpad && !con->workspace; | 1654 | return con->scratchpad && !con->pending.workspace; |
1619 | } | 1655 | } |
1620 | 1656 | ||
1621 | bool container_is_scratchpad_hidden_or_child(struct sway_container *con) { | 1657 | bool container_is_scratchpad_hidden_or_child(struct sway_container *con) { |
1622 | con = container_toplevel_ancestor(con); | 1658 | con = container_toplevel_ancestor(con); |
1623 | return con->scratchpad && !con->workspace; | 1659 | return con->scratchpad && !con->pending.workspace; |
1624 | } | 1660 | } |
1625 | 1661 | ||
1626 | bool container_is_sticky(struct sway_container *con) { | 1662 | bool container_is_sticky(struct sway_container *con) { |
@@ -1648,39 +1684,39 @@ static bool is_parallel(enum sway_container_layout first, | |||
1648 | static bool container_is_squashable(struct sway_container *con, | 1684 | static bool container_is_squashable(struct sway_container *con, |
1649 | struct sway_container *child) { | 1685 | struct sway_container *child) { |
1650 | enum sway_container_layout gp_layout = container_parent_layout(con); | 1686 | enum sway_container_layout gp_layout = container_parent_layout(con); |
1651 | return (con->layout == L_HORIZ || con->layout == L_VERT) && | 1687 | return (con->pending.layout == L_HORIZ || con->pending.layout == L_VERT) && |
1652 | (child->layout == L_HORIZ || child->layout == L_VERT) && | 1688 | (child->pending.layout == L_HORIZ || child->pending.layout == L_VERT) && |
1653 | !is_parallel(con->layout, child->layout) && | 1689 | !is_parallel(con->pending.layout, child->pending.layout) && |
1654 | is_parallel(gp_layout, child->layout); | 1690 | is_parallel(gp_layout, child->pending.layout); |
1655 | } | 1691 | } |
1656 | 1692 | ||
1657 | static void container_squash_children(struct sway_container *con) { | 1693 | static void container_squash_children(struct sway_container *con) { |
1658 | for (int i = 0; i < con->children->length; i++) { | 1694 | for (int i = 0; i < con->pending.children->length; i++) { |
1659 | struct sway_container *child = con->children->items[i]; | 1695 | struct sway_container *child = con->pending.children->items[i]; |
1660 | i += container_squash(child); | 1696 | i += container_squash(child); |
1661 | } | 1697 | } |
1662 | } | 1698 | } |
1663 | 1699 | ||
1664 | int container_squash(struct sway_container *con) { | 1700 | int container_squash(struct sway_container *con) { |
1665 | if (!con->children) { | 1701 | if (!con->pending.children) { |
1666 | return 0; | 1702 | return 0; |
1667 | } | 1703 | } |
1668 | if (con->children->length != 1) { | 1704 | if (con->pending.children->length != 1) { |
1669 | container_squash_children(con); | 1705 | container_squash_children(con); |
1670 | return 0; | 1706 | return 0; |
1671 | } | 1707 | } |
1672 | struct sway_container *child = con->children->items[0]; | 1708 | struct sway_container *child = con->pending.children->items[0]; |
1673 | int idx = container_sibling_index(con); | 1709 | int idx = container_sibling_index(con); |
1674 | int change = 0; | 1710 | int change = 0; |
1675 | if (container_is_squashable(con, child)) { | 1711 | if (container_is_squashable(con, child)) { |
1676 | // con and child are a redundant H/V pair. Destroy them. | 1712 | // con and child are a redundant H/V pair. Destroy them. |
1677 | while (child->children->length) { | 1713 | while (child->pending.children->length) { |
1678 | struct sway_container *current = child->children->items[0]; | 1714 | struct sway_container *current = child->pending.children->items[0]; |
1679 | container_detach(current); | 1715 | container_detach(current); |
1680 | if (con->parent) { | 1716 | if (con->pending.parent) { |
1681 | container_insert_child(con->parent, current, idx); | 1717 | container_insert_child(con->pending.parent, current, idx); |
1682 | } else { | 1718 | } else { |
1683 | workspace_insert_tiling_direct(con->workspace, current, idx); | 1719 | workspace_insert_tiling_direct(con->pending.workspace, current, idx); |
1684 | } | 1720 | } |
1685 | change++; | 1721 | change++; |
1686 | } | 1722 | } |