summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/modules/compose/compose.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/modules/compose/compose.c b/src/modules/compose/compose.c
index f3a1442..38ea539 100644
--- a/src/modules/compose/compose.c
+++ b/src/modules/compose/compose.c
@@ -171,21 +171,24 @@ static void compose_render_fragment(til_module_context_t *context, til_stream_t
/* return a randomized valid layers= setting */
static char * compose_random_layers_setting(unsigned seed)
{
- size_t n_modules, n_rand_overlays, n_overlayable = 0, base_idx;
+ size_t n_modules, n_rand_overlays, n_overlayable = 0, n_unusable = 0, base_idx;
char *layers = NULL;
const til_module_t **modules;
til_get_modules(&modules, &n_modules);
for (size_t i = 0; i < n_modules; i++) {
- if ((modules[i]->flags & (TIL_MODULE_HERMETIC | TIL_MODULE_EXPERIMENTAL)))
+ if ((modules[i]->flags & (TIL_MODULE_HERMETIC | TIL_MODULE_EXPERIMENTAL))) {
+ n_unusable++;
+
continue;
+ }
if (modules[i]->flags & TIL_MODULE_OVERLAYABLE)
n_overlayable++;
}
- base_idx = rand_r(&seed) % (n_modules - n_overlayable);
+ base_idx = rand_r(&seed) % (n_modules - (n_overlayable + n_unusable));
for (size_t i = 0, j = 0; !layers && i < n_modules; i++) {
if ((modules[i]->flags & (TIL_MODULE_HERMETIC | TIL_MODULE_EXPERIMENTAL)))
continue;
© All Rights Reserved