sites

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

tabbed-alpha-0.9.diff (3881B)


      1 diff --git a/Makefile b/Makefile
      2 index d7a2c35..16ceff0 100644
      3 --- a/Makefile
      4 +++ b/Makefile
      5 @@ -10,7 +10,7 @@ DOCPREFIX = ${PREFIX}/share/doc/${NAME}
      6 
      7  # use system flags.
      8  TABBED_CFLAGS = -I/usr/X11R6/include -I/usr/include/freetype2 ${CFLAGS}
      9 -TABBED_LDFLAGS = -L/usr/X11R6/lib -lX11 -lfontconfig -lXft ${LDFLAGS}
     10 +TABBED_LDFLAGS = -L/usr/X11R6/lib -lX11 -lfontconfig -lXft -lXrender ${LDFLAGS}
     11  TABBED_CPPFLAGS = -DVERSION=\"${VERSION}\" -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=700L
     12 
     13  # OpenBSD (uncomment)
     14 diff --git a/tabbed.c b/tabbed.c
     15 index aa45716..d1911a3 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 @@ -254,8 +257,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 
     37  		if (!obh && (wh <= bh)) {
     38  			obh = bh;
     39 @@ -407,7 +410,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 @@ -587,7 +590,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 @@ -1049,18 +1052,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 |
    123 --
    124 2.51.0