Adding README.md

This commit is contained in:
bakkeby 2019-09-05 00:32:39 +02:00
parent c34c536f3e
commit 2c9a889b22
8 changed files with 93 additions and 58 deletions

19
README.md Normal file
View File

@ -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

1
drw.c
View File

@ -5,6 +5,7 @@
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xft/Xft.h> #include <X11/Xft/Xft.h>
#include "patches.h"
#include "drw.h" #include "drw.h"
#include "util.h" #include "util.h"

62
dwm.c
View File

@ -41,12 +41,7 @@
#endif /* XINERAMA */ #endif /* XINERAMA */
#include <X11/Xft/Xft.h> #include <X11/Xft/Xft.h>
/* patch options */ #include "patches.h"
#define ALPHA_PATCH 0
#include "drw.h" #include "drw.h"
#include "util.h" #include "util.h"
@ -63,10 +58,6 @@
#define TAGMASK ((1 << LENGTH(tags)) - 1) #define TAGMASK ((1 << LENGTH(tags)) - 1)
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad) #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
#if ALPHA_PATCH
#define OPAQUE 0xffU
#endif // ALPHA_PATCH
/* enums */ /* enums */
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
enum { SchemeNorm, SchemeSel }; /* color schemes */ enum { SchemeNorm, SchemeSel }; /* color schemes */
@ -242,9 +233,6 @@ static Monitor *wintomon(Window w);
static int xerror(Display *dpy, XErrorEvent *ee); static int xerror(Display *dpy, XErrorEvent *ee);
static int xerrordummy(Display *dpy, XErrorEvent *ee); static int xerrordummy(Display *dpy, XErrorEvent *ee);
static int xerrorstart(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); static void zoom(const Arg *arg);
/* variables */ /* variables */
@ -281,16 +269,13 @@ static Drw *drw;
static Monitor *mons, *selmon; static Monitor *mons, *selmon;
static Window root, wmcheckwin; static Window root, wmcheckwin;
#if ALPHA_PATCH #include "patch/include.h"
static int useargb = 0;
static Visual *visual;
static int depth;
static Colormap cmap;
#endif // ALPHA_PATCH
/* configuration, allows nested code to access above variables */ /* configuration, allows nested code to access above variables */
#include "config.h" #include "config.h"
#include "patch/include.c"
/* compile-time check if all tags fit into an unsigned int bit array. */ /* compile-time check if all tags fit into an unsigned int bit array. */
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; }; struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
@ -2151,45 +2136,6 @@ xerrorstart(Display *dpy, XErrorEvent *ee)
return -1; 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 void
zoom(const Arg *arg) zoom(const Arg *arg)
{ {

42
patch/alpha.c Normal file
View File

@ -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);
}
}

3
patch/alpha.h Normal file
View File

@ -0,0 +1,3 @@
#define OPAQUE 0xffU
static void xinitvisual();

5
patch/include.c Normal file
View File

@ -0,0 +1,5 @@
#if ALPHA_PATCH
#include "alpha.c"
#endif

5
patch/include.h Normal file
View File

@ -0,0 +1,5 @@
#if ALPHA_PATCH
#include "alpha.h"
#endif

14
patches.h Normal file
View File

@ -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