diff --git a/README.md b/README.md index 8f9dc15..95f6203 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t ### Changelog: -2020-08-10 - Added cool autostart patch +2020-08-10 - Added cool autostart and insets patches 2020-08-02 - Added reorganizetags patch @@ -301,6 +301,10 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t - [inplacerotate](https://dwm.suckless.org/patches/inplacerotate/) - allows rotation of all clients in the master or stack area without affecting the other area + - [insets](https://dwm.suckless.org/patches/insets/) + - lets custom insets from each edge of the screen to be defined + - an example use case would be to make space for an external bar + - [ispermanent](https://dwm.suckless.org/patches/ispermanent/) - adds rule option for clients to avoid accidental termination by killclient for sticky windows diff --git a/config.def.h b/config.def.h index 76b9d01..4e98ff0 100644 --- a/config.def.h +++ b/config.def.h @@ -403,6 +403,15 @@ static const MonitorRule monrules[] = { #endif // PERTAG_PATCH #endif // MONITOR_RULES_PATCH +#if INSETS_PATCH +static const Inset default_inset = { + .x = 0, + .y = 30, + .w = 0, + .h = 0, +}; +#endif // INSETS_PATCH + /* Bar rules allow you to configure what is shown where on the bar, as well as * introducing your own bar modules. * @@ -944,6 +953,9 @@ static Key keys[] = { #if REORGANIZETAGS_PATCH { MODKEY|ControlMask, XK_r, reorganizetags, {0} }, #endif // REORGANIZETAGS_PATCH + #if INSETS_PATCH + { MODKEY|ShiftMask|ControlMask, XK_a, updateinset, {.v = &default_inset } }, + #endif // INSETS_PATCH { MODKEY, XK_Return, zoom, {0} }, #if VANITYGAPS_PATCH { MODKEY|Mod4Mask, XK_u, incrgaps, {.i = +1 } }, diff --git a/dwm.c b/dwm.c index f9d923f..09261a4 100644 --- a/dwm.c +++ b/dwm.c @@ -333,6 +333,15 @@ typedef struct { #endif // FLEXTILE_DELUXE_LAYOUT } Layout; +#if INSETS_PATCH +typedef struct { + int x; + int y; + int w; + int h; +} Inset; +#endif // INSETS_PATCH + #if PERTAG_PATCH typedef struct Pertag Pertag; #endif // PERTAG_PATCH @@ -372,6 +381,9 @@ struct Monitor { #if PERTAG_PATCH Pertag *pertag; #endif // PERTAG_PATCH + #if INSETS_PATCH + Inset inset; + #endif // INSETS_PATCH }; typedef struct { @@ -1387,6 +1399,9 @@ createmon(void) #endif // VANITYGAPS_PATCH } #endif // PERTAG_PATCH + #if INSETS_PATCH + m->inset = default_inset; + #endif // INSETS_PATCH return m; } @@ -3516,7 +3531,9 @@ updatebars(void) void updatebarpos(Monitor *m) { + m->wx = m->mx; m->wy = m->my; + m->ww = m->mw; m->wh = m->mh; int num_bars; Bar *bar; @@ -3528,8 +3545,17 @@ updatebarpos(Monitor *m) int x_pad = 0; #endif // BAR_PADDING_PATCH + #if INSETS_PATCH + // Custom insets + Inset inset = m->inset; + m->wx += inset.x; + m->wy += inset.y; + m->ww -= inset.w + inset.x; + m->wh -= inset.h + inset.y; + #endif // INSETS_PATCH + for (bar = m->bar; bar; bar = bar->next) { - bar->bx = m->mx + x_pad; + bar->bx = m->wx + x_pad; bar->bw = m->ww - 2 * x_pad; bar->bh = bh; } @@ -3542,7 +3568,7 @@ updatebarpos(Monitor *m) for (num_bars = 0, bar = m->bar; bar; bar = bar->next, num_bars++) if (bar->topbar) - m->wy = m->my + bh + y_pad; + m->wy = m->wy + bh + y_pad; m->wh = m->wh - y_pad * num_bars - bh * num_bars; for (bar = m->bar; bar; bar = bar->next) diff --git a/patch/include.c b/patch/include.c index aaaf123..81901a1 100644 --- a/patch/include.c +++ b/patch/include.c @@ -111,6 +111,9 @@ #if INPLACEROTATE_PATCH #include "inplacerotate.c" #endif +#if INSETS_PATCH +#include "insets.c" +#endif #if KEYMODES_PATCH #include "keymodes.c" #endif diff --git a/patch/include.h b/patch/include.h index e879d80..a556964 100644 --- a/patch/include.h +++ b/patch/include.h @@ -111,6 +111,9 @@ #if INPLACEROTATE_PATCH #include "inplacerotate.h" #endif +#if INSETS_PATCH +#include "insets.h" +#endif #if KEYMODES_PATCH #include "keymodes.h" #endif diff --git a/patch/insets.c b/patch/insets.c new file mode 100644 index 0000000..c0836cf --- /dev/null +++ b/patch/insets.c @@ -0,0 +1,18 @@ +void +setinset(Monitor *m, Inset inset) +{ + Bar *bar; + m->inset = inset; + updatebarpos(m); + for (bar = m->bar; bar; bar = bar->next) + XMoveResizeWindow(dpy, bar->win, bar->bx, bar->by, bar->bw, bar->bh); + arrange(m); +} + +void +updateinset(const Arg *arg) +{ + Inset *inset = (Inset *)arg->v; + for (Monitor *m = mons; m; m = m->next) + setinset(m, *inset); +} \ No newline at end of file diff --git a/patch/insets.h b/patch/insets.h new file mode 100644 index 0000000..ab76278 --- /dev/null +++ b/patch/insets.h @@ -0,0 +1,2 @@ +static void setinset(Monitor *m, Inset inset); +static void updateinset(const Arg *arg); \ No newline at end of file diff --git a/patches.def.h b/patches.def.h index b88338b..9ba99f7 100644 --- a/patches.def.h +++ b/patches.def.h @@ -458,6 +458,12 @@ */ #define INPLACEROTATE_PATCH 0 +/* This patch lets you define custom insets from each edge of the screen. One use case would be + * to arrange space for an external bar. + * https://dwm.suckless.org/patches/insets/ + */ +#define INSETS_PATCH 0 + /* Adds rule option for clients to avoid accidental termination by killclient for sticky windows. * https://dwm.suckless.org/patches/ispermanent/ */