dwm-mark-new-6.2.diff (6906B)
1 From 753860d3435e2968358f2bf8daf70bf625fe75fe Mon Sep 17 00:00:00 2001 2 From: Kajetan Puchalski <kajetan.puchalski@tuta.io> 3 Date: Mon, 5 Oct 2020 11:04:31 +0100 4 Subject: [PATCH] Updated Mark patch to work with 6.2 5 6 --- 7 config.def.h | 14 +++++-- 8 drw.h | 2 +- 9 dwm.c | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 10 3 files changed, 118 insertions(+), 9 deletions(-) 11 12 diff --git a/config.def.h b/config.def.h 13 index 3858d75..a416c97 100644 14 --- a/config.def.h 15 +++ b/config.def.h 16 @@ -12,10 +12,13 @@ static const char col_gray2[] = "#444444"; 17 static const char col_gray3[] = "#bbbbbb"; 18 static const char col_gray4[] = "#eeeeee"; 19 static const char col_cyan[] = "#005577"; 20 -static const char *colors[][3] = { 21 - /* fg bg border */ 22 - [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, 23 - [SchemeSel] = { col_gray4, col_cyan, col_cyan }, 24 +static const char normmarkcolor[] = "#775500"; /*border color for marked client*/ 25 +static const char selmarkcolor[] = "#775577"; /*border color for marked client on focus*/ 26 + 27 +static const char *colors[][4] = { 28 + /* fg bg border mark */ 29 + [SchemeNorm] = { col_gray3, col_gray1, col_gray2, normmarkcolor }, 30 + [SchemeSel] = { col_gray4, col_cyan, col_cyan, selmarkcolor }, 31 }; 32 33 /* tagging */ 34 @@ -94,6 +97,9 @@ static Key keys[] = { 35 TAGKEYS( XK_8, 7) 36 TAGKEYS( XK_9, 8) 37 { MODKEY|ShiftMask, XK_q, quit, {0} }, 38 + { MODKEY, XK_semicolon, togglemark, {0} }, 39 + { MODKEY, XK_o, swapfocus, {0} }, 40 + { MODKEY, XK_u, swapclient, {0} }, 41 }; 42 43 /* button definitions */ 44 diff --git a/drw.h b/drw.h 45 index 4bcd5ad..97aae99 100644 46 --- a/drw.h 47 +++ b/drw.h 48 @@ -12,7 +12,7 @@ typedef struct Fnt { 49 struct Fnt *next; 50 } Fnt; 51 52 -enum { ColFg, ColBg, ColBorder }; /* Clr scheme index */ 53 +enum { ColFg, ColBg, ColBorder, ColMark }; /* Clr scheme index */ 54 typedef XftColor Clr; 55 56 typedef struct { 57 diff --git a/dwm.c b/dwm.c 58 index 664c527..195b8eb 100644 59 --- a/dwm.c 60 +++ b/dwm.c 61 @@ -201,17 +201,21 @@ static void setclientstate(Client *c, long state); 62 static void setfocus(Client *c); 63 static void setfullscreen(Client *c, int fullscreen); 64 static void setlayout(const Arg *arg); 65 +static void setmark(Client *c); 66 static void setmfact(const Arg *arg); 67 static void setup(void); 68 static void seturgent(Client *c, int urg); 69 static void showhide(Client *c); 70 static void sigchld(int unused); 71 static void spawn(const Arg *arg); 72 +static void swapclient(const Arg *arg); 73 +static void swapfocus(const Arg *arg); 74 static void tag(const Arg *arg); 75 static void tagmon(const Arg *arg); 76 static void tile(Monitor *); 77 static void togglebar(const Arg *arg); 78 static void togglefloating(const Arg *arg); 79 +static void togglemark(const Arg *arg); 80 static void toggletag(const Arg *arg); 81 static void toggleview(const Arg *arg); 82 static void unfocus(Client *c, int setfocus); 83 @@ -268,6 +272,7 @@ static Display *dpy; 84 static Drw *drw; 85 static Monitor *mons, *selmon; 86 static Window root, wmcheckwin; 87 +static Client *mark; 88 89 /* configuration, allows nested code to access above variables */ 90 #include "config.h" 91 @@ -796,7 +801,10 @@ focus(Client *c) 92 detachstack(c); 93 attachstack(c); 94 grabbuttons(c, 1); 95 - XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel); 96 + if (c == mark) 97 + XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColMark].pixel); 98 + else 99 + XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel); 100 setfocus(c); 101 } else { 102 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); 103 @@ -1052,7 +1060,10 @@ manage(Window w, XWindowAttributes *wa) 104 105 wc.border_width = c->bw; 106 XConfigureWindow(dpy, w, CWBorderWidth, &wc); 107 - XSetWindowBorder(dpy, w, scheme[SchemeNorm][ColBorder].pixel); 108 + if (c == mark) 109 + XSetWindowBorder(dpy, w, scheme[SchemeNorm][ColMark].pixel); 110 + else 111 + XSetWindowBorder(dpy, w, scheme[SchemeNorm][ColBorder].pixel); 112 configure(c); /* propagates border_width, if size doesn't change */ 113 updatewindowtype(c); 114 updatesizehints(c); 115 @@ -1512,6 +1523,23 @@ setlayout(const Arg *arg) 116 drawbar(selmon); 117 } 118 119 +void 120 +setmark(Client *c) 121 +{ 122 + if (c == mark) 123 + return; 124 + if (mark) { 125 + XSetWindowBorder(dpy, mark->win, scheme[mark == selmon->sel 126 + ? SchemeSel : SchemeNorm][ColBorder].pixel); 127 + mark = 0; 128 + } 129 + if (c) { 130 + XSetWindowBorder(dpy, c->win, scheme[c == selmon->sel 131 + ? SchemeSel : SchemeNorm][ColMark].pixel); 132 + mark = c; 133 + } 134 +} 135 + 136 /* arg > 1.0 will set mfact absolutely */ 137 void 138 setmfact(const Arg *arg) 139 @@ -1570,7 +1598,7 @@ setup(void) 140 /* init appearance */ 141 scheme = ecalloc(LENGTH(colors), sizeof(Clr *)); 142 for (i = 0; i < LENGTH(colors); i++) 143 - scheme[i] = drw_scm_create(drw, colors[i], 3); 144 + scheme[i] = drw_scm_create(drw, colors[i], 4); 145 /* init bars */ 146 updatebars(); 147 updatestatus(); 148 @@ -1653,6 +1681,75 @@ spawn(const Arg *arg) 149 } 150 } 151 152 +void 153 +swapclient(const Arg *arg) 154 +{ 155 + Client *s, *m, t; 156 + 157 + if (!mark || !selmon->sel || mark == selmon->sel 158 + || !selmon->lt[selmon->sellt]->arrange) 159 + return; 160 + s = selmon->sel; 161 + m = mark; 162 + t = *s; 163 + strcpy(s->name, m->name); 164 + s->win = m->win; 165 + s->x = m->x; 166 + s->y = m->y; 167 + s->w = m->w; 168 + s->h = m->h; 169 + 170 + m->win = t.win; 171 + strcpy(m->name, t.name); 172 + m->x = t.x; 173 + m->y = t.y; 174 + m->w = t.w; 175 + m->h = t.h; 176 + 177 + selmon->sel = m; 178 + mark = s; 179 + focus(s); 180 + setmark(m); 181 + 182 + arrange(s->mon); 183 + if (s->mon != m->mon) { 184 + arrange(m->mon); 185 + } 186 +} 187 + 188 +void 189 +swapfocus(const Arg *arg) 190 +{ 191 + Client *t; 192 + 193 + if (!selmon->sel || !mark || selmon->sel == mark) 194 + return; 195 + t = selmon->sel; 196 + if (mark->mon != selmon) { 197 + unfocus(selmon->sel, 0); 198 + selmon = mark->mon; 199 + } 200 + if (ISVISIBLE(mark)) { 201 + focus(mark); 202 + restack(selmon); 203 + } else { 204 + selmon->seltags ^= 1; 205 + selmon->tagset[selmon->seltags] = mark->tags; 206 + focus(mark); 207 + arrange(selmon); 208 + } 209 + setmark(t); 210 +} 211 + 212 +void 213 +togglemark(const Arg *arg) 214 +{ 215 + if (!selmon->sel) 216 + return; 217 + setmark(selmon->sel == mark ? 0 : selmon->sel); 218 +} 219 + 220 + 221 void 222 tag(const Arg *arg) 223 { 224 @@ -1755,7 +1852,10 @@ unfocus(Client *c, int setfocus) 225 if (!c) 226 return; 227 grabbuttons(c, 0); 228 - XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColBorder].pixel); 229 + if (c == mark) 230 + XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColMark].pixel); 231 + else 232 + XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColBorder].pixel); 233 if (setfocus) { 234 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); 235 XDeleteProperty(dpy, root, netatom[NetActiveWindow]); 236 @@ -1768,6 +1868,9 @@ unmanage(Client *c, int destroyed) 237 Monitor *m = c->mon; 238 XWindowChanges wc; 239 240 + if (c == mark) 241 + setmark(0); 242 + 243 detach(c); 244 detachstack(c); 245 if (!destroyed) { 246 -- 247 2.28.0 248