// Xft stuff
XftFont *font;
- XftDraw *xft_draw;
+ XftDraw *mask_draw;
+ XftDraw *image_draw;
};
int
osd->screen_height = XDisplayHeight(osd->dpy, osd->screen);
XSetWindowAttributes win_attr = {
- .override_redirect = 0, // FIXME: 1
+ .override_redirect = 1,
};
osd->win = XCreateWindow(osd->dpy,
XRootWindow(osd->dpy, osd->screen),
osd->mask_gc = XCreateGC(osd->dpy, osd->mask_bitmap, GCGraphicsExposures, &gcv);
XSetBackground(osd->dpy, osd->gc, BlackPixel(osd->dpy, osd->screen));
- XSetForeground(osd->dpy, osd->gc, BlackPixel(osd->dpy, osd->screen));
+ XColor shadow_color = { .red = 0xffff, .green = 0xffff, .blue = 0 };
+ XAllocColor(osd->dpy, osd->cmap, &shadow_color);
+ XSetForeground(osd->dpy, osd->gc, shadow_color.pixel);
XSetBackground(osd->dpy, osd->mask_gc, WhitePixel(osd->dpy, osd->screen));
XSetForeground(osd->dpy, osd->mask_gc, BlackPixel(osd->dpy, osd->screen));
XFillRectangle(osd->dpy, osd->image_pixmap, osd->gc, 0, 0, osd->screen_width, osd->screen_height);
+ XFillRectangle(osd->dpy, osd->mask_bitmap, osd->mask_gc, 0, 0, osd->screen_width, osd->screen_height);
+
osd->font = XftFontOpenName(osd->dpy, osd->screen, "times-64");
if (!osd->font)
die("Cannot open font");
- osd->xft_draw = XftDrawCreate(osd->dpy, osd->image_pixmap, osd->visual, osd->cmap);
- if (!osd->xft_draw)
+ osd->mask_draw = XftDrawCreateBitmap(osd->dpy, osd->mask_bitmap);
+ if (!osd->mask_draw)
+ die("Cannot create XftDraw");
+
+ osd->image_draw = XftDrawCreate(osd->dpy, osd->image_pixmap, osd->visual, osd->cmap);
+ if (!osd->image_draw)
die("Cannot create XftDraw");
XRenderColor xrc = { .red = 0, .green = 0xffff, .blue = 0, .alpha = 0xffff };
if (!XftColorAllocValue(osd->dpy, osd->visual, osd->cmap, &xrc, &xfc))
die("XftColorAllocValue failed");
const unsigned char str[] = "Žluťoučká vlkodlačice";
- XftDrawStringUtf8(osd->xft_draw, &xfc, osd->font, 100, 100, str, strlen((char *) str));
+ XftDrawStringUtf8(osd->image_draw, &xfc, osd->font, 100, 100, str, strlen((char *) str));
+
+ XRenderColor xrcm = { .red = 0xffff, .green = 0xffff, .blue = 0xffff, .alpha = 0xffff };
+ XftColor xfcm;
+ if (!XftColorAllocValue(osd->dpy, osd->visual, osd->cmap, &xrcm, &xfcm))
+ die("XftColorAllocValue failed");
+
+ // FIXME: This is very ugly!
+ XftDrawStringUtf8(osd->mask_draw, &xfcm, osd->font, 100, 100, str, strlen((char *) str));
+ for (int off=1; off<=2; off++)
+ for (int dir=0; dir<9; dir++)
+ if (dir != 4)
+ XftDrawStringUtf8(osd->mask_draw, &xfcm, osd->font, 100 + (dir/3 - 1) * off, 100 + (dir%3 - 1) * off, str, strlen((char *) str));
+#if 0
XGlyphInfo gi;
XftTextExtentsUtf8(osd->dpy, osd->font, str, strlen((char *) str), &gi);
DBG("Glyph info: (%d,%d)+(%d,%d) off (%d,%d)\n", gi.x, gi.y, gi.width, gi.height, gi.xOff, gi.yOff);
- XftDrawRect(osd->xft_draw, &xfc, 100 + gi.x, 100 - gi.y, gi.width, gi.height);
+ XftDrawRect(osd->image_draw, &xfc, 100 + gi.x, 100 - gi.y, gi.width, gi.height);
+#endif
- XftDrawRect(osd->xft_draw, &xfc, 30, 30, 50, 50);
+ XShapeCombineMask(osd->dpy, osd->win, ShapeBounding, 0, 0, osd->mask_bitmap, ShapeSet);
XSelectInput(osd->dpy, osd->win, ExposureMask);
XMapRaised(osd->dpy, osd->win);