summaryrefslogtreecommitdiff
path: root/src/sxwm.c
diff options
context:
space:
mode:
authorAbhinav <abhinav.prsai@gmail.com>2025-05-29 15:42:35 +0100
committerAbhinav <abhinav.prsai@gmail.com>2025-05-29 15:42:35 +0100
commit50fb82ec80847c7dca113d3f848b0bf75be6df92 (patch)
tree4d0298283c67f0e008f9e0ee4e7c7480329d1ff8 /src/sxwm.c
parentfe66c602b5d540f2e20ef346b5acfa64ef611ca7 (diff)
allow mod + alt
Diffstat (limited to 'src/sxwm.c')
-rw-r--r--src/sxwm.c72
1 files changed, 42 insertions, 30 deletions
diff --git a/src/sxwm.c b/src/sxwm.c
index c7d041d..91c0839 100644
--- a/src/sxwm.c
+++ b/src/sxwm.c
@@ -537,42 +537,54 @@ void hdl_destroy_ntf(XEvent *xev)
{
Window w = xev->xdestroywindow.window;
- Client *prev = NULL, *c = workspaces[current_ws];
- while (c && c->win != w) {
- prev = c;
- c = c->next;
- }
- if (c) {
- if (focused == c) {
- if (c->next) {
- focused = c->next;
+ // Search all workspaces, not just current one
+ for (int ws = 0; ws < NUM_WORKSPACES; ws++) {
+ Client *prev = NULL, *c = workspaces[ws];
+ while (c && c->win != w) {
+ prev = c;
+ c = c->next;
+ }
+ if (c) {
+ // Update focused if this was the focused client
+ if (focused == c) {
+ if (c->next) {
+ focused = c->next;
+ }
+ else if (prev) {
+ focused = prev;
+ }
+ else {
+ // If this was the only client in current workspace, find next client
+ if (ws == current_ws) {
+ focused = NULL;
+ }
+ }
}
- else if (prev) {
- focused = prev;
+
+ // Remove from linked list
+ if (!prev) {
+ workspaces[ws] = c->next;
}
else {
- focused = NULL;
+ prev->next = c->next;
}
- }
- if (!prev) {
- workspaces[current_ws] = c->next;
- }
- else {
- prev->next = c->next;
- }
+ free(c);
+ update_net_client_list();
+ open_windows--;
- free(c);
- update_net_client_list();
- open_windows--;
- }
-
- tile();
- update_borders();
+ // Only tile and update borders if we're dealing with current workspace
+ if (ws == current_ws) {
+ tile();
+ update_borders();
- if (focused) {
- XSetInputFocus(dpy, focused->win, RevertToPointerRoot, CurrentTime);
- XRaiseWindow(dpy, focused->win);
+ if (focused) {
+ XSetInputFocus(dpy, focused->win, RevertToPointerRoot, CurrentTime);
+ XRaiseWindow(dpy, focused->win);
+ }
+ }
+ return; // Found and removed the client, we're done
+ }
}
}
@@ -1754,4 +1766,4 @@ int main(int ac, char **av)
printf("sxwm: starting...\n");
run();
return 0;
-}
+} \ No newline at end of file