Skip to content

Commit 1893218

Browse files
committed
fix: readd stack, unstack
1 parent 524d465 commit 1893218

3 files changed

Lines changed: 58 additions & 27 deletions

File tree

include/scroller.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ bool scroller_focus_down(desktop_t *d);
6161
bool scroller_focus_up(desktop_t *d);
6262
void scroller_center_window(desktop_t *d, client_t *client);
6363

64+
bool scroller_consume_into_column(desktop_t *d);
65+
bool scroller_expel_from_column(desktop_t *d);
66+
6467
bool scroller_is_tiled(const client_t *c);
6568
void scroller_apply_client_rules(client_t *c, float rule_proportion, float rule_proportion_single);
6669

src/ipc_cmd/scroller.c

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -72,25 +72,11 @@ void ipc_cmd_scroller(char **args, int num, int client_fd) {
7272
return;
7373
}
7474

75-
node_t *target = prev_leaf(desk->focus, desk->root);
76-
if (!target || !target->client) {
77-
send_failure(client_fd, "scroller stack: no target to stack with\n");
75+
if (!scroller_consume_into_column(desk)) {
76+
send_failure(client_fd, "scroller stack: nothing to stack into\n");
7877
return;
7978
}
8079

81-
// find target's column and move focused client into it
82-
if (!s) {
83-
send_failure(client_fd, "scroller stack: not in scroller layout\n");
84-
return;
85-
}
86-
87-
int target_col, target_tile;
88-
if (!find_focused_tile(desk, &target_col, &target_tile)) {
89-
send_failure(client_fd, "scroller stack: find focused failed\n");
90-
return;
91-
}
92-
93-
// TODO: proper consume or expel window logic
9480
arrange(mon, desk, true);
9581
send_success(client_fd, "stacked\n");
9682
} else if (streq("unstack", *args)) {
@@ -99,7 +85,11 @@ void ipc_cmd_scroller(char **args, int num, int client_fd) {
9985
return;
10086
}
10187

102-
// TODO: proper unstack (remove from column, create new column).
88+
if (!scroller_expel_from_column(desk)) {
89+
send_failure(client_fd, "scroller unstack: nothing to unstack\n");
90+
return;
91+
}
92+
10393
arrange(mon, desk, true);
10494
send_success(client_fd, "unstacked\n");
10595
} else if (streq("resize", *args)) {

src/scroller.c

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -504,18 +504,56 @@ bool scroller_focus_up(desktop_t *d) {
504504
}
505505

506506
void scroller_center_window(desktop_t *d, client_t *client) {
507-
scroller_state_t *s = d->scroller_state;
508-
if (!s || !client)
509-
return;
507+
scroller_state_t *s = d->scroller_state;
508+
if (!s || !client)
509+
return;
510+
511+
int col_idx, tile_idx;
512+
if (!find_tile(s, client, &col_idx, &tile_idx))
513+
return;
514+
515+
s->active_column_idx = col_idx;
516+
s->columns[col_idx].active_tile_idx = tile_idx;
517+
s->view_offset = 0.0;
518+
apply_active_focus(d);
519+
}
510520

511-
int col_idx, tile_idx;
512-
if (!find_tile(s, client, &col_idx, &tile_idx))
513-
return;
521+
// ── Consume / Expel ────────────────────────────────────────────────────────
514522

515-
s->active_column_idx = col_idx;
516-
s->columns[col_idx].active_tile_idx = tile_idx;
517-
s->view_offset = 0.0;
518-
apply_active_focus(d);
523+
bool scroller_consume_into_column(desktop_t *d) {
524+
scroller_state_t *s = d ? d->scroller_state : NULL;
525+
if (!s || s->column_count < 2) return false;
526+
527+
int col = s->active_column_idx;
528+
if (col == 0) return false;
529+
530+
scroller_column_t *src = &s->columns[col];
531+
if (src->tile_count == 0) return false;
532+
533+
client_t *cl = src->tiles[src->active_tile_idx].client;
534+
if (!cl) return false;
535+
536+
scroller_remove_tile(s, cl, NULL);
537+
538+
int target_col = col - 1;
539+
if (target_col >= s->column_count) return false;
540+
541+
return scroller_add_tile_to_column(s, cl, target_col, true);
542+
}
543+
544+
bool scroller_expel_from_column(desktop_t *d) {
545+
scroller_state_t *s = d ? d->scroller_state : NULL;
546+
if (!s || s->column_count == 0) return false;
547+
548+
int col = s->active_column_idx;
549+
scroller_column_t *src = &s->columns[col];
550+
if (src->tile_count < 2) return false;
551+
552+
client_t *cl = src->tiles[src->active_tile_idx].client;
553+
if (!cl) return false;
554+
555+
scroller_remove_tile(s, cl, NULL);
556+
return scroller_add_tile(s, cl, true);
519557
}
520558

521559
bool scroller_is_tiled(const client_t *c) {

0 commit comments

Comments
 (0)