From cb3f58ad06993f7ef3a7d8f61468012e2b786cab Mon Sep 17 00:00:00 2001 From: Anselm R Garbe Date: Sat, 2 Feb 2019 04:50:42 -0800 Subject: [PATCH 01/13] Prepare 6.2 release. --- LICENSE | 2 +- config.mk | 2 +- drw.c | 16 +++++++++++++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/LICENSE b/LICENSE index 954cdc9..d221f09 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT/X Consortium License -© 2006-2017 Anselm R Garbe +© 2006-2019 Anselm R Garbe © 2006-2009 Jukka Salmi © 2006-2007 Sander van Dijk © 2007-2011 Peter Hartlich diff --git a/config.mk b/config.mk index 25e2685..6d36cb7 100644 --- a/config.mk +++ b/config.mk @@ -1,5 +1,5 @@ # dwm version -VERSION = 6.1 +VERSION = 6.2 # Customize below to fit your system diff --git a/drw.c b/drw.c index c638323..8fd1ca4 100644 --- a/drw.c +++ b/drw.c @@ -132,6 +132,19 @@ xfont_create(Drw *drw, const char *fontname, FcPattern *fontpattern) die("no font specified."); } + /* Do not allow using color fonts. This is a workaround for a BadLength + * error from Xft with color glyphs. Modelled on the Xterm workaround. See + * https://bugzilla.redhat.com/show_bug.cgi?id=1498269 + * https://lists.suckless.org/dev/1701/30932.html + * https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=916349 + * and lots more all over the internet. + */ + FcBool iscol; + if(FcPatternGetBool(xfont->pattern, FC_COLOR, 0, &iscol) == FcResultMatch && iscol) { + XftFontClose(drw->dpy, xfont); + return NULL; + } + font = ecalloc(1, sizeof(Fnt)); font->xfont = xfont; font->pattern = pattern; @@ -200,7 +213,7 @@ drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount) Clr *ret; /* need at least two colors for a scheme */ - if (!drw || !clrnames || clrcount < 2 || !(ret = ecalloc(clrcount, sizeof(Clr)))) + if (!drw || !clrnames || clrcount < 2 || !(ret = ecalloc(clrcount, sizeof(XftColor)))) return NULL; for (i = 0; i < clrcount; i++) @@ -337,6 +350,7 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp fcpattern = FcPatternDuplicate(drw->fonts->pattern); FcPatternAddCharSet(fcpattern, FC_CHARSET, fccharset); FcPatternAddBool(fcpattern, FC_SCALABLE, FcTrue); + FcPatternAddBool(fcpattern, FC_COLOR, FcFalse); FcConfigSubstitute(NULL, fcpattern, FcMatchPattern); FcDefaultSubstitute(fcpattern); From c82db690cc0c4624dad4dc6ae899020799ec84db Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Fri, 3 Apr 2020 15:36:32 +0200 Subject: [PATCH 02/13] config.mk: fix POSIX_C_SOURCE macro for feature test for snprintf() The feature test was incorrect: _POSIX_C_SOURCE=2 "The value 2 or greater additionally exposes definitions for POSIX.2-1992." http://man7.org/linux/man-pages/man7/feature_test_macros.7.html A higher value is needed (atleast 1995): https://pubs.opengroup.org/onlinepubs/9699919799/functions/snprintf.html FreeBSD feature test macro: on https://github.com/freebsd/freebsd/blob/master/include/stdio.h line 297 This was already fixed in dmenu. This fixes a warning on FreeBSD, reported by Plasmoduck on IRC, thanks. --- config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.mk b/config.mk index 6d36cb7..7084c33 100644 --- a/config.mk +++ b/config.mk @@ -25,7 +25,7 @@ INCS = -I${X11INC} -I${FREETYPEINC} LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} # flags -CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=2 -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} +CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} #CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS} CFLAGS = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS} LDFLAGS = ${LIBS} From a8e9513783f335b1ac7255e40a663adfffc4b475 Mon Sep 17 00:00:00 2001 From: Chris Down Date: Mon, 20 Apr 2020 16:41:52 +0100 Subject: [PATCH 03/13] setmfact: Unify bounds for compile-time and runtime mfact There are two places that mfact can be set: - In the mfact global, which is defined at compile time and passed into m->mfact during monitor setup. No bounds checks are performed, but the comment alongside it says that valid values are [0.05..0.95]: static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */ - By setmfact, which adjusts m->mfact at runtime. It also does some minimum and maximum bounds checks, allowing [0.1..0.9]. Values outside of that range are ignored, and mfact is not adjusted. These different thresholds mean that one cannot setmfact 0.95 or 0.05, despite the comment above that lists the legal range for mfact. Clarify this by enforcing the same bounds in setmfact at runtime as those listed for mfact at compile time. --- dwm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dwm.c b/dwm.c index 4465af1..41c6767 100644 --- a/dwm.c +++ b/dwm.c @@ -1520,7 +1520,7 @@ setmfact(const Arg *arg) if (!arg || !selmon->lt[selmon->sellt]->arrange) return; f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0; - if (f < 0.1 || f > 0.9) + if (f < 0.05 || f > 0.95) return; selmon->mfact = f; arrange(selmon); From f087d20e6e60a49c756936b4312f5d194d8e63b4 Mon Sep 17 00:00:00 2001 From: Chris Down Date: Wed, 22 Apr 2020 15:48:08 +0100 Subject: [PATCH 04/13] getatomprop: Add forward declaration No functional changes, but for every other function we have a forward declaration here. getatomprop should be no exception. --- dwm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/dwm.c b/dwm.c index 41c6767..972f261 100644 --- a/dwm.c +++ b/dwm.c @@ -169,6 +169,7 @@ static void focus(Client *c); static void focusin(XEvent *e); static void focusmon(const Arg *arg); static void focusstack(const Arg *arg); +static Atom getatomprop(Client *c, Atom prop); static int getrootptr(int *x, int *y); static long getstate(Window w); static int gettextprop(Window w, Atom atom, char *text, unsigned int size); From ed3ab6b4fceded0e9f2d22372df49a2bbd58de66 Mon Sep 17 00:00:00 2001 From: Chris Down Date: Wed, 22 Apr 2020 15:48:27 +0100 Subject: [PATCH 05/13] drawbar: Don't shadow sw global This jarred me a bit while reading the code, since "sw" usually refers to the global screen geometry, but in drawbar() only it refers to text-related geometry. Renaming it makes it more obvious that these are not related. --- dwm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dwm.c b/dwm.c index 972f261..fb1e326 100644 --- a/dwm.c +++ b/dwm.c @@ -696,7 +696,7 @@ dirtomon(int dir) void drawbar(Monitor *m) { - int x, w, sw = 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; @@ -705,8 +705,8 @@ drawbar(Monitor *m) /* draw status first so it can be overdrawn by tags later */ if (m == selmon) { /* status is only drawn on selected monitor */ drw_setscheme(drw, scheme[SchemeNorm]); - sw = TEXTW(stext) - lrpad + 2; /* 2px right padding */ - drw_text(drw, m->ww - sw, 0, sw, bh, 0, stext, 0); + tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */ + drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0); } for (c = m->clients; c; c = c->next) { @@ -729,7 +729,7 @@ drawbar(Monitor *m) drw_setscheme(drw, scheme[SchemeNorm]); x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0); - if ((w = m->ww - sw - x) > bh) { + if ((w = m->ww - tw - x) > bh) { if (m->sel) { drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]); drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0); From f09418bbb6651ab4c299cfefbe1d18de401f630e Mon Sep 17 00:00:00 2001 From: bakkeby Date: Thu, 23 Apr 2020 09:50:54 +0200 Subject: [PATCH 06/13] dwm crashes when opening 50+ clients (tile layout) Many users new to dwm find themselves caught out by being kicked out to the login manager (dwm crashing) when they open 50+ clients for demonstration purposes. The number of clients reported varies depending on the resolution of the monitor. The cause of this is due to how the default tile layout calculates the height of the next client based on the position of the previous client. Because clients have a minimum size the (ty) position can exceed that of the window height, resulting in (m->wh - ty) becoming negative. The negative height stored as an unsigned int results in a very large height ultimately resulting in dwm crashing. This patch adds safeguards to prevent the ty and my positions from exceeding that of the window height. --- dwm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dwm.c b/dwm.c index fb1e326..9fd0286 100644 --- a/dwm.c +++ b/dwm.c @@ -1689,11 +1689,13 @@ tile(Monitor *m) if (i < m->nmaster) { h = (m->wh - my) / (MIN(n, m->nmaster) - i); resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0); - my += HEIGHT(c); + if (my + HEIGHT(c) < m->wh) + my += HEIGHT(c); } else { h = (m->wh - ty) / (n - i); resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0); - ty += HEIGHT(c); + if (ty + HEIGHT(c) < m->wh) + ty += HEIGHT(c); } } From f04cac6d6e39cd9e3fc4fae526e3d1e8df5e34b2 Mon Sep 17 00:00:00 2001 From: Alex Flierl Date: Thu, 11 Jun 2020 15:28:32 +0200 Subject: [PATCH 07/13] Fix memory leaks in drw The function drw_fontset_free in drw.c was never called. --- drw.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drw.c b/drw.c index 8fd1ca4..4cdbcbe 100644 --- a/drw.c +++ b/drw.c @@ -95,6 +95,7 @@ drw_free(Drw *drw) { XFreePixmap(drw->dpy, drw->drawable); XFreeGC(drw->dpy, drw->gc); + drw_fontset_free(drw->fonts); free(drw); } From bb2e7222baeec7776930354d0e9f210cc2aaad5f Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Wed, 8 Jul 2020 18:05:50 +0200 Subject: [PATCH 08/13] dwm.1: fix wrong text in man page --- dwm.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dwm.1 b/dwm.1 index 13b3729..ddc8321 100644 --- a/dwm.1 +++ b/dwm.1 @@ -33,7 +33,7 @@ dwm draws a small border around windows to indicate the focus state. .SH OPTIONS .TP .B \-v -prints version information to standard output, then exits. +prints version information to stderr, then exits. .SH USAGE .SS Status bar .TP From 61bb8b2241d4db08bea4261c82e27cd9797099e7 Mon Sep 17 00:00:00 2001 From: Ian Remmler Date: Tue, 3 Mar 2020 16:23:53 -0600 Subject: [PATCH 09/13] Fix x coordinate calculation in buttonpress. --- dwm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dwm.c b/dwm.c index 9fd0286..664c527 100644 --- a/dwm.c +++ b/dwm.c @@ -440,7 +440,7 @@ buttonpress(XEvent *e) arg.ui = 1 << i; } else if (ev->x < x + blw) click = ClkLtSymbol; - else if (ev->x > selmon->ww - TEXTW(stext)) + else if (ev->x > selmon->ww - (int)TEXTW(stext)) click = ClkStatusText; else click = ClkWinTitle; From 67d76bdc68102df976177de351f65329d8683064 Mon Sep 17 00:00:00 2001 From: Chris Down Date: Thu, 2 Jul 2020 20:18:30 +0100 Subject: [PATCH 10/13] Do not allow focus to drift from fullscreen client via focusstack() It generally doesn't make much sense to allow focusstack() to navigate away from the selected fullscreen client, as you can't even see which client you're selecting behind it. I have had this up for a while on the wiki as a separate patch[0], but it seems reasonable to avoid this behaviour in dwm mainline, since I'm struggling to think of any reason to navigate away from a fullscreen client other than a mistake. 0: https://dwm.suckless.org/patches/alwaysfullscreen/ --- dwm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dwm.c b/dwm.c index 664c527..b0b3466 100644 --- a/dwm.c +++ b/dwm.c @@ -835,7 +835,7 @@ focusstack(const Arg *arg) { Client *c = NULL, *i; - if (!selmon->sel) + if (!selmon->sel || selmon->sel->isfullscreen) return; if (arg->i > 0) { for (c = selmon->sel->next; c && !ISVISIBLE(c); c = c->next); From 138b405f0c8aa24d8a040cc1a1cf6e3eb5a0ebc7 Mon Sep 17 00:00:00 2001 From: Quentin Rameau Date: Mon, 12 Jul 2021 23:44:16 +0200 Subject: [PATCH 11/13] Add a configuration option for fullscreen locking Some people are annoyed to have this new behaviour forced for some application which use fake fullscreen. --- config.def.h | 1 + dwm.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/config.def.h b/config.def.h index 1c0b587..a2ac963 100644 --- a/config.def.h +++ b/config.def.h @@ -35,6 +35,7 @@ static const Rule rules[] = { static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */ static const int nmaster = 1; /* number of clients in master area */ static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */ +static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */ static const Layout layouts[] = { /* symbol arrange function */ diff --git a/dwm.c b/dwm.c index b0b3466..5e4d494 100644 --- a/dwm.c +++ b/dwm.c @@ -835,7 +835,7 @@ focusstack(const Arg *arg) { Client *c = NULL, *i; - if (!selmon->sel || selmon->sel->isfullscreen) + if (!selmon->sel || (selmon->sel->isfullscreen && lockfullscreen)) return; if (arg->i > 0) { for (c = selmon->sel->next; c && !ISVISIBLE(c); c = c->next); From 716233534b35f74dba5a46ade8f1a6f8cc72fea4 Mon Sep 17 00:00:00 2001 From: Miles Alan Date: Mon, 9 Aug 2021 18:24:14 +0200 Subject: [PATCH 12/13] Improve speed of drw_text when provided with large strings Calculates len & ew in drw_font_getexts loop by incrementing instead of decrementing; as such avoids proportional increase in time spent in loop based on provided strings size. --- drw.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drw.c b/drw.c index 4cdbcbe..9c39086 100644 --- a/drw.c +++ b/drw.c @@ -310,8 +310,11 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp if (utf8strlen) { drw_font_getexts(usedfont, utf8str, utf8strlen, &ew, NULL); /* shorten text if necessary */ - for (len = MIN(utf8strlen, sizeof(buf) - 1); len && ew > w; len--) - drw_font_getexts(usedfont, utf8str, len, &ew, NULL); + if (ew > w) + for (ew = 0, len = 0; ew < w - lpad * 2 && len < MIN(utf8strlen, sizeof(buf) - 1); len++) + drw_font_getexts(usedfont, utf8str, len, &ew, NULL); + else + len = MIN(utf8strlen, sizeof(buf) - 1); if (len) { memcpy(buf, utf8str, len); From a786211d6cb794fba0ea406d86002c7618998afc Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Fri, 20 Aug 2021 23:09:48 +0200 Subject: [PATCH 13/13] Revert "Improve speed of drw_text when provided with large strings" This reverts commit 716233534b35f74dba5a46ade8f1a6f8cc72fea4. It causes issues with truncation of characters when the text does not fit and so on. The patch should be reworked and properly tested. --- drw.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drw.c b/drw.c index 9c39086..4cdbcbe 100644 --- a/drw.c +++ b/drw.c @@ -310,11 +310,8 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp if (utf8strlen) { drw_font_getexts(usedfont, utf8str, utf8strlen, &ew, NULL); /* shorten text if necessary */ - if (ew > w) - for (ew = 0, len = 0; ew < w - lpad * 2 && len < MIN(utf8strlen, sizeof(buf) - 1); len++) - drw_font_getexts(usedfont, utf8str, len, &ew, NULL); - else - len = MIN(utf8strlen, sizeof(buf) - 1); + for (len = MIN(utf8strlen, sizeof(buf) - 1); len && ew > w; len--) + drw_font_getexts(usedfont, utf8str, len, &ew, NULL); if (len) { memcpy(buf, utf8str, len);