aboutsummaryrefslogtreecommitdiffstats
path: root/dwm.c
diff options
context:
space:
mode:
authorJustin Gassner <justin.gassner@mailbox.org>2023-03-19 18:24:42 +0100
committerJustin Gassner <justin.gassner@mailbox.org>2024-03-21 18:32:32 +0100
commit28cbda9460c0e1bd900d1ce502a1233de1dc2a0b (patch)
treed828c4fb731a2c72da1d9f5c3ac9a8b364f5fb33 /dwm.c
parent061e9fe9a7db396c0c4f3d996c3908fb43a6d50c (diff)
downloaddwm-28cbda9460c0e1bd900d1ce502a1233de1dc2a0b.tar.zst
applied suckless.org center patchcenter
Diffstat (limited to 'dwm.c')
-rw-r--r--dwm.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/dwm.c b/dwm.c
index f1d86b2..1ecede7 100644
--- a/dwm.c
+++ b/dwm.c
@@ -92,7 +92,7 @@ struct Client {
int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid;
int bw, oldbw;
unsigned int tags;
- int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
+ int isfixed, iscentered, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
Client *next;
Client *snext;
Monitor *mon;
@@ -137,6 +137,7 @@ typedef struct {
const char *instance;
const char *title;
unsigned int tags;
+ int iscentered;
int isfloating;
int monitor;
} Rule;
@@ -285,6 +286,7 @@ applyrules(Client *c)
XClassHint ch = { NULL, NULL };
/* rule matching */
+ c->iscentered = 0;
c->isfloating = 0;
c->tags = 0;
XGetClassHint(dpy, c->win, &ch);
@@ -297,6 +299,7 @@ applyrules(Client *c)
&& (!r->class || strstr(class, r->class))
&& (!r->instance || strstr(instance, r->instance)))
{
+ c->iscentered = r->iscentered;
c->isfloating = r->isfloating;
c->tags |= r->tags;
for (m = mons; m && m->num != r->monitor; m = m->next);
@@ -1068,6 +1071,10 @@ manage(Window w, XWindowAttributes *wa)
updatewindowtype(c);
updatesizehints(c);
updatewmhints(c);
+ if (c->iscentered) {
+ c->x = c->mon->mx + (c->mon->mw - WIDTH(c)) / 2;
+ c->y = c->mon->my + (c->mon->mh - HEIGHT(c)) / 2;
+ }
XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
grabbuttons(c, 0);
if (!c->isfloating)
@@ -2027,8 +2034,10 @@ updatewindowtype(Client *c)
if (state == netatom[NetWMFullscreen])
setfullscreen(c, 1);
- if (wtype == netatom[NetWMWindowTypeDialog])
+ if (wtype == netatom[NetWMWindowTypeDialog]) {
+ c->iscentered = 1;
c->isfloating = 1;
+ }
}
void