[wiki] [sites] Patch for alpha windows in tabbed || Sébastien Dailly

From: <git_AT_suckless.org>
Date: Tue, 28 Feb 2017 21:43:22 +0100

commit be6a2648221e7ebb58e9cd6368ec7092f07af646
Author: Sébastien Dailly <sebastien_AT_chimrod.com>
Date: Tue Feb 28 21:43:20 2017 +0100

    Patch for alpha windows in tabbed

diff --git a/tools.suckless.org/tabbed/patches/alpha.diff b/tools.suckless.org/tabbed/patches/alpha.diff
new file mode 100644
index 0000000..3ce77a7
--- /dev/null
+++ b/tools.suckless.org/tabbed/patches/alpha.diff
_AT_@ -0,0 +1,122 @@
+diff --git a/config.mk b/config.mk
+index 3a71529..095cead 100644
+--- a/config.mk
++++ b/config.mk
+_AT_@ -9,7 +9,7 @@ MANPREFIX = ${PREFIX}/share/man
+
+ # includes and libs
+ INCS = -I. -I/usr/include -I/usr/include/freetype2
+-LIBS = -L/usr/lib -lc -lX11 -lfontconfig -lXft
++LIBS = -L/usr/lib -lc -lX11 -lfontconfig -lXft -lXrender
+
+ # flags
+ CPPFLAGS = -DVERSION=\"${VERSION}\" -D_DEFAULT_SOURCE
+diff --git a/tabbed.c b/tabbed.c
+index 9a44795..b4d47d1 100644
+--- a/tabbed.c
++++ b/tabbed.c
+_AT_@ -170,6 +170,9 @@ static char **cmd;
+ static char *wmname = "tabbed";
+ static const char *geometry;
+
++static Colormap cmap;
++static Visual *visual = NULL;
++
+ char *argv0;
+
+ /* configuration, allows nested code to access above variables */
+_AT_@ -255,8 +258,8 @@ configurenotify(const XEvent *e)
+ ww = ev->width;
+ wh = ev->height;
+ XFreePixmap(dpy, dc.drawable);
+- dc.drawable = XCreatePixmap(dpy, root, ww, wh,
+- DefaultDepth(dpy, screen));
++ dc.drawable = XCreatePixmap(dpy, win, ww, wh,
++ 32);
+ if (sel > -1)
+ resize(sel, ww, wh - bh);
+ XSync(dpy, False);
+_AT_@ -399,7 +402,7 @@ drawtext(const char *text, XftColor col[ColLast])
+ ;
+ }
+
+- d = XftDrawCreate(dpy, dc.drawable, DefaultVisual(dpy, screen), DefaultColormap(dpy, screen));
++ d = XftDrawCreate(dpy, dc.drawable, visual, cmap);
+ XftDrawStringUtf8(d, &col[ColFG], dc.font.xfont, x, y, (XftChar8 *) buf, len);
+ XftDrawDestroy(d);
+ }
+_AT_@ -564,7 +567,7 @@ getcolor(const char *colstr)
+ {
+ XftColor color;
+
+- if (!XftColorAllocName(dpy, DefaultVisual(dpy, screen), DefaultColormap(dpy, screen), colstr, &color))
++ if (!XftColorAllocName(dpy, visual, cmap, colstr, &color))
+ die("%s: cannot allocate color '%s'
", argv0, colstr);
+
+ return color;
+_AT_@ -1016,18 +1019,60 @@ setup(void)
+ wy = dh + wy - wh - 1;
+ }
+
++ XVisualInfo *vis;
++ XRenderPictFormat *fmt;
++ int nvi;
++ int i;
++
++ XVisualInfo tpl = {
++ .screen = screen,
++ .depth = 32,
++ .class = TrueColor
++ };
++
++ vis = XGetVisualInfo(dpy, VisualScreenMask | VisualDepthMask | VisualClassMask, &tpl, &nvi);
++ for(i = 0; i < nvi; i ++) {
++ fmt = XRenderFindVisualFormat(dpy, vis[i].visual);
++ if (fmt->type == PictTypeDirect && fmt->direct.alphaMask) {
++ visual = vis[i].visual;
++ break;
++ }
++ }
++
++ XFree(vis);
++
++ if (! visual) {
++ fprintf(stderr, "Couldn't find ARGB visual.
");
++ exit(1);
++ }
++
++ cmap = XCreateColormap( dpy, root, visual, None);
+ dc.norm[ColBG] = getcolor(normbgcolor);
+ dc.norm[ColFG] = getcolor(normfgcolor);
+ dc.sel[ColBG] = getcolor(selbgcolor);
+ dc.sel[ColFG] = getcolor(selfgcolor);
+ dc.urg[ColBG] = getcolor(urgbgcolor);
+ dc.urg[ColFG] = getcolor(urgfgcolor);
+- dc.drawable = XCreatePixmap(dpy, root, ww, wh,
+- DefaultDepth(dpy, screen));
+- dc.gc = XCreateGC(dpy, root, 0, 0);
+
+- win = XCreateSimpleWindow(dpy, root, wx, wy, ww, wh, 0,
+- dc.norm[ColFG].pixel, dc.norm[ColBG].pixel);
++ XSetWindowAttributes attrs;
++ attrs.background_pixel = dc.norm[ColBG].pixel;
++ attrs.border_pixel = dc.norm[ColFG].pixel;
++ attrs.bit_gravity = NorthWestGravity;
++ attrs.event_mask = FocusChangeMask | KeyPressMask
++ | ExposureMask | VisibilityChangeMask | StructureNotifyMask
++ | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask;
++ attrs.background_pixmap = None ;
++ attrs.colormap = cmap;
++
++ win = XCreateWindow(dpy, root, wx, wy,
++ ww, wh, 0, 32, InputOutput,
++ visual, CWBackPixmap | CWBorderPixel | CWBitGravity
++ | CWEventMask | CWColormap, &attrs);
++
++ dc.drawable = XCreatePixmap(dpy, win, ww, wh,
++ 32);
++ dc.gc = XCreateGC(dpy, dc.drawable, 0, 0);
++
+ XMapRaised(dpy, win);
+ XSelectInput(dpy, win, SubstructureNotifyMask | FocusChangeMask |
+ ButtonPressMask | ExposureMask | KeyPressMask |
diff --git a/tools.suckless.org/tabbed/patches/alpha.md b/tools.suckless.org/tabbed/patches/alpha.md
new file mode 100644
index 0000000..51b7476
--- /dev/null
+++ b/tools.suckless.org/tabbed/patches/alpha.md
_AT_@ -0,0 +1,38 @@
+Alpha
+=====
+
+Description
+-----------
+
+This patch create 32bit window in tabbed. This allows to handle windows with
+transparency
+
+Note that *you need an X composite manager* (e.g. compton, xcompmgr) to make
+this patch effective.
+
+If you want to use transparency in st with this patch, you also need to replace
+
+
+```C
+#define USE_ARGB (alpha != OPAQUE && opt_embed == NULL)
+```
+
+by
+
+```C
+#define USE_ARGB (alpha != OPAQUE)
+```
+
+in st.c
+
+Download
+--------
+
+* [alpha.diff](alpha.diff) (3.8k) (28 Feb 2017)
+
+
+Author
+------
+
+* Sébastien Dailly - `<contact at chimrod dot com>`
+
Received on Tue Feb 28 2017 - 21:43:22 CET

This archive was generated by hypermail 2.3.0 : Tue Feb 28 2017 - 21:48:17 CET