Skip to content

Commit

Permalink
Adding the do-not-die-on-color-allocation-failure patch ref. #404
Browse files Browse the repository at this point in the history
  • Loading branch information
bakkeby committed Dec 22, 2023
1 parent 9869c22 commit 5a0c5e6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Browsing patches? There is a [map of patches](https://coggle.it/diagram/X9IiSSM6
### Changelog:
2023-12-22 - Added the do-not-die-on-color-allocation-failure patch
2023-12-01 - Added the sendmoncenter patch
2023-11-12 - Added the focusmaster-return patch variant
Expand Down Expand Up @@ -359,6 +361,10 @@ Browsing patches? There is a [map of patches](https://coggle.it/diagram/X9IiSSM6
- i.e. if topbar is 0 then dmenu will appear at the bottom and if 1 then dmenu will appear at
the top
- do-not-die-on-color-allocation-failure
- avoids dwm terminating (dying) on color allocation failures
- useful for the xrdb (xresources) and status2d patches
- [dragcfact](https://github.com/bakkeby/patches/wiki/dragcfact/)
- lets you resize clients' size (i.e. modify cfact) by holding modkey + shift + right-click
and dragging the mouse
Expand Down
8 changes: 8 additions & 0 deletions drw.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,14 +337,22 @@ drw_clr_create(
#if BAR_ALPHA_PATCH
if (!XftColorAllocName(drw->dpy, drw->visual, drw->cmap,
clrname, dest))
#if DO_NOT_DIE_ON_COLOR_ALLOCATION_FAILURE_PATCH
fprintf(stderr, "warning, cannot allocate color '%s'", clrname);
#else
die("error, cannot allocate color '%s'", clrname);
#endif // DO_NOT_DIE_ON_COLOR_ALLOCATION_FAILURE_PATCH

dest->pixel = (dest->pixel & 0x00ffffffU) | (alpha << 24);
#else
if (!XftColorAllocName(drw->dpy, DefaultVisual(drw->dpy, drw->screen),
DefaultColormap(drw->dpy, drw->screen),
clrname, dest))
#if DO_NOT_DIE_ON_COLOR_ALLOCATION_FAILURE_PATCH
fprintf(stderr, "warning, cannot allocate color '%s'", clrname);
#else
die("error, cannot allocate color '%s'", clrname);
#endif // DO_NOT_DIE_ON_COLOR_ALLOCATION_FAILURE_PATCH

#if NO_TRANSPARENT_BORDERS_PATCH
dest->pixel |= 0xff << 24;
Expand Down
12 changes: 12 additions & 0 deletions patches.def.h
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,18 @@
*/
#define DISTRIBUTETAGS_PATCH 0

/* By default dwm will terminate on color allocation failure and the behaviour is intended to
* catch and inform the user of color configuration issues.
*
* Some patches like status2d and xresources / xrdb can change colours during runtime, which
* means that if a color can't be allocated at this time then the window manager will abruptly
* terminate.
*
* This patch will ignore color allocation failures and continue on as normal. The effect of
* this is that the existing color, that was supposed to be replaced, will remain as-is.
*/
#define DO_NOT_DIE_ON_COLOR_ALLOCATION_FAILURE_PATCH 0

/* Similarly to the dragmfact patch this allows you to click and drag clients to change the
* cfact to adjust the client's size in the stack. This patch depends on the cfacts patch.
*/
Expand Down

0 comments on commit 5a0c5e6

Please sign in to comment.