diff --git a/README.md b/README.md index 8ea03f9..82a4f82 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t ### Changelog: +2020-06-15 - Added sizehints patch + 2020-06-14 - Added RULE macro to replace rules setup making the default config less of an abomination and making it simpler to include new rules based patches 2020-06-11 - Added the pango patch @@ -359,6 +361,9 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t - [shiftviewclients](https://github.com/bakkeby/patches/blob/master/dwm/dwm-shiftviewclients-6.2.diff) - variant of the shiftview patch which skips tags that has no clients + - [sizehints](https://dwm.suckless.org/patches/sizehints/) + - makes dwm obey even "soft" sizehints for new clients + - [sortscreens](https://www.mail-archive.com/hackers@suckless.org/msg09400.html) - this patch aims to address some inconsistencies when it comes to focusmon, tagmon and similar functionality by explicitly sorting screens left to right (or top to bottom in a vertical layout) diff --git a/dwm.c b/dwm.c index 3e50117..3d1d1c6 100644 --- a/dwm.c +++ b/dwm.c @@ -3950,7 +3950,11 @@ updatesizehints(Client *c) if (!XGetWMNormalHints(dpy, c->win, &size, &msize)) /* size is uninitialized, ensure that size.flags aren't used */ + #if SIZEHINTS_PATCH || SIZEHINTS_RULED_PATCH + size.flags = 0; + #else size.flags = PSize; + #endif // SIZEHINTS_PATCH | SIZEHINTS_RULED_PATCH if (size.flags & PBaseSize) { c->basew = size.base_width; c->baseh = size.base_height; @@ -3982,6 +3986,16 @@ updatesizehints(Client *c) c->maxa = (float)size.max_aspect.x / size.max_aspect.y; } else c->maxa = c->mina = 0.0; + #if SIZEHINTS_PATCH || SIZEHINTS_RULED_PATCH + if (size.flags & PSize) { + c->basew = size.base_width; + c->baseh = size.base_height; + c->isfloating = 1; + } + #if SIZEHINTS_RULED_PATCH + checkfloatingrules(c); + #endif // SIZEHINTS_RULED_PATCH + #endif // SIZEHINTS_PATCH c->isfixed = (c->maxw && c->maxh && c->maxw == c->minw && c->maxh == c->minh); } diff --git a/patch/include.c b/patch/include.c index 9d88b94..77abf89 100644 --- a/patch/include.c +++ b/patch/include.c @@ -117,6 +117,9 @@ #if SHIFTVIEW_CLIENTS_PATCH #include "shiftviewclients.c" #endif +#if SIZEHINTS_RULED_PATCH +#include "sizehints_ruled.c" +#endif #if SORTSCREENS_PATCH #ifdef XINERAMA #include "sortscreens.c" diff --git a/patch/include.h b/patch/include.h index bb91ee2..93442f1 100644 --- a/patch/include.h +++ b/patch/include.h @@ -120,6 +120,9 @@ #if SHIFTVIEW_CLIENTS_PATCH #include "shiftviewclients.h" #endif +#if SIZEHINTS_RULED_PATCH +#include "sizehints_ruled.h" +#endif #if SORTSCREENS_PATCH #ifdef XINERAMA #include "sortscreens.h" diff --git a/patch/sizehints_ruled.c b/patch/sizehints_ruled.c new file mode 100644 index 0000000..885707f --- /dev/null +++ b/patch/sizehints_ruled.c @@ -0,0 +1,24 @@ +void +checkfloatingrules(Client *c) +{ + const char *class, *instance; + unsigned int i; + const Rule *r; + XClassHint ch = { NULL, NULL }; + + XGetClassHint(dpy, c->win, &ch); + class = ch.res_class ? ch.res_class : broken; + instance = ch.res_name ? ch.res_name : broken; + + for (i = 0; i < LENGTH(rules); i++) { + r = &rules[i]; + if ((!r->title || strstr(c->name, r->title)) + && (!r->class || strstr(class, r->class)) + && (!r->instance || strstr(instance, r->instance))) + c->isfloating = r->isfloating; + } + if (ch.res_class) + XFree(ch.res_class); + if (ch.res_name) + XFree(ch.res_name); +} diff --git a/patch/sizehints_ruled.h b/patch/sizehints_ruled.h new file mode 100644 index 0000000..d21b2e4 --- /dev/null +++ b/patch/sizehints_ruled.h @@ -0,0 +1 @@ +static void checkfloatingrules(Client *c); \ No newline at end of file diff --git a/patches.def.h b/patches.def.h index 358ec4a..64dbd1f 100644 --- a/patches.def.h +++ b/patches.def.h @@ -500,6 +500,23 @@ */ #define SHIFTVIEW_CLIENTS_PATCH 0 +/* This patch makes dwm obey even "soft" sizehints for new clients. Any window + * that requests a specific initial size will be floated and set to that size. + * Unlike with "fixed size" windows, you are able to resize and/or unfloat these + * windows freely - only the initial state is affected. + * This version of the patch is honestly of limited utility since there are many + * clients that will abuse it. + * https://dwm.suckless.org/patches/sizehints/ + */ +#define SIZEHINTS_PATCH 0 + +/* This patch makes dwm obey even "soft" sizehints for new clients. This ruled + * version is essentially the same patch except it obeys the "isfloating" rule + * if it is available in config.h for the given client. + * https://dwm.suckless.org/patches/sizehints/ + */ +#define SIZEHINTS_RULED_PATCH 0 + /* In a multi-head setup monitor 0 is by default the primary screen, with the left and right * screen being monitor 1 and 2 respectively. This patch sorts screens left to right (or * top to bottom in a vertical layout) which aims to address some inconsistencies when it