dwm-noxz

[fork] suckless dwm - personal fork
git clone https://noxz.tech/git/dwm-noxz.git
Log | Files | README | LICENSE

commit: cf7337b6e584ae6e1867bc5adde24071aadf87ef
parent: 9b5fe4975956f3aef7dea9f29fce98627243bdd4
author: Chris Noxz <chris@noxz.tech>
date:   Tue, 26 Jul 2022 19:56:04 +0200
Extend color scheme, implement attachabove and fix title centering
Mconfig.def.h19++++++++--
Mdrw.c1+
Mdwm.c40+++++++++++++++-----
3 files changed, 47 insertions(+), 13 deletions(-)
diff --git a/config.def.h b/config.def.h
@@ -23,9 +23,15 @@ static char col_tanbr[]         = COL_DEF;
 static char col_tasfg[]         = COL_DEF;
 static char col_tasbg[]         = COL_DEF;
 static char col_tasbr[]         = COL_DEF;
+static char col_layfg[]         = COL_DEF;
+static char col_laybg[]         = COL_DEF;
+static char col_laybr[]         = COL_DEF;
 static char col_tinfg[]         = COL_DEF;
+static char col_tinbg[]         = COL_DEF;
 static char col_tisfg[]         = COL_DEF;
+static char col_tisbg[]         = COL_DEF;
 static char col_snfg[]          = COL_DEF;
+static char col_snbg[]          = COL_DEF;
 static char col_safg[]          = COL_DEF;
 static char col_sabg[]          = COL_DEF;
 static char col_sdfg[]          = COL_DEF;
@@ -38,10 +44,11 @@ static char *colors[][4]        = {
 	[SchemeSel]             = { col_none,   col_none,   col_sbr,    col_sfl },
 	[SchemeTagsNorm]        = { col_tanfg,  col_tanbg,  col_tanbr,  col_none },
 	[SchemeTagsSel]         = { col_tasfg,  col_tasbg,  col_tasbr,  col_none },
-	[SchemeTitleNorm]       = { col_tinfg,  col_none,   col_none,   col_none },
-	[SchemeTitleSel]        = { col_tisfg,  col_none,   col_none,   col_none },
+	[SchemeLayout]          = { col_layfg,  col_laybg,  col_laybr,  col_none },
+	[SchemeTitleNorm]       = { col_tinfg,  col_tinbg,  col_none,   col_none },
+	[SchemeTitleSel]        = { col_tisfg,  col_tisbg,  col_none,   col_none },
 
-	[SchemeStatusNorm]      = { col_snfg,   col_none,   col_none,   col_none },
+	[SchemeStatusNorm]      = { col_snfg,   col_snbg,   col_none,   col_none },
 	[SchemeStatusAct]       = { col_safg,   col_sabg,   col_none,   col_none },
 	[SchemeStatusDist]      = { col_sdfg,   col_sdbg,   col_none,   col_none },
 	[SchemeStatusNoti]      = { col_snofg,  col_snobg,  col_none,   col_none },
@@ -99,9 +106,15 @@ ResourcePref resources[] = {
 	{ "tagsSelectedForeground",     STRING,     &col_tasfg },
 	{ "tagsSelectedBackground",     STRING,     &col_tasbg },
 	{ "tagsSelectedBorderColor",    STRING,     &col_tasbr },
+	{ "layoutsForeground",          STRING,     &col_layfg },
+	{ "layoutsBackground",          STRING,     &col_laybg },
+	{ "layoutsBorderColor",         STRING,     &col_laybr },
 	{ "titleNormalForeground",      STRING,     &col_tinfg },
+	{ "titleNormalBackground",      STRING,     &col_tinbg },
 	{ "titleSelectedForeground",    STRING,     &col_tisfg },
+	{ "titleSelectedBackground",    STRING,     &col_tisbg },
 	{ "statusNormalForeground",     STRING,     &col_snfg },
+	{ "statusNormalBackground",     STRING,     &col_snbg },
 	{ "statusActForeground",        STRING,     &col_safg },
 	{ "statusActBackground",        STRING,     &col_sabg },
 	{ "statusDistForeground",       STRING,     &col_sdfg },
diff --git a/drw.c b/drw.c
@@ -203,6 +203,7 @@ drw_clr_create(Drw *drw, Clr *dest, const char *clrname)
 	                       DefaultColormap(drw->dpy, drw->screen),
 	                       clrname, dest))
 		die("error, cannot allocate color '%s'", clrname);
+	dest->pixel |= 0xff << 24;
 }
 
 /* Wrapper to create color schemes. The caller has to call free(3) on the
diff --git a/dwm.c b/dwm.c
@@ -64,8 +64,9 @@
 enum { DispUi, DispCmdLine }; /* dispatch types */
 enum { LayoutGrid, LayoutTiled, LayoutMonocle, LayoutFloating }; /* layouts, first is default */
 enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
-enum { SchemeNorm, SchemeSel, SchemeTagsNorm, SchemeTagsSel, SchemeTitleNorm, SchemeTitleSel,
-	SchemeStatusNorm, SchemeStatusAct, SchemeStatusDist, SchemeStatusNoti }; /* color schemes */
+enum { SchemeNorm, SchemeSel, SchemeTagsNorm, SchemeTagsSel, SchemeLayout,
+	SchemeTitleNorm, SchemeTitleSel, SchemeStatusNorm, SchemeStatusAct,
+	SchemeStatusDist, SchemeStatusNoti }; /* color schemes */
 enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
        NetWMFullscreen, NetActiveWindow, NetWMWindowType,
        NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
@@ -167,6 +168,7 @@ static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interac
 static void arrange(Monitor *m);
 static void arrangemon(Monitor *m);
 static void attach(Client *c);
+static void attachabove(Client *c);
 static void attachstack(Client *c);
 static void buttonpress(XEvent *e);
 static void checkotherwm(void);
@@ -448,6 +450,20 @@ attach(Client *c)
 	c->mon->clients = c;
 }
 
+void
+attachabove(Client *c)
+{
+	if (c->mon->sel == NULL || c->mon->sel == c->mon->clients || c->mon->sel->isfloating) {
+		attach(c);
+		return;
+	}
+	
+	Client *at;
+	for (at = c->mon->clients; at->next != c->mon->sel; at = at->next);
+	c->next = at->next;
+	at->next = c;
+}
+
 void
 attachstack(Client *c)
 {
@@ -853,7 +869,7 @@ dispatchcmd(void)
 void
 drawbar(Monitor *m)
 {
-	int x, w, mid, tw = 0;
+	int x, w, tw = 0;
 	int boxs = drw->fonts->h / 9;
 	int boxw = drw->fonts->h / 6 + 2;
 	unsigned int i, occ = 0, urg = 0;
@@ -909,14 +925,16 @@ drawbar(Monitor *m)
 		x += w;
 	}
 	w = blw = TEXTW(m->ltsymbol);
-	drw_setscheme(drw, scheme[SchemeTagsSel]);
+	drw_setscheme(drw, scheme[SchemeLayout]);
 	x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
 
 	if ((w = m->ww - tw - x) > bh) {
 		if (m->sel) {
-			mid = (m->ww - TEXTW(m->sel->name)) / 2 - x;
 			drw_setscheme(drw, scheme[m == selmon ? SchemeTitleSel : SchemeTitleNorm]);
-			drw_text(drw, x, 0, w, bh, mid, m->sel->name, 0);
+			if (TEXTW(m->sel->name) > (m->ww - x))
+				drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
+			else
+				drw_text(drw, x, 0, w, bh, (m->ww - TEXTW(m->sel->name)) / 2 - x, m->sel->name, 0);
 			if (m->sel->isfloating)
 				drw_rect(drw, x + boxs + 1, boxs + 1, boxw, boxw, m->sel->isfixed, 0);
 		} else {
@@ -1237,7 +1255,7 @@ manage(Window w, XWindowAttributes *wa)
 		XRaiseWindow(dpy, c->win);
 	if (c->isfloating)
 		XSetWindowBorder(dpy, w, scheme[SchemeNorm][ColFloat].pixel);
-	attach(c);
+	attachabove(c);
 	attachstack(c);
 	XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
 		(unsigned char *) &(c->win), 1);
@@ -1432,7 +1450,9 @@ resizeclient(Client *c, int x, int y, int w, int h)
 	wc.border_width = c->bw;
 	if (((nexttiled(c->mon->clients) == c && !nexttiled(c->next))
 		|| &monocle == c->mon->lt[c->mon->sellt]->arrange)
-		&& !c->isfullscreen && !c->isfloating) {
+		&& !c->isfullscreen
+		&& !c->isfloating
+		&& !c->mon->pertag->enablegaps[c->mon->pertag->curtag]) {
 			c->w = wc.width += c->bw * 2;
 			c->h = wc.height += c->bw * 2;
 			wc.border_width = 0;
@@ -1673,7 +1693,7 @@ sendmon(Client *c, Monitor *m)
 	detachstack(c);
 	c->mon = m;
 	c->tags = (m->tagset[m->seltags] ? m->tagset[m->seltags] : 1);
-	attach(c);
+	attachabove(c);
 	attachstack(c);
 	focus(NULL);
 	arrange(NULL);
@@ -1967,7 +1987,7 @@ getgap(Monitor *m, unsigned int n, unsigned int *g, unsigned int r, unsigned int
 		m->gap = m->ww / (c + 1);
 
 	/* set gap if used */
-	*g = (m->pertag->enablegaps[m->pertag->curtag] && n > 1) ? m->gap : 0;
+	*g = (m->pertag->enablegaps[m->pertag->curtag] && n > 0) ? m->gap : 0;
 }
 
 void