diff options
| author | uint23 <72694427+uint23@users.noreply.github.com> | 2025-05-20 16:04:35 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-20 16:04:35 +0100 |
| commit | 1ff3b26f9c7fe03aeacb321c093018c4d9683300 (patch) | |
| tree | 30a4446bf08a4b649a27b3c76ca59247638b5b55 | |
| parent | 0f7dd226b703e783e837f2a7db59d1b1a255872a (diff) | |
| parent | 63cc84921657c2b7ff094e5ccc0d1f5987444de9 (diff) | |
Merge pull request #27 from elbachir-one/main
Adding a Check for XGetWindowAttributes failure.
| -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); |
