From 9367499e4917c7fca9ec41169a9a7b8a493afe87 Mon Sep 17 00:00:00 2001 From: xtheeq Date: Thu, 7 May 2026 00:27:01 +0530 Subject: [PATCH] feat: add consume & expel for scroller stack --- src/config/parse_config.h | 4 ++++ src/dispatch/bind_define.h | 35 +++++++++++++++++++++++++++++++++++ src/mango.c | 2 +- 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/config/parse_config.h b/src/config/parse_config.h index f70a17d6..853dda1c 100644 --- a/src/config/parse_config.h +++ b/src/config/parse_config.h @@ -537,6 +537,10 @@ int32_t parse_direction(const char *str) { return LEFT; } else if (strcmp(lowerStr, "right") == 0) { return RIGHT; + } else if (strcmp(lowerStr, "consume") == 0) { + return CONSUME; + } else if (strcmp(lowerStr, "expel") == 0) { + return EXPEL; } else { return UNDIR; } diff --git a/src/dispatch/bind_define.h b/src/dispatch/bind_define.h index f8822af3..19b89aa6 100644 --- a/src/dispatch/bind_define.h +++ b/src/dispatch/bind_define.h @@ -1855,6 +1855,41 @@ int32_t scroller_stack(const Arg *arg) { if (!c || !c->mon || c->isfloating || !is_scroller_layout(selmon)) return 0; + if (arg->i == CONSUME) { + bool is_horizontal_layout = + c->mon->pertag->ltidxs[c->mon->pertag->curtag]->id == SCROLLER; + int32_t consume_dir = is_horizontal_layout ? RIGHT : DOWN; + + Client *target_client = find_client_by_direction(c, &(Arg){.i = consume_dir}, false, true); + + if (target_client) { + Client *stack_tail = get_scroll_stack_head(c); + while (stack_tail->next_in_stack) { + stack_tail = stack_tail->next_in_stack; + } + + scroller_insert_stack(target_client, stack_tail, false); + } + return 0; + } + + if (arg->i == EXPEL) { + Client *stack_head = get_scroll_stack_head(c); + Client *stack_tail = stack_head; + + while (stack_tail->next_in_stack) { + stack_tail = stack_tail->next_in_stack; + } + + if (stack_tail != stack_head) { + exit_scroller_stack(stack_tail); + wl_list_remove(&stack_tail->link); + wl_list_insert(&stack_head->link, &stack_tail->link); + arrange(selmon, false, false); + } + return 0; + } + Client *target_client = find_client_by_direction(c, arg, false, true); return scroller_apply_stack(c, target_client, arg->i); diff --git a/src/mango.c b/src/mango.c index b4bc67bf..e15fbb29 100644 --- a/src/mango.c +++ b/src/mango.c @@ -172,7 +172,7 @@ enum { NetLast }; /* EWMH atoms */ #endif -enum { UP, DOWN, LEFT, RIGHT, UNDIR }; /* smartmovewin */ +enum { UP, DOWN, LEFT, RIGHT, UNDIR, CONSUME, EXPEL }; /* smartmovewin */ enum { NONE, OPEN, MOVE, CLOSE, TAG, FOCUS, OPAFADEIN, OPAFADEOUT }; enum { UNFOLD, FOLD, INVALIDFOLD }; enum { PREV, NEXT };