summaryrefslogtreecommitdiffstats
path: root/sway/tree/arrange.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/tree/arrange.c')
-rw-r--r--sway/tree/arrange.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/sway/tree/arrange.c b/sway/tree/arrange.c
index 8aebc0cc..bdef56ea 100644
--- a/sway/tree/arrange.c
+++ b/sway/tree/arrange.c
@@ -86,12 +86,14 @@ static void apply_horiz_layout(struct sway_container *parent) {
86 if (!num_children) { 86 if (!num_children) {
87 return; 87 return;
88 } 88 }
89 size_t parent_height = parent->height;
90 size_t parent_offset = 0; 89 size_t parent_offset = 0;
91 if (parent->parent->layout == L_TABBED) { 90 if (parent->parent->layout == L_TABBED) {
92 parent_offset = config->border_thickness * 2 + config->font_height; 91 parent_offset = container_titlebar_height();
93 parent_height -= parent_offset; 92 } else if (parent->parent->layout == L_STACKED) {
93 parent_offset =
94 container_titlebar_height() * parent->parent->children->length;
94 } 95 }
96 size_t parent_height = parent->height - parent_offset;
95 97
96 // Calculate total width of children 98 // Calculate total width of children
97 double total_width = 0; 99 double total_width = 0;
@@ -132,12 +134,14 @@ static void apply_vert_layout(struct sway_container *parent) {
132 if (!num_children) { 134 if (!num_children) {
133 return; 135 return;
134 } 136 }
135 size_t parent_height = parent->height;
136 size_t parent_offset = 0; 137 size_t parent_offset = 0;
137 if (parent->parent->layout == L_TABBED) { 138 if (parent->parent->layout == L_TABBED) {
138 parent_offset = config->border_thickness * 2 + config->font_height; 139 parent_offset = container_titlebar_height();
139 parent_height -= parent_offset; 140 } else if (parent->parent->layout == L_STACKED) {
141 parent_offset =
142 container_titlebar_height() * parent->parent->children->length;
140 } 143 }
144 size_t parent_height = parent->height - parent_offset;
141 145
142 // Calculate total height of children 146 // Calculate total height of children
143 double total_height = 0; 147 double total_height = 0;
@@ -173,16 +177,24 @@ static void apply_vert_layout(struct sway_container *parent) {
173 child->height = parent->y + parent_offset + parent_height - child->y; 177 child->height = parent->y + parent_offset + parent_height - child->y;
174} 178}
175 179
176static void apply_tabbed_layout(struct sway_container *parent) { 180static void apply_tabbed_or_stacked_layout(struct sway_container *parent) {
177 if (!parent->children->length) { 181 if (!parent->children->length) {
178 return; 182 return;
179 } 183 }
184 size_t parent_offset = 0;
185 if (parent->parent->layout == L_TABBED) {
186 parent_offset = container_titlebar_height();
187 } else if (parent->parent->layout == L_STACKED) {
188 parent_offset =
189 container_titlebar_height() * parent->parent->children->length;
190 }
191 size_t parent_height = parent->height - parent_offset;
180 for (int i = 0; i < parent->children->length; ++i) { 192 for (int i = 0; i < parent->children->length; ++i) {
181 struct sway_container *child = parent->children->items[i]; 193 struct sway_container *child = parent->children->items[i];
182 child->x = parent->x; 194 child->x = parent->x;
183 child->y = parent->y; 195 child->y = parent->y + parent_offset;
184 child->width = parent->width; 196 child->width = parent->width;
185 child->height = parent->height; 197 child->height = parent_height;
186 } 198 }
187} 199}
188 200
@@ -217,7 +229,8 @@ void arrange_children_of(struct sway_container *parent) {
217 apply_vert_layout(parent); 229 apply_vert_layout(parent);
218 break; 230 break;
219 case L_TABBED: 231 case L_TABBED:
220 apply_tabbed_layout(parent); 232 case L_STACKED:
233 apply_tabbed_or_stacked_layout(parent);
221 break; 234 break;
222 default: 235 default:
223 wlr_log(L_DEBUG, "TODO: arrange layout type %d", parent->layout); 236 wlr_log(L_DEBUG, "TODO: arrange layout type %d", parent->layout);