From e8e315db0e6fe72e1369df1c128a78b3cdb9c07a Mon Sep 17 00:00:00 2001 From: Kim Woelders Date: Sun, 28 Dec 2003 17:57:31 +0000 Subject: [PATCH] A pseudo-transparency support hack. SVN revision: 8222 --- src/E.h | 9 +- src/borders.c | 16 +- src/conf.h | 1 + src/config.c | 3 + src/dialog.c | 21 +- src/iclass.c | 704 ++++++++++++++++----------------- src/menus.c | 9 + src/themes/configs/definitions | 1 + src/x.c | 21 + 9 files changed, 401 insertions(+), 384 deletions(-) diff --git a/src/E.h b/src/E.h index b9df1525..b7322d8b 100644 --- a/src/E.h +++ b/src/E.h @@ -753,8 +753,8 @@ typedef struct _imagestate char *im_file; char *real_file; char unloadable; + char transparent; Imlib_Image *im; - Imlib_Color *transp; Imlib_Border *border; int pixmapfillstyle; XColor bg, hi, lo, hihi, lolo; @@ -1728,6 +1728,9 @@ void EMapWindow(Display * d, Window win); void EUnmapWindow(Display * d, Window win); void EShapeCombineMask(Display * d, Window win, int dest, int x, int y, Pixmap pmap, int op); +void EShapeCombineMaskTiled(Display * d, Window win, int dest, + int x, int y, Pixmap pmap, int op, + int w, int h); void EShapeCombineRectangles(Display * d, Window win, int dest, int x, int y, XRectangle * rect, int n_rects, int op, int ordering); @@ -1853,6 +1856,7 @@ ImageState *CreateImageState(void); void ImageStatePopulate(ImageState * is); void ImageStateRealize(ImageState * is); void IclassPopulate(ImageClass * iclass); +int IclassIsTransparent(ImageClass * iclass); void IclassApply(ImageClass * iclass, Window win, int w, int h, int active, int sticky, int state, char expose); void IclassApplyCopy(ImageClass * iclass, Window win, int w, @@ -2398,6 +2402,7 @@ void MenuHide(Menu * m); void MenuShow(Menu * m, char noshow); void MenuRepack(Menu * m); void MenuEmpty(Menu * m); +void MenuMove(Menu * m); MenuItem *MenuItemCreate(char *text, ImageClass * iclass, int action_id, char *action_params, Menu * child); @@ -2615,6 +2620,7 @@ char SanitiseThemeDir(char *dir); void Quicksort(void **a, int l, int r, int (*CompareFunc) (void *d1, void *d2)); +/* dialog.c */ Dialog *CreateDialog(char *name); void DialogBindKey(Dialog * d, char *key, void (*func) (int val, void *data), int val, @@ -2630,6 +2636,7 @@ void DialogActivateButton(Window win, int inclick); void DialogDraw(Dialog * d); void DialogDrawArea(Dialog * d, int x, int y, int w, int h); void DialogRedraw(Dialog * d); +void DialogMove(Dialog * d); void ShowDialog(Dialog * d); void DialogClose(Dialog * d); void DialogSetParamText(Dialog * d, char *fmt, ...); diff --git a/src/borders.c b/src/borders.c index b65ea53b..64829e3a 100644 --- a/src/borders.c +++ b/src/borders.c @@ -1803,7 +1803,7 @@ ResizeEwin(EWin * ewin, int w, int h) } if (ewin->pager) PagerResize(ewin->pager, ewin->client.w, ewin->client.h); - if (ewin->ibox) + else if (ewin->ibox) IconboxResize(ewin->ibox, ewin->client.w, ewin->client.h); EDBUG_RETURN_; } @@ -1880,6 +1880,11 @@ MoveEwin(EWin * ewin, int x, int y) } if ((mode.mode == MODE_NONE) && (move)) { + if (ewin->dialog) + DialogMove(ewin->dialog); + else if (ewin->menu) + MenuMove(ewin->menu); + PagerEwinOutsideAreaUpdate(ewin); ForceUpdatePagersForDesktop(ewin->desktop); } @@ -1948,15 +1953,22 @@ MoveResizeEwin(EWin * ewin, int x, int y, int w, int h) Efree(lst); } } + if ((mode.mode == MODE_NONE) && (change)) { + if (ewin->dialog) + DialogMove(ewin->dialog); + else if (ewin->menu) + MenuMove(ewin->menu); + PagerEwinOutsideAreaUpdate(ewin); ForceUpdatePagersForDesktop(ewin->desktop); } if (ewin->pager) PagerResize(ewin->pager, ewin->client.w, ewin->client.h); - if (ewin->ibox) + else if (ewin->ibox) IconboxResize(ewin->ibox, ewin->client.w, ewin->client.h); + call_depth--; EDBUG_RETURN_; } diff --git a/src/conf.h b/src/conf.h index 6d1705e1..f42c7ff3 100644 --- a/src/conf.h +++ b/src/conf.h @@ -164,6 +164,7 @@ #define ICLASS_STICKY_ACTIVE_DISABLED 369 #define ICLASS_COLORMOD 370 #define ICLASS_FILLRULE 371 +#define ICLASS_TRANSPARENT 372 #define DESKTOP_DRAGDIR 400 #define DESKTOP_DRAGBAR_WIDTH 401 #define DESKTOP_DRAGBAR_ORDERING 402 diff --git a/src/config.c b/src/config.c index 61347b50..5dda8a11 100644 --- a/src/config.c +++ b/src/config.c @@ -2399,6 +2399,9 @@ Config_ImageClass(FILE * ConfigFile) case ICLASS_FILLRULE: ICToRead->pixmapfillstyle = atoi(s2); break; + case ICLASS_TRANSPARENT: + ICToRead->transparent = atoi(s2); + break; case CONFIG_INHERIT: { ImageClass *ICToInherit; diff --git a/src/dialog.c b/src/dialog.c index e0f548fa..6279988a 100644 --- a/src/dialog.c +++ b/src/dialog.c @@ -617,11 +617,22 @@ DialogRedraw(Dialog * d) if ((!d->tclass) || (!d->iclass)) return; + + IclassApply(d->iclass, d->win, d->w, d->h, 0, 0, STATE_NORMAL, 0); + for (i = 0; i < d->num_buttons; i++) DialogDrawButton(d, i); + DialogDraw(d); } +void +DialogMove(Dialog * d) +{ + if (IclassIsTransparent(d->iclass)) + DialogRedraw(d); +} + void ShowDialog(Dialog * d) { @@ -696,16 +707,11 @@ ShowDialog(Dialog * d) d->button[i]->y, d->button[i]->w, d->button[i]->h); } d->w = w; - d->h = d->h - d->iclass->padding.bottom; + d->h = h; EResizeWindow(disp, d->win, w, h); + pq = queue_up; queue_up = 0; - IclassApply(d->iclass, d->win, w, h, 0, 0, STATE_NORMAL, 0); - - for (i = 0; i < d->num_buttons; i++) - IclassApply(d->button[i]->iclass, d->button[i]->win, d->button[i]->w, - d->button[i]->h, 0, 0, STATE_NORMAL, 0); - queue_up = pq; ewin = AddInternalToFamily(d->win, 1, NULL, EWIN_TYPE_DIALOG, d); XSelectInput(disp, d->win, @@ -738,6 +744,7 @@ ShowDialog(Dialog * d) AddItem(d, d->name, d->win, LIST_TYPE_DIALOG); XSync(disp, False); DialogRedraw(d); + queue_up = pq; } void diff --git a/src/iclass.c b/src/iclass.c index a415dd3a..f015cd38 100644 --- a/src/iclass.c +++ b/src/iclass.c @@ -22,6 +22,8 @@ */ #include "E.h" +#define ENABLE_TRANSPARENCY USE_IMLIB2 + ImageClass * CreateIclass() { @@ -68,8 +70,6 @@ FreeImageState(ImageState * i) imlib_free_image(); i->im = NULL; } - if (i->transp) - Efree(i->transp); if (i->border) Efree(i->border); @@ -148,8 +148,8 @@ CreateImageState() is->im_file = NULL; is->real_file = NULL; is->unloadable = 0; + is->transparent = 0; is->im = NULL; - is->transp = NULL; is->border = NULL; is->pixmapfillstyle = FILL_STRETCH; ESetColor(&(is->bg), 160, 160, 160); @@ -178,6 +178,9 @@ ImageStatePopulate(ImageState * is) EAllocColor(&is->hihi); EAllocColor(&is->lolo); + if (is->transparent) + is->unloadable = 1; + EDBUG_RETURN_; } @@ -471,8 +474,14 @@ IclassPopulate(ImageClass * iclass) cm->ref_count++; } } - EDBUG_RETURN_; + EDBUG_RETURN_; +} + +int +IclassIsTransparent(ImageClass * ic) +{ + return ic && ic->norm.normal && ic->norm.normal->transparent; } static ImageState * @@ -525,14 +534,299 @@ IclassGetImageState2(ImageClass * iclass, int state, int active, int sticky) return is; } +static void +ImageStateMakePmapMask(ImageState * is, Drawable win, PmapMask * pmm, + int make_mask, int w, int h) +{ + int apply; + int ww, hh; + PmapMask pmml; + Pixmap mask = 0; + +#if ENABLE_TRANSPARENCY + Pixmap pmap = 0; + Imlib_Image *ii = NULL; + + /* + * is->transparent flags: + * 0x01: Use desktop background pixmap as base + * 0x02: Use root window as base (use only for transients, if at all) + * 0x04: Don't apply image mask to result + */ +#endif + + apply = !pmm; + if (!pmm) + pmm = &pmml; + + imlib_context_set_drawable(win); + imlib_context_set_image(is->im); + + if (is->border) + imlib_image_set_border(is->border); + + ww = imlib_image_get_width(); + hh = imlib_image_get_height(); + + pmm->type = 1; + pmm->pmap = pmm->mask = 0; + +#if ENABLE_TRANSPARENCY + if (is->transparent && is->pixmapfillstyle == FILL_STRETCH && + imlib_image_has_alpha()) + { + Window cr; + Pixmap bg; + int xx, yy; + + /* Create the background base image */ + bg = root.win; + if ((is->transparent & 0x02) == 0 && + desks.desk[desks.current].bg && desks.desk[desks.current].bg->pmap) + bg = desks.desk[desks.current].bg->pmap; + XTranslateCoordinates(disp, win, root.win, 0, 0, &xx, &yy, &cr); + imlib_context_set_drawable(bg); + ii = imlib_create_image_from_drawable(0, xx, yy, w, h, 1); + imlib_context_set_image(ii); + imlib_context_set_drawable(win); + } +#endif + + if (is->pixmapfillstyle == FILL_STRETCH) + { +#if ENABLE_TRANSPARENCY + if (ii) + { + imlib_context_set_blend(1); + imlib_context_set_operation(IMLIB_OP_COPY); + imlib_blend_image_onto_image(is->im, 0, 0, 0, ww, hh, 0, 0, w, h); + imlib_context_set_blend(0); + } +#endif + pmm->type = 1; + imlib_render_pixmaps_for_whole_image_at_size(&pmm->pmap, &pmm->mask, + w, h); + mask = pmm->mask; +#if ENABLE_TRANSPARENCY + if (ii && make_mask && (is->transparent & 0x04) == 0) + { + /* Make the scaled clip mask to be used (is this really the way?) */ + imlib_context_set_image(is->im); + imlib_render_pixmaps_for_whole_image_at_size(&pmap, &mask, w, h); + } +#endif + } + else + { + int cw, ch, pw, ph; + + pw = w; + ph = h; + if (is->pixmapfillstyle & FILL_TILE_H) + pw = ww; + if (is->pixmapfillstyle & FILL_TILE_V) + ph = hh; + if (is->pixmapfillstyle & FILL_INT_TILE_H) + { + cw = w / ww; + if (cw * ww < w) + cw++; + if (cw < 1) + cw = 1; + pw = w / cw; + } + if (is->pixmapfillstyle & FILL_INT_TILE_V) + { + ch = h / hh; + if (ch * hh < h) + ch++; + if (ch < 1) + ch = 1; + ph = h / ch; + } + imlib_render_pixmaps_for_whole_image_at_size(&pmm->pmap, &pmm->mask, + pw, ph); + } + + if (apply) + { + /* Rendering on drawable */ + if (is->pixmapfillstyle == FILL_STRETCH) + { + if (pmm->pmap) + { + ESetWindowBackgroundPixmap(disp, win, pmm->pmap); + EShapeCombineMask(disp, win, ShapeBounding, 0, 0, + mask, ShapeSet); + } + } + else + { + if (pmm->pmap) + { + ESetWindowBackgroundPixmap(disp, win, pmm->pmap); + if (pmm->mask) + EShapeCombineMaskTiled(disp, win, ShapeBounding, 0, 0, + pmm->mask, ShapeSet, w, h); + } + } + FreePmapMask(pmm); + XClearWindow(disp, win); + } + else + { + /* Making pmap/mask */ + if (is->pixmapfillstyle == FILL_STRETCH) + { + /* pmap and mask are already rendered at the correct size */ + } + else + { + /* Create new full sized pixmaps and fill them with the */ + /* pmap and mask tiles */ + Pixmap tp = 0, tm = 0; + GC gc; + XGCValues gcv; + + tp = ECreatePixmap(disp, win, w, h, root.depth); + gcv.fill_style = FillTiled; + gcv.tile = pmm->pmap; + gcv.ts_x_origin = 0; + gcv.ts_y_origin = 0; + gc = XCreateGC(disp, tp, GCFillStyle | GCTile | + GCTileStipXOrigin | GCTileStipYOrigin, &gcv); + XFillRectangle(disp, tp, gc, 0, 0, w, h); + XFreeGC(disp, gc); + if (pmm->mask) + { + tm = ECreatePixmap(disp, win, w, h, 1); + gcv.fill_style = FillTiled; + gcv.tile = pmm->mask; + gcv.ts_x_origin = 0; + gcv.ts_y_origin = 0; + gc = XCreateGC(disp, tm, GCFillStyle | GCTile | + GCTileStipXOrigin | GCTileStipYOrigin, &gcv); + XFillRectangle(disp, tm, gc, 0, 0, w, h); + XFreeGC(disp, gc); + } + FreePmapMask(pmm); + pmm->type = 0; + pmm->pmap = tp; + pmm->mask = tm; + } + } + +#if ENABLE_TRANSPARENCY + if (pmap) + imlib_free_pixmap_and_mask(pmap); + if (ii) + { + imlib_context_set_image(ii); + imlib_free_image(); + } +#endif +} + +static void +ImageStateDrawBevel(ImageState * is, Drawable win, GC gc, int w, int h) +{ + switch (is->bevelstyle) + { + case BEVEL_AMIGA: + XSetForeground(disp, gc, is->hihi.pixel); + XDrawLine(disp, win, gc, 0, 0, w - 2, 0); + XDrawLine(disp, win, gc, 0, 0, 0, h - 2); + XSetForeground(disp, gc, is->lolo.pixel); + XDrawLine(disp, win, gc, 1, h - 1, w - 1, h - 1); + XDrawLine(disp, win, gc, w - 1, 1, w - 1, h - 1); + break; + case BEVEL_MOTIF: + XSetForeground(disp, gc, is->hi.pixel); + XDrawLine(disp, win, gc, 0, 0, w - 1, 0); + XDrawLine(disp, win, gc, 0, 0, 0, h - 1); + XDrawLine(disp, win, gc, 1, 1, w - 2, 1); + XDrawLine(disp, win, gc, 1, 1, 1, h - 2); + XSetForeground(disp, gc, is->lo.pixel); + XDrawLine(disp, win, gc, 0, h - 1, w - 1, h - 1); + XDrawLine(disp, win, gc, w - 1, 1, w - 1, h - 1); + XDrawLine(disp, win, gc, 1, h - 2, w - 2, h - 2); + XDrawLine(disp, win, gc, w - 2, 2, w - 2, h - 2); + break; + case BEVEL_NEXT: + XSetForeground(disp, gc, is->hihi.pixel); + XDrawLine(disp, win, gc, 0, 0, w - 1, 0); + XDrawLine(disp, win, gc, 0, 0, 0, h - 1); + XSetForeground(disp, gc, is->hi.pixel); + XDrawLine(disp, win, gc, 1, 1, w - 2, 1); + XDrawLine(disp, win, gc, 1, 1, 1, h - 2); + XSetForeground(disp, gc, is->lolo.pixel); + XDrawLine(disp, win, gc, 1, h - 1, w - 1, h - 1); + XDrawLine(disp, win, gc, w - 1, 1, w - 1, h - 1); + XSetForeground(disp, gc, is->lo.pixel); + XDrawLine(disp, win, gc, 2, h - 2, w - 2, h - 2); + XDrawLine(disp, win, gc, w - 2, 2, w - 2, h - 2); + break; + case BEVEL_DOUBLE: + XSetForeground(disp, gc, is->hi.pixel); + XDrawLine(disp, win, gc, 0, 0, w - 2, 0); + XDrawLine(disp, win, gc, 0, 0, 0, h - 2); + XSetForeground(disp, gc, is->lo.pixel); + XDrawLine(disp, win, gc, 1, 1, w - 3, 1); + XDrawLine(disp, win, gc, 1, 1, 1, h - 3); + XSetForeground(disp, gc, is->lo.pixel); + XDrawLine(disp, win, gc, 1, h - 1, w - 1, h - 1); + XDrawLine(disp, win, gc, w - 1, 1, w - 1, h - 1); + XSetForeground(disp, gc, is->hi.pixel); + XDrawLine(disp, win, gc, 2, h - 2, w - 2, h - 2); + XDrawLine(disp, win, gc, w - 2, 2, w - 2, h - 2); + break; + case BEVEL_WIDEDOUBLE: + XSetForeground(disp, gc, is->hihi.pixel); + XDrawLine(disp, win, gc, 0, 0, w - 1, 0); + XDrawLine(disp, win, gc, 0, 0, 0, h - 1); + XSetForeground(disp, gc, is->hi.pixel); + XDrawLine(disp, win, gc, 1, 1, w - 2, 1); + XDrawLine(disp, win, gc, 1, 1, 1, h - 2); + XDrawLine(disp, win, gc, 3, h - 4, w - 4, h - 4); + XDrawLine(disp, win, gc, w - 4, 3, w - 4, h - 4); + XSetForeground(disp, gc, is->lolo.pixel); + XDrawLine(disp, win, gc, 1, h - 1, w - 1, h - 1); + XDrawLine(disp, win, gc, w - 1, 1, w - 1, h - 1); + XSetForeground(disp, gc, is->lo.pixel); + XDrawLine(disp, win, gc, 2, h - 2, w - 2, h - 2); + XDrawLine(disp, win, gc, w - 2, 2, w - 2, h - 2); + XDrawLine(disp, win, gc, 3, 3, w - 4, 3); + XDrawLine(disp, win, gc, 3, 3, 3, h - 4); + break; + case BEVEL_THINPOINT: + XSetForeground(disp, gc, is->hi.pixel); + XDrawLine(disp, win, gc, 0, 0, w - 2, 0); + XDrawLine(disp, win, gc, 0, 0, 0, h - 2); + XSetForeground(disp, gc, is->lo.pixel); + XDrawLine(disp, win, gc, 1, h - 1, w - 1, h - 1); + XDrawLine(disp, win, gc, w - 1, 1, w - 1, h - 1); + XSetForeground(disp, gc, is->hihi.pixel); + XDrawLine(disp, win, gc, 0, 0, 1, 0); + XDrawLine(disp, win, gc, 0, 0, 0, 1); + XSetForeground(disp, gc, is->lolo.pixel); + XDrawLine(disp, win, gc, w - 2, h - 1, w - 1, h - 1); + XDrawLine(disp, win, gc, w - 1, h - 2, w - 1, h - 1); + XSync(disp, False); + break; + case BEVEL_THICKPOINT: + XSetForeground(disp, gc, is->hi.pixel); + XDrawRectangle(disp, win, gc, 0, 0, w - 1, h - 1); + break; + default: + break; + } +} + void IclassApply(ImageClass * iclass, Window win, int w, int h, int active, int sticky, int state, char expose) { ImageState *is; - XGCValues gcv; - GC gc; - Pixmap pmap, mask; EDBUG(4, "IclassApply"); @@ -579,199 +873,39 @@ IclassApply(ImageClass * iclass, Window win, int w, int h, int active, if (!is) EDBUG_RETURN_; - imlib_context_set_drawable(win); if (!expose) { - if (is->im_file) + if (is->im == NULL && is->im_file) + ImageStateRealize(is); + + if (is->im) { - /* has bg pixmap */ - if (!is->im) - ImageStateRealize(is); + ImageStateMakePmapMask(is, win, NULL, 1, w, h); - if (is->im) - { - imlib_context_set_image(is->im); - - /* if image, render */ - if (is->pixmapfillstyle == FILL_STRETCH) - { - imlib_render_pixmaps_for_whole_image_at_size(&pmap, - &mask, w, - h); - if (pmap) - { - ESetWindowBackgroundPixmap(disp, win, pmap); - EShapeCombineMask(disp, win, ShapeBounding, 0, - 0, mask, ShapeSet); - imlib_free_pixmap_and_mask(pmap); - } - } - else - { - int cw, ch, pw, ph; - Pixmap tm = 0; - GC gc; - XGCValues gcv; - - pw = w; - ph = h; - if (is->pixmapfillstyle & FILL_TILE_H) - pw = imlib_image_get_width(); - if (is->pixmapfillstyle & FILL_TILE_V) - ph = imlib_image_get_height(); - if (is->pixmapfillstyle & FILL_INT_TILE_H) - { - cw = w / imlib_image_get_width(); - if (cw * imlib_image_get_width() < w) - cw++; - if (cw < 1) - cw = 1; - pw = w / cw; - } - if (is->pixmapfillstyle & FILL_INT_TILE_V) - { - ch = h / imlib_image_get_height(); - if (ch * imlib_image_get_height() < h) - ch++; - if (ch < 1) - ch = 1; - ph = h / ch; - } - imlib_render_pixmaps_for_whole_image_at_size(&pmap, - &mask, pw, - ph); - if (mask) - { - gcv.fill_style = FillTiled; - gcv.tile = mask; - gcv.ts_x_origin = 0; - gcv.ts_y_origin = 0; - tm = ECreatePixmap(disp, win, w, h, 1); - gc = XCreateGC(disp, tm, - GCFillStyle | GCTile | - GCTileStipXOrigin | - GCTileStipYOrigin, &gcv); - XFillRectangle(disp, tm, gc, 0, 0, w, h); - XFreeGC(disp, gc); - EShapeCombineMask(disp, win, ShapeBounding, 0, - 0, tm, ShapeSet); - EFreePixmap(disp, tm); - } - ESetWindowBackgroundPixmap(disp, win, pmap); - imlib_free_pixmap_and_mask(pmap); - } - } - } - if (!is->im) - /* bg color */ - ESetWindowBackground(disp, win, is->bg.pixel); - else if (is->im_file) - { - /* if unloadable - then unload */ if ((is->unloadable) || (mode.memory_paranoia)) { + imlib_context_set_image(is->im); imlib_free_image(); is->im = NULL; } } + else + { + ESetWindowBackground(disp, win, is->bg.pixel); + XClearWindow(disp, win); + } } - XClearWindow(disp, win); - /* if there is a bevel to draw, draw it */ + if (is->bevelstyle != BEVEL_NONE) { + XGCValues gcv; + GC gc; + gc = XCreateGC(disp, win, 0, &gcv); - switch (is->bevelstyle) - { - case BEVEL_AMIGA: - XSetForeground(disp, gc, is->hihi.pixel); - XDrawLine(disp, win, gc, 0, 0, w - 2, 0); - XDrawLine(disp, win, gc, 0, 0, 0, h - 2); - XSetForeground(disp, gc, is->lolo.pixel); - XDrawLine(disp, win, gc, 1, h - 1, w - 1, h - 1); - XDrawLine(disp, win, gc, w - 1, 1, w - 1, h - 1); - break; - case BEVEL_MOTIF: - XSetForeground(disp, gc, is->hi.pixel); - XDrawLine(disp, win, gc, 0, 0, w - 1, 0); - XDrawLine(disp, win, gc, 0, 0, 0, h - 1); - XDrawLine(disp, win, gc, 1, 1, w - 2, 1); - XDrawLine(disp, win, gc, 1, 1, 1, h - 2); - XSetForeground(disp, gc, is->lo.pixel); - XDrawLine(disp, win, gc, 0, h - 1, w - 1, h - 1); - XDrawLine(disp, win, gc, w - 1, 1, w - 1, h - 1); - XDrawLine(disp, win, gc, 1, h - 2, w - 2, h - 2); - XDrawLine(disp, win, gc, w - 2, 2, w - 2, h - 2); - break; - case BEVEL_NEXT: - XSetForeground(disp, gc, is->hihi.pixel); - XDrawLine(disp, win, gc, 0, 0, w - 1, 0); - XDrawLine(disp, win, gc, 0, 0, 0, h - 1); - XSetForeground(disp, gc, is->hi.pixel); - XDrawLine(disp, win, gc, 1, 1, w - 2, 1); - XDrawLine(disp, win, gc, 1, 1, 1, h - 2); - XSetForeground(disp, gc, is->lolo.pixel); - XDrawLine(disp, win, gc, 1, h - 1, w - 1, h - 1); - XDrawLine(disp, win, gc, w - 1, 1, w - 1, h - 1); - XSetForeground(disp, gc, is->lo.pixel); - XDrawLine(disp, win, gc, 2, h - 2, w - 2, h - 2); - XDrawLine(disp, win, gc, w - 2, 2, w - 2, h - 2); - break; - case BEVEL_DOUBLE: - XSetForeground(disp, gc, is->hi.pixel); - XDrawLine(disp, win, gc, 0, 0, w - 2, 0); - XDrawLine(disp, win, gc, 0, 0, 0, h - 2); - XSetForeground(disp, gc, is->lo.pixel); - XDrawLine(disp, win, gc, 1, 1, w - 3, 1); - XDrawLine(disp, win, gc, 1, 1, 1, h - 3); - XSetForeground(disp, gc, is->lo.pixel); - XDrawLine(disp, win, gc, 1, h - 1, w - 1, h - 1); - XDrawLine(disp, win, gc, w - 1, 1, w - 1, h - 1); - XSetForeground(disp, gc, is->hi.pixel); - XDrawLine(disp, win, gc, 2, h - 2, w - 2, h - 2); - XDrawLine(disp, win, gc, w - 2, 2, w - 2, h - 2); - break; - case BEVEL_WIDEDOUBLE: - XSetForeground(disp, gc, is->hihi.pixel); - XDrawLine(disp, win, gc, 0, 0, w - 1, 0); - XDrawLine(disp, win, gc, 0, 0, 0, h - 1); - XSetForeground(disp, gc, is->hi.pixel); - XDrawLine(disp, win, gc, 1, 1, w - 2, 1); - XDrawLine(disp, win, gc, 1, 1, 1, h - 2); - XDrawLine(disp, win, gc, 3, h - 4, w - 4, h - 4); - XDrawLine(disp, win, gc, w - 4, 3, w - 4, h - 4); - XSetForeground(disp, gc, is->lolo.pixel); - XDrawLine(disp, win, gc, 1, h - 1, w - 1, h - 1); - XDrawLine(disp, win, gc, w - 1, 1, w - 1, h - 1); - XSetForeground(disp, gc, is->lo.pixel); - XDrawLine(disp, win, gc, 2, h - 2, w - 2, h - 2); - XDrawLine(disp, win, gc, w - 2, 2, w - 2, h - 2); - XDrawLine(disp, win, gc, 3, 3, w - 4, 3); - XDrawLine(disp, win, gc, 3, 3, 3, h - 4); - break; - case BEVEL_THINPOINT: - XSetForeground(disp, gc, is->hi.pixel); - XDrawLine(disp, win, gc, 0, 0, w - 2, 0); - XDrawLine(disp, win, gc, 0, 0, 0, h - 2); - XSetForeground(disp, gc, is->lo.pixel); - XDrawLine(disp, win, gc, 1, h - 1, w - 1, h - 1); - XDrawLine(disp, win, gc, w - 1, 1, w - 1, h - 1); - XSetForeground(disp, gc, is->hihi.pixel); - XDrawLine(disp, win, gc, 0, 0, 1, 0); - XDrawLine(disp, win, gc, 0, 0, 0, 1); - XSetForeground(disp, gc, is->lolo.pixel); - XDrawLine(disp, win, gc, w - 2, h - 1, w - 1, h - 1); - XDrawLine(disp, win, gc, w - 1, h - 2, w - 1, h - 1); - XSync(disp, False); - break; - case BEVEL_THICKPOINT: - XSetForeground(disp, gc, is->hi.pixel); - XDrawRectangle(disp, win, gc, 0, 0, w - 1, h - 1); - break; - default: - break; - } + ImageStateDrawBevel(is, win, gc, w, h); XFreeGC(disp, gc); } + EDBUG_RETURN_; } @@ -797,109 +931,23 @@ IclassApplyCopy(ImageClass * iclass, Window win, int w, int h, int active, if (!is) EDBUG_RETURN_; - imlib_context_set_drawable(win); + if (is->im == NULL && is->im_file) + ImageStateRealize(is); - if (is->im_file) + if (is->im) { - /* has bg pixmap */ - if (!is->im) - { - ImageStateRealize(is); - } - if (is->im) - { - /* if image, render */ - if (is->pixmapfillstyle == FILL_STRETCH) - { - pmm->type = 1; - imlib_context_set_image(is->im); - imlib_render_pixmaps_for_whole_image_at_size(&pmm->pmap, - &pmm->mask, - w, h); - /* if unloadable - then unload */ - if ((is->unloadable) || (mode.memory_paranoia)) - { - imlib_free_image(); - is->im = NULL; - } - EDBUG_RETURN_; - } - else - { - int cw, ch, pw, ph; - Pixmap pmap, mask, tp = 0, tm = 0; - GC gc; - XGCValues gcv; + ImageStateMakePmapMask(is, win, pmm, make_mask, w, h); - imlib_context_set_image(is->im); - pw = w; - ph = h; - if (is->pixmapfillstyle & FILL_TILE_H) - pw = imlib_image_get_width(); - if (is->pixmapfillstyle & FILL_TILE_V) - ph = imlib_image_get_height(); - if (is->pixmapfillstyle & FILL_INT_TILE_H) - { - cw = w / imlib_image_get_width(); - if (cw * imlib_image_get_width() < w) - cw++; - if (cw < 1) - cw = 1; - pw = w / cw; - } - if (is->pixmapfillstyle & FILL_INT_TILE_V) - { - ch = h / imlib_image_get_height(); - if (ch * imlib_image_get_height() < h) - ch++; - if (ch < 1) - ch = 1; - ph = h / ch; - } - imlib_render_pixmaps_for_whole_image_at_size(&pmap, &mask, pw, - ph); - tp = ECreatePixmap(disp, win, w, h, root.depth); - if ((make_mask) && (mask)) - tm = ECreatePixmap(disp, win, w, h, 1); - gcv.fill_style = FillTiled; - gcv.tile = pmap; - gcv.ts_x_origin = 0; - gcv.ts_y_origin = 0; - gc = XCreateGC(disp, tp, - GCFillStyle | GCTile | GCTileStipXOrigin | - GCTileStipYOrigin, &gcv); - XFillRectangle(disp, tp, gc, 0, 0, w, h); - XFreeGC(disp, gc); - if (tm) - { - gcv.fill_style = FillTiled; - gcv.tile = mask; - gcv.ts_x_origin = 0; - gcv.ts_y_origin = 0; - gc = XCreateGC(disp, tm, - GCFillStyle | GCTile | - GCTileStipXOrigin | - GCTileStipYOrigin, &gcv); - XFillRectangle(disp, tm, gc, 0, 0, w, h); - XFreeGC(disp, gc); - } - pmm->type = 0; - pmm->pmap = tp; - pmm->mask = tm; - IMLIB_FREE_PIXMAP_AND_MASK(pmap, mask); - /* if unloadable - then unload */ - if ((is->unloadable) || (mode.memory_paranoia)) - { - imlib_free_image(); - is->im = NULL; - } - EDBUG_RETURN_; - } + if ((is->unloadable) || (mode.memory_paranoia)) + { + imlib_context_set_image(is->im); + imlib_free_image(); + is->im = NULL; } + + EDBUG_RETURN_; } - /* TBD should we return here ? */ - /* if there is a bevel to draw, draw it */ if (is->bevelstyle != BEVEL_NONE) { @@ -917,96 +965,7 @@ IclassApplyCopy(ImageClass * iclass, Window win, int w, int h, int active, /* bg color */ XSetForeground(disp, gc, is->bg.pixel); XFillRectangle(disp, pmap, gc, 0, 0, w, h); - switch (is->bevelstyle) - { - case BEVEL_AMIGA: - XSetForeground(disp, gc, is->hihi.pixel); - XDrawLine(disp, pmap, gc, 0, 0, w - 2, 0); - XDrawLine(disp, pmap, gc, 0, 0, 0, h - 2); - XSetForeground(disp, gc, is->lolo.pixel); - XDrawLine(disp, pmap, gc, 1, h - 1, w - 1, h - 1); - XDrawLine(disp, pmap, gc, w - 1, 1, w - 1, h - 1); - break; - case BEVEL_MOTIF: - XSetForeground(disp, gc, is->hi.pixel); - XDrawLine(disp, pmap, gc, 0, 0, w - 1, 0); - XDrawLine(disp, pmap, gc, 0, 0, 0, h - 1); - XDrawLine(disp, pmap, gc, 1, 1, w - 2, 1); - XDrawLine(disp, pmap, gc, 1, 1, 1, h - 2); - XSetForeground(disp, gc, is->lo.pixel); - XDrawLine(disp, pmap, gc, 0, h - 1, w - 1, h - 1); - XDrawLine(disp, pmap, gc, w - 1, 1, w - 1, h - 1); - XDrawLine(disp, pmap, gc, 1, h - 2, w - 2, h - 2); - XDrawLine(disp, pmap, gc, w - 2, 2, w - 2, h - 2); - break; - case BEVEL_NEXT: - XSetForeground(disp, gc, is->hihi.pixel); - XDrawLine(disp, pmap, gc, 0, 0, w - 1, 0); - XDrawLine(disp, pmap, gc, 0, 0, 0, h - 1); - XSetForeground(disp, gc, is->hi.pixel); - XDrawLine(disp, pmap, gc, 1, 1, w - 2, 1); - XDrawLine(disp, pmap, gc, 1, 1, 1, h - 2); - XSetForeground(disp, gc, is->lolo.pixel); - XDrawLine(disp, pmap, gc, 1, h - 1, w - 1, h - 1); - XDrawLine(disp, pmap, gc, w - 1, 1, w - 1, h - 1); - XSetForeground(disp, gc, is->lo.pixel); - XDrawLine(disp, pmap, gc, 2, h - 2, w - 2, h - 2); - XDrawLine(disp, pmap, gc, w - 2, 2, w - 2, h - 2); - break; - case BEVEL_DOUBLE: - XSetForeground(disp, gc, is->hi.pixel); - XDrawLine(disp, pmap, gc, 0, 0, w - 2, 0); - XDrawLine(disp, pmap, gc, 0, 0, 0, h - 2); - XSetForeground(disp, gc, is->lo.pixel); - XDrawLine(disp, pmap, gc, 1, 1, w - 3, 1); - XDrawLine(disp, pmap, gc, 1, 1, 1, h - 3); - XSetForeground(disp, gc, is->lo.pixel); - XDrawLine(disp, pmap, gc, 1, h - 1, w - 1, h - 1); - XDrawLine(disp, pmap, gc, w - 1, 1, w - 1, h - 1); - XSetForeground(disp, gc, is->hi.pixel); - XDrawLine(disp, pmap, gc, 2, h - 2, w - 2, h - 2); - XDrawLine(disp, pmap, gc, w - 2, 2, w - 2, h - 2); - break; - case BEVEL_WIDEDOUBLE: - XSetForeground(disp, gc, is->hihi.pixel); - XDrawLine(disp, pmap, gc, 0, 0, w - 1, 0); - XDrawLine(disp, pmap, gc, 0, 0, 0, h - 1); - XSetForeground(disp, gc, is->hi.pixel); - XDrawLine(disp, pmap, gc, 1, 1, w - 2, 1); - XDrawLine(disp, pmap, gc, 1, 1, 1, h - 2); - XDrawLine(disp, pmap, gc, 3, h - 4, w - 4, h - 4); - XDrawLine(disp, pmap, gc, w - 4, 3, w - 4, h - 4); - XSetForeground(disp, gc, is->lolo.pixel); - XDrawLine(disp, pmap, gc, 1, h - 1, w - 1, h - 1); - XDrawLine(disp, pmap, gc, w - 1, 1, w - 1, h - 1); - XSetForeground(disp, gc, is->lo.pixel); - XDrawLine(disp, pmap, gc, 2, h - 2, w - 2, h - 2); - XDrawLine(disp, pmap, gc, w - 2, 2, w - 2, h - 2); - XDrawLine(disp, pmap, gc, 3, 3, w - 4, 3); - XDrawLine(disp, pmap, gc, 3, 3, 3, h - 4); - break; - case BEVEL_THINPOINT: - XSetForeground(disp, gc, is->hi.pixel); - XDrawLine(disp, pmap, gc, 0, 0, w - 2, 0); - XDrawLine(disp, pmap, gc, 0, 0, 0, h - 2); - XSetForeground(disp, gc, is->lo.pixel); - XDrawLine(disp, pmap, gc, 1, h - 1, w - 1, h - 1); - XDrawLine(disp, pmap, gc, w - 1, 1, w - 1, h - 1); - XSetForeground(disp, gc, is->hihi.pixel); - XDrawLine(disp, pmap, gc, 0, 0, 1, 0); - XDrawLine(disp, pmap, gc, 0, 0, 0, 1); - XSetForeground(disp, gc, is->lolo.pixel); - XDrawLine(disp, pmap, gc, w - 2, h - 1, w - 1, h - 1); - XDrawLine(disp, pmap, gc, w - 1, h - 2, w - 1, h - 1); - XSync(disp, False); - break; - case BEVEL_THICKPOINT: - XSetForeground(disp, gc, is->hi.pixel); - XDrawRectangle(disp, pmap, gc, 0, 0, w - 1, h - 1); - break; - default: - break; - } + ImageStateDrawBevel(is, pmap, gc, w, h); XFreeGC(disp, gc); } @@ -1038,9 +997,6 @@ ImageStateRealize(ImageState * is) imlib_image_set_border(is->border); #if !USE_IMLIB2 - if (is->transp) - Imlib_set_image_shape(pImlib_Context, is->im, is->transp); - if (is->colmod) { Imlib_set_image_red_curve(pImlib_Context, is->im, is->colmod->red.map); diff --git a/src/menus.c b/src/menus.c index f1b96b9f..f0aff141 100644 --- a/src/menus.c +++ b/src/menus.c @@ -551,6 +551,13 @@ MenuRepack(Menu * m) EDBUG_RETURN_; } +void +MenuMove(Menu * m) +{ + if (IclassIsTransparent(m->style->bg_iclass)) + MenuRealize(m); +} + void MenuAddItem(Menu * menu, MenuItem * item) { @@ -830,6 +837,8 @@ MenuDrawItem(Menu * m, MenuItem * mi, char shape) queue_up = 0; mi_pmm = &(mi->pmm[(int)(mi->state)]); + if (IclassIsTransparent(m->style->bg_iclass)) + FreePmapMask(mi_pmm); if (!mi_pmm->pmap) { if (mi->text) diff --git a/src/themes/configs/definitions b/src/themes/configs/definitions index 783ea431..921bf4e3 100644 --- a/src/themes/configs/definitions +++ b/src/themes/configs/definitions @@ -182,6 +182,7 @@ #define __HILITED_ACTIVE_STICKY 364 #define __MODIFIER 370 #define __FILLRULE 371 +#define __TRANSPARENT 372 #define __KEEP_ON_TOP 453 #define __FLAGS 454 diff --git a/src/x.c b/src/x.c index bdcda331..3f8c24b2 100644 --- a/src/x.c +++ b/src/x.c @@ -343,6 +343,27 @@ EShapeCombineMask(Display * d, Window win, int dest, int x, int y, Pixmap pmap, XShapeCombineMask(d, win, dest, x, y, pmap, op); } +void +EShapeCombineMaskTiled(Display * d, Window win, int dest, int x, int y, + Pixmap pmap, int op, int w, int h) +{ + XGCValues gcv; + GC gc; + Window tm; + + gcv.fill_style = FillTiled; + gcv.tile = pmap; + gcv.ts_x_origin = 0; + gcv.ts_y_origin = 0; + tm = ECreatePixmap(disp, win, w, h, 1); + gc = XCreateGC(disp, tm, GCFillStyle | GCTile | + GCTileStipXOrigin | GCTileStipYOrigin, &gcv); + XFillRectangle(disp, tm, gc, 0, 0, w, h); + XFreeGC(disp, gc); + EShapeCombineMask(disp, win, dest, x, y, tm, op); + EFreePixmap(disp, tm); +} + void EShapeCombineRectangles(Display * d, Window win, int dest, int x, int y, XRectangle * rect, int n_rects, int op, int ordering)