Krolyxon
Commit c7ca547

Branches

Refs →

nsxivc7ca547

Fix in tabbed with alpha patch (#3)

* Fix in tabbed with alpha patch
Author
Berke Kocaoğlu
Date
2021-09-11 08:46 +0300
Committer
Berke Kocaoğlu · 2021-09-16 22:55 +0300
Parent
ba0d87f
Commit
c7ca547b55e98914264351502e581fe6ae17ae15

+23 −9

2 files changed

  1. M image.c +2 −1
  2. M window.c +21 −8
M image.c View
@@ -482,7 +482,7 @@ void img_render(img_t *img)
482482 if ((bg = imlib_create_image(dw, dh)) == NULL)
483483 error(EXIT_FAILURE, ENOMEM, NULL);
484484 imlib_context_set_image(bg);
485− imlib_image_set_has_alpha(0);
485+ imlib_image_set_has_alpha(1);
486486
487487 if (img->alpha) {
488488 int i, c, r;
@@ -510,6 +510,7 @@ void img_render(img_t *img)
510510 imlib_free_image();
511511 imlib_context_set_color_modifier(img->cmod);
512512 } else {
513+ imlib_image_set_has_alpha(1);
513514 imlib_render_image_part_on_drawable_at_size(sx, sy, sw, sh, dx, dy, dw, dh);
514515 }
515516 img->dirty = false;
M window.c View
@@ -64,8 +64,8 @@ void win_init_font(const win_env_t *e, const char *fontstr)
6464
6565 void win_alloc_color(const win_env_t *e, const char *name, XftColor *col)
6666 {
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))
6969 {
7070 error(EXIT_FAILURE, 0, "Error allocating color '%s'", name);
7171 }
@@ -95,6 +95,9 @@ void win_init(win_t *win)
9595 const char *bg, *fg, *f;
9696 char *res_man;
9797 XrmDatabase db;
98+ XVisualInfo vis;
99+ XWindowAttributes attr;
100+ Window parent;
98101
99102 memset(win, 0, sizeof(win_t));
100103
@@ -105,9 +108,19 @@ void win_init(win_t *win)
105108 e->scr = DefaultScreen(e->dpy);
106109 e->scrw = DisplayWidth(e->dpy, e->scr);
107110 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);
111124
112125 if (setlocale(LC_CTYPE, "") == NULL || XSupportsLocale() == 0)
113126 error(0, 0, "No locale support");
@@ -210,7 +223,7 @@ void win_open(win_t *win)
210223 if (i != CURSOR_NONE)
211224 cursors[i].icon = XCreateFontCursor(e->dpy, cursors[i].name);
212225 }
213− if (XAllocNamedColor(e->dpy, DefaultColormap(e->dpy, e->scr), "black",
226+ if (XAllocNamedColor(e->dpy, e->cmap, "black",
214227 &col, &col) == 0)
215228 {
216229 error(EXIT_FAILURE, 0, "Error allocating color 'black'");
@@ -400,8 +413,8 @@ void win_draw_bar(win_t *win)
400413 e = &win->env;
401414 y = win->h + font->ascent + V_TEXT_PAD;
402415 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);
405418
406419 XSetForeground(e->dpy, gc, win->fg.pixel);
407420 XFillRectangle(e->dpy, win->buf.pm, gc, 0, win->h, win->w, win->bar.h);