All other windows focus properly just the only one left does not, when you close the second to last. Please help, here is my function. Let me know if more info is needed as well.
void remove_client(Window win) {
if (!clients) return;
Client *prev = NULL, *curr = clients;
while (curr) {
if (curr->win == win) {
if (prev) {
prev->next = curr->next; // Unlink the node
} else {
clients = curr->next; // Update head if first node is removed
}
if (focused == curr) {
focused = clients; // Update focus if needed
}
free(curr);
return;
}
prev = curr;
curr = curr->next;
}
}
I tried changing focused = clients. to: focused = clients ? clients : prev;
But that didn't work, I'm at a loss not sure whats happening why the first element in the linked list isn't focusing.
curr->nextis definitelyNULL?