aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBerke Kocaoğlu <berke.kocaoglu@metu.edu.tr>2021-09-11 08:46:33 +0300
committerBerke Kocaoğlu <berke.kocaoglu@metu.edu.tr>2021-09-16 22:55:31 +0300
commitc7ca547b55e98914264351502e581fe6ae17ae15 (patch)
tree16b55f8fb6adde580a39b9c2f9f2a1ca8a3a18c2
parentba0d87fadf4bb292d7baadf9f01843da354c4a43 (diff)
Fix in tabbed with alpha patch (#3)
* Fix in tabbed with alpha patch Co-authored-by: Jared Forrest <jared_forrest@mailbox.org>
-rw-r--r--image.c3
-rw-r--r--window.c29
2 files changed, 23 insertions, 9 deletions
diff --git a/image.c b/image.c
index fa10ab9..2c6852f 100644
--- a/image.c
+++ b/image.c
@@ -482,7 +482,7 @@ void img_render(img_t *img)
if ((bg = imlib_create_image(dw, dh)) == NULL)
error(EXIT_FAILURE, ENOMEM, NULL);
imlib_context_set_image(bg);
- imlib_image_set_has_alpha(0);
+ imlib_image_set_has_alpha(1);
if (img->alpha) {
int i, c, r;
@@ -510,6 +510,7 @@ void img_render(img_t *img)
imlib_free_image();
imlib_context_set_color_modifier(img->cmod);
} else {
+ imlib_image_set_has_alpha(1);
imlib_render_image_part_on_drawable_at_size(sx, sy, sw, sh, dx, dy, dw, dh);
}
img->dirty = false;
diff --git a/window.c b/window.c
index eb534a7..439062c 100644
--- a/window.c
+++ b/window.c
@@ -64,8 +64,8 @@ void win_init_font(const win_env_t *e, const char *fontstr)
void win_alloc_color(const win_env_t *e, const char *name, XftColor *col)
{
- if (!XftColorAllocName(e->dpy, DefaultVisual(e->dpy, e->scr),
- DefaultColormap(e->dpy, e->scr), name, col))
+ if (!XftColorAllocName(e->dpy, e->vis,
+ e->cmap, name, col))
{
error(EXIT_FAILURE, 0, "Error allocating color '%s'", name);
}
@@ -95,6 +95,9 @@ void win_init(win_t *win)
const char *bg, *fg, *f;
char *res_man;
XrmDatabase db;
+ XVisualInfo vis;
+ XWindowAttributes attr;
+ Window parent;
memset(win, 0, sizeof(win_t));
@@ -105,9 +108,19 @@ void win_init(win_t *win)
e->scr = DefaultScreen(e->dpy);
e->scrw = DisplayWidth(e->dpy, e->scr);
e->scrh = DisplayHeight(e->dpy, e->scr);
- e->vis = DefaultVisual(e->dpy, e->scr);
- e->cmap = DefaultColormap(e->dpy, e->scr);
- e->depth = DefaultDepth(e->dpy, e->scr);
+
+ parent = options->embed != 0 ? options->embed : RootWindow(e->dpy, e->scr);
+
+ if (options->embed == 0) {
+ e->depth = DefaultDepth(e->dpy, e->scr);
+ } else {
+ XGetWindowAttributes(e->dpy, parent, &attr);
+ e->depth = attr.depth;
+ }
+
+ XMatchVisualInfo(e->dpy, e->scr, e->depth, TrueColor, &vis);
+ e->vis = vis.visual;
+ e->cmap = XCreateColormap(e->dpy, parent, e->vis, None);
if (setlocale(LC_CTYPE, "") == NULL || XSupportsLocale() == 0)
error(0, 0, "No locale support");
@@ -210,7 +223,7 @@ void win_open(win_t *win)
if (i != CURSOR_NONE)
cursors[i].icon = XCreateFontCursor(e->dpy, cursors[i].name);
}
- if (XAllocNamedColor(e->dpy, DefaultColormap(e->dpy, e->scr), "black",
+ if (XAllocNamedColor(e->dpy, e->cmap, "black",
&col, &col) == 0)
{
error(EXIT_FAILURE, 0, "Error allocating color 'black'");
@@ -400,8 +413,8 @@ void win_draw_bar(win_t *win)
e = &win->env;
y = win->h + font->ascent + V_TEXT_PAD;
w = win->w - 2*H_TEXT_PAD;
- d = XftDrawCreate(e->dpy, win->buf.pm, DefaultVisual(e->dpy, e->scr),
- DefaultColormap(e->dpy, e->scr));
+ d = XftDrawCreate(e->dpy, win->buf.pm, e->vis,
+ e->cmap);
XSetForeground(e->dpy, gc, win->fg.pixel);
XFillRectangle(e->dpy, win->buf.pm, gc, 0, win->h, win->w, win->bar.h);