summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorbakkeby <[email protected]>2020-06-15 15:34:44 +0200
committerbakkeby <[email protected]>2020-06-15 15:34:44 +0200
commitcac3e7d2c92a178ed415e268ffacfcc570f81b61 (patch)
treec2710fe26a035d08fa36756ffe8ff17caa452115
parenta7b226de41122f5cd6c9a9b0ed410f1616654342 (diff)
downloaddwm-flexipatch-cac3e7d2c92a178ed415e268ffacfcc570f81b61.tar.gz
dwm-flexipatch-cac3e7d2c92a178ed415e268ffacfcc570f81b61.zip
Rule macro improvements + rule macro helper macros
-rw-r--r--config.def.h4
-rw-r--r--dwm.c52
2 files changed, 26 insertions, 30 deletions
diff --git a/config.def.h b/config.def.h
index d970fa6..d9f83ab 100644
--- a/config.def.h
+++ b/config.def.h
@@ -318,10 +318,6 @@ static const int tagrows = 2;
* RULE(.class = "Gimp", .tags = 1 << 4)
* RULE(.class = "Firefox", .tags = 1 << 7)
*
- * One benefit of using the RULE macro with a flexipatch build is that you do not have
- * to worry about having to fiddle with rules when enabling or disabling patches. Field
- * names that do not apply are simply ignored by the macro.
- *
* Refer to the Rule struct definition for the list of available fields depending on
* the patches you enable.
*/
diff --git a/dwm.c b/dwm.c
index 3d61f9c..3e50117 100644
--- a/dwm.c
+++ b/dwm.c
@@ -322,32 +322,32 @@ typedef struct {
int monitor;
} Rule;
-#define R_WINDOWROLERULE_(enabled) R_WINDOWROLERULE_##enabled
-#define R_WINDOWROLERULE(enabled) R_WINDOWROLERULE_(enabled)
-#define R_WINDOWROLERULE_0
-#define R_WINDOWROLERULE_1 .role = NULL,
-
-#define R_SWITCHTAG_(enabled) R_SWITCHTAG_##enabled
-#define R_SWITCHTAG(enabled) R_SWITCHTAG_(enabled)
-#define R_SWITCHTAG_0
-#define R_SWITCHTAG_1 .switchtag = 0,
-
-#define R_CENTER_(enabled) R_CENTER_##enabled
-#define R_CENTER(enabled) R_CENTER_(enabled)
-#define R_CENTER_0
-#define R_CENTER_1 .iscentered = 0,
-
-#define R_ISPERMANENT_(enabled) R_ISPERMANENT_##enabled
-#define R_ISPERMANENT(enabled) R_ISPERMANENT_(enabled)
-#define R_ISPERMANENT_0
-#define R_ISPERMANENT_1 .ispermanent = 0,
-
-#define R_SWALLOW_(enabled) R_SWALLOW_##enabled
-#define R_SWALLOW(enabled) R_SWALLOW_(enabled)
-#define R_SWALLOW_0
-#define R_SWALLOW_1 .isterminal = 0, .noswallow = 0,
-
-#define RULE(...) { .class = NULL, R_WINDOWROLERULE(WINDOWROLERULE_PATCH) .instance = NULL, .title = NULL, .wintype = NULL, .tags = 0, R_SWITCHTAG(SWITCHTAG_PATCH) R_CENTER(CENTER_PATCH) .isfloating = 0, R_ISPERMANENT(ISPERMANENT_PATCH) R_SWALLOW(SWALLOW_PATCH) .monitor = -1 },
+#define RULE(...) { .monitor = -1, ##__VA_ARGS__ },
+
+/* Cross patch compatibility rule macro helper macros */
+#define FLOATING , .isfloating = 1
+#if CENTER_PATCH
+#define CENTERED , .iscentered = 1
+#else
+#define CENTERED
+#endif // CENTER_PATCH
+#if ISPERMANENT_PATCH
+#define PERMANENT , .ispermanent = 1
+#else
+#define PERMANENT
+#endif // ISPERMANENT_PATCH
+#if SWALLOW_PATCH
+#define NOSWALLOW , .noswallow = 1
+#define TERMINAL , .isterminal = 1
+#else
+#define NOSWALLOW
+#define TERMINAL
+#endif // SWALLOW_PATCH
+#if SWITCHTAG_PATCH
+#define SWITCHTAG , .switchtag = 1
+#else
+#define SWITCHTAG
+#endif // SWITCHTAG_PATCH
#if MONITOR_RULES_PATCH
typedef struct {