mirror of
https://github.com/swaywm/sway.git
synced 2024-11-29 03:11:27 +00:00
Merge pull request #2579 from RyanDwyer/adjust-container-box
Adjust container box
This commit is contained in:
commit
f255881134
|
@ -97,15 +97,14 @@ static void apply_tabbed_layout(list_t *children, struct wlr_box *parent) {
|
||||||
if (!children->length) {
|
if (!children->length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
size_t parent_offset = container_titlebar_height();
|
|
||||||
size_t parent_height = parent->height - parent_offset;
|
|
||||||
for (int i = 0; i < children->length; ++i) {
|
for (int i = 0; i < children->length; ++i) {
|
||||||
struct sway_container *child = children->items[i];
|
struct sway_container *child = children->items[i];
|
||||||
|
size_t parent_offset = child->view ? 0 : container_titlebar_height();
|
||||||
container_remove_gaps(child);
|
container_remove_gaps(child);
|
||||||
child->x = parent->x;
|
child->x = parent->x;
|
||||||
child->y = parent->y + parent_offset;
|
child->y = parent->y + parent_offset;
|
||||||
child->width = parent->width;
|
child->width = parent->width;
|
||||||
child->height = parent_height;
|
child->height = parent->height - parent_offset;
|
||||||
container_add_gaps(child);
|
container_add_gaps(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,15 +113,15 @@ static void apply_stacked_layout(list_t *children, struct wlr_box *parent) {
|
||||||
if (!children->length) {
|
if (!children->length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
size_t parent_offset = container_titlebar_height() * children->length;
|
|
||||||
size_t parent_height = parent->height - parent_offset;
|
|
||||||
for (int i = 0; i < children->length; ++i) {
|
for (int i = 0; i < children->length; ++i) {
|
||||||
struct sway_container *child = children->items[i];
|
struct sway_container *child = children->items[i];
|
||||||
|
size_t parent_offset = child->view ? 0 :
|
||||||
|
container_titlebar_height() * children->length;
|
||||||
container_remove_gaps(child);
|
container_remove_gaps(child);
|
||||||
child->x = parent->x;
|
child->x = parent->x;
|
||||||
child->y = parent->y + parent_offset;
|
child->y = parent->y + parent_offset;
|
||||||
child->width = parent->width;
|
child->width = parent->width;
|
||||||
child->height = parent_height;
|
child->height = parent->height - parent_offset;
|
||||||
container_add_gaps(child);
|
container_add_gaps(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -219,14 +219,17 @@ void view_autoconfigure(struct sway_view *view) {
|
||||||
x = y = width = height = 0;
|
x = y = width = height = 0;
|
||||||
double y_offset = 0;
|
double y_offset = 0;
|
||||||
|
|
||||||
// In a tabbed or stacked container, the swayc's y is the bottom of the
|
// In a tabbed or stacked container, the container's y is the top of the
|
||||||
// title area. We have to disable any top border because the title bar is
|
// title area. We have to offset the surface y by the height of the title,
|
||||||
// rendered by the parent.
|
// bar, and disable any top border because we'll always have the title bar.
|
||||||
enum sway_container_layout layout = container_parent_layout(con);
|
enum sway_container_layout layout = container_parent_layout(con);
|
||||||
if (layout == L_TABBED || layout == L_STACKED) {
|
if (layout == L_TABBED) {
|
||||||
view->border_top = false;
|
|
||||||
} else {
|
|
||||||
y_offset = container_titlebar_height();
|
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;
|
enum sway_container_border border = view->border;
|
||||||
|
@ -237,17 +240,17 @@ void view_autoconfigure(struct sway_view *view) {
|
||||||
switch (border) {
|
switch (border) {
|
||||||
case B_NONE:
|
case B_NONE:
|
||||||
x = con->x;
|
x = con->x;
|
||||||
y = con->y;
|
y = con->y + y_offset;
|
||||||
width = con->width;
|
width = con->width;
|
||||||
height = con->height;
|
height = con->height - y_offset;
|
||||||
break;
|
break;
|
||||||
case B_PIXEL:
|
case B_PIXEL:
|
||||||
x = con->x + view->border_thickness * view->border_left;
|
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
|
width = con->width
|
||||||
- view->border_thickness * view->border_left
|
- view->border_thickness * view->border_left
|
||||||
- view->border_thickness * view->border_right;
|
- 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_top
|
||||||
- view->border_thickness * view->border_bottom;
|
- view->border_thickness * view->border_bottom;
|
||||||
break;
|
break;
|
||||||
|
@ -257,9 +260,15 @@ void view_autoconfigure(struct sway_view *view) {
|
||||||
width = con->width
|
width = con->width
|
||||||
- view->border_thickness * view->border_left
|
- view->border_thickness * view->border_left
|
||||||
- view->border_thickness * view->border_right;
|
- view->border_thickness * view->border_right;
|
||||||
|
if (y_offset) {
|
||||||
y = con->y + y_offset;
|
y = con->y + y_offset;
|
||||||
height = con->height - y_offset
|
height = con->height - y_offset
|
||||||
- view->border_thickness * view->border_bottom;
|
- 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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue