commit a569e7edec0e04ebcb078ef7a84a915636334eaf
parent 853e335d07e98df860b13920f7f620eaca7eefa5
Author: Cem Keylan <cem@ckyln.com>
Date: Sat, 25 Jan 2020 18:56:17 +0300
add alpha and autohide patches
Diffstat:
M | config.mk | | | 2 | +- |
M | tabbed.c | | | 80 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------- |
2 files changed, 68 insertions(+), 14 deletions(-)
diff --git a/config.mk b/config.mk
@@ -11,7 +11,7 @@ X11INC = /usr/X11R6/include
X11LIB = /usr/X11R6/lib
# freetype
-FREETYPELIBS = -lfontconfig -lXft
+FREETYPELIBS = -lfontconfig -lXft -lXrender
FREETYPEINC = /usr/include/freetype2
# OpenBSD (uncomment)
#FREETYPEINC = ${X11INC}/freetype2
diff --git a/tabbed.c b/tabbed.c
@@ -152,7 +152,7 @@ static void (*handler[LASTEvent]) (const XEvent *) = {
[MapRequest] = maprequest,
[PropertyNotify] = propertynotify,
};
-static int bh, wx, wy, ww, wh;
+static int bh, wx, wy, ww, wh, vbh;
static unsigned int numlockmask;
static Bool running = True, nextfocus, doinitspawn = True,
fillagain = False, closelastclient = False,
@@ -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 */
@@ -254,8 +257,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);
@@ -315,7 +318,7 @@ void
drawbar(void)
{
XftColor *col;
- int c, cc, fc, width;
+ int c, cc, fc, width, nbh, i;
char *name = NULL;
if (nclients == 0) {
@@ -323,12 +326,21 @@ drawbar(void)
dc.w = ww;
XFetchName(dpy, win, &name);
drawtext(name ? name : "", dc.norm);
- XCopyArea(dpy, dc.drawable, win, dc.gc, 0, 0, ww, bh, 0, 0);
+ XCopyArea(dpy, dc.drawable, win, dc.gc, 0, 0, ww, vbh, 0, 0);
XSync(dpy, False);
return;
}
+ nbh = nclients > 1 ? vbh : 0;
+ if (bh != nbh) {
+ bh = nbh;
+ for (i = 0; i < nclients; i++)
+ XMoveResizeWindow(dpy, clients[i]->win, 0, bh, ww, wh - bh);
+ }
+ if (bh == 0)
+ return;
+
width = ww;
cc = ww / tabwidth;
if (nclients > cc)
@@ -398,7 +410,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);
}
@@ -566,7 +578,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'\n", argv0, colstr);
return color;
@@ -975,7 +987,7 @@ setup(void)
screen = DefaultScreen(dpy);
root = RootWindow(dpy, screen);
initfont(font);
- bh = dc.h = dc.font.height + 2;
+ vbh = dc.h = dc.font.height + 2;
/* init atoms */
wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
@@ -1021,18 +1033,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.\n");
+ 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 |