summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--README.md19
-rw-r--r--drw.c1
-rw-r--r--dwm.c62
-rw-r--r--patch/alpha.c42
-rw-r--r--patch/alpha.h3
-rw-r--r--patch/include.c5
-rw-r--r--patch/include.h5
-rw-r--r--patches.h14
8 files changed, 93 insertions, 58 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..93bc99c
--- /dev/null
+++ b/README.md
@@ -0,0 +1,19 @@
+This side project has a very different take on dwm patching. It uses preprocessor directives to decide whether or not to include a patch during build time; essentially this means that this build, for better or worse, contains both the patched _and_ the original code. The aim being that you can select which patches to include and the build will contain that code and nothing more.
+
+For example to include the alpha patch then you would only need to flip this setting from 0 to 1 in `dwm.c`:
+```c
+#define ALPHA_PATCH 1
+```
+
+Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on the dwm window manager, how to install it and how it works.
+
+---
+
+### Changelog:
+
+2019-09-05 - Alpha patch added
+
+### Patches included:
+
+ - [alpha](https://dwm.suckless.org/patches/alpha/)
+ - adds transparency for the status bar
diff --git a/drw.c b/drw.c
index b3d719e..0b2da00 100644
--- a/drw.c
+++ b/drw.c
@@ -5,6 +5,7 @@
#include <X11/Xlib.h>
#include <X11/Xft/Xft.h>
+#include "patches.h"
#include "drw.h"
#include "util.h"
diff --git a/dwm.c b/dwm.c
index d4d22f7..d717679 100644
--- a/dwm.c
+++ b/dwm.c
@@ -41,12 +41,7 @@
#endif /* XINERAMA */
#include <X11/Xft/Xft.h>
-/* patch options */
-#define ALPHA_PATCH 0
-
-
-
-
+#include "patches.h"
#include "drw.h"
#include "util.h"
@@ -63,10 +58,6 @@
#define TAGMASK ((1 << LENGTH(tags)) - 1)
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
-#if ALPHA_PATCH
-#define OPAQUE 0xffU
-#endif // ALPHA_PATCH
-
/* enums */
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
enum { SchemeNorm, SchemeSel }; /* color schemes */
@@ -242,9 +233,6 @@ static Monitor *wintomon(Window w);
static int xerror(Display *dpy, XErrorEvent *ee);
static int xerrordummy(Display *dpy, XErrorEvent *ee);
static int xerrorstart(Display *dpy, XErrorEvent *ee);
-#if ALPHA_PATCH
-static void xinitvisual();
-#endif // ALPHA_PATCH
static void zoom(const Arg *arg);
/* variables */
@@ -281,16 +269,13 @@ static Drw *drw;
static Monitor *mons, *selmon;
static Window root, wmcheckwin;
-#if ALPHA_PATCH
-static int useargb = 0;
-static Visual *visual;
-static int depth;
-static Colormap cmap;
-#endif // ALPHA_PATCH
+#include "patch/include.h"
/* configuration, allows nested code to access above variables */
#include "config.h"
+#include "patch/include.c"
+
/* compile-time check if all tags fit into an unsigned int bit array. */
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
@@ -2151,45 +2136,6 @@ xerrorstart(Display *dpy, XErrorEvent *ee)
return -1;
}
-#if ALPHA_PATCH
-void
-xinitvisual()
-{
- XVisualInfo *infos;
- XRenderPictFormat *fmt;
- int nitems;
- int i;
-
- XVisualInfo tpl = {
- .screen = screen,
- .depth = 32,
- .class = TrueColor
- };
- long masks = VisualScreenMask | VisualDepthMask | VisualClassMask;
-
- infos = XGetVisualInfo(dpy, masks, &tpl, &nitems);
- visual = NULL;
- for(i = 0; i < nitems; i ++) {
- fmt = XRenderFindVisualFormat(dpy, infos[i].visual);
- if (fmt->type == PictTypeDirect && fmt->direct.alphaMask) {
- visual = infos[i].visual;
- depth = infos[i].depth;
- cmap = XCreateColormap(dpy, root, visual, AllocNone);
- useargb = 1;
- break;
- }
- }
-
- XFree(infos);
-
- if (! visual) {
- visual = DefaultVisual(dpy, screen);
- depth = DefaultDepth(dpy, screen);
- cmap = DefaultColormap(dpy, screen);
- }
-}
-#endif // ALPHA_PATCH
-
void
zoom(const Arg *arg)
{
diff --git a/patch/alpha.c b/patch/alpha.c
new file mode 100644
index 0000000..7da7215
--- /dev/null
+++ b/patch/alpha.c
@@ -0,0 +1,42 @@
+
+static int useargb = 0;
+static Visual *visual;
+static int depth;
+static Colormap cmap;
+
+void
+xinitvisual()
+{
+ XVisualInfo *infos;
+ XRenderPictFormat *fmt;
+ int nitems;
+ int i;
+
+ XVisualInfo tpl = {
+ .screen = screen,
+ .depth = 32,
+ .class = TrueColor
+ };
+ long masks = VisualScreenMask | VisualDepthMask | VisualClassMask;
+
+ infos = XGetVisualInfo(dpy, masks, &tpl, &nitems);
+ visual = NULL;
+ for (i = 0; i < nitems; i ++) {
+ fmt = XRenderFindVisualFormat(dpy, infos[i].visual);
+ if (fmt->type == PictTypeDirect && fmt->direct.alphaMask) {
+ visual = infos[i].visual;
+ depth = infos[i].depth;
+ cmap = XCreateColormap(dpy, root, visual, AllocNone);
+ useargb = 1;
+ break;
+ }
+ }
+
+ XFree(infos);
+
+ if (! visual) {
+ visual = DefaultVisual(dpy, screen);
+ depth = DefaultDepth(dpy, screen);
+ cmap = DefaultColormap(dpy, screen);
+ }
+}
diff --git a/patch/alpha.h b/patch/alpha.h
new file mode 100644
index 0000000..3c81522
--- /dev/null
+++ b/patch/alpha.h
@@ -0,0 +1,3 @@
+#define OPAQUE 0xffU
+
+static void xinitvisual();
diff --git a/patch/include.c b/patch/include.c
new file mode 100644
index 0000000..de31d1e
--- /dev/null
+++ b/patch/include.c
@@ -0,0 +1,5 @@
+
+#if ALPHA_PATCH
+#include "alpha.c"
+#endif
+
diff --git a/patch/include.h b/patch/include.h
new file mode 100644
index 0000000..c5c8947
--- /dev/null
+++ b/patch/include.h
@@ -0,0 +1,5 @@
+
+#if ALPHA_PATCH
+#include "alpha.h"
+#endif
+
diff --git a/patches.h b/patches.h
new file mode 100644
index 0000000..c683143
--- /dev/null
+++ b/patches.h
@@ -0,0 +1,14 @@
+/*
+ * This file contains patch control flags.
+ *
+ * In principle you should be able to mix and match any patches
+ * you may want. In cases where patches are logically incompatible
+ * one patch may take precedence over the other as noted in the
+ * relevant descriptions.
+ */
+
+/*
+ * The alpha patch adds transparency for the status bar.
+ * https://dwm.suckless.org/patches/alpha/
+ */
+#define ALPHA_PATCH 0 \ No newline at end of file