mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-05-10 23:50:41 -04:00
refactor: split scroller_stack consume/expel into standalone dispatchers
This commit is contained in:
parent
111e647c24
commit
674618643b
5 changed files with 48 additions and 32 deletions
|
|
@ -145,8 +145,8 @@ bindr=Super,Super_L,spawn,rofi -show run
|
|||
| `set_proportion` | `float` | Set scroller window proportion (0.0–1.0). |
|
||||
| `switch_proportion_preset` | - | Cycle proportion presets of scroller window. |
|
||||
| `scroller_stack` | `left/right/up/down` | Move window inside/outside scroller stack by direction. |
|
||||
| `scroller_stack` | `consume` | Add the adjacent neighbor into the current stack. |
|
||||
| `scroller_stack` | `expel` | Remove the last window from the current stack. |
|
||||
| `scroller_stack_consume` | - | Add the adjacent neighbor into the current stack. |
|
||||
| `scroller_stack_expel` | - | Remove the last window from the current stack. |
|
||||
| `incgaps` | `+/-value` | Adjust gap size. |
|
||||
| `togglegaps` | - | Toggle gaps. |
|
||||
|
||||
|
|
|
|||
|
|
@ -537,10 +537,6 @@ 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;
|
||||
}
|
||||
|
|
@ -1216,6 +1212,10 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value,
|
|||
} else if (strcmp(func_name, "scroller_stack") == 0) {
|
||||
func = scroller_stack;
|
||||
(*arg).i = parse_direction(arg_value);
|
||||
} else if (strcmp(func_name, "scroller_stack_consume") == 0) {
|
||||
func = scroller_stack_consume;
|
||||
} else if (strcmp(func_name, "scroller_stack_expel") == 0) {
|
||||
func = scroller_stack_expel;
|
||||
} else if (strcmp(func_name, "toggle_all_floating") == 0) {
|
||||
func = toggle_all_floating;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -70,4 +70,6 @@ int32_t disable_monitor(const Arg *arg);
|
|||
int32_t enable_monitor(const Arg *arg);
|
||||
int32_t toggle_monitor(const Arg *arg);
|
||||
int32_t scroller_stack(const Arg *arg);
|
||||
int32_t scroller_stack_consume(const Arg *arg);
|
||||
int32_t scroller_stack_expel(const Arg *arg);
|
||||
int32_t toggle_all_floating(const Arg *arg);
|
||||
|
|
@ -1855,44 +1855,58 @@ 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, false, true);
|
||||
|
||||
Client *target_client = find_client_by_direction(c, &(Arg){.i = consume_dir}, false, true);
|
||||
return scroller_apply_stack(c, target_client, arg->i);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
int32_t scroller_stack_consume(const Arg *arg) {
|
||||
if (!selmon)
|
||||
return 0;
|
||||
Client *c = selmon->sel;
|
||||
if (!c || !c->mon || c->isfloating || !is_scroller_layout(selmon))
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (arg->i == EXPEL) {
|
||||
Client *stack_head = get_scroll_stack_head(c);
|
||||
Client *stack_tail = stack_head;
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
if (target_client != stack_tail) {
|
||||
scroller_insert_stack(target_client, stack_tail, false);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t scroller_stack_expel(const Arg *arg) {
|
||||
if (!selmon)
|
||||
return 0;
|
||||
Client *c = selmon->sel;
|
||||
if (!c || !c->mon || c->isfloating || !is_scroller_layout(selmon))
|
||||
return 0;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
Client *target_client = find_client_by_direction(c, arg, false, true);
|
||||
|
||||
return scroller_apply_stack(c, target_client, arg->i);
|
||||
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;
|
||||
}
|
||||
|
||||
int32_t toggle_all_floating(const Arg *arg) {
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ enum {
|
|||
NetLast
|
||||
}; /* EWMH atoms */
|
||||
#endif
|
||||
enum { UP, DOWN, LEFT, RIGHT, UNDIR, CONSUME, EXPEL }; /* smartmovewin */
|
||||
enum { UP, DOWN, LEFT, RIGHT, UNDIR }; /* smartmovewin */
|
||||
enum { NONE, OPEN, MOVE, CLOSE, TAG, FOCUS, OPAFADEIN, OPAFADEOUT };
|
||||
enum { UNFOLD, FOLD, INVALIDFOLD };
|
||||
enum { PREV, NEXT };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue