diff options
| author | elbachir-one <bachiralfa@gmail.com> | 2025-05-18 20:47:19 +0100 |
|---|---|---|
| committer | elbachir-one <bachiralfa@gmail.com> | 2025-05-18 20:47:58 +0100 |
| commit | 63cc84921657c2b7ff094e5ccc0d1f5987444de9 (patch) | |
| tree | 6b5211b677b5deeb9d6e460b290fd1aa73bf710d /src/sxwm.c | |
| parent | b34263441d6f91667bf05a5741b92549f1e16e60 (diff) | |
Adding a Check for XGetWindowAttributes failure
Diffstat (limited to 'src/sxwm.c')
| -rw-r--r-- | src/sxwm.c | 31 |
1 files changed, 20 insertions, 11 deletions
@@ -1527,30 +1527,39 @@ void toggle_floating(void) return; } - focused->floating = !focused->floating; if (focused->fullscreen) { focused->fullscreen = False; tile(); XSetWindowBorderWidth(dpy, focused->win, user_config.border_width); } + focused->floating = !focused->floating; + if (focused->floating) { XWindowAttributes wa; - XGetWindowAttributes(dpy, focused->win, &wa); - focused->x = wa.x; - focused->y = wa.y; - focused->w = wa.width; - focused->h = wa.height; - - XConfigureWindow( - dpy, focused->win, CWX | CWY | CWWidth | CWHeight, - &(XWindowChanges){.x = focused->x, .y = focused->y, .width = focused->w, .height = focused->h}); + if (XGetWindowAttributes(dpy, focused->win, &wa)) { + focused->x = wa.x; + focused->y = wa.y; + focused->w = wa.width; + focused->h = wa.height; + + XConfigureWindow( + dpy, focused->win, + CWX | CWY | CWWidth | CWHeight, + &(XWindowChanges){ + .x = focused->x, + .y = focused->y, + .width = focused->w, + .height = focused->h + } + ); + } } tile(); update_borders(); - /* floating windows are on top */ + /* Raise and refocus floating window */ if (focused->floating) { XRaiseWindow(dpy, focused->win); XSetInputFocus(dpy, focused->win, RevertToPointerRoot, CurrentTime); |
