From 50fb82ec80847c7dca113d3f848b0bf75be6df92 Mon Sep 17 00:00:00 2001 From: Abhinav Date: Thu, 29 May 2025 15:42:35 +0100 Subject: allow mod + alt --- src/parser.c | 8 ------- src/sxwm.c | 72 +++++++++++++++++++++++++++++++++++------------------------- 2 files changed, 42 insertions(+), 38 deletions(-) (limited to 'src') diff --git a/src/parser.c b/src/parser.c index 0d086a2..eb6ba21 100644 --- a/src/parser.c +++ b/src/parser.c @@ -32,14 +32,6 @@ static const struct { static void remap_and_dedupe_binds(Config *cfg) { - for (int i = 0; i < cfg->bindsn; i++) { - Binding *b = &cfg->binds[i]; - if (b->mods & (Mod1Mask | Mod4Mask)) { - unsigned others = b->mods & ~(Mod1Mask | Mod4Mask); - b->mods = others | cfg->modkey; - } - } - for (int i = 0; i < cfg->bindsn; i++) { for (int j = i + 1; j < cfg->bindsn; j++) { if (cfg->binds[i].mods == cfg->binds[j].mods && cfg->binds[i].keysym == cfg->binds[j].keysym) { 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 -- cgit v1.2.3