summaryrefslogtreecommitdiff
path: root/src/sxwm.c
diff options
context:
space:
mode:
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 878e9e2..a40d69c 100644
--- a/src/sxwm.c
+++ b/src/sxwm.c
@@ -1534,30 +1534,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);