From 5d4e92801206d47090236498d35f199e46dd07f6 Mon Sep 17 00:00:00 2001 From: MLquest8 Date: Sat, 20 Jun 2020 15:40:43 +0400 Subject: [PATCH] sizehints-ruled now with a separate rule "isfreesize" and cleaner code. --- config.def.h | 8 +++++--- dwm.c | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/config.def.h b/config.def.h index 1c0b587..0e4a5ea 100644 --- a/config.def.h +++ b/config.def.h @@ -26,9 +26,11 @@ static const Rule rules[] = { * WM_CLASS(STRING) = instance, class * WM_NAME(STRING) = title */ - /* class instance title tags mask isfloating monitor */ - { "Gimp", NULL, NULL, 0, 1, -1 }, - { "Firefox", NULL, NULL, 1 << 8, 0, -1 }, + /* class instance title tags mask isfloating isfreesize monitor */ + { "Gimp", NULL, NULL, 0, 1, 1, -1 }, + { "Firefox", NULL, NULL, 1 << 8, 0, 0, -1 }, + { "st", NULL, NULL, 0, 0, 0, -1 }, + { "St", NULL, NULL, 0, 0, 0, -1 }, /* St with Xresources patch */ }; /* layout(s) */ diff --git a/dwm.c b/dwm.c index 9fd0286..73825d1 100644 --- a/dwm.c +++ b/dwm.c @@ -92,7 +92,7 @@ struct Client { int basew, baseh, incw, inch, maxw, maxh, minw, minh; int bw, oldbw; unsigned int tags; - int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen; + int isfixed, isfloating, isfreesize, isurgent, neverfocus, oldstate, isfullscreen; Client *next; Client *snext; Monitor *mon; @@ -138,6 +138,7 @@ typedef struct { const char *title; unsigned int tags; int isfloating; + int isfreesize; int monitor; } Rule; @@ -287,6 +288,7 @@ applyrules(Client *c) /* rule matching */ c->isfloating = 0; + c->isfreesize = 1; c->tags = 0; XGetClassHint(dpy, c->win, &ch); class = ch.res_class ? ch.res_class : broken; @@ -299,6 +301,7 @@ applyrules(Client *c) && (!r->instance || strstr(instance, r->instance))) { c->isfloating = r->isfloating; + c->isfreesize = r->isfreesize; c->tags |= r->tags; for (m = mons; m && m->num != r->monitor; m = m->next); if (m) @@ -1952,7 +1955,7 @@ updatesizehints(Client *c) if (!XGetWMNormalHints(dpy, c->win, &size, &msize)) /* size is uninitialized, ensure that size.flags aren't used */ - size.flags = PSize; + size.flags = 0; if (size.flags & PBaseSize) { c->basew = size.base_width; c->baseh = size.base_height; @@ -1984,6 +1987,11 @@ updatesizehints(Client *c) c->maxa = (float)size.max_aspect.x / size.max_aspect.y; } else c->maxa = c->mina = 0.0; + if((size.flags & PSize) && c->isfreesize) { + c->basew = size.base_width; + c->baseh = size.base_height; + c->isfloating = 1; + } c->isfixed = (c->maxw && c->maxh && c->maxw == c->minw && c->maxh == c->minh); } @@ -2012,8 +2020,10 @@ updatewindowtype(Client *c) if (state == netatom[NetWMFullscreen]) setfullscreen(c, 1); - if (wtype == netatom[NetWMWindowTypeDialog]) + if (wtype == netatom[NetWMWindowTypeDialog]) { c->isfloating = 1; + c->isfreesize = 1; + } } void -- 2.26.2