dwm-insets-6.2.diff (2379B)
1 From c74af17bcab18263ea565e6760728d03987359a7 Mon Sep 17 00:00:00 2001 2 From: jD91mZM2 <me@krake.one> 3 Date: Sun, 31 May 2020 22:06:00 +0200 4 Subject: [PATCH] Custom screen insets 5 6 --- 7 config.def.h | 7 +++++++ 8 dwm.c | 35 +++++++++++++++++++++++++++++++++++ 9 2 files changed, 42 insertions(+) 10 11 diff --git a/config.def.h b/config.def.h 12 index 1c0b587..43b464a 100644 13 --- a/config.def.h 14 +++ b/config.def.h 15 @@ -18,6 +18,13 @@ static const char *colors[][3] = { 16 [SchemeSel] = { col_gray4, col_cyan, col_cyan }, 17 }; 18 19 +static const Inset default_inset = { 20 + .x = 0, 21 + .y = 30, 22 + .w = 0, 23 + .h = 0, 24 +}; 25 + 26 /* tagging */ 27 static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; 28 29 diff --git a/dwm.c b/dwm.c 30 index 4465af1..f91da15 100644 31 --- a/dwm.c 32 +++ b/dwm.c 33 @@ -111,6 +111,13 @@ typedef struct { 34 void (*arrange)(Monitor *); 35 } Layout; 36 37 +typedef struct { 38 + int x; 39 + int y; 40 + int w; 41 + int h; 42 +} Inset; 43 + 44 struct Monitor { 45 char ltsymbol[16]; 46 float mfact; 47 @@ -130,6 +137,7 @@ struct Monitor { 48 Monitor *next; 49 Window barwin; 50 const Layout *lt[2]; 51 + Inset inset; 52 }; 53 54 typedef struct { 55 @@ -199,6 +207,8 @@ static void sendmon(Client *c, Monitor *m); 56 static void setclientstate(Client *c, long state); 57 static void setfocus(Client *c); 58 static void setfullscreen(Client *c, int fullscreen); 59 +static void setinset(Monitor *m, Inset inset); 60 +static void updateinset(const Arg *arg); 61 static void setlayout(const Arg *arg); 62 static void setmfact(const Arg *arg); 63 static void setup(void); 64 @@ -641,6 +651,7 @@ createmon(void) 65 m->lt[0] = &layouts[0]; 66 m->lt[1] = &layouts[1 % LENGTH(layouts)]; 67 strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); 68 + m->inset = default_inset; 69 return m; 70 } 71 72 @@ -1497,6 +1508,23 @@ setfullscreen(Client *c, int fullscreen) 73 } 74 } 75 76 +void 77 +setinset(Monitor *m, Inset inset) 78 +{ 79 + m->inset = inset; 80 + updatebarpos(m); 81 + arrange(m); 82 +} 83 + 84 +void 85 +updateinset(const Arg *arg) 86 +{ 87 + Inset *inset = (Inset *)arg->v; 88 + 89 + for (Monitor *m = mons; m; m = m->next) 90 + setinset(m, *inset); 91 +} 92 + 93 void 94 setlayout(const Arg *arg) 95 { 96 @@ -1831,6 +1859,13 @@ updatebarpos(Monitor *m) 97 m->wy = m->topbar ? m->wy + bh : m->wy; 98 } else 99 m->by = -bh; 100 + 101 + // Custom insets 102 + Inset inset = m->inset; 103 + m->wx += inset.x; 104 + m->wy += inset.y; 105 + m->ww -= inset.w + inset.x; 106 + m->wh -= inset.h + inset.y; 107 } 108 109 void 110 -- 111 2.26.2 112