From 660633bd1d3bdfcbe3d7d6e614e0df3b23da544d Mon Sep 17 00:00:00 2001 From: nixpup Date: Fri, 16 Jan 2026 22:02:22 +0100 Subject: [PATCH] Fix: Prevent window overlap when killing a stacked client When a client within a vertical stack was killed, the layout was not correctly updated, causing other windows to overlap. This commit modifies the pending_kill_client function to properly update the next_in_stack and prev_in_stack pointers of neighboring clients when a stacked client is killed. It also triggers an arrange call to refresh the layout, ensuring that windows no longer overlap and the remaining clients in the stack resize correctly. --- src/mango.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/mango.c b/src/mango.c index 57e4326..5a06e3a 100644 --- a/src/mango.c +++ b/src/mango.c @@ -3638,7 +3638,27 @@ void keypressmod(struct wl_listener *listener, void *data) { } void pending_kill_client(Client *c) { - // c->iskilling = 1; //不可以提前标记已经杀掉,因为有些客户端可能拒绝 + if (!c || c->iskilling) + return; + + // If the client is in a stack, remove it from the stack + if (c->prev_in_stack || c->next_in_stack) { + if (c->prev_in_stack) { + c->prev_in_stack->next_in_stack = c->next_in_stack; + } + if (c->next_in_stack) { + c->next_in_stack->prev_in_stack = c->prev_in_stack; + if (!c->prev_in_stack) { // c was the head of the stack + // The next client becomes the new head, so we need to ensure it's treated as such. + // This is implicitly handled by setting its prev_in_stack to NULL. + } + } + c->prev_in_stack = NULL; + c->next_in_stack = NULL; + arrange(c->mon, false, false); + } + + c->iskilling = 1; client_send_close(c); }