alpha.diff 3.7 KB

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