aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/arrange.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-05-21 22:58:46 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-05-22 08:27:24 +1000
commit664169fbf1c4e07f17a48b2b801dad9cea31ea4c (patch)
treee20b1f39a89abd5a6567f7e9d398f002e9ee5bee /sway/tree/arrange.c
parentFix focus follows mouse with no focus (diff)
downloadsway-664169fbf1c4e07f17a48b2b801dad9cea31ea4c.tar.gz
sway-664169fbf1c4e07f17a48b2b801dad9cea31ea4c.tar.zst
sway-664169fbf1c4e07f17a48b2b801dad9cea31ea4c.zip
Implement stacked layout
Diffstat (limited to 'sway/tree/arrange.c')
-rw-r--r--sway/tree/arrange.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/sway/tree/arrange.c b/sway/tree/arrange.c
index 8aebc0cc..b8e07bca 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 = config->font_height + 8;
93 parent_height -= parent_offset; 92 } else if (parent->parent->layout == L_STACKED) {
93 parent_offset = (config->font_height + 8)
94 * 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 = config->font_height + 8;
139 parent_height -= parent_offset; 140 } else if (parent->parent->layout == L_STACKED) {
141 parent_offset = (config->font_height + 8)
142 * 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;
@@ -186,6 +190,19 @@ static void apply_tabbed_layout(struct sway_container *parent) {
186 } 190 }
187} 191}
188 192
193static void apply_stacked_layout(struct sway_container *parent) {
194 if (!parent->children->length) {
195 return;
196 }
197 for (int i = 0; i < parent->children->length; ++i) {
198 struct sway_container *child = parent->children->items[i];
199 child->x = parent->x;
200 child->y = parent->y;
201 child->width = parent->width;
202 child->height = parent->height;
203 }
204}
205
189void arrange_children_of(struct sway_container *parent) { 206void arrange_children_of(struct sway_container *parent) {
190 if (config->reloading) { 207 if (config->reloading) {
191 return; 208 return;
@@ -219,6 +236,9 @@ void arrange_children_of(struct sway_container *parent) {
219 case L_TABBED: 236 case L_TABBED:
220 apply_tabbed_layout(parent); 237 apply_tabbed_layout(parent);
221 break; 238 break;
239 case L_STACKED:
240 apply_stacked_layout(parent);
241 break;
222 default: 242 default:
223 wlr_log(L_DEBUG, "TODO: arrange layout type %d", parent->layout); 243 wlr_log(L_DEBUG, "TODO: arrange layout type %d", parent->layout);
224 apply_horiz_layout(parent); 244 apply_horiz_layout(parent);