summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStein <bakkeby@gmail.com>2022-08-11 11:15:55 +0200
committerrafa_99 <raroma09@gmail.com>2022-08-12 11:00:00 +0100
commit31ed89895cfbba740d169a9bd3473f1cc59e0a9d (patch)
tree25ebdc24743c29c54782c85828cc9be5855d67dd
parentfb4fa465788edd5833ab6f1f0c04148910aafbef (diff)
Make floating windows spawn within the monitor's window area
This is a follow-up on this thread: https://lists.suckless.org/hackers/2208/18462.html The orginal code had constraints such that if a window's starting attributes (position and size) were to place the window outside of the edges of the monitor, then the window would be moved into view at the closest monitor edge. There was an exception to this where if a top bar is used then the window should not obscure the bar if present, which meant to place the window within the window area instead. The proposed change here makes it the general rule that floating windows should spawn within the window area rather than within the monitor area. This makes it simple and consistent with no exceptions and it makes the intention of the code clear. This has the benefit of making the behaviour consistent regardless of whether the user is using a top bar or a bottom bar. Additionally this will have an effect on patches that modify the size of the window area. For example if the insets patch is used to reserve space on the left hand side of the monitor for a dock or a vertical bar then new floating clients will not obscure that area.
-rw-r--r--dwm.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/dwm.c b/dwm.c
index d5ded17..568e549 100644
--- a/dwm.c
+++ b/dwm.c
@@ -1136,11 +1136,11 @@ manage(Window w, XWindowAttributes *wa)
term = termforwin(c);
}
- if (c->x + WIDTH(c) > c->mon->mx + c->mon->mw)
- c->x = c->mon->mx + c->mon->mw - WIDTH(c);
- if (c->y + HEIGHT(c) > c->mon->my + c->mon->mh)
- c->y = c->mon->my + c->mon->mh - HEIGHT(c);
- c->x = MAX(c->x, c->mon->mx);
+ if (c->x + WIDTH(c) > c->mon->wx + c->mon->ww)
+ c->x = c->mon->wx + c->mon->ww - WIDTH(c);
+ if (c->y + HEIGHT(c) > c->mon->wy + c->mon->wh)
+ c->y = c->mon->wy + c->mon->wh - HEIGHT(c);
+ c->x = MAX(c->x, c->mon->wx);
c->y = MAX(c->y, c->mon->wy);
c->bw = borderpx;