From 71e61d180ec5d365a3fd3eb4739d33f5da80a517 Mon Sep 17 00:00:00 2001 From: bakkeby Date: Tue, 22 Oct 2019 18:30:00 +0200 Subject: [PATCH] Adding ispermanent patch --- README.md | 5 +++++ config.def.h | 48 ++++++++++++++++++++++++++++++++++++++++-------- dwm.c | 13 +++++++++++++ patches.h | 5 +++++ 4 files changed, 63 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 6cc7880..2c1431a 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t ### Changelog: +2019-10-22 - Added ispermanent patch + 2019-10-16 - Introduced [flexipatch-finalizer](https://github.com/bakkeby/flexipatch-finalizer) 2019-10-11 - Added the patch to ignore Xft errors when drawing text in the status bar @@ -160,6 +162,9 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t - sometimes dwm crashes when it cannot render some glyphs in window titles (usually emoji) - this patch is essentially a hack to ignore any errors when drawing text on the status bar and may be removed if a more appropriate solution comes up + - [ispermanent](https://dwm.suckless.org/patches/ispermanent/) + - adds rule option for clients to avoid accidental termination by killclient for sticky windows + - [leftlayout](http://dwm.suckless.org/patches/leftlayout/) - moves the layout symbol in the status bar to the left hand side diff --git a/config.def.h b/config.def.h index 8c887c5..92b8320 100644 --- a/config.def.h +++ b/config.def.h @@ -186,39 +186,71 @@ static const Rule rules[] = { * WM_NAME(STRING) = title * WM_WINDOW_ROLE(STRING) = role */ - #if WINDOWROLERULE_PATCH && SWITCHTAG_PATCH && CENTER_PATCH + #if WINDOWROLERULE_PATCH && SWITCHTAG_PATCH && CENTER_PATCH && ISPERMANENT_PATCH + /* class role instance title tags mask switchtag iscentered isfloating ispermanent monitor */ + { "Gimp", NULL, NULL, NULL, 0, 1, 0, 1, 0, -1 }, + { "Firefox", NULL, NULL, NULL, 1 << 8, 1, 0, 0, 0, -1 }, + #elif WINDOWROLERULE_PATCH && SWITCHTAG_PATCH && CENTER_PATCH && !ISPERMANENT_PATCH /* class role instance title tags mask switchtag iscentered isfloating monitor */ { "Gimp", NULL, NULL, NULL, 0, 1, 0, 1, -1 }, { "Firefox", NULL, NULL, NULL, 1 << 8, 1, 0, 0, -1 }, - #elif WINDOWROLERULE_PATCH && !SWITCHTAG_PATCH && CENTER_PATCH + #elif WINDOWROLERULE_PATCH && !SWITCHTAG_PATCH && CENTER_PATCH && ISPERMANENT_PATCH + /* class role instance title tags mask iscentered isfloating ispermanent monitor */ + { "Gimp", NULL, NULL, NULL, 0, 0, 1, 0, -1 }, + { "Firefox", NULL, NULL, NULL, 1 << 8, 0, 0, 0, -1 }, + #elif WINDOWROLERULE_PATCH && !SWITCHTAG_PATCH && CENTER_PATCH && !ISPERMANENT_PATCH /* class role instance title tags mask iscentered isfloating monitor */ { "Gimp", NULL, NULL, NULL, 0, 0, 1, -1 }, { "Firefox", NULL, NULL, NULL, 1 << 8, 0, 0, -1 }, - #elif WINDOWROLERULE_PATCH && SWITCHTAG_PATCH && !CENTER_PATCH + #elif WINDOWROLERULE_PATCH && SWITCHTAG_PATCH && !CENTER_PATCH && ISPERMANENT_PATCH + /* class role instance title tags mask switchtag isfloating ispermanent monitor */ + { "Gimp", NULL, NULL, NULL, 0, 1, 1, 0, -1 }, + { "Firefox", NULL, NULL, NULL, 1 << 8, 1, 0, 0, -1 }, + #elif WINDOWROLERULE_PATCH && SWITCHTAG_PATCH && !CENTER_PATCH && !ISPERMANENT_PATCH /* class role instance title tags mask switchtag isfloating monitor */ { "Gimp", NULL, NULL, NULL, 0, 1, 1, -1 }, { "Firefox", NULL, NULL, NULL, 1 << 8, 1, 0, -1 }, - #elif !WINDOWROLERULE_PATCH && SWITCHTAG_PATCH && CENTER_PATCH + #elif !WINDOWROLERULE_PATCH && SWITCHTAG_PATCH && CENTER_PATCH && ISPERMANENT_PATCH + /* class instance title tags mask switchtag iscentered isfloating ispermanent monitor */ + { "Gimp", NULL, NULL, 0, 1, 0, 1, 0, -1 }, + { "Firefox", NULL, NULL, 1 << 8, 1, 0, 0, 0, -1 }, + #elif !WINDOWROLERULE_PATCH && SWITCHTAG_PATCH && CENTER_PATCH && !ISPERMANENT_PATCH /* class instance title tags mask switchtag iscentered isfloating monitor */ { "Gimp", NULL, NULL, 0, 1, 0, 1, -1 }, { "Firefox", NULL, NULL, 1 << 8, 1, 0, 0, -1 }, - #elif WINDOWROLERULE_PATCH && !SWITCHTAG_PATCH && !CENTER_PATCH + #elif WINDOWROLERULE_PATCH && !SWITCHTAG_PATCH && !CENTER_PATCH && ISPERMANENT_PATCH + /* class role instance title tags mask isfloating ispermanent monitor */ + { "Gimp", NULL, NULL, NULL, 0, 1, 0, -1 }, + { "Firefox", NULL, NULL, NULL, 1 << 8, 0, 0, -1 }, + #elif WINDOWROLERULE_PATCH && !SWITCHTAG_PATCH && !CENTER_PATCH && !ISPERMANENT_PATCH /* class role instance title tags mask isfloating monitor */ { "Gimp", NULL, NULL, NULL, 0, 1, -1 }, { "Firefox", NULL, NULL, NULL, 1 << 8, 0, -1 }, - #elif !WINDOWROLERULE_PATCH && SWITCHTAG_PATCH && !CENTER_PATCH + #elif !WINDOWROLERULE_PATCH && SWITCHTAG_PATCH && !CENTER_PATCH && ISPERMANENT_PATCH + /* class instance title tags mask switchtag isfloating ispermanent monitor */ + { "Gimp", NULL, NULL, 0, 1, 1, 0, -1 }, + { "Firefox", NULL, NULL, 1 << 8, 1, 0, 0, -1 }, + #elif !WINDOWROLERULE_PATCH && SWITCHTAG_PATCH && !CENTER_PATCH && !ISPERMANENT_PATCH /* class instance title tags mask switchtag isfloating monitor */ { "Gimp", NULL, NULL, 0, 1, 1, -1 }, { "Firefox", NULL, NULL, 1 << 8, 1, 0, -1 }, - #elif !WINDOWROLERULE_PATCH && !SWITCHTAG_PATCH && CENTER_PATCH + #elif !WINDOWROLERULE_PATCH && !SWITCHTAG_PATCH && CENTER_PATCH && ISPERMANENT_PATCH + /* class instance title tags mask iscentered isfloating ispermanent monitor */ + { "Gimp", NULL, NULL, 0, 0, 1, 0, -1 }, + { "Firefox", NULL, NULL, 1 << 8, 0, 0, 0, -1 }, + #elif !WINDOWROLERULE_PATCH && !SWITCHTAG_PATCH && CENTER_PATCH && !ISPERMANENT_PATCH /* class instance title tags mask iscentered isfloating monitor */ { "Gimp", NULL, NULL, 0, 0, 1, -1 }, { "Firefox", NULL, NULL, 1 << 8, 0, 0, -1 }, + #elif !WINDOWROLERULE_PATCH && !SWITCHTAG_PATCH && !CENTER_PATCH && ISPERMANENT_PATCH + /* class instance title tags mask isfloating ispermanent monitor */ + { "Gimp", NULL, NULL, 0, 1, 0, -1 }, + { "Firefox", NULL, NULL, 1 << 8, 0, 0, -1 }, #else /* class instance title tags mask isfloating monitor */ { "Gimp", NULL, NULL, 0, 1, -1 }, { "Firefox", NULL, NULL, 1 << 8, 0, -1 }, - #endif // granted the above will be confusing, do remember to delete rule entries for patches that you do not take + #endif }; #if MONITOR_RULES_PATCH diff --git a/dwm.c b/dwm.c index 336d3c3..80aeca2 100644 --- a/dwm.c +++ b/dwm.c @@ -159,6 +159,9 @@ struct Client { #if CENTER_PATCH int iscentered; #endif // CENTER_PATCH + #if ISPERMANENT_PATCH + int ispermanent; + #endif // ISPERMANENT_PATCH #if STICKY_PATCH int issticky; #endif // STICKY_PATCH @@ -257,6 +260,9 @@ typedef struct { int iscentered; #endif // CENTER_PATCH int isfloating; + #if ISPERMANENT_PATCH + int ispermanent; + #endif // ISPERMANENT_PATCH int monitor; } Rule; @@ -468,6 +474,9 @@ applyrules(Client *c) #if CENTER_PATCH c->iscentered = r->iscentered; #endif // CENTER_PATCH + #if ISPERMANENT_PATCH + c->ispermanent = r->ispermanent; + #endif // ISPERMANENT_PATCH c->isfloating = r->isfloating; c->tags |= r->tags; for (m = mons; m && m->num != r->monitor; m = m->next); @@ -1837,7 +1846,11 @@ keypress(XEvent *e) void killclient(const Arg *arg) { + #if ISPERMANENT_PATCH + if (!selmon->sel || selmon->sel->ispermanent) + #else if (!selmon->sel) + #endif // ISPERMANENT_PATCH return; #if SYSTRAY_PATCH if (!sendevent(selmon->sel->win, wmatom[WMDelete], NoEventMask, wmatom[WMDelete], CurrentTime, 0, 0, 0)) { diff --git a/patches.h b/patches.h index 81f37ef..04cbd52 100644 --- a/patches.h +++ b/patches.h @@ -199,6 +199,11 @@ */ #define HOLDBAR_PATCH 0 +/* Adds rule option for clients to avoid accidental termination by killclient for sticky windows. + * https://dwm.suckless.org/patches/ispermanent/ + */ +#define ISPERMANENT_PATCH 0 + /* Sometimes dwm crashes when it cannot render some glyphs in window titles (usually emoji). * This patch is essentially a hack to ignore any errors when drawing text on the status bar. * https://groups.google.com/forum/m/#!topic/wmii/7bncCahYIww