diff options
-rw-r--r-- | README.md | 5 | ||||
-rw-r--r-- | include/sway/container.h | 4 | ||||
-rw-r--r-- | include/sway/layout.h | 4 | ||||
-rw-r--r-- | sway/commands/layout.c | 22 | ||||
-rw-r--r-- | sway/commands/resize.c | 70 | ||||
-rw-r--r-- | sway/layout.c | 44 |
6 files changed, 79 insertions, 70 deletions
@@ -1,4 +1,3 @@ | |||
1 | |||
2 | # sway [![](https://api.travis-ci.org/SirCmpwn/sway.svg)](https://travis-ci.org/SirCmpwn/sway) [![Donate with fosspay](https://drewdevault.com/donate/static/donate-with-fosspay.png)](https://drewdevault.com/donate?project=4) | 1 | # sway [![](https://api.travis-ci.org/SirCmpwn/sway.svg)](https://travis-ci.org/SirCmpwn/sway) [![Donate with fosspay](https://drewdevault.com/donate/static/donate-with-fosspay.png)](https://drewdevault.com/donate?project=4) |
3 | 2 | ||
4 | "**S**irCmpwn's **Way**land compositor" is a **work in progress** | 3 | "**S**irCmpwn's **Way**land compositor" is a **work in progress** |
@@ -11,10 +10,6 @@ irc.freenode.net). | |||
11 | 10 | ||
12 | [More screenshots](https://github.com/SirCmpwn/sway/wiki/Screenshots-of-Sway) | 11 | [More screenshots](https://github.com/SirCmpwn/sway/wiki/Screenshots-of-Sway) |
13 | 12 | ||
14 | This fork attempts to add | ||
15 | [Awesome](http://awesomewm.org)/[Monad](http://xmonad.org) style auto layouts | ||
16 | to Sway. For us lazies that just want things to happen automatically! | ||
17 | |||
18 | ## Release Signatures | 13 | ## Release Signatures |
19 | 14 | ||
20 | Releases are signed with [B22DA89A](http://pgp.mit.edu/pks/lookup?op=vindex&search=0x52CB6609B22DA89A) | 15 | Releases are signed with [B22DA89A](http://pgp.mit.edu/pks/lookup?op=vindex&search=0x52CB6609B22DA89A) |
diff --git a/include/sway/container.h b/include/sway/container.h index f0574b1b..ff65628c 100644 --- a/include/sway/container.h +++ b/include/sway/container.h | |||
@@ -158,12 +158,12 @@ struct sway_container { | |||
158 | /** | 158 | /** |
159 | * Number of master views in auto layouts. | 159 | * Number of master views in auto layouts. |
160 | */ | 160 | */ |
161 | uint32_t nb_master; | 161 | size_t nb_master; |
162 | 162 | ||
163 | /** | 163 | /** |
164 | * Number of slave groups (e.g. columns) in auto layouts. | 164 | * Number of slave groups (e.g. columns) in auto layouts. |
165 | */ | 165 | */ |
166 | uint32_t nb_slave_groups; | 166 | size_t nb_slave_groups; |
167 | }; | 167 | }; |
168 | 168 | ||
169 | enum visibility_mask { | 169 | enum visibility_mask { |
diff --git a/include/sway/layout.h b/include/sway/layout.h index a771a72e..8cc513d8 100644 --- a/include/sway/layout.h +++ b/include/sway/layout.h | |||
@@ -75,7 +75,5 @@ void swayc_log(log_importance_t verbosity, swayc_t *cont, const char* format, .. | |||
75 | */ | 75 | */ |
76 | enum swayc_layouts default_layout(swayc_t *output); | 76 | enum swayc_layouts default_layout(swayc_t *output); |
77 | 77 | ||
78 | inline bool is_auto_layout(enum swayc_layouts layout) { | 78 | bool is_auto_layout(enum swayc_layouts layout); |
79 | return (layout >= L_AUTO_FIRST) && (layout <= L_AUTO_LAST); | ||
80 | } | ||
81 | #endif | 79 | #endif |
diff --git a/sway/commands/layout.c b/sway/commands/layout.c index 2da65765..0cdac1b4 100644 --- a/sway/commands/layout.c +++ b/sway/commands/layout.c | |||
@@ -64,11 +64,18 @@ struct cmd_results *cmd_layout(int argc, char **argv) { | |||
64 | } else if (strcasecmp(argv[0], "auto_bot") == 0) { | 64 | } else if (strcasecmp(argv[0], "auto_bot") == 0) { |
65 | swayc_change_layout(parent, L_AUTO_BOTTOM); | 65 | swayc_change_layout(parent, L_AUTO_BOTTOM); |
66 | } else if (strcasecmp(argv[0], "incnmaster") == 0) { | 66 | } else if (strcasecmp(argv[0], "incnmaster") == 0) { |
67 | if ((error = checkarg(argc, "layout incnmaster", | 67 | const char *name = "layout incnmaster"; |
68 | if ((error = checkarg(argc, name, | ||
68 | EXPECTED_EQUAL_TO, 2))) { | 69 | EXPECTED_EQUAL_TO, 2))) { |
69 | return error; | 70 | return error; |
70 | } | 71 | } |
71 | int inc = (int) strtol(argv[1], NULL, 10); | 72 | char *end; |
73 | int inc = (int) strtol(argv[1], &end, 10); | ||
74 | if (*end) { | ||
75 | return cmd_results_new(CMD_INVALID, name, "Invalid %s command " | ||
76 | "(argument must be an integer)", name); | ||
77 | |||
78 | } | ||
72 | swayc_t *container = get_focused_view(swayc_active_workspace()); | 79 | swayc_t *container = get_focused_view(swayc_active_workspace()); |
73 | if (container && inc && | 80 | if (container && inc && |
74 | is_auto_layout(container->parent->layout) && | 81 | is_auto_layout(container->parent->layout) && |
@@ -83,11 +90,18 @@ struct cmd_results *cmd_layout(int argc, char **argv) { | |||
83 | container->parent->nb_master += inc; | 90 | container->parent->nb_master += inc; |
84 | } | 91 | } |
85 | } else if ((strcasecmp(argv[0], "incncol") == 0) && argc ==2) { | 92 | } else if ((strcasecmp(argv[0], "incncol") == 0) && argc ==2) { |
86 | if ((error = checkarg(argc, "layout incncol", | 93 | const char *name = "layout incncol"; |
94 | if ((error = checkarg(argc, name, | ||
87 | EXPECTED_EQUAL_TO, 2))) { | 95 | EXPECTED_EQUAL_TO, 2))) { |
88 | return error; | 96 | return error; |
89 | } | 97 | } |
90 | int inc = (int) strtol(argv[1], NULL, 10); | 98 | char *end; |
99 | int inc = (int) strtol(argv[1], &end, 10); | ||
100 | if (*end) { | ||
101 | return cmd_results_new(CMD_INVALID, name, "Invalid %s command " | ||
102 | "(argument must be an integer)", name); | ||
103 | |||
104 | } | ||
91 | swayc_t *container = get_focused_view(swayc_active_workspace()); | 105 | swayc_t *container = get_focused_view(swayc_active_workspace()); |
92 | if (container && inc && is_auto_layout(container->parent->layout) && | 106 | if (container && inc && is_auto_layout(container->parent->layout) && |
93 | ((int)container->parent->nb_slave_groups + inc >= 1)) { | 107 | ((int)container->parent->nb_slave_groups + inc >= 1)) { |
diff --git a/sway/commands/resize.c b/sway/commands/resize.c index 9a756e81..1c052286 100644 --- a/sway/commands/resize.c +++ b/sway/commands/resize.c | |||
@@ -66,7 +66,7 @@ static bool resize_floating(int amount, bool use_width) { | |||
66 | * Return the number of children in the slave groups. This corresponds to the children | 66 | * Return the number of children in the slave groups. This corresponds to the children |
67 | * that are not members of the master group. | 67 | * that are not members of the master group. |
68 | */ | 68 | */ |
69 | static inline uint_fast32_t slave_count(swayc_t *container) { | 69 | static inline size_t auto_slave_count(swayc_t *container) { |
70 | return container->children->length - container->nb_master; | 70 | return container->children->length - container->nb_master; |
71 | 71 | ||
72 | } | 72 | } |
@@ -75,13 +75,13 @@ static inline uint_fast32_t slave_count(swayc_t *container) { | |||
75 | * given the index of a container's child, return the index of the first child of the group | 75 | * given the index of a container's child, return the index of the first child of the group |
76 | * which index is a member of. | 76 | * which index is a member of. |
77 | */ | 77 | */ |
78 | static int group_start_index(swayc_t *container, int index) { | 78 | static int auto_group_start_index(swayc_t *container, int index) { |
79 | if ((index < 0) || (! is_auto_layout(container->layout)) || | 79 | if (index < 0 || ! is_auto_layout(container->layout) |
80 | ((uint_fast32_t) index < container->nb_master)) { | 80 | || (size_t) index < container->nb_master) { |
81 | return 0; | 81 | return 0; |
82 | } else { | 82 | } else { |
83 | uint_fast32_t grp_sz = slave_count(container) / container->nb_slave_groups; | 83 | size_t grp_sz = auto_slave_count(container) / container->nb_slave_groups; |
84 | uint_fast32_t remainder = slave_count(container) % container->nb_slave_groups; | 84 | size_t remainder = auto_slave_count(container) % container->nb_slave_groups; |
85 | int start_idx; | 85 | int start_idx; |
86 | int idx2 = (container->nb_slave_groups - remainder) * grp_sz + container->nb_master; | 86 | int idx2 = (container->nb_slave_groups - remainder) * grp_sz + container->nb_master; |
87 | if (index < idx2) { | 87 | if (index < idx2) { |
@@ -98,16 +98,16 @@ static int group_start_index(swayc_t *container, int index) { | |||
98 | * that follows the one which index is a member of. | 98 | * that follows the one which index is a member of. |
99 | * This makes the function usable to walk through the groups in a container. | 99 | * This makes the function usable to walk through the groups in a container. |
100 | */ | 100 | */ |
101 | static int group_end_index(swayc_t *container, int index) { | 101 | static int auto_group_end_index(swayc_t *container, int index) { |
102 | if (index < 0 || ! is_auto_layout(container->layout)) { | 102 | if (index < 0 || ! is_auto_layout(container->layout)) { |
103 | return container->children->length; | 103 | return container->children->length; |
104 | } else { | 104 | } else { |
105 | int nxt_idx; | 105 | int nxt_idx; |
106 | if ((uint_fast32_t)index < container->nb_master) { | 106 | if ((size_t)index < container->nb_master) { |
107 | nxt_idx = container->nb_master; | 107 | nxt_idx = container->nb_master; |
108 | } else { | 108 | } else { |
109 | uint_fast32_t grp_sz = slave_count(container) / container->nb_slave_groups; | 109 | size_t grp_sz = auto_slave_count(container) / container->nb_slave_groups; |
110 | uint_fast32_t remainder = slave_count(container) % container->nb_slave_groups; | 110 | size_t remainder = auto_slave_count(container) % container->nb_slave_groups; |
111 | int idx2 = (container->nb_slave_groups - remainder) * grp_sz + container->nb_master; | 111 | int idx2 = (container->nb_slave_groups - remainder) * grp_sz + container->nb_master; |
112 | if (index < idx2) { | 112 | if (index < idx2) { |
113 | nxt_idx = ((index - container->nb_master) / grp_sz + 1) * grp_sz + container->nb_master; | 113 | nxt_idx = ((index - container->nb_master) / grp_sz + 1) * grp_sz + container->nb_master; |
@@ -122,30 +122,30 @@ static int group_end_index(swayc_t *container, int index) { | |||
122 | /** | 122 | /** |
123 | * Return the combined number of master and slave groups in the container. | 123 | * Return the combined number of master and slave groups in the container. |
124 | */ | 124 | */ |
125 | static inline uint_fast32_t group_count(swayc_t *container) { | 125 | static inline size_t auto_group_count(swayc_t *container) { |
126 | return MIN(container->nb_slave_groups, slave_count(container)) + (container->nb_master ? 1 : 0); | 126 | return MIN(container->nb_slave_groups, auto_slave_count(container)) + (container->nb_master ? 1 : 0); |
127 | } | 127 | } |
128 | 128 | ||
129 | /** | 129 | /** |
130 | * return the index of the Group containing <index>th child of <container>. | 130 | * return the index of the Group containing <index>th child of <container>. |
131 | * The index is the order of the group along the container's major axis (starting at 0). | 131 | * The index is the order of the group along the container's major axis (starting at 0). |
132 | */ | 132 | */ |
133 | static uint_fast32_t group_index(swayc_t *container, int index) { | 133 | static size_t auto_group_index(swayc_t *container, int index) { |
134 | if (index < 0) { | 134 | if (index < 0) { |
135 | return 0; | 135 | return 0; |
136 | } | 136 | } |
137 | bool master_first = (container->layout == L_AUTO_LEFT || container->layout == L_AUTO_TOP); | 137 | bool master_first = (container->layout == L_AUTO_LEFT || container->layout == L_AUTO_TOP); |
138 | int nb_slaves = slave_count(container); | 138 | int nb_slaves = auto_slave_count(container); |
139 | if ((uint_fast32_t) index < container->nb_master) { | 139 | if ((size_t) index < container->nb_master) { |
140 | if (master_first || nb_slaves <= 0) { | 140 | if (master_first || nb_slaves <= 0) { |
141 | return 0; | 141 | return 0; |
142 | } else { | 142 | } else { |
143 | return MIN(container->nb_slave_groups, nb_slaves); | 143 | return MIN(container->nb_slave_groups, nb_slaves); |
144 | } | 144 | } |
145 | } else { | 145 | } else { |
146 | uint_fast32_t grp_sz = slave_count(container) / container->nb_slave_groups; | 146 | size_t grp_sz = auto_slave_count(container) / container->nb_slave_groups; |
147 | uint_fast32_t remainder = slave_count(container) % container->nb_slave_groups; | 147 | size_t remainder = auto_slave_count(container) % container->nb_slave_groups; |
148 | uint_fast32_t grp_idx; | 148 | size_t grp_idx; |
149 | int idx2 = (container->nb_slave_groups - remainder) * grp_sz + container->nb_master; | 149 | int idx2 = (container->nb_slave_groups - remainder) * grp_sz + container->nb_master; |
150 | if (index < idx2) { | 150 | if (index < idx2) { |
151 | grp_idx = (index - container->nb_master) / grp_sz; | 151 | grp_idx = (index - container->nb_master) / grp_sz; |
@@ -161,16 +161,16 @@ static bool resize_tiled(int amount, bool use_width) { | |||
161 | swayc_t *parent = container->parent; | 161 | swayc_t *parent = container->parent; |
162 | int idx_focused = 0; | 162 | int idx_focused = 0; |
163 | bool use_major = false; | 163 | bool use_major = false; |
164 | uint_fast32_t nb_before = 0; | 164 | size_t nb_before = 0; |
165 | uint_fast32_t nb_after = 0; | 165 | size_t nb_after = 0; |
166 | 166 | ||
167 | // 1. Identify a container ancestor that will allow the focused child to grow in the requested | 167 | // 1. Identify a container ancestor that will allow the focused child to grow in the requested |
168 | // direction. | 168 | // direction. |
169 | while (container->parent) { | 169 | while (container->parent) { |
170 | parent = container->parent; | 170 | parent = container->parent; |
171 | if ((parent->children && parent->children->length > 1) && | 171 | if ((parent->children && parent->children->length > 1) |
172 | (is_auto_layout(parent->layout) || (use_width ? parent->layout == L_HORIZ : | 172 | && (is_auto_layout(parent->layout) |
173 | parent->layout == L_VERT))) { | 173 | || (use_width ? parent->layout == L_HORIZ : parent->layout == L_VERT))) { |
174 | // check if container has siblings that can provide/absorb the space needed for | 174 | // check if container has siblings that can provide/absorb the space needed for |
175 | // the resize operation. | 175 | // the resize operation. |
176 | use_major = use_width | 176 | use_major = use_width |
@@ -185,15 +185,15 @@ static bool resize_tiled(int amount, bool use_width) { | |||
185 | continue; | 185 | continue; |
186 | } | 186 | } |
187 | if (use_major) { | 187 | if (use_major) { |
188 | nb_before = group_index(parent, idx_focused); | 188 | nb_before = auto_group_index(parent, idx_focused); |
189 | nb_after = group_count(parent) - nb_before - 1; | 189 | nb_after = auto_group_count(parent) - nb_before - 1; |
190 | } else { | 190 | } else { |
191 | nb_before = idx_focused - group_start_index(parent, idx_focused); | 191 | nb_before = idx_focused - auto_group_start_index(parent, idx_focused); |
192 | nb_after = group_end_index(parent, idx_focused) - idx_focused - 1; | 192 | nb_after = auto_group_end_index(parent, idx_focused) - idx_focused - 1; |
193 | sway_log(L_DEBUG, "+++ focused: %d, start: %d, end: %d, before: %d, after: %d", | 193 | sway_log(L_DEBUG, "+++ focused: %d, start: %d, end: %d, before: %d, after: %d", |
194 | idx_focused, | 194 | idx_focused, |
195 | (int)group_start_index(parent, idx_focused), | 195 | (int)auto_group_start_index(parent, idx_focused), |
196 | (int)group_end_index(parent, idx_focused), | 196 | (int)auto_group_end_index(parent, idx_focused), |
197 | (int)nb_before, (int)nb_after); | 197 | (int)nb_before, (int)nb_after); |
198 | 198 | ||
199 | } | 199 | } |
@@ -206,14 +206,14 @@ static bool resize_tiled(int amount, bool use_width) { | |||
206 | if (parent == &root_container) { | 206 | if (parent == &root_container) { |
207 | return true; | 207 | return true; |
208 | } | 208 | } |
209 | sway_log(L_DEBUG, "Found the proper parent: %p. It has %" PRIuFAST32 " before conts, and %" | 209 | sway_log(L_DEBUG, "Found the proper parent: %p. It has %zu before conts, " |
210 | PRIuFAST32 " after conts", parent, nb_before, nb_after); | 210 | "and %zu after conts", parent, nb_before, nb_after); |
211 | // 2. Ensure that the resize operation will not make one of the resized containers drop | 211 | // 2. Ensure that the resize operation will not make one of the resized containers drop |
212 | // below the "sane" size threshold. | 212 | // below the "sane" size threshold. |
213 | bool valid = true; | 213 | bool valid = true; |
214 | swayc_t *focused = parent->children->items[idx_focused]; | 214 | swayc_t *focused = parent->children->items[idx_focused]; |
215 | int start = use_major ? 0 : group_start_index(parent, idx_focused); | 215 | int start = use_major ? 0 : auto_group_start_index(parent, idx_focused); |
216 | int end = use_major ? parent->children->length : group_end_index(parent, idx_focused); | 216 | int end = use_major ? parent->children->length : auto_group_end_index(parent, idx_focused); |
217 | sway_log(L_DEBUG, "Check children of container %p [%d,%d[", container, start, end); | 217 | sway_log(L_DEBUG, "Check children of container %p [%d,%d[", container, start, end); |
218 | for (int i = start; i < end; ) { | 218 | for (int i = start; i < end; ) { |
219 | swayc_t *sibling = parent->children->items[i]; | 219 | swayc_t *sibling = parent->children->items[i]; |
@@ -235,13 +235,13 @@ static bool resize_tiled(int amount, bool use_width) { | |||
235 | sway_log(L_DEBUG, "Container size no longer sane"); | 235 | sway_log(L_DEBUG, "Container size no longer sane"); |
236 | break; | 236 | break; |
237 | } | 237 | } |
238 | i = use_major ? group_end_index(parent, i) : (i + 1); | 238 | i = use_major ? auto_group_end_index(parent, i) : (i + 1); |
239 | sway_log(L_DEBUG, "+++++ check %i", i); | 239 | sway_log(L_DEBUG, "+++++ check %i", i); |
240 | } | 240 | } |
241 | // 3. Apply the size change | 241 | // 3. Apply the size change |
242 | if (valid) { | 242 | if (valid) { |
243 | for (int i = start; i < end; ) { | 243 | for (int i = start; i < end; ) { |
244 | int next_i = use_major ? group_end_index(parent, i) : (i + 1); | 244 | int next_i = use_major ? auto_group_end_index(parent, i) : (i + 1); |
245 | swayc_t *sibling = parent->children->items[i]; | 245 | swayc_t *sibling = parent->children->items[i]; |
246 | double pixels = amount; | 246 | double pixels = amount; |
247 | bool is_before = use_width ? sibling->x < focused->x : sibling->y < focused->y; | 247 | bool is_before = use_width ? sibling->x < focused->x : sibling->y < focused->y; |
diff --git a/sway/layout.c b/sway/layout.c index 6212ec75..faab9196 100644 --- a/sway/layout.c +++ b/sway/layout.c | |||
@@ -253,8 +253,7 @@ void swap_geometry(swayc_t *a, swayc_t *b) { | |||
253 | void move_container(swayc_t *container, enum movement_direction dir) { | 253 | void move_container(swayc_t *container, enum movement_direction dir) { |
254 | enum swayc_layouts layout = L_NONE; | 254 | enum swayc_layouts layout = L_NONE; |
255 | swayc_t *parent = container->parent; | 255 | swayc_t *parent = container->parent; |
256 | if (container->is_floating | 256 | if (container->is_floating || (container->type != C_VIEW && container->type != C_CONTAINER)) { |
257 | || (container->type != C_VIEW && container->type != C_CONTAINER)) { | ||
258 | return; | 257 | return; |
259 | } | 258 | } |
260 | if (dir == MOVE_UP || dir == MOVE_DOWN) { | 259 | if (dir == MOVE_UP || dir == MOVE_DOWN) { |
@@ -323,14 +322,14 @@ void move_container(swayc_t *container, enum movement_direction dir) { | |||
323 | // if move command makes container change from master to slave | 322 | // if move command makes container change from master to slave |
324 | // (or the contrary), reset its geometry an the one of the replaced item. | 323 | // (or the contrary), reset its geometry an the one of the replaced item. |
325 | if (parent->nb_master && | 324 | if (parent->nb_master && |
326 | (uint_fast32_t) parent->children->length > parent->nb_master) { | 325 | (size_t) parent->children->length > parent->nb_master) { |
327 | swayc_t *swap_geom = NULL; | 326 | swayc_t *swap_geom = NULL; |
328 | // if child is being promoted/demoted, it will swap geometry | 327 | // if child is being promoted/demoted, it will swap geometry |
329 | // with the sibling being demoted/promoted. | 328 | // with the sibling being demoted/promoted. |
330 | if ((dir == MOVE_NEXT && desired == 0) | 329 | if ((dir == MOVE_NEXT && desired == 0) |
331 | || (dir == MOVE_PREV && (uint_fast32_t) desired == parent->nb_master - 1)) { | 330 | || (dir == MOVE_PREV && (size_t) desired == parent->nb_master - 1)) { |
332 | swap_geom = parent->children->items[parent->nb_master - 1]; | 331 | swap_geom = parent->children->items[parent->nb_master - 1]; |
333 | } else if ((dir == MOVE_NEXT && (uint_fast32_t) desired == parent->nb_master) | 332 | } else if ((dir == MOVE_NEXT && (size_t) desired == parent->nb_master) |
334 | || (dir == MOVE_PREV && desired == parent->children->length - 1)) { | 333 | || (dir == MOVE_PREV && desired == parent->children->length - 1)) { |
335 | swap_geom = parent->children->items[parent->nb_master]; | 334 | swap_geom = parent->children->items[parent->nb_master]; |
336 | } | 335 | } |
@@ -822,20 +821,24 @@ void update_geometry(swayc_t *container) { | |||
822 | } | 821 | } |
823 | } | 822 | } |
824 | 823 | ||
824 | bool is_auto_layout(enum swayc_layouts layout) { | ||
825 | return (layout >= L_AUTO_FIRST) && (layout <= L_AUTO_LAST); | ||
826 | } | ||
827 | |||
825 | /** | 828 | /** |
826 | * Layout application prototypes | 829 | * Layout application prototypes |
827 | */ | 830 | */ |
828 | static void apply_horiz_layout(swayc_t *container, const double x, | 831 | static void apply_horiz_layout(swayc_t *container, const double x, |
829 | const double y, const double width, | 832 | const double y, const double width, |
830 | const double height, const int start, | 833 | const double height, const int start, |
831 | const int end); | 834 | const int end); |
832 | static void apply_vert_layout(swayc_t *container, const double x, | 835 | static void apply_vert_layout(swayc_t *container, const double x, |
833 | const double y, const double width, | 836 | const double y, const double width, |
834 | const double height, const int start, | 837 | const double height, const int start, |
835 | const int end); | 838 | const int end); |
836 | static void apply_tabbed_or_stacked_layout(swayc_t *container, double x, | 839 | static void apply_tabbed_or_stacked_layout(swayc_t *container, double x, |
837 | double y, double width, | 840 | double y, double width, |
838 | double height); | 841 | double height); |
839 | 842 | ||
840 | static void apply_auto_layout(swayc_t *container, const double x, const double y, | 843 | static void apply_auto_layout(swayc_t *container, const double x, const double y, |
841 | const double width, const double height, | 844 | const double width, const double height, |
@@ -1164,8 +1167,8 @@ void apply_auto_layout(swayc_t *container, const double x, const double y, | |||
1164 | // a single slave group (containing slave 1 and 2). The master | 1167 | // a single slave group (containing slave 1 and 2). The master |
1165 | // group and slave group are layed out using L_VERT. | 1168 | // group and slave group are layed out using L_VERT. |
1166 | 1169 | ||
1167 | uint_fast32_t nb_slaves = container->children->length - container->nb_master; | 1170 | size_t nb_slaves = container->children->length - container->nb_master; |
1168 | uint_fast32_t nb_groups = (container->nb_master > 0 ? 1 : 0) + | 1171 | size_t nb_groups = (container->nb_master > 0 ? 1 : 0) + |
1169 | MIN(container->nb_slave_groups, nb_slaves); | 1172 | MIN(container->nb_slave_groups, nb_slaves); |
1170 | 1173 | ||
1171 | // the target dimension of the container along the "major" axis, each | 1174 | // the target dimension of the container along the "major" axis, each |
@@ -1186,9 +1189,9 @@ void apply_auto_layout(swayc_t *container, const double x, const double y, | |||
1186 | // height and width of next group to be laid out. | 1189 | // height and width of next group to be laid out. |
1187 | const double *group_h, *group_w; | 1190 | const double *group_h, *group_w; |
1188 | 1191 | ||
1189 | switch(group_layout) { | 1192 | switch (group_layout) { |
1190 | default: | 1193 | default: |
1191 | sway_log(L_ERROR, "Unknown layout type (%d) used in %s()", | 1194 | sway_log(L_DEBUG, "Unknown layout type (%d) used in %s()", |
1192 | group_layout, __func__); | 1195 | group_layout, __func__); |
1193 | /* fall through */ | 1196 | /* fall through */ |
1194 | case L_VERT: | 1197 | case L_VERT: |
@@ -1216,7 +1219,7 @@ void apply_auto_layout(swayc_t *container, const double x, const double y, | |||
1216 | * layout. */ | 1219 | * layout. */ |
1217 | double old_group_dim[nb_groups]; | 1220 | double old_group_dim[nb_groups]; |
1218 | double old_dim = 0; | 1221 | double old_dim = 0; |
1219 | uint_fast32_t group = 0; | 1222 | size_t group = 0; |
1220 | for (int i = 0; i < container->children->length;) { | 1223 | for (int i = 0; i < container->children->length;) { |
1221 | swayc_t *child = container->children->items[i]; | 1224 | swayc_t *child = container->children->items[i]; |
1222 | double *dim = group_layout == L_HORIZ ? &child->height : &child->width; | 1225 | double *dim = group_layout == L_HORIZ ? &child->height : &child->width; |
@@ -1252,7 +1255,7 @@ void apply_auto_layout(swayc_t *container, const double x, const double y, | |||
1252 | 1255 | ||
1253 | for (group = 0; group < nb_groups; ++group) { | 1256 | for (group = 0; group < nb_groups; ++group) { |
1254 | // column to include next by increasing position. | 1257 | // column to include next by increasing position. |
1255 | uint_fast32_t layout_group = master_first ? group : (group + 1) % nb_groups; | 1258 | size_t layout_group = master_first ? group : (group + 1) % nb_groups; |
1256 | 1259 | ||
1257 | // adjusted size of the group | 1260 | // adjusted size of the group |
1258 | group_dim = old_group_dim[layout_group] * scale; | 1261 | group_dim = old_group_dim[layout_group] * scale; |
@@ -1270,8 +1273,7 @@ void apply_auto_layout(swayc_t *container, const double x, const double y, | |||
1270 | if (group == nb_groups - 1) { | 1273 | if (group == nb_groups - 1) { |
1271 | group_dim = pos_maj + dim_maj - pos; // remaining width | 1274 | group_dim = pos_maj + dim_maj - pos; // remaining width |
1272 | } | 1275 | } |
1273 | sway_log(L_DEBUG, "Arranging container %p column %" PRIuFAST32 | 1276 | sway_log(L_DEBUG, "Arranging container %p column %zu, children [%d,%d[ (%fx%f+%f,%f)", |
1274 | ", children [%d,%d[ (%fx%f+%f,%f)", | ||
1275 | container, group, start, end, *group_w, *group_h, *group_x, *group_y); | 1277 | container, group, start, end, *group_w, *group_h, *group_x, *group_y); |
1276 | switch (group_layout) { | 1278 | switch (group_layout) { |
1277 | default: | 1279 | default: |