From 065c17de4c3e91071a3ed863b7d0f85d72a757d3 Mon Sep 17 00:00:00 2001 From: bakkeby Date: Fri, 11 Feb 2022 10:10:28 +0100 Subject: [PATCH] Adding the isfreesize version of the sizehints patch ref. #229 --- README.md | 2 ++ dwm.c | 25 +++++++++++++++++++++---- patches.def.h | 13 +++++++++++++ 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3fc48f5..abec291 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,8 @@ If you are experiencing issues then you may want to check out the [Known Issues] ### Changelog: +2022-02-11 - Added the isfreesize version of the sizehints patch + 2021-11-23 - Added the taglabels and underlinetags patches 2021-09-08 - Added the alwayscenter patch diff --git a/dwm.c b/dwm.c index 3e52255..475e778 100644 --- a/dwm.c +++ b/dwm.c @@ -368,6 +368,9 @@ struct Client { #if PLACEMOUSE_PATCH int beingmoved; #endif // PLACEMOUSE_PATCH + #if SIZEHINTS_ISFREESIZE_PATCH + int isfreesize; + #endif // SIZEHINTS_ISFREESIZE_PATCH #if SWALLOW_PATCH int isterminal, noswallow; pid_t pid; @@ -515,6 +518,9 @@ typedef struct { #if SELECTIVEFAKEFULLSCREEN_PATCH && FAKEFULLSCREEN_CLIENT_PATCH && !FAKEFULLSCREEN_PATCH int isfakefullscreen; #endif // SELECTIVEFAKEFULLSCREEN_PATCH + #if SIZEHINTS_ISFREESIZE_PATCH + int isfreesize; + #endif // SIZEHINTS_ISFREESIZE_PATCH #if ISPERMANENT_PATCH int ispermanent; #endif // ISPERMANENT_PATCH @@ -825,6 +831,9 @@ applyrules(Client *c) #if SWALLOW_PATCH c->noswallow = -1; #endif // SWALLOW_PATCH + #if SIZEHINTS_ISFREESIZE_PATCH + c->isfreesize = 1; + #endif // SIZEHINTS_ISFREESIZE_PATCH c->isfloating = 0; c->tags = 0; XGetClassHint(dpy, c->win, &ch); @@ -863,6 +872,9 @@ applyrules(Client *c) c->isterminal = r->isterminal; c->noswallow = r->noswallow; #endif // SWALLOW_PATCH + #if SIZEHINTS_ISFREESIZE_PATCH + c->isfreesize = r->isfreesize; + #endif // SIZEHINTS_ISFREESIZE_PATCH c->isfloating = r->isfloating; c->tags |= r->tags; #if SCRATCHPADS_PATCH @@ -4521,11 +4533,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 + #if SIZEHINTS_PATCH || SIZEHINTS_RULED_PATCH || SIZEHINTS_ISFREESIZE_PATCH size.flags = 0; #else size.flags = PSize; - #endif // SIZEHINTS_PATCH | SIZEHINTS_RULED_PATCH + #endif // SIZEHINTS_PATCH | SIZEHINTS_RULED_PATCH | SIZEHINTS_ISFREESIZE_PATCH if (size.flags & PBaseSize) { c->basew = size.base_width; c->baseh = size.base_height; @@ -4557,8 +4569,13 @@ 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) { + #if SIZEHINTS_PATCH || SIZEHINTS_RULED_PATCH || SIZEHINTS_ISFREESIZE_PATCH + #if SIZEHINTS_ISFREESIZE_PATCH + if ((size.flags & PSize) && c->isfreesize) + #else + if (size.flags & PSize) + #endif // SIZEHINTS_ISFREESIZE_PATCH + { c->basew = size.base_width; c->baseh = size.base_height; c->isfloating = 1; diff --git a/patches.def.h b/patches.def.h index 022a4a6..a410afd 100644 --- a/patches.def.h +++ b/patches.def.h @@ -964,6 +964,19 @@ */ #define SIZEHINTS_RULED_PATCH 0 +/* This patch makes dwm obey even "soft" sizehints for new clients. The isfreesize + * version is similar to the sizehints ruled patch except it allows you to specify + * via client rules which clients this should apply to. Soft sizehints applies by + * default to clients that are not ruled, and will be disabled by default for clients + * that are. + * + * Example client rule enabling soft sizehints: + * - RULE(.wintype = WTYPE "DIALOG", .isfloating = 1, .isfreesize = 1) + * + * https://dwm.suckless.org/patches/sizehints/ + */ +#define SIZEHINTS_ISFREESIZE_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