1

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.

1
  • weird question buy are you sure that curr->next is definitely NULL? Commented Feb 12 at 6:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.