From 24f702fbc137cea17a52a005b7fe474cd9a59a4e Mon Sep 17 00:00:00 2001 From: Guido Cella Date: Sat, 17 Apr 2021 08:59:55 +0200 Subject: [PATCH] Center floating windows Credits to Benjamin Chausse for fixing this with multiple monitors. --- dwl.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dwl.c b/dwl.c index aac6eb8..74f363d 100644 --- a/dwl.c +++ b/dwl.c @@ -519,6 +519,8 @@ applyrules(Client *c) mon = m; } } + c->geom.x = (mon->w.width - c->geom.width) / 2 + mon->m.x; + c->geom.y = (mon->w.height - c->geom.height) / 2 + mon->m.y; wlr_scene_node_reparent(c->scene, layers[c->isfloating ? LyrFloat : LyrTile]); setmon(c, mon, newtags); } @@ -1667,6 +1669,8 @@ mapnotify(struct wl_listener *listener, void *data) c->isfloating = 1; wlr_scene_node_reparent(c->scene, layers[LyrFloat]); setmon(c, p->mon, p->tags); + c->geom.x = (c->mon->w.width - c->geom.width) / 2 + c->mon->m.x; + c->geom.y = (c->mon->w.height - c->geom.height) / 2 + c->mon->m.y; } else { applyrules(c); }