feat: add consume & expel for scroller stack

This commit is contained in:
xtheeq 2026-05-07 00:27:01 +05:30
parent 42c02e3dc2
commit 9367499e49
3 changed files with 40 additions and 1 deletions

View file

@ -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;
}

View file

@ -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);

View file

@ -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 };