Hi guys, These are some fixes and improvements for dwm.
Kind regards, HIltjo
From ef3ee18387b8cfe3282d53a33f0f47fb58b6d8c9 Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma <[email protected]> Date: Mon, 4 May 2015 20:30:57 +0200 Subject: [PATCH 1/4] drw: drw_rect: use specified w and h --- drw.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drw.c b/drw.c index eb3b3c3..4d3e238 100644 --- a/drw.c +++ b/drw.c @@ -204,16 +204,13 @@ drw_setscheme(Drw *drw, ClrScheme *scheme) { void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int empty, int invert) { - int dx; - - if(!drw || !drw->fontcount || !drw->scheme) + if(!drw || !drw->scheme) return; XSetForeground(drw->dpy, drw->gc, invert ? drw->scheme->bg->pix : drw->scheme->fg->pix); - dx = (drw->fonts[0]->ascent + drw->fonts[0]->descent + 2) / 4; if(filled) - XFillRectangle(drw->dpy, drw->drawable, drw->gc, x+1, y+1, dx+1, dx+1); + XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w + 1, h + 1); else if(empty) - XDrawRectangle(drw->dpy, drw->drawable, drw->gc, x+1, y+1, dx, dx); + XDrawRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h); } int -- 2.3.7
From 3735b48d8fd4cb30fdc54d8ce24e85d1193afc5d Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma <[email protected]> Date: Mon, 4 May 2015 20:31:30 +0200 Subject: [PATCH 2/4] dwm: adjust drw_rect for libdrw drw_rect change --- dwm.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dwm.c b/dwm.c index 169adcb..f447f60 100644 --- a/dwm.c +++ b/dwm.c @@ -691,10 +691,12 @@ dirtomon(int dir) { void drawbar(Monitor *m) { - int x, xx, w; + int x, xx, w, dx; unsigned int i, occ = 0, urg = 0; Client *c; + dx = (drw->fonts[0]->ascent + drw->fonts[0]->descent + 2) / 4; + for(c = m->clients; c; c = c->next) { occ |= c->tags; if(c->isurgent) @@ -705,7 +707,7 @@ drawbar(Monitor *m) { w = TEXTW(tags[i]); drw_setscheme(drw, m->tagset[m->seltags] & 1 << i ? &scheme[SchemeSel] : &scheme[SchemeNorm]); drw_text(drw, x, 0, w, bh, tags[i], urg & 1 << i); - drw_rect(drw, x, 0, w, bh, m == selmon && selmon->sel && selmon->sel->tags & 1 << i, + drw_rect(drw, x + 1, 1, dx, dx, m == selmon && selmon->sel && selmon->sel->tags & 1 << i, occ & 1 << i, urg & 1 << i); x += w; } @@ -730,7 +732,7 @@ drawbar(Monitor *m) { if(m->sel) { drw_setscheme(drw, m == selmon ? &scheme[SchemeSel] : &scheme[SchemeNorm]); drw_text(drw, x, 0, w, bh, m->sel->name, 0); - drw_rect(drw, x, 0, w, bh, m->sel->isfixed, m->sel->isfloating, 0); + drw_rect(drw, x + 1, 1, dx, dx, m->sel->isfixed, m->sel->isfloating, 0); } else { drw_setscheme(drw, &scheme[SchemeNorm]); -- 2.3.7
From b7b5462bde6ed791c19ea5a918cb4ff1dd532175 Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma <[email protected]> Date: Mon, 4 May 2015 22:06:17 +0200 Subject: [PATCH 3/4] util: die(): print errno if last character is ':' ... and make use of it for some functions. --- dwm.c | 8 ++++---- util.c | 15 +++++++++++---- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/dwm.c b/dwm.c index f447f60..1446800 100644 --- a/dwm.c +++ b/dwm.c @@ -632,7 +632,7 @@ createmon(void) { Monitor *m; if(!(m = (Monitor *)calloc(1, sizeof(Monitor)))) - die("fatal: could not malloc() %u bytes\n", sizeof(Monitor)); + die("fatal: could not malloc() %u bytes:", sizeof(Monitor)); m->tagset[0] = m->tagset[1] = 1; m->mfact = mfact; m->nmaster = nmaster; @@ -1011,7 +1011,7 @@ manage(Window w, XWindowAttributes *wa) { XWindowChanges wc; if(!(c = calloc(1, sizeof(Client)))) - die("fatal: could not malloc() %u bytes\n", sizeof(Client)); + die("fatal: could not malloc() %u bytes:", sizeof(Client)); c->win = w; updatetitle(c); if(XGetTransientForHint(dpy, w, &trans) && (t = wintoclient(trans))) { @@ -1575,7 +1575,7 @@ showhide(Client *c) { void sigchld(int unused) { if(signal(SIGCHLD, sigchld) == SIG_ERR) - die("Can't install SIGCHLD handler"); + die("Can't install SIGCHLD handler:"); while(0 < waitpid(-1, NULL, WNOHANG)); } @@ -1792,7 +1792,7 @@ updategeom(void) { for(n = 0, m = mons; m; m = m->next, n++); /* only consider unique geometries as separate screens */ if(!(unique = (XineramaScreenInfo *)malloc(sizeof(XineramaScreenInfo) * nn))) - die("fatal: could not malloc() %u bytes\n", sizeof(XineramaScreenInfo) * nn); + die("fatal: could not malloc() %u bytes:", sizeof(XineramaScreenInfo) * nn); for(i = 0, j = 0; i < nn; i++) if(isuniquegeom(unique, j, &info[i])) memcpy(&unique[j++], &info[i], sizeof(XineramaScreenInfo)); diff --git a/util.c b/util.c index 51acd1a..78d3035 100644 --- a/util.c +++ b/util.c @@ -2,16 +2,23 @@ #include <stdarg.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> #include "util.h" void -die(const char *errstr, ...) { +die(const char *fmt, ...) { va_list ap; - va_start(ap, errstr); - vfprintf(stderr, errstr, ap); + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); va_end(ap); - exit(EXIT_FAILURE); + + if (fmt[0] && fmt[strlen(fmt)-1] == ':') { + fputc(' ', stderr); + perror(NULL); + } + + exit(1); } -- 2.3.7
From e6d252396176f23e5d075099668fd55c2c4f0221 Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma <[email protected]> Date: Mon, 4 May 2015 22:09:53 +0200 Subject: [PATCH 4/4] config.def.h: use monospace as default font also use Xft font name to pass to dmenu. --- config.def.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/config.def.h b/config.def.h index eaae8f3..3fde3cf 100644 --- a/config.def.h +++ b/config.def.h @@ -2,11 +2,9 @@ /* appearance */ static const char *fonts[] = { - "Sans:size=10.5", - "VL Gothic:size=10.5", - "WenQuanYi Micro Hei:size=10.5", + "monospace:size=10" }; -static const char dmenufont[] = "-*-terminus-medium-r-*-*-16-*-*-*-*-*-*-*"; +static const char dmenufont[] = "monospace:size=10"; static const char normbordercolor[] = "#444444"; static const char normbgcolor[] = "#222222"; static const char normfgcolor[] = "#bbbbbb"; -- 2.3.7
