nsxivc7ca547
Fix in tabbed with alpha patch (#3)
* Fix in tabbed with alpha patch
+23 −9
2 files changed
| @@ -482,7 +482,7 @@ void img_render(img_t *img) | |||
| 482 | 482 | if ((bg = imlib_create_image(dw, dh)) == NULL) | |
| 483 | 483 | error(EXIT_FAILURE, ENOMEM, NULL); | |
| 484 | 484 | imlib_context_set_image(bg); | |
| 485 | − | imlib_image_set_has_alpha(0); | |
| 485 | + | imlib_image_set_has_alpha(1); | |
| 486 | 486 | ||
| 487 | 487 | if (img->alpha) { | |
| 488 | 488 | int i, c, r; | |
| @@ -510,6 +510,7 @@ void img_render(img_t *img) | |||
| 510 | 510 | imlib_free_image(); | |
| 511 | 511 | imlib_context_set_color_modifier(img->cmod); | |
| 512 | 512 | } else { | |
| 513 | + | imlib_image_set_has_alpha(1); | |
| 513 | 514 | imlib_render_image_part_on_drawable_at_size(sx, sy, sw, sh, dx, dy, dw, dh); | |
| 514 | 515 | } | |
| 515 | 516 | img->dirty = false; | |
| @@ -64,8 +64,8 @@ void win_init_font(const win_env_t *e, const char *fontstr) | |||
| 64 | 64 | ||
| 65 | 65 | void win_alloc_color(const win_env_t *e, const char *name, XftColor *col) | |
| 66 | 66 | { | |
| 67 | − | if (!XftColorAllocName(e->dpy, DefaultVisual(e->dpy, e->scr), | |
| 68 | − | DefaultColormap(e->dpy, e->scr), name, col)) | |
| 67 | + | if (!XftColorAllocName(e->dpy, e->vis, | |
| 68 | + | e->cmap, name, col)) | |
| 69 | 69 | { | |
| 70 | 70 | error(EXIT_FAILURE, 0, "Error allocating color '%s'", name); | |
| 71 | 71 | } | |
| @@ -95,6 +95,9 @@ void win_init(win_t *win) | |||
| 95 | 95 | const char *bg, *fg, *f; | |
| 96 | 96 | char *res_man; | |
| 97 | 97 | XrmDatabase db; | |
| 98 | + | XVisualInfo vis; | |
| 99 | + | XWindowAttributes attr; | |
| 100 | + | Window parent; | |
| 98 | 101 | ||
| 99 | 102 | memset(win, 0, sizeof(win_t)); | |
| 100 | 103 | ||
| @@ -105,9 +108,19 @@ void win_init(win_t *win) | |||
| 105 | 108 | e->scr = DefaultScreen(e->dpy); | |
| 106 | 109 | e->scrw = DisplayWidth(e->dpy, e->scr); | |
| 107 | 110 | e->scrh = DisplayHeight(e->dpy, e->scr); | |
| 108 | − | e->vis = DefaultVisual(e->dpy, e->scr); | |
| 109 | − | e->cmap = DefaultColormap(e->dpy, e->scr); | |
| 110 | − | e->depth = DefaultDepth(e->dpy, e->scr); | |
| 111 | + | ||
| 112 | + | parent = options->embed != 0 ? options->embed : RootWindow(e->dpy, e->scr); | |
| 113 | + | ||
| 114 | + | if (options->embed == 0) { | |
| 115 | + | e->depth = DefaultDepth(e->dpy, e->scr); | |
| 116 | + | } else { | |
| 117 | + | XGetWindowAttributes(e->dpy, parent, &attr); | |
| 118 | + | e->depth = attr.depth; | |
| 119 | + | } | |
| 120 | + | ||
| 121 | + | XMatchVisualInfo(e->dpy, e->scr, e->depth, TrueColor, &vis); | |
| 122 | + | e->vis = vis.visual; | |
| 123 | + | e->cmap = XCreateColormap(e->dpy, parent, e->vis, None); | |
| 111 | 124 | ||
| 112 | 125 | if (setlocale(LC_CTYPE, "") == NULL || XSupportsLocale() == 0) | |
| 113 | 126 | error(0, 0, "No locale support"); | |
| @@ -210,7 +223,7 @@ void win_open(win_t *win) | |||
| 210 | 223 | if (i != CURSOR_NONE) | |
| 211 | 224 | cursors[i].icon = XCreateFontCursor(e->dpy, cursors[i].name); | |
| 212 | 225 | } | |
| 213 | − | if (XAllocNamedColor(e->dpy, DefaultColormap(e->dpy, e->scr), "black", | |
| 226 | + | if (XAllocNamedColor(e->dpy, e->cmap, "black", | |
| 214 | 227 | &col, &col) == 0) | |
| 215 | 228 | { | |
| 216 | 229 | error(EXIT_FAILURE, 0, "Error allocating color 'black'"); | |
| @@ -400,8 +413,8 @@ void win_draw_bar(win_t *win) | |||
| 400 | 413 | e = &win->env; | |
| 401 | 414 | y = win->h + font->ascent + V_TEXT_PAD; | |
| 402 | 415 | w = win->w - 2*H_TEXT_PAD; | |
| 403 | − | d = XftDrawCreate(e->dpy, win->buf.pm, DefaultVisual(e->dpy, e->scr), | |
| 404 | − | DefaultColormap(e->dpy, e->scr)); | |
| 416 | + | d = XftDrawCreate(e->dpy, win->buf.pm, e->vis, | |
| 417 | + | e->cmap); | |
| 405 | 418 | ||
| 406 | 419 | XSetForeground(e->dpy, gc, win->fg.pixel); | |
| 407 | 420 | XFillRectangle(e->dpy, win->buf.pm, gc, 0, win->h, win->w, win->bar.h); | |