opt: Ensure that the client remains in the linked list until it is destroyed

This commit is contained in:
DreamMaoMao 2026-06-29 09:58:13 +08:00
parent b73cd4ef90
commit 3b3170ef7d
6 changed files with 49 additions and 41 deletions

View file

@ -1290,8 +1290,7 @@ void show_scratchpad(Client *c) {
}
c->oldtags = c->mon->tagset[c->mon->seltags];
wl_list_remove(&c->link); // 从原来位置移除
wl_list_insert(clients.prev->next, &c->link); // 插入开头
wl_list_safe_reinsert_next(&clients, &c->link);
show_hide_client(c);
setborder_color(c);
}
@ -1376,11 +1375,9 @@ void client_replace(Client *c, Client *w, bool isgroupaction) {
wlr_scene_node_set_enabled(&w->group_bar->scene_buffer->node, false);
}
wl_list_remove(&c->link);
wl_list_insert(&w->link, &c->link);
wl_list_safe_reinsert_next(&w->link, &c->link);
wl_list_remove(&c->flink);
wl_list_insert(&w->flink, &c->flink);
wl_list_safe_reinsert_prev(&w->flink, &c->flink);
w->is_logic_hide = true;
c->is_logic_hide = false;
@ -1871,11 +1868,7 @@ void applyrules(Client *c) {
(!c->istagsilent || !newtags || newtags & mon->tagset[mon->seltags]);
if (!should_init_get_focus) {
if (c->flink.prev && c->flink.next && c->flink.prev != &c->flink) {
wl_list_remove(&c->flink);
wl_list_init(&c->flink);
}
wl_list_insert(fstack.prev, &c->flink);
wl_list_safe_reinsert_prev(&fstack, &c->flink);
}
setmon(c, mon, newtags, should_init_get_focus);
@ -1911,11 +1904,7 @@ void applyrules(Client *c) {
}
if (c->isfloating && !c->iscustompos && !c->isnamedscratchpad) {
if (c->link.prev && c->link.next && c->link.prev != &c->link) {
wl_list_remove(&c->link);
wl_list_init(&c->link);
}
wl_list_insert(clients.prev, &c->link);
wl_list_safe_reinsert_prev(&clients, &c->link);
set_float_malposition(c);
}
@ -2384,8 +2373,7 @@ void place_drag_tile_client(Client *c) {
if (closest->drop_direction == UNDIR) {
setfloating(c, 0);
wl_list_remove(&c->link);
wl_list_insert(closest->link.prev, &c->link);
wl_list_safe_reinsert_prev(&closest->link, &c->link);
arrange(closest->mon, false, false);
return;
}
@ -2412,11 +2400,9 @@ void place_drag_tile_client(Client *c) {
}
if (closest->drop_direction == LEFT || closest->drop_direction == UP) {
wl_list_remove(&c->link);
wl_list_insert(closest->link.prev, &c->link);
wl_list_safe_reinsert_prev(&closest->link, &c->link);
} else {
wl_list_remove(&c->link);
wl_list_insert(&closest->link, &c->link);
wl_list_safe_reinsert_next(&closest->link, &c->link);
}
}
@ -4657,6 +4643,8 @@ void init_client_properties(Client *c) {
c->animation.overining = false;
c->animation.tagouting = false;
c->animation.tagouted = false;
wl_list_init(&c->link);
wl_list_init(&c->flink);
}
void // old fix to 0.5