From 535f41e76b3f47f2ccd9945d537516a8bb486308 Mon Sep 17 00:00:00 2001 From: nixpup Date: Fri, 16 Jan 2026 23:40:13 +0100 Subject: [PATCH] feat: Add stacker_loop option This commit introduces a new configuration option `stacker_loop` to control the behavior of the `stack_with_left` function. When `stacker_loop` is set to `false` in the user's `config.conf`, invoking `stack_with_left` on the first window in the layout will have no effect. When `stacker_loop` is set to `true` or is not present in the config file, the default behavior is maintained, where `stack_with_left` on the first window will wrap around and create a stack with the last window. This provides users with more control over the stacking behavior in the stacker layout. --- src/config/parse_config.h | 3 +++ src/config/preset.h | 1 + src/dispatch/bind_define.h | 14 ++++++++++++++ 3 files changed, 18 insertions(+) diff --git a/src/config/parse_config.h b/src/config/parse_config.h index a90e337..3020485 100644 --- a/src/config/parse_config.h +++ b/src/config/parse_config.h @@ -205,6 +205,7 @@ typedef struct { int32_t scroller_ignore_proportion_single; int32_t scroller_focus_center; int32_t scroller_prefer_center; + int32_t stacker_loop; int32_t edge_scroller_pointer_focus; int32_t focus_cross_monitor; int32_t exchange_cross_monitor; @@ -1241,6 +1242,8 @@ void parse_option(Config *config, char *key, char *value) { config->scroller_focus_center = atoi(value); } else if (strcmp(key, "scroller_prefer_center") == 0) { config->scroller_prefer_center = atoi(value); + } else if (strcmp(key, "stacker_loop") == 0) { + config->stacker_loop = atoi(value); } else if (strcmp(key, "edge_scroller_pointer_focus") == 0) { config->edge_scroller_pointer_focus = atoi(value); } else if (strcmp(key, "focus_cross_monitor") == 0) { diff --git a/src/config/preset.h b/src/config/preset.h index 6f3cd89..2955eba 100644 --- a/src/config/preset.h +++ b/src/config/preset.h @@ -65,6 +65,7 @@ float scroller_default_proportion_single = 1.0; int32_t scroller_ignore_proportion_single = 0; int32_t scroller_focus_center = 0; int32_t scroller_prefer_center = 0; +int32_t stacker_loop = 1; int32_t focus_cross_monitor = 0; int32_t focus_cross_tag = 0; int32_t exchange_cross_monitor = 0; diff --git a/src/dispatch/bind_define.h b/src/dispatch/bind_define.h index e50d63c..694d610 100644 --- a/src/dispatch/bind_define.h +++ b/src/dispatch/bind_define.h @@ -1623,6 +1623,20 @@ int32_t stack_with_left(const Arg *arg) { if (!c || c->isfloating || !is_scroller_layout(selmon)) return 0; + if (!config.stacker_loop) { + Client *first_tiled = NULL; + Client *iter_c = NULL; + wl_list_for_each(iter_c, &clients, link) { + if (ISTILED(iter_c) && VISIBLEON(iter_c, selmon)) { + first_tiled = iter_c; + break; + } + } + if (c == first_tiled) { + return 0; // It's the first client and loop is disabled, so do nothing. + } + } + Client *left_c = get_next_stack_client(c, true); if (!left_c) return 0;