mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-05-20 21:38:15 -04:00
fix: error when move head out of stack in scroller layout
This commit is contained in:
parent
8eb0323e03
commit
3a1920f024
1 changed files with 27 additions and 32 deletions
|
|
@ -1808,15 +1808,25 @@ int32_t scroller_apply_stack(Client *c, Client *target_client,
|
||||||
|
|
||||||
Monitor *m = c->mon;
|
Monitor *m = c->mon;
|
||||||
uint32_t tag = m->pertag->curtag;
|
uint32_t tag = m->pertag->curtag;
|
||||||
|
|
||||||
|
bool is_horizontal = (m->pertag->ltidxs[tag]->id == SCROLLER);
|
||||||
|
|
||||||
|
if (is_horizontal && (direction == UP || direction == DOWN))
|
||||||
|
return 0;
|
||||||
|
if (!is_horizontal && (direction == LEFT || direction == RIGHT))
|
||||||
|
return 0;
|
||||||
|
|
||||||
struct TagScrollerState *st = ensure_scroller_state(m, tag);
|
struct TagScrollerState *st = ensure_scroller_state(m, tag);
|
||||||
|
|
||||||
/* 获取当前节点 */
|
/* 获取当前节点 */
|
||||||
struct ScrollerStackNode *cnode = find_scroller_node(st, c);
|
struct ScrollerStackNode *cnode = find_scroller_node(st, c);
|
||||||
|
|
||||||
|
if (!cnode)
|
||||||
|
return 0;
|
||||||
|
|
||||||
struct ScrollerStackNode *tnode =
|
struct ScrollerStackNode *tnode =
|
||||||
target_client ? find_scroller_node(st, target_client) : NULL;
|
target_client ? find_scroller_node(st, target_client) : NULL;
|
||||||
|
|
||||||
bool is_horizontal = (m->pertag->ltidxs[tag]->id == SCROLLER);
|
|
||||||
|
|
||||||
/* 若方向为 UNDIR 且有目标,直接插入到目标尾部 */
|
/* 若方向为 UNDIR 且有目标,直接插入到目标尾部 */
|
||||||
if (direction == UNDIR && target_client && target_client->mon == c->mon) {
|
if (direction == UNDIR && target_client && target_client->mon == c->mon) {
|
||||||
scroller_insert_stack(c, target_client, false);
|
scroller_insert_stack(c, target_client, false);
|
||||||
|
|
@ -1824,39 +1834,25 @@ int32_t scroller_apply_stack(Client *c, Client *target_client,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 处理从堆叠中移出的情况(方向 LEFT/UP 或 RIGHT/DOWN) */
|
/* 处理从堆叠中移出的情况(方向 LEFT/UP 或 RIGHT/DOWN) */
|
||||||
if (cnode && (cnode->prev_in_stack || cnode->next_in_stack)) {
|
if (cnode->prev_in_stack || cnode->next_in_stack) {
|
||||||
bool to_left_or_up = (is_horizontal && direction == LEFT) ||
|
struct ScrollerStackNode *move_out_refer_node =
|
||||||
(!is_horizontal && direction == UP);
|
cnode->prev_in_stack ? cnode->prev_in_stack : cnode->next_in_stack;
|
||||||
bool to_right_or_down = (is_horizontal && direction == RIGHT) ||
|
scroller_node_remove(st, cnode);
|
||||||
(!is_horizontal && direction == DOWN);
|
Client *stack_head =
|
||||||
|
scroll_get_stack_head_client(move_out_refer_node->client);
|
||||||
if (to_left_or_up || to_right_or_down) {
|
if (direction == LEFT || direction == UP) {
|
||||||
/* 找到当前堆叠的头节点,以便移动全局链表位置 */
|
|
||||||
struct ScrollerStackNode *head = cnode;
|
|
||||||
while (head->prev_in_stack)
|
|
||||||
head = head->prev_in_stack;
|
|
||||||
Client *source_stack_head = head->client;
|
|
||||||
|
|
||||||
/* 从 tag 状态中移除该客户端对应的节点 */
|
|
||||||
scroller_node_remove(st, cnode);
|
|
||||||
/* 重新创建一个独立的节点(无堆叠关系) */
|
|
||||||
scroller_node_create(st, c);
|
|
||||||
|
|
||||||
/* 调整全局客户端链表顺序:移到源堆叠头的前面或后面 */
|
|
||||||
wl_list_remove(&c->link);
|
wl_list_remove(&c->link);
|
||||||
if (to_left_or_up)
|
wl_list_insert(stack_head->link.prev, &c->link);
|
||||||
wl_list_insert(source_stack_head->link.prev, &c->link);
|
} else if (direction == RIGHT || direction == DOWN) {
|
||||||
else
|
wl_list_remove(&c->link);
|
||||||
wl_list_insert(&source_stack_head->link, &c->link);
|
wl_list_insert(&stack_head->link, &c->link);
|
||||||
|
|
||||||
/* 同步到客户端字段并重排 */
|
|
||||||
sync_scroller_state_to_clients(m, tag);
|
|
||||||
arrange(m, false, false);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
sync_scroller_state_to_clients(m, tag);
|
||||||
|
arrange(m, false, false);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!target_client || target_client->mon != c->mon)
|
if (!tnode || target_client->mon != c->mon)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* 找到目标堆叠的尾部节点 */
|
/* 找到目标堆叠的尾部节点 */
|
||||||
|
|
@ -1866,7 +1862,6 @@ int32_t scroller_apply_stack(Client *c, Client *target_client,
|
||||||
|
|
||||||
/* 通过封装好的插入函数实现(尾部插入) */
|
/* 通过封装好的插入函数实现(尾部插入) */
|
||||||
scroller_insert_stack(c, tail->client, false);
|
scroller_insert_stack(c, tail->client, false);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue