X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=render%2Fmask.c;h=868c76125aad1f88c0b871fec9e9280673e16ca4;hb=216a04bdd057c03a719a0908cd003503b4f73fdb;hp=14836be71e54cb5048d792ac89a505fcbb08bedf;hpb=57314ce52246ce74ff2c64c7fc2da8794a8aaa4e;p=chaz%2Fopenbox diff --git a/render/mask.c b/render/mask.c index 14836be7..868c7612 100644 --- a/render/mask.c +++ b/render/mask.c @@ -16,6 +16,22 @@ void pixmap_mask_free(pixmap_mask *m) g_free(m); } -void mask_draw(pixmap_mask *p, TextureMask *m) +void mask_draw(Pixmap p, TextureMask *m, int width, int height) { + int x, y; + if (m->mask == None) return; // no mask given + + // set the clip region + x = (width - m->mask->w) / 2; + y = (height - m->mask->h) / 2; + XSetClipMask(ob_display, m->color->gc, m->mask->mask); + XSetClipOrigin(ob_display, m->color->gc, x, y); + + // fill in the clipped region + XFillRectangle(ob_display, p, m->color->gc, x, y, + x + m->mask->w, y + m->mask->h); + + // unset the clip region + XSetClipMask(ob_display, m->color->gc, None); + XSetClipOrigin(ob_display, m->color->gc, 0, 0); }