From 9869c22cb21f925496d4dce08b7640eaa02db479 Mon Sep 17 00:00:00 2001 From: bakkeby Date: Fri, 1 Dec 2023 09:38:22 +0100 Subject: [PATCH 1/2] Adding sendmoncenter patch ref. #402 --- README.md | 5 +++++ dwm.c | 8 ++++++++ patches.def.h | 5 +++++ 3 files changed, 18 insertions(+) diff --git a/README.md b/README.md index 6ee0bdf..fc6f331 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,8 @@ Browsing patches? There is a [map of patches](https://coggle.it/diagram/X9IiSSM6 ### Changelog: +2023-12-01 - Added the sendmoncenter patch + 2023-11-12 - Added the focusmaster-return patch variant 2023-06-27 - Added the focusfollowmouse and unmanaged patches @@ -650,6 +652,9 @@ Browsing patches? There is a [map of patches](https://coggle.it/diagram/X9IiSSM6 - [selfrestart](https://dwm.suckless.org/patches/selfrestart/) - restart dwm without the unnecessary dependency of an external script + - [sendmoncenter](https://dwm.suckless.org/patches/sendmoncenter/) + - floating windows being sent to another monitor will be centered + - [sendmon\_keepfocus](https://github.com/bakkeby/patches/wiki/sendmon_keepfocus/) - minor patch that allow clients to keep focus when being sent to another monitor diff --git a/dwm.c b/dwm.c index c3c6292..fa51816 100644 --- a/dwm.c +++ b/dwm.c @@ -3383,6 +3383,14 @@ sendmon(Client *c, Monitor *m) #else c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */ #endif // EMPTYVIEW_PATCH + #if SENDMON_CENTER_PATCH + c->x = m->mx + (m->mw - WIDTH(c)) / 2; + c->y = m->my + (m->mh - HEIGHT(c)) / 2; + #if SAVEFLOATS_PATCH + c->sfx = m->mx + (m->mw - c->sfw - 2 * c->bw) / 2; + c->sfy = m->my + (m->mh - c->sfh - 2 * c->bw) / 2; + #endif // SAVEFLOATS_PATCH + #endif // SENDMON_CENTER_PATCH #if ATTACHABOVE_PATCH || ATTACHASIDE_PATCH || ATTACHBELOW_PATCH || ATTACHBOTTOM_PATCH attachx(c); #else diff --git a/patches.def.h b/patches.def.h index 7b43fda..4ec5351 100644 --- a/patches.def.h +++ b/patches.def.h @@ -1028,6 +1028,11 @@ */ #define SELFRESTART_PATCH 0 +/* Floating windows being sent to another monitor will be centered. + * https://dwm.suckless.org/patches/sendmoncenter/ + */ +#define SENDMON_CENTER_PATCH 0 + /* This patch allow clients to keep focus when being sent to another monitor. * https://github.com/bakkeby/patches/blob/master/dwm/dwm-sendmon_keepfocus-6.2.diff */ From 5a0c5e617f4854e5fb64884d15d6f584c8f72b81 Mon Sep 17 00:00:00 2001 From: bakkeby Date: Fri, 22 Dec 2023 10:42:16 +0100 Subject: [PATCH 2/2] Adding the do-not-die-on-color-allocation-failure patch ref. #404 --- README.md | 6 ++++++ drw.c | 8 ++++++++ patches.def.h | 12 ++++++++++++ 3 files changed, 26 insertions(+) diff --git a/README.md b/README.md index fc6f331..38741c0 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 diff --git a/drw.c b/drw.c index 2e74b20..8f81439 100644 --- a/drw.c +++ b/drw.c @@ -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; diff --git a/patches.def.h b/patches.def.h index 4ec5351..90cedf9 100644 --- a/patches.def.h +++ b/patches.def.h @@ -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. */