From c74af17bcab18263ea565e6760728d03987359a7 Mon Sep 17 00:00:00 2001 From: jD91mZM2 Date: Sun, 31 May 2020 22:06:00 +0200 Subject: [PATCH] Custom screen insets --- config.def.h | 7 +++++++ dwm.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/config.def.h b/config.def.h index 1c0b587..43b464a 100644 --- a/config.def.h +++ b/config.def.h @@ -18,6 +18,13 @@ static const char *colors[][3] = { [SchemeSel] = { col_gray4, col_cyan, col_cyan }, }; +static const Inset default_inset = { + .x = 0, + .y = 30, + .w = 0, + .h = 0, +}; + /* tagging */ static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; diff --git a/dwm.c b/dwm.c index 4465af1..f91da15 100644 --- a/dwm.c +++ b/dwm.c @@ -111,6 +111,13 @@ typedef struct { void (*arrange)(Monitor *); } Layout; +typedef struct { + int x; + int y; + int w; + int h; +} Inset; + struct Monitor { char ltsymbol[16]; float mfact; @@ -130,6 +137,7 @@ struct Monitor { Monitor *next; Window barwin; const Layout *lt[2]; + Inset inset; }; typedef struct { @@ -199,6 +207,8 @@ static void sendmon(Client *c, Monitor *m); static void setclientstate(Client *c, long state); static void setfocus(Client *c); static void setfullscreen(Client *c, int fullscreen); +static void setinset(Monitor *m, Inset inset); +static void updateinset(const Arg *arg); static void setlayout(const Arg *arg); static void setmfact(const Arg *arg); static void setup(void); @@ -641,6 +651,7 @@ createmon(void) m->lt[0] = &layouts[0]; m->lt[1] = &layouts[1 % LENGTH(layouts)]; strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); + m->inset = default_inset; return m; } @@ -1497,6 +1508,23 @@ setfullscreen(Client *c, int fullscreen) } } +void +setinset(Monitor *m, Inset inset) +{ + m->inset = inset; + updatebarpos(m); + arrange(m); +} + +void +updateinset(const Arg *arg) +{ + Inset *inset = (Inset *)arg->v; + + for (Monitor *m = mons; m; m = m->next) + setinset(m, *inset); +} + void setlayout(const Arg *arg) { @@ -1831,6 +1859,13 @@ updatebarpos(Monitor *m) m->wy = m->topbar ? m->wy + bh : m->wy; } else m->by = -bh; + + // 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; } void -- 2.26.2