sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

alpha.diff (3790B)


      1 diff --git a/config.mk b/config.mk
      2 index 3a71529..095cead 100644
      3 --- a/config.mk
      4 +++ b/config.mk
      5 @@ -9,7 +9,7 @@ MANPREFIX = ${PREFIX}/share/man
      6  
      7  # includes and libs
      8  INCS = -I. -I/usr/include -I/usr/include/freetype2
      9 -LIBS = -L/usr/lib -lc -lX11 -lfontconfig -lXft
     10 +LIBS = -L/usr/lib -lc -lX11 -lfontconfig -lXft -lXrender
     11  
     12  # flags
     13  CPPFLAGS = -DVERSION=\"${VERSION}\" -D_DEFAULT_SOURCE
     14 diff --git a/tabbed.c b/tabbed.c
     15 index 9a44795..b4d47d1 100644
     16 --- a/tabbed.c
     17 +++ b/tabbed.c
     18 @@ -170,6 +170,9 @@ static char **cmd;
     19  static char *wmname = "tabbed";
     20  static const char *geometry;
     21  
     22 +static Colormap cmap;
     23 +static Visual *visual = NULL;
     24 +
     25  char *argv0;
     26  
     27  /* configuration, allows nested code to access above variables */
     28 @@ -255,8 +258,8 @@ configurenotify(const XEvent *e)
     29  		ww = ev->width;
     30  		wh = ev->height;
     31  		XFreePixmap(dpy, dc.drawable);
     32 -		dc.drawable = XCreatePixmap(dpy, root, ww, wh,
     33 -		              DefaultDepth(dpy, screen));
     34 +		dc.drawable = XCreatePixmap(dpy, win, ww, wh,
     35 +		              32);
     36  		if (sel > -1)
     37  			resize(sel, ww, wh - bh);
     38  		XSync(dpy, False);
     39 @@ -399,7 +402,7 @@ drawtext(const char *text, XftColor col[ColLast])
     40  			;
     41  	}
     42  
     43 -	d = XftDrawCreate(dpy, dc.drawable, DefaultVisual(dpy, screen), DefaultColormap(dpy, screen));
     44 +	d = XftDrawCreate(dpy, dc.drawable, visual, cmap);
     45  	XftDrawStringUtf8(d, &col[ColFG], dc.font.xfont, x, y, (XftChar8 *) buf, len);
     46  	XftDrawDestroy(d);
     47  }
     48 @@ -564,7 +567,7 @@ getcolor(const char *colstr)
     49  {
     50  	XftColor color;
     51  
     52 -	if (!XftColorAllocName(dpy, DefaultVisual(dpy, screen), DefaultColormap(dpy, screen), colstr, &color))
     53 +  if (!XftColorAllocName(dpy, visual, cmap, colstr, &color))
     54  		die("%s: cannot allocate color '%s'\n", argv0, colstr);
     55  
     56  	return color;
     57 @@ -1016,18 +1019,60 @@ setup(void)
     58  			wy = dh + wy - wh - 1;
     59  	}
     60  
     61 +	XVisualInfo *vis;
     62 +	XRenderPictFormat *fmt;
     63 +	int nvi;
     64 +	int i;
     65 +
     66 +	XVisualInfo tpl = {
     67 +		.screen = screen,
     68 +		.depth = 32,
     69 +		.class = TrueColor
     70 +	};
     71 +
     72 +	vis = XGetVisualInfo(dpy, VisualScreenMask | VisualDepthMask | VisualClassMask, &tpl, &nvi);
     73 +	for(i = 0; i < nvi; i ++) {
     74 +		fmt = XRenderFindVisualFormat(dpy, vis[i].visual);
     75 +		if (fmt->type == PictTypeDirect && fmt->direct.alphaMask) {
     76 +			visual = vis[i].visual;
     77 +			break;
     78 +		}
     79 +	}
     80 +
     81 +	XFree(vis);
     82 +
     83 +	if (! visual) {
     84 +		fprintf(stderr, "Couldn't find ARGB visual.\n");
     85 +		exit(1);
     86 +	}
     87 +
     88 +	cmap = XCreateColormap( dpy, root, visual, None);
     89  	dc.norm[ColBG] = getcolor(normbgcolor);
     90  	dc.norm[ColFG] = getcolor(normfgcolor);
     91  	dc.sel[ColBG] = getcolor(selbgcolor);
     92  	dc.sel[ColFG] = getcolor(selfgcolor);
     93  	dc.urg[ColBG] = getcolor(urgbgcolor);
     94  	dc.urg[ColFG] = getcolor(urgfgcolor);
     95 -	dc.drawable = XCreatePixmap(dpy, root, ww, wh,
     96 -	                            DefaultDepth(dpy, screen));
     97 -	dc.gc = XCreateGC(dpy, root, 0, 0);
     98  
     99 -	win = XCreateSimpleWindow(dpy, root, wx, wy, ww, wh, 0,
    100 -	                          dc.norm[ColFG].pixel, dc.norm[ColBG].pixel);
    101 +	XSetWindowAttributes attrs;
    102 +	attrs.background_pixel = dc.norm[ColBG].pixel;
    103 +	attrs.border_pixel = dc.norm[ColFG].pixel;
    104 +	attrs.bit_gravity = NorthWestGravity;
    105 +	attrs.event_mask = FocusChangeMask | KeyPressMask
    106 +		| ExposureMask | VisibilityChangeMask | StructureNotifyMask
    107 +		| ButtonMotionMask | ButtonPressMask | ButtonReleaseMask;
    108 +	attrs.background_pixmap = None ;
    109 +	attrs.colormap = cmap;
    110 +
    111 +	win = XCreateWindow(dpy, root, wx, wy,
    112 +	ww, wh, 0, 32, InputOutput,
    113 +	visual, CWBackPixmap | CWBorderPixel | CWBitGravity
    114 +	| CWEventMask | CWColormap, &attrs);
    115 +
    116 +	dc.drawable = XCreatePixmap(dpy, win, ww, wh,
    117 +	                            32);
    118 +	dc.gc = XCreateGC(dpy, dc.drawable, 0, 0);
    119 +
    120  	XMapRaised(dpy, win);
    121  	XSelectInput(dpy, win, SubstructureNotifyMask | FocusChangeMask |
    122  	             ButtonPressMask | ExposureMask | KeyPressMask |