diff options
-rw-r--r-- | dblbuf.c | 4 | ||||
-rw-r--r-- | refresh.c | 1 | ||||
-rw-r--r-- | xlib.c | 49 |
3 files changed, 35 insertions, 19 deletions
@@ -117,6 +117,10 @@ void uudisp_predraw_cell(struct uudisp *d, int idx, int x, int color) b->slices[idx].colors[2*x+1] = expand_color(d, color>>4) ^ b->slices[idx].colors[2*x]; } +void uudisp_finalize_cell(struct uudisp *d, int idx, int x) +{ +} + void uudisp_draw_glyph(struct uudisp *d, int idx, int x, const void *glyph) { struct dblbuf *b = (void *)&d->priv; @@ -59,6 +59,7 @@ void uuterm_refresh_row(struct uudisp *d, struct uurow *row, int x1, int x2) const void *glyph = lookup_glyph(d->font, i, chp, ch[(x+3)&3], ch[(x+1)&3], width, part); if (glyph) uudisp_draw_glyph(d, row->idx, x, glyph); } + uudisp_finalize_cell(d, row->idx, x); } } @@ -23,8 +23,9 @@ struct priv Window window; XIM im; XIC ic; - GC wingc, cugc, bggc, fggc, maskgc; + GC wingc, cugc, fg, bg, mask_fg, mask_bg; Pixmap pixmap; + Pixmap mask; Pixmap *glyph_cache; int *slices_y; int curs_x, curs_y; @@ -125,19 +126,21 @@ int uudisp_open(struct uudisp *d) resize_window(d, px_w, px_h); + p->mask = XCreatePixmap(p->display, DefaultRootWindow(p->display), + d->cell_w, d->cell_h, 1); + p->wingc = XCreateGC(p->display, p->window, 0, &values); p->cugc = XCreateGC(p->display, p->window, 0, &values); - p->fggc = XCreateGC(p->display, p->pixmap, 0, &values); - p->bggc = XCreateGC(p->display, p->pixmap, 0, &values); - p->maskgc = XCreateGC(p->display, p->pixmap, 0, &values); + p->fg = XCreateGC(p->display, p->pixmap, 0, &values); + p->bg = XCreateGC(p->display, p->pixmap, 0, &values); + p->mask_fg = XCreateGC(p->display, p->mask, 0, &values); + p->mask_bg = XCreateGC(p->display, p->mask, 0, &values); + XSetClipMask(p->display, p->fg, p->mask); XSetFunction(p->display, p->cugc, GXxor); - XSetFunction(p->display, p->fggc, GXor); - XSetFunction(p->display, p->bggc, GXcopy); - XSetFunction(p->display, p->maskgc, GXandInverted); + XSetFunction(p->display, p->mask_fg, GXor); XSetForeground(p->display, p->cugc, WhitePixel(p->display, p->screen)); - XSetBackground(p->display, p->fggc, BlackPixel(p->display, p->screen)); - XSetForeground(p->display, p->maskgc, WhitePixel(p->display, p->screen)); - XSetBackground(p->display, p->maskgc, BlackPixel(p->display, p->screen)); + XSetForeground(p->display, p->mask_fg, WhitePixel(p->display, p->screen)); + XSetForeground(p->display, p->mask_bg, BlackPixel(p->display, p->screen)); npages = (nglyphs+1023) / 1024; // allows up to 64 pixel cell height.. p->glyph_cache = calloc(sizeof(p->glyph_cache[0]), npages); @@ -348,20 +351,28 @@ void uudisp_draw_glyph(struct uudisp *d, int idx, int x, const void *glyph) int gp = g >> 10; g &= 1023; - XCopyPlane(p->display, p->glyph_cache[gp], p->pixmap, p->maskgc, - 0, g*d->cell_h, d->cell_w, d->cell_h, - x * d->cell_w, idx * d->cell_h, 1); - XCopyPlane(p->display, p->glyph_cache[gp], p->pixmap, p->fggc, - 0, g*d->cell_h, d->cell_w, d->cell_h, - x * d->cell_w, idx * d->cell_h, 1); + XCopyArea(p->display, p->glyph_cache[gp], p->mask, p->mask_fg, + 0, g*d->cell_h, d->cell_w, d->cell_h, 0, 0); } void uudisp_predraw_cell(struct uudisp *d, int idx, int x, int color) { struct priv *p = (void *)&d->priv; - XSetForeground(p->display, p->fggc, p->colors[color&15]); - XSetForeground(p->display, p->bggc, p->colors[color>>4]); - XFillRectangle(p->display, p->pixmap, p->bggc, + + XSetClipOrigin(p->display, p->fg, x*d->cell_w, idx*d->cell_h); + XSetForeground(p->display, p->fg, p->colors[color&15]); + XSetForeground(p->display, p->bg, p->colors[color>>4]); + XFillRectangle(p->display, p->pixmap, p->bg, + x*d->cell_w, idx*d->cell_h, d->cell_w, d->cell_h); + XFillRectangle(p->display, p->mask, p->mask_bg, + 0, 0, d->cell_w, d->cell_h); +} + +void uudisp_finalize_cell(struct uudisp *d, int idx, int x) +{ + struct priv *p = (void *)&d->priv; + XSetClipMask(p->display, p->fg, p->mask); + XFillRectangle(p->display, p->pixmap, p->fg, x*d->cell_w, idx*d->cell_h, d->cell_w, d->cell_h); } |