From e6b0bc835fdc3eecc6ca8c78f852be17ed106d4a Mon Sep 17 00:00:00 2001 From: 0scar Date: Wed, 1 Mar 2023 11:43:12 +0100 Subject: Patch: center Source: https://github.com/djpohly/dwl/compare/main...dm1tz:04-center.patch --- dwl.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'dwl.c') diff --git a/dwl.c b/dwl.c index 0e07ac4..74840e4 100644 --- a/dwl.c +++ b/dwl.c @@ -143,7 +143,7 @@ struct Client { #endif unsigned int bw; uint32_t tags; - int isfloating, isurgent, isfullscreen, issticky, isterm, noswallow; + int iscentered, isfloating, isurgent, isfullscreen, issticky, isterm, noswallow; char scratchkey; uint32_t resize; /* configure serial of a pending resize */ pid_t pid; @@ -236,6 +236,7 @@ typedef struct { const char *id; const char *title; uint32_t tags; + int iscentered; int isfloating; int isterm; int noswallow; @@ -490,6 +491,7 @@ applyrules(Client *c) for (r = rules; r < END(rules); r++) { if ((!r->title || strstr(title, r->title)) && (!r->id || strstr(appid, r->id))) { + c->iscentered = r->iscentered; c->isfloating = r->isfloating; c->scratchkey = r->scratchkey; c->isterm = r->isterm; @@ -517,6 +519,12 @@ applyrules(Client *c) newtags = p->tags; } } + + if (c->iscentered) { + 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; + } + setmon(c, mon, newtags); } -- cgit v1.3