aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2020-08-10 15:02:34 +0200
committerOmar Polo <op@omarpolo.com>2020-08-10 15:02:34 +0200
commita00060cdedaf7f6d8caf0f9e5d4972dd23c06b15 (patch)
treec8a435a22dc289cef59a669a3a5d2ec107f267a6
parent770f4148881e1d8af14d3def59bb17c8355b9a32 (diff)
downloaddwm-retake-a00060cdedaf7f6d8caf0f9e5d4972dd23c06b15.tar.gz
dwm-retake-a00060cdedaf7f6d8caf0f9e5d4972dd23c06b15.tar.bz2
center windows around mouse
if a window does not specify an exact (x, y) position (i.e. dino) move it so it's centered around the mouse.
-rw-r--r--dwm.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/dwm.c b/dwm.c
index 2009416..64dccb1 100644
--- a/dwm.c
+++ b/dwm.c
@@ -1253,6 +1253,7 @@ manage(Window w, XWindowAttributes *wa)
Client *c, *t = NULL, *term = NULL;
Window trans = None;
XWindowChanges wc;
+ int ptrx, ptry;
c = ecalloc(1, sizeof(Client));
c->win = w;
@@ -1274,6 +1275,12 @@ manage(Window w, XWindowAttributes *wa)
term = termforwin(c);
}
+ if (c->x == 0 && c->y == 0) {
+ getrootptr(&ptrx, &ptry);
+ c->x = ptrx - (WIDTH(c) / 2);
+ c->y = ptry - (HEIGHT(c) / 2);
+ }
+
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)