@Eon, I'd be happy to integrate parts of the patch into the systray
patch. Would you mind posting your version as a proper patch file in
the wiki or in this list?
On Fri 23-12-2016 17:21 +0900, Eon S. Jeon wrote:
> This patch is a merge b/w systray and alpha.
>
> Additional changes are:
> - create systray-> win with apropriate visual and attributes
> - utilize _NET_SYSTEM_TRAY_VISUAL to let tray icon alpha-aware
> ---
> config.def.h | 14 +-
> config.mk| 2 +-
> drw.c| 59 +++--
> drw.h| 3 +
> dwm.c| 409
> +++
> 5 files changed, 446 insertions(+), 41 deletions(-)
>
> diff --git a/config.def.h b/config.def.h
> index ba9a240..498b5bb 100644
> --- a/config.def.h
> +++ b/config.def.h
> @@ -3,15 +3,19 @@
> /* appearance */
> static const unsigned int borderpx = 1;/* border pixel of windows */
> static const unsigned int snap = 32; /* snap pixel */
> +static const unsigned int systraypinning = 0; /* 0: sloppy systray follows
> selected monitor, > 0: pin systray to monitor X */
> +static const unsigned int systrayspacing = 2; /* systray spacing */
> +static const int systraypinningfailfirst = 1; /* 1: if pinning fails,
> display systray on the first monitor, False: display systray on the last
> monitor*/
> +static const int showsystray= 1; /* 0 means no systray */
> static const int showbar= 1;/* 0 means no bar */
> static const int topbar = 1;/* 0 means bottom bar */
> static const char *fonts[] = { "monospace:size=10" };
> static const char dmenufont[] = "monospace:size=10";
> -static const char col_gray1[] = "#22";
> -static const char col_gray2[] = "#44";
> -static const char col_gray3[] = "#bb";
> -static const char col_gray4[] = "#ee";
> -static const char col_cyan[]= "#005577";
> +static const char col_gray1[] = "#22A#dd";
> +static const char col_gray2[] = "#44A#ff";
> +static const char col_gray3[] = "#bbA#ff";
> +static const char col_gray4[] = "#eeA#ff";
> +static const char col_cyan[]= "#005577A#dd";
> static const char *colors[][3] = {
> /* fg bg border */
> [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
> diff --git a/config.mk b/config.mk
> index 80dc936..2c62e89 100644
> --- a/config.mk
> +++ b/config.mk
> @@ -22,7 +22,7 @@ FREETYPEINC = /usr/include/freetype2
>
> # includes and libs
> INCS = -I${X11INC} -I${FREETYPEINC}
> -LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS}
> +LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lXrender
>
> # flags
> CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=2
> -DVERSION="${VERSION}\" ${XINERAMAFLAGS}
> diff --git a/drw.c b/drw.c
> index 319eb6b..833e8d1 100644
> --- a/drw.c
> +++ b/drw.c
> @@ -60,6 +60,39 @@ utf8decode(const char *c, long *u, size_t clen)
> return len;
> }
>
> +static void
> +drw_initvisual(Drw *drw, Display *dpy, int screen, Window root)
> +{
> + 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);
> + for(i = 0; i < nitems; i ++) {
> + fmt = XRenderFindVisualFormat(dpy, infos[i].visual);
> + if (fmt-> type == PictTypeDirect && fmt->direct.alphaMask)
> + goto found;
> + }
> +
> + drw-> visual = DefaultVisual(dpy, screen);
> + drw-> depth = DefaultDepth(dpy, screen);
> + drw-> cmap = DefaultColormap(dpy, screen);
> + return;
> +
> +found:
> + drw-> visual = infos[i].visual;
> + drw-> depth = infos[i].depth;
> + drw-> cmap = XCreateColormap(dpy, root, drw->visual, AllocNone);
> +}
> +
> Drw *
> drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned
> int h)
> {
> @@ -70,8 +103,9 @@ drw_create(Display *dpy, int screen, Window root, unsigned
> int w, unsigned int h
> drw-> root = root;
> drw-> w = w;
> drw-> h = h;
> - drw-> drawable = XCreatePixmap(dpy, root, w, h, DefaultDepth(dpy,
> screen));
> - drw-> gc = XCreateGC(dpy, root, 0, NULL);
> + drw_initvisual(drw, dpy, screen, root);
> + drw-> drawable = XCreatePixmap(dpy, root, w, h, drw->depth);
> + drw-> gc = XCreateGC(dpy, drw->drawable, 0, NULL);
> XSetLineAttributes(dpy, drw-> gc, 1, LineSolid, CapButt, JoinMiter);
>
> return drw;
> @@ -87,7 +121,7 @@ drw_resize(Drw *drw, unsigned int w, unsigned int h)
> drw-> h = h;
> if (drw-> drawable)
> XFreePixmap(drw-> dpy, drw->drawable);
> - drw-> drawabl