summaryrefslogtreecommitdiff
path: root/src/sxwm.c
diff options
context:
space:
mode:
authoruint23 <72694427+uint23@users.noreply.github.com>2025-05-20 16:04:35 +0100
committerGitHub <noreply@github.com>2025-05-20 16:04:35 +0100
commit1ff3b26f9c7fe03aeacb321c093018c4d9683300 (patch)
tree30a4446bf08a4b649a27b3c76ca59247638b5b55 /src/sxwm.c
parent0f7dd226b703e783e837f2a7db59d1b1a255872a (diff)
parent63cc84921657c2b7ff094e5ccc0d1f5987444de9 (diff)
Merge pull request #27 from elbachir-one/main
Adding a Check for XGetWindowAttributes failure.
Diffstat (limited to 'src/sxwm.c')
-rw-r--r--src/sxwm.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/sxwm.c b/src/sxwm.c
index a2dfdcd..e7161d9 100644
--- a/src/sxwm.c
+++ b/src/sxwm.c
@@ -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);