diff options
Diffstat (limited to 'sway/tree/view.c')
-rw-r--r-- | sway/tree/view.c | 46 |
1 files changed, 20 insertions, 26 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c index 7bf7325a..1a98c5f2 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -13,12 +13,12 @@ #include "log.h" #include "sway/criteria.h" #include "sway/commands.h" +#include "sway/desktop/transaction.h" #include "sway/ipc-server.h" #include "sway/output.h" #include "sway/input/seat.h" #include "sway/tree/arrange.h" #include "sway/tree/container.h" -#include "sway/tree/layout.h" #include "sway/tree/view.h" #include "sway/tree/workspace.h" #include "sway/config.h" @@ -35,7 +35,7 @@ void view_init(struct sway_view *view, enum sway_view_type type, wl_signal_init(&view->events.unmap); } -void view_free(struct sway_view *view) { +void view_destroy(struct sway_view *view) { if (!sway_assert(view->surface == NULL, "Tried to free mapped view")) { return; } @@ -75,14 +75,14 @@ void view_free(struct sway_view *view) { * destroying flag will make the view get freed when the transaction is * finished. */ -void view_destroy(struct sway_view *view) { +void view_begin_destroy(struct sway_view *view) { if (!sway_assert(view->surface == NULL, "Tried to destroy a mapped view")) { return; } view->destroying = true; if (!view->swayc) { - view_free(view); + view_destroy(view); } } @@ -225,15 +225,13 @@ void view_autoconfigure(struct sway_view *view) { x = y = width = height = 0; double y_offset = 0; - // In a tabbed or stacked container, the swayc's y is the top of the title - // area. We have to offset the surface y by the height of the title bar, and - // disable any top border because we'll always have the title bar. - if (con->parent->layout == L_TABBED) { - y_offset = container_titlebar_height(); - view->border_top = false; - } else if (con->parent->layout == L_STACKED) { - y_offset = container_titlebar_height() * con->parent->children->length; + // In a tabbed or stacked container, the swayc's y is the bottom of the + // title area. We have to disable any top border because the title bar is + // rendered by the parent. + if (con->parent->layout == L_TABBED || con->parent->layout == L_STACKED) { view->border_top = false; + } else { + y_offset = container_titlebar_height(); } enum sway_container_border border = view->border; @@ -244,17 +242,17 @@ void view_autoconfigure(struct sway_view *view) { switch (border) { case B_NONE: x = con->x; - y = con->y + y_offset; + y = con->y; width = con->width; - height = con->height - y_offset; + height = con->height; break; case B_PIXEL: x = con->x + view->border_thickness * view->border_left; - y = con->y + view->border_thickness * view->border_top + y_offset; + y = con->y + view->border_thickness * view->border_top; width = con->width - view->border_thickness * view->border_left - view->border_thickness * view->border_right; - height = con->height - y_offset + height = con->height - view->border_thickness * view->border_top - view->border_thickness * view->border_bottom; break; @@ -264,15 +262,9 @@ void view_autoconfigure(struct sway_view *view) { width = con->width - view->border_thickness * view->border_left - view->border_thickness * view->border_right; - if (y_offset) { - y = con->y + y_offset; - height = con->height - y_offset - - view->border_thickness * view->border_bottom; - } else { - y = con->y + container_titlebar_height(); - height = con->height - container_titlebar_height() - - view->border_thickness * view->border_bottom; - } + y = con->y + y_offset; + height = con->height - y_offset + - view->border_thickness * view->border_bottom; break; } @@ -560,7 +552,9 @@ void view_unmap(struct sway_view *view) { } bool was_fullscreen = view->swayc->is_fullscreen; - struct sway_container *surviving_ancestor = container_destroy(view->swayc); + struct sway_container *parent = view->swayc->parent; + container_begin_destroy(view->swayc); + struct sway_container *surviving_ancestor = container_reap_empty(parent); // If the workspace wasn't reaped if (surviving_ancestor && surviving_ancestor->type >= C_WORKSPACE) { |