summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorelbachir-one <bachiralfa@gmail.com>2025-05-18 20:47:19 +0100
committerelbachir-one <bachiralfa@gmail.com>2025-05-18 20:47:58 +0100
commit63cc84921657c2b7ff094e5ccc0d1f5987444de9 (patch)
tree6b5211b677b5deeb9d6e460b290fd1aa73bf710d /src
parentb34263441d6f91667bf05a5741b92549f1e16e60 (diff)
Adding a Check for XGetWindowAttributes failure
Diffstat (limited to 'src')
-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);