diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-09-06 09:13:36 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-09-06 09:13:36 +1000 |
commit | c6368febc8045ce884cc0047e89b980d6a81ce2f (patch) | |
tree | e2db4a2927bb81e3baf579d01a2bed4f1be62e62 /sway/tree/view.c | |
parent | 49c937fc878da3ffb155429216ad8298202f1767 (diff) |
Adjust container box
Prior to f5b9815128b6c000bb5d47c339480fa481a5e99d, children of tabbed
and stacked containers would have their container size and position set
to the same as the tabbed/stacked container. Normally this would be a
problem for a layout such as T[V[view]], but there was some code in the
arrange functions which would check if the grandparent of the view was a
tabbed or stacked container and would offset the view's Y accordingly.
Commit f5b9815128b6c000bb5d47c339480fa481a5e99d changed the box to
exclude the titlebar for all tabbed/stacked children so that the
grandparent check could be removed. But this meant the title was not
covered in the container and wasn't damaged when the child changed its
title.
This patch changes it so that a child of a tabbed/stacked container will
have its box include the title bar if the child is a view, but not if
it's a layout container. This fixes the title damage issue while
avoiding the grandparent check in the arrange functions, and matches
what we see visually.
Diffstat (limited to 'sway/tree/view.c')
-rw-r--r-- | sway/tree/view.c | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c index f63a35b5..f9dcb11a 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -219,14 +219,17 @@ 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 bottom of the - // title area. We have to disable any top border because the title bar is - // rendered by the parent. + // In a tabbed or stacked container, the container'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. enum sway_container_layout layout = container_parent_layout(con); - if (layout == L_TABBED || layout == L_STACKED) { - view->border_top = false; - } else { + if (layout == L_TABBED) { y_offset = container_titlebar_height(); + view->border_top = false; + } else if (layout == L_STACKED) { + list_t *siblings = container_get_siblings(con); + y_offset = container_titlebar_height() * siblings->length; + view->border_top = false; } enum sway_container_border border = view->border; @@ -237,17 +240,17 @@ void view_autoconfigure(struct sway_view *view) { switch (border) { case B_NONE: x = con->x; - y = con->y; + y = con->y + y_offset; width = con->width; - height = con->height; + height = con->height - y_offset; break; case B_PIXEL: x = con->x + view->border_thickness * view->border_left; - y = con->y + view->border_thickness * view->border_top; + y = con->y + view->border_thickness * view->border_top + y_offset; width = con->width - view->border_thickness * view->border_left - view->border_thickness * view->border_right; - height = con->height + height = con->height - y_offset - view->border_thickness * view->border_top - view->border_thickness * view->border_bottom; break; @@ -257,9 +260,15 @@ void view_autoconfigure(struct sway_view *view) { width = con->width - view->border_thickness * view->border_left - view->border_thickness * view->border_right; - y = con->y + y_offset; - height = con->height - y_offset - - view->border_thickness * view->border_bottom; + 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; + } break; } |