diff options
| -rw-r--r-- | src/parser.c | 19 | ||||
| -rw-r--r-- | src/sxwm.c | 31 |
2 files changed, 34 insertions, 16 deletions
diff --git a/src/parser.c b/src/parser.c index 79cf29b..713a298 100644 --- a/src/parser.c +++ b/src/parser.c @@ -183,11 +183,9 @@ found: /* Initialize should_float matrix */ for (int j = 0; j < 256; j++) { - cfg->should_float[j] = calloc(1, sizeof(char *)); + cfg->should_float[j] = calloc(2, sizeof(char *)); if (!cfg->should_float[j]) { - fprintf(stderr, "calloc failed\n"); - fclose(f); - return -1; + goto cleanup_file; } } @@ -540,6 +538,19 @@ cleanup_file: free(cfg->should_float[j][0]); free(cfg->should_float[j]); } + if (cfg->can_swallow[j]) { + free(cfg->can_swallow[j][0]); + free(cfg->can_swallow[j]); + } + if (cfg->can_be_swallowed[j]) { + free(cfg->can_be_swallowed[j][0]); + free(cfg->can_be_swallowed[j]); + } + if (cfg->open_in_workspace[j]) { + free(cfg->open_in_workspace[j][0]); + free(cfg->open_in_workspace[j][1]); + free(cfg->open_in_workspace[j]); + } } for (int i = 0; i < torun; i++) { free(cfg->torun[i]); @@ -1838,11 +1838,16 @@ void reload_config(void) void remove_scratchpad(int n) { - if (scratchpads[n].client == NULL) { + if (n < 0 || n >= MAX_SCRATCHPADS || scratchpads[n].client == NULL) { return; } - XMapWindow(dpy, scratchpads[n].client->win); + Client *c = scratchpads[n].client; + + if (c->win) { + XMapWindow(dpy, c->win); + } + scratchpads[n].client = NULL; scratchpads[n].enabled = False; } @@ -2511,13 +2516,13 @@ void toggle_fullscreen(void) void toggle_scratchpad(int n) { - if (scratchpads[n].client == NULL) { + if (n < 0 || n >= MAX_SCRATCHPADS || scratchpads[n].client == NULL) { return; } - if (scratchpads[n].client->ws != current_ws) { - Client *c = scratchpads[n].client; + Client *c = scratchpads[n].client; + if (c->ws != current_ws) { /* unlink from old workspace */ Client **pp = &workspaces[c->ws]; while (*pp && *pp != c) { @@ -2541,19 +2546,21 @@ void toggle_scratchpad(int n) } if (scratchpads[n].enabled) { - XUnmapWindow(dpy, scratchpads[n].client->win); + XUnmapWindow(dpy, c->win); scratchpads[n].enabled = False; focus_prev(); - send_wm_take_focus(focused->win); + if (focused) { + send_wm_take_focus(focused->win); + } update_borders(); } else { - XMapWindow(dpy, scratchpads[n].client->win); - XRaiseWindow(dpy, scratchpads[n].client->win); + XMapWindow(dpy, c->win); + XRaiseWindow(dpy, c->win); scratchpads[n].enabled = True; - focused = scratchpads[n].client; - XSetInputFocus(dpy, focused->win, RevertToPointerRoot, CurrentTime); - send_wm_take_focus(scratchpads[n].client->win); + focused = c; + XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); + send_wm_take_focus(c->win); if (user_config.warp_cursor) { warp_cursor(focused); } |
