From 9560634f4fee70c4923b122f35e26f2bf22858c5 Mon Sep 17 00:00:00 2001 From: Kim Woelders Date: Sat, 15 Nov 2003 22:27:17 +0000 Subject: [PATCH] Initial imlib2 port. SVN revision: 7898 --- configure.in | 22 +- src/E.h | 175 +++++-- src/Makefile.am | 11 +- src/actions.c | 4 +- src/alert.c | 37 +- src/borders.c | 21 +- src/buttons.c | 9 +- src/comms.c | 49 +- src/config.c | 78 ++-- src/cursors.c | 27 +- src/desktops.c | 374 ++++++++------- src/dialog.c | 183 +++----- src/draw.c | 83 ++-- src/evhandlers.c | 2 +- src/fx.c | 59 +-- src/globals.c | 9 +- src/iclass.c | 1130 +++++++++++++++++++++------------------------- src/iconify.c | 380 +++++++--------- src/init.c | 127 ++---- src/ipc.c | 54 ++- src/main.c | 23 +- src/menus.c | 218 +++++---- src/pager.c | 208 ++++----- src/settings.c | 248 +++++----- src/setup.c | 100 ++-- src/startup.c | 6 +- src/text.c | 195 +++----- src/tooltips.c | 609 ++++++++++--------------- src/ttfont.c | 2 +- 29 files changed, 2072 insertions(+), 2371 deletions(-) diff --git a/configure.in b/configure.in index 0b8e5044..d887ade4 100644 --- a/configure.in +++ b/configure.in @@ -74,6 +74,9 @@ AC_ARG_ENABLE(hints-ewmh, [ --enable-hints-ewmh compile with Extended Window Manager Hints support [default=yes]],, enable_hints_ewmh=yes) AC_ARG_ENABLE(hints-gnome, [ --enable-hints-gnome compile with GNOME(<2.0) hints support [default=no]],, enable_hints_gnome=no) +AC_ARG_WITH(imlib2, + [ --with-imlib2 compile with Imlib2 support [default=no]],, with_imlib2=no) + AC_ARG_WITH(fnlib, [ --with-fnlib compile with Fnlib support [default=yes]],, with_fnlib=yes) @@ -108,14 +111,20 @@ echo "Sound support has been turned off, per the --enable-sound=no" echo "passed to your configure line." fi +LDFLAGS="$LDFLAGS -L$prefix/lib" +LDFLAGS="$LDFLAGS -L$x_libraries" + +if test "x$with_imlib2" = "xyes"; then +AC_CHECK_LIB(Imlib2, imlib_create_image, IMLIB_LIBS=-lImlib2, [ +echo "ERROR: Imlib2 support requested but not found (imlib2)." +AC_MSG_ERROR([Fatal Error: no Imlib2 detected.])], -lm) +AC_DEFINE(USE_IMLIB2, 1, [Imlib2 support]) +with_fnlib="no" +else AM_PATH_IMLIB(1.9.8, , [ echo "ERROR: Enlightenment needs a system with Imlib 1.9.8 or higher." AC_MSG_ERROR([Fatal Error: no Imlib detected.])]) - -LDFLAGS="$LDFLAGS -L$prefix/lib" -LDFLAGS="$LDFLAGS `echo $IMLIB_LIBS | sed 's/\(.*\)-lImlib.*/\1/'`" -LDFLAGS="$LDFLAGS `echo $IMLIB_LIBS | sed 's/.*-lImlib.*\(-L[[^ ]]*\).*$/\1/'`" -XTST_LIBS="" +fi if test "x$with_fnlib" = "xyes"; then # AC_CHECK_HEADER(Fnlib.h, ,AC_MSG_ERROR([Fatal Error: no Fnlib header detected.])) @@ -151,8 +160,11 @@ AC_MSG_WARN([Module Support Disabled (no dynamic loader)])], -lm) AC_SUBST(DL_LIBS) AC_CHECK_LIB(Xtst, XTestGrabControl, , , $X_LIBS) + +XTST_LIBS="" AC_CHECK_LIB(Xtst, XTestQueryExtension, XTST_LIBS=-lXtst, , $X_LIBS) AC_SUBST(XTST_LIBS) + AC_CHECK_LIB(Xext, XkbQueryExtension, AC_DEFINE(WITH_TARTY_WARP, 1, [Tarty Warp]), , $X_LIBS) AC_CHECK_LIB(Xinerama, XineramaQueryExtension, AC_DEFINE(HAS_XINERAMA, 1, [Xinerama support]) XINERAMA_LIBS=-lXinerama diff --git a/src/E.h b/src/E.h index ef55ff74..8fac3ea2 100644 --- a/src/E.h +++ b/src/E.h @@ -29,11 +29,119 @@ #include #include #include +#include #include #include #include #include + +#define ESetColor(pxc, r, g, b) \ + ({ (pxc)->red = ((r)<<8)|r; (pxc)->green = ((g)<<8)|g; (pxc)->blue = ((b)<<8)|b; }) +#define EGetColor(pxc, pr, pg, pb) \ + ({ *(pr) = ((pxc)->red)>>8; *(pg) = ((pxc)->green)>>8; *(pb) = ((pxc)->blue)>>8; }) + +#if USE_IMLIB2 +#include + +#define IMLIB1_SET_CONTEXT(root_ctx) + +#define EAllocColor(pxc) \ + XAllocColor(disp, root.cmap, pxc) + +#define IMLIB_FREE_PIXMAP_AND_MASK(pmap, mask) \ + imlib_free_pixmap_and_mask(pmap) + +#define IC_RenderDepth() DefaultDepth(disp, root.scr) + +#else + #include + +extern ImlibData *pI1Ctx; +extern ImlibImage *pIcImg; +extern Drawable vIcDrw; + +#define IMLIB1_SET_CONTEXT(root_ctx) \ + pI1Ctx = ((root_ctx) && prImlib_Context) ? prImlib_Context : pImlib_Context + +#define imlib_context_set_image(im_img) \ + pIcImg = im_img +#define imlib_context_set_drawable(im_drw) \ + vIcDrw = im_drw + +#define imlib_context_set_dither(onoff) \ + Imlib_set_render_type(pI1Ctx, RT_DITHER_TRUECOL) +#define imlib_context_get_dither() \ + Imlib_get_render_type(pI1Ctx) + +#define imlib_image_get_width() \ + pIcImg->rgb_width +#define imlib_image_get_height() \ + pIcImg->rgb_height + +#define imlib_load_image(file) \ + Imlib_load_image(pI1Ctx, file) +#define imlib_create_image_from_drawable(mask, x, y, w, h, grab) \ + Imlib_create_image_from_drawable(pI1Ctx, vIcDrw, mask, x, y, w, h) + +#define imlib_image_set_format(fmt) +#define imlib_save_image(file) \ + Imlib_save_image_to_ppm(pI1Ctx, pIcImg, file) + +#define imlib_render_pixmaps_for_whole_image(p, m) \ + Imlib_render(pI1Ctx, pIcImg, imlib_image_get_width(), imlib_image_get_height()); \ + if (p) *p = Imlib_copy_image(pI1Ctx, pIcImg); \ + if (m) *m = Imlib_copy_mask(pI1Ctx, pIcImg) +#define imlib_render_pixmaps_for_whole_image_at_size(p, m, w, h) \ + Imlib_render(pI1Ctx, pIcImg, w, h); \ + if (p) *p = Imlib_copy_image(pI1Ctx, pIcImg); \ + if (m) *m = Imlib_copy_mask(pI1Ctx, pIcImg) +#define imlib_render_image_on_drawable(x, y) \ + Imlib_apply_image(pI1Ctx, pIcImg, vIcDrw) +#define imlib_render_image_on_drawable_at_size(x, y, w, h) \ + Imlib_paste_image(pI1Ctx, pIcImg, vIcDrw, x, y, w, h) + +#define imlib_create_cropped_scaled_image(x, y, w, h, w2, h2) \ + Imlib_clone_scaled_image(pI1Ctx, pIcImg, w2, h2) + +#define imlib_image_orientate(rot) \ + switch (rot) { \ + case 1: \ + Imlib_rotate_image(pI1Ctx, pIcImg, 1); \ + Imlib_flip_image_horizontal(pI1Ctx, pIcImg); \ + break; \ + case 2: \ + Imlib_flip_image_vertical(pI1Ctx, pIcImg); \ + Imlib_flip_image_horizontal(pI1Ctx, pIcImg); \ + case 3: \ + Imlib_rotate_image(pI1Ctx, pIcImg, -1); \ + Imlib_flip_image_vertical(pI1Ctx, pIcImg); \ + break; \ + } + +#define imlib_free_image() \ + ({ Imlib_destroy_image(pI1Ctx, pIcImg); pIcImg = NULL; }) +#define imlib_free_image_and_decache() \ + ({ Imlib_kill_image(pI1Ctx, pIcImg); pIcImg = NULL; }) +#define imlib_free_pixmap_and_mask(pmap) \ + Imlib_free_pixmap(pI1Ctx, pmap) + +#define IMLIB_FREE_PIXMAP_AND_MASK(pmap, mask) \ + ({ Imlib_free_pixmap(pI1Ctx, pmap); Imlib_free_pixmap(pI1Ctx, mask); }) + +#define imlib_image_set_border(im_bdr) \ + Imlib_set_image_border(pI1Ctx, pIcImg, im_bdr) + +#define EAllocColor(pxc) \ + ({ int r = ((pxc)->red)>>8, g = ((pxc)->green)>>8, b = ((pxc)->blue)>>8; \ + (pxc)->pixel = Imlib_best_color_match(pI1Ctx, &r, &g, &b); }) + +#define Imlib_Context ImlibData +#define Imlib_Image ImlibImage +#define Imlib_Color ImlibColor +#define Imlib_Border ImlibBorder +#define IC_RenderDepth() (pImlib_Context->x.render_depth) +#endif #if USE_FNLIB #include #endif @@ -556,6 +664,14 @@ typedef struct _snapshot Snapshot; typedef struct _iconbox Iconbox; typedef struct _group Group; +typedef struct +{ + char type; + Pixmap pmap; + Pixmap mask; +} +PmapMask; + typedef struct _icondef { char *title_match; @@ -633,11 +749,11 @@ typedef struct _imagestate char *im_file; char *real_file; char unloadable; - ImlibImage *im; - ImlibColor *transp; - ImlibBorder *border; + Imlib_Image *im; + Imlib_Color *transp; + Imlib_Border *border; int pixmapfillstyle; - ImlibColor bg, hi, lo, hihi, lolo; + XColor bg, hi, lo, hihi, lolo; int bevelstyle; ColorModifierClass *colmod; } @@ -657,7 +773,7 @@ typedef struct _imageclass char *name; char external; ImageStateArray norm, active, sticky, sticky_active; - ImlibBorder padding; + Imlib_Border padding; ColorModifierClass *colmod; unsigned int ref_count; } @@ -702,8 +818,8 @@ typedef struct _textstate char orientation; } style; #endif - ImlibColor fg_col; - ImlibColor bg_col; + XColor fg_col; + XColor bg_col; int effect; Efont *efont; XFontStruct *xfont; @@ -781,7 +897,9 @@ Geometry; typedef struct _ecursor { char *name; - ImlibColor fg, bg; +#if 0 /* Not used */ + Imlib_Color fg, bg; +#endif char *file; Cursor cursor; unsigned int ref_count; @@ -806,7 +924,7 @@ typedef struct _border { char *name; char *group_border_name; - ImlibBorder border; + Imlib_Border border; int num_winparts; WinPart *part; char changes_shape; @@ -933,11 +1051,11 @@ typedef struct _ewin int area_y; char *session_id; int has_transients; + PmapMask mini_pmm; int mini_w, mini_h; - Pixmap mini_pmap, mini_mask; Snapshot *snap; - int icon_pmap_w, icon_pmap_h; - Pixmap icon_pmap, icon_mask; + PmapMask icon_pmm; + int icon_w, icon_h; int head; } EWin; @@ -1035,10 +1153,10 @@ typedef struct _background time_t last_viewed; struct _bg { - ImlibColor solid; + XColor solid; char *file; char *real_file; - ImlibImage *im; + Imlib_Image *im; char tile; char keep_aspect; int xjust, yjust; @@ -1049,7 +1167,7 @@ typedef struct _background { char *file; char *real_file; - ImlibImage *im; + Imlib_Image *im; char keep_aspect; int xjust, yjust; int xperc, yperc; @@ -1330,8 +1448,7 @@ typedef struct _menuitem void *params; Menu *child; char state; - Pixmap pmap[3]; - Pixmap mask[3]; + PmapMask pmm[3]; Window win; Window icon_win; short icon_w; @@ -1351,8 +1468,7 @@ struct _menu int num; MenuItem **items; Window win; - Pixmap pmap; - Pixmap mask; + PmapMask pmm; char stuck; Menu *parent; MenuItem *sel_item; @@ -1749,8 +1865,6 @@ void UnShadeEwin(EWin * ewin); /* iclass.c functions */ ImageClass *CreateIclass(void); -void FreeImageState(ImageState * i); -void FreeImageStateArray(ImageStateArray * isa); void FreeImageClass(ImageClass * i); ImageState *CreateImageState(void); void ImageStatePopulate(ImageState * is); @@ -1760,7 +1874,8 @@ 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, int h, int active, int sticky, int state, - Pixmap * pret, Pixmap * mret); + PmapMask * pmm, int make_mask); +void FreePmapMask(PmapMask * pmm); /* draw.c functions */ void HandleDrawQueue(void); @@ -1775,8 +1890,7 @@ void EDestroyPixImg(PixImg * pi); void EBlendPixImg(EWin * ewin, PixImg * s1, PixImg * s2, PixImg * dst, int x, int y, int w, int h); -ImlibImage *ELoadImage(char *file); -ImlibImage *ELoadImageImlibData(ImlibData * imd, char *file); +Imlib_Image *ELoadImage(char *file); void DrawEwinShape(EWin * ewin, int md, int x, int y, int w, int h, char firstlast); void PropagateShapes(Window win); @@ -1966,15 +2080,14 @@ void SlideWindowTo(Window win, int fx, int fy, int tx, int ty, void KeepBGimages(Background * bg, char onoff); void RemoveImagesFromBG(Background * bg); void FreeDesktopBG(Background * bg); -Background *CreateDesktopBG(char *name, ImlibColor * solid, char *bg, +Background *CreateDesktopBG(char *name, XColor * solid, char *bg, char tile, char keep_aspect, int xjust, int yjust, int xperc, int yperc, char *top, char tkeep_aspect, int txjust, int tyjust, int txperc, int typerc); void RefreshCurrentDesktop(void); void RefreshDesktop(int num); -void SetBackgroundTo(ImlibData * imd, Window win, - Background * dsk, char setbg); +void SetBackgroundTo(Window win, Background * dsk, char setbg); void InitDesktopBgs(void); void InitDesktopControls(void); void SetDesktopBg(int desk, Background * bg); @@ -2455,7 +2568,7 @@ int findLocalizedFile(char *fname); /* cursors.c functions */ ECursor *CreateECursor(char *name, char *image, int native_id, - ImlibColor * fg, ImlibColor * bg); + XColor * fg, XColor * bg); void ApplyECursor(Window win, ECursor * ec); void FreeECursor(ECursor * ec); @@ -2750,9 +2863,11 @@ extern int master_screen; extern int display_screens; extern int single_screen_mode; extern Display *disp; -extern ImlibData *pImlibData; -extern ImlibData *prImlibData; +#if !USE_IMLIB2 +extern Imlib_Context *pImlib_Context; +extern Imlib_Context *prImlib_Context; +#endif #if USE_FNLIB extern FnlibData *pFnlibData; #endif diff --git a/src/Makefile.am b/src/Makefile.am index b48100f2..0565b1dc 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -87,17 +87,18 @@ enlightenment_SOURCES = \ LDADD = \ - @INTLLIBS@ \ + @INTLLIBS@ \ $(FNLIB_LIBS) \ $(TTF_LIBS) \ $(ESD_LIBS) \ $(IMLIB_LIBS) \ $(XTST_LIBS) \ $(XVM_LIBS) \ - $(GHTTP_LIBS) \ - $(DL_LIBS) \ - $(XINERAMA_LIBS) \ - -lm + $(GHTTP_LIBS) \ + $(DL_LIBS) \ + $(XINERAMA_LIBS) \ + $(X_PRE_LIBS) \ + -lX11 -lm INCLUDES = $(ESD_CFLAGS) $(IMLIB_CFLAGS) -I$(top_builddir) -I$(top_srcdir)/intl diff --git a/src/actions.c b/src/actions.c index 2e0a92f7..d9f02397 100644 --- a/src/actions.c +++ b/src/actions.c @@ -2013,8 +2013,10 @@ doMoveModeSet(void *params) if (mode.movemode > 5) mode.movemode = 0; } - if ((prImlibData) && (mode.movemode == 5)) +#if !USE_IMLIB2 + if ((prImlib_Context) && (mode.movemode == 5)) mode.movemode = 3; +#endif autosave(); EDBUG_RETURN(0); } diff --git a/src/alert.c b/src/alert.c index 64379cd3..f67d50fc 100644 --- a/src/alert.c +++ b/src/alert.c @@ -150,7 +150,7 @@ ShowAlert(char *text) XColor xcl; Colormap cmap; int cols[256]; - int cnum, r, g, b, fh, x, y, ww, hh, mh; + int cnum, fh, x, y, ww, hh, mh; static char *title = NULL, *str1 = NULL, *str2 = NULL, *str3 = NULL; KeyCode key; @@ -256,44 +256,19 @@ goto CN; \ if (colorful) { cmap = DefaultColormap(dd, DefaultScreen(dd)); - r = 220; - g = 220; - b = 220; - xcl.red = (r << 8) | r; - xcl.green = (g << 8) | g; - xcl.blue = (b << 8) | b; + ESetColor(&xcl, 220, 220, 220); ALLOC_COLOR(dd, cmap, &xcl); cols[cnum++] = xcl.pixel; - r = 160; - g = 160; - b = 160; - xcl.red = (r << 8) | r; - xcl.green = (g << 8) | g; - xcl.blue = (b << 8) | b; + ESetColor(&xcl, 160, 160, 160); ALLOC_COLOR(dd, cmap, &xcl); cols[cnum++] = xcl.pixel; - r = 100; - g = 100; - b = 100; - xcl.red = (r << 8) | r; - xcl.green = (g << 8) | g; - xcl.blue = (b << 8) | b; + ESetColor(&xcl, 100, 100, 100); ALLOC_COLOR(dd, cmap, &xcl); cols[cnum++] = xcl.pixel; - r = 0; - g = 0; - b = 0; - xcl.red = (r << 8) | r; - xcl.green = (g << 8) | g; - xcl.blue = (b << 8) | b; + ESetColor(&xcl, 0, 0, 0); ALLOC_COLOR(dd, cmap, &xcl); cols[cnum++] = xcl.pixel; - r = 255; - g = 255; - b = 255; - xcl.red = (r << 8) | r; - xcl.green = (g << 8) | g; - xcl.blue = (b << 8) | b; + ESetColor(&xcl, 255, 255, 255); ALLOC_COLOR(dd, cmap, &xcl); cols[cnum++] = xcl.pixel; } diff --git a/src/borders.c b/src/borders.c index e800855f..be8a5b02 100644 --- a/src/borders.c +++ b/src/borders.c @@ -1507,11 +1507,13 @@ CreateEwin() ewin->has_transients = 0; ewin->mini_w = 0; ewin->mini_h = 0; - ewin->mini_pmap = 0; - ewin->mini_mask = 0; + ewin->mini_pmm.type = 0; + ewin->mini_pmm.pmap = 0; + ewin->mini_pmm.mask = 0; ewin->snap = NULL; - ewin->icon_pmap = 0; - ewin->icon_mask = 0; + ewin->icon_pmm.type = 0; + ewin->icon_pmm.pmap = 0; + ewin->icon_pmm.mask = 0; att.event_mask = StructureNotifyMask | ResizeRedirectMask | ButtonPressMask | @@ -1642,14 +1644,8 @@ FreeEwin(EWin * ewin) Efree(ewin->bits); if (ewin->session_id) Efree(ewin->session_id); - if (ewin->mini_pmap) - EFreePixmap(disp, ewin->mini_pmap); - if (ewin->mini_mask) - EFreePixmap(disp, ewin->mini_mask); - if (ewin->icon_pmap) - Imlib_free_pixmap(pImlibData, ewin->icon_pmap); - if (ewin->icon_mask) - Imlib_free_pixmap(pImlibData, ewin->icon_mask); + FreePmapMask(&ewin->mini_pmm); + FreePmapMask(&ewin->icon_pmm); if (ewin->groups) { num_groups = ewin->num_groups; @@ -2181,6 +2177,7 @@ void ShowEwin(EWin * ewin) { EDBUG(3, "ShowEwin"); + if (ewin->visible) EDBUG_RETURN_; if (ewin->client.win) diff --git a/src/buttons.c b/src/buttons.c index 87de396f..55c84860 100644 --- a/src/buttons.c +++ b/src/buttons.c @@ -158,7 +158,7 @@ void CalcButton(Button * b) { int w, h, x, y, xo, yo; - ImlibImage *im; + Imlib_Image *im; EDBUG(4, "CalcButton"); x = 0; @@ -172,9 +172,10 @@ CalcButton(Button * b) im = ELoadImage(b->iclass->norm.normal->im_file); if (im) { - w = im->rgb_width; - h = im->rgb_height; - Imlib_destroy_image(pImlibData, im); + imlib_context_set_image(im); + w = imlib_image_get_width(); + h = imlib_image_get_height(); + imlib_free_image(); } else { diff --git a/src/comms.c b/src/comms.c index 8cb5a08f..e3621968 100644 --- a/src/comms.c +++ b/src/comms.c @@ -505,7 +505,7 @@ HandleComms(XClientMessageEvent * ev) if (bg->top.file) Efree(bg->top.file); if (bg->pmap) - Imlib_free_pixmap(pImlibData, bg->pmap); + imlib_free_pixmap_and_mask(bg->pmap); Efree(bg); } } @@ -829,7 +829,7 @@ HandleComms(XClientMessageEvent * ev) bg->cmclass = cm; } if (bg->pmap) - Imlib_free_pixmap(pImlibData, bg->pmap); + imlib_free_pixmap_and_mask(bg->pmap); bg->pmap = 0; for (i = 0; i < ENLIGHTENMENT_CONF_NUM_DESKTOPS; i++) { @@ -987,6 +987,7 @@ HandleComms(XClientMessageEvent * ev) { Background *bg; char buf[FILEPATH_LEN_MAX]; + int r, g, b; sscanf(s, "%*s %1000s", w); bg = (Background *) FindItem(w, 0, LIST_FINDBY_NAME, @@ -994,11 +995,11 @@ HandleComms(XClientMessageEvent * ev) Esnprintf(buf, sizeof(buf), "(null)"); if (bg) { + EGetColor(&(bg->bg.solid), &r, &g, &b); if ((bg->bg.file) && (bg->top.file)) Esnprintf(buf, sizeof(buf), "%s %i %i %i %s %i %i %i %i %i %i %s %i %i %i %i %i", - bg->name, bg->bg.solid.r, bg->bg.solid.g, - bg->bg.solid.b, bg->bg.file, bg->bg.tile, + bg->name, r, g, b, bg->bg.file, bg->bg.tile, bg->bg.keep_aspect, bg->bg.xjust, bg->bg.yjust, bg->bg.xperc, bg->bg.yperc, bg->top.file, bg->top.keep_aspect, bg->top.xjust, bg->top.yjust, @@ -1006,8 +1007,7 @@ HandleComms(XClientMessageEvent * ev) else if ((!(bg->bg.file)) && (bg->top.file)) Esnprintf(buf, sizeof(buf), "%s %i %i %i %s %i %i %i %i %i %i %s %i %i %i %i %i", - bg->name, bg->bg.solid.r, bg->bg.solid.g, - bg->bg.solid.b, "(null)", bg->bg.tile, + bg->name, r, g, b, "(null)", bg->bg.tile, bg->bg.keep_aspect, bg->bg.xjust, bg->bg.yjust, bg->bg.xperc, bg->bg.yperc, bg->top.file, bg->top.keep_aspect, bg->top.xjust, bg->top.yjust, @@ -1015,8 +1015,7 @@ HandleComms(XClientMessageEvent * ev) else if ((bg->bg.file) && (!(bg->top.file))) Esnprintf(buf, sizeof(buf), "%s %i %i %i %s %i %i %i %i %i %i %s %i %i %i %i %i", - bg->name, bg->bg.solid.r, bg->bg.solid.g, - bg->bg.solid.b, bg->bg.file, bg->bg.tile, + bg->name, r, g, b, bg->bg.file, bg->bg.tile, bg->bg.keep_aspect, bg->bg.xjust, bg->bg.yjust, bg->bg.xperc, bg->bg.yperc, "(null)", bg->top.keep_aspect, bg->top.xjust, bg->top.yjust, @@ -1024,8 +1023,7 @@ HandleComms(XClientMessageEvent * ev) else if ((!(bg->bg.file)) && (!(bg->top.file))) Esnprintf(buf, sizeof(buf), "%s %i %i %i %s %i %i %i %i %i %i %s %i %i %i %i %i", - bg->name, bg->bg.solid.r, bg->bg.solid.g, - bg->bg.solid.b, "(null)", bg->bg.tile, + bg->name, r, g, b, "(null)", bg->bg.tile, bg->bg.keep_aspect, bg->bg.xjust, bg->bg.yjust, bg->bg.xperc, bg->bg.yperc, "(null)", bg->top.keep_aspect, bg->top.xjust, bg->top.yjust, @@ -1036,8 +1034,8 @@ HandleComms(XClientMessageEvent * ev) else if (!strcmp(w, "set_bg")) { Background *bg; - ImlibColor icl; - int i; + XColor xclr; + int i, r, g, b; char tmp[1024]; char *name = NULL, *bgf = NULL, *topf = NULL; int updated = 0, tile, keep_aspect, tkeep_aspect; @@ -1047,12 +1045,14 @@ HandleComms(XClientMessageEvent * ev) sscanf(s, "%1000s %1000s", tmp, w); bg = (Background *) FindItem(w, 0, LIST_FINDBY_NAME, LIST_TYPE_BACKGROUND); - icl.r = 99; + r = 99; i = sscanf(s, "%1000s %1000s %i %i %i %1000s %i %i %i %i %i %i %1000s %i %i %i %i %i", - tmp, tmp, &(icl.r), &(icl.g), &(icl.b), tmp, &tile, + tmp, tmp, &r, &g, &b, tmp, &tile, (int *)&keep_aspect, &xjust, &yjust, &xperc, &yperc, tmp, &tkeep_aspect, &txjust, &tyjust, &txperc, &typerc); + ESetColor(&xclr, r, g, b); + if (bg) { name = duplicate(w); @@ -1063,15 +1063,13 @@ HandleComms(XClientMessageEvent * ev) if (strcmp("(null)", w)) topf = duplicate(w); - if (icl.r != bg->bg.solid.r) + if (xclr.red != bg->bg.solid.red) updated = 1; - if (icl.g != bg->bg.solid.g) + if (xclr.green != bg->bg.solid.green) updated = 1; - if (icl.b != bg->bg.solid.b) + if (xclr.blue != bg->bg.solid.blue) updated = 1; - bg->bg.solid.r = icl.r; - bg->bg.solid.g = icl.g; - bg->bg.solid.b = icl.b; + bg->bg.solid = xclr; if ((bg->bg.file) && (bgf)) { if (strcmp(bg->bg.file, bgf)) @@ -1128,8 +1126,9 @@ HandleComms(XClientMessageEvent * ev) if (updated) { if (bg->pmap) - Imlib_free_pixmap(pImlibData, bg->pmap); + imlib_free_pixmap_and_mask(bg->pmap); bg->pmap = 0; + for (i = 0; i < ENLIGHTENMENT_CONF_NUM_DESKTOPS; i++) { if (desks.desk[i].bg == bg) @@ -1156,7 +1155,7 @@ HandleComms(XClientMessageEvent * ev) word(s, 13, w); if (strcmp("(null)", w)) topf = duplicate(w); - bg = CreateDesktopBG(name, &icl, bgf, tile, keep_aspect, xjust, + bg = CreateDesktopBG(name, &xclr, bgf, tile, keep_aspect, xjust, yjust, xperc, yperc, topf, tkeep_aspect, txjust, tyjust, txperc, typerc); if (name) @@ -1177,7 +1176,7 @@ HandleComms(XClientMessageEvent * ev) bg = (Background *) FindItem(w, 0, LIST_FINDBY_NAME, LIST_TYPE_BACKGROUND); if (bg) - SetBackgroundTo(pImlibData, win, bg, 0); + SetBackgroundTo(win, bg, 0); CommsSend(c, "done"); } else if (!strcmp(w, "set_controls")) @@ -1217,8 +1216,10 @@ HandleComms(XClientMessageEvent * ev) { word(s, wd, w); mode.movemode = atoi(w); - if ((prImlibData) && (mode.movemode == 5)) +#if !USE_IMLIB2 + if ((prImlib_Context) && (mode.movemode == 5)) mode.movemode = 3; +#endif } else if (!strcmp(w, "RESIZEMODE:")) { diff --git a/src/config.c b/src/config.c index 4c1e8c3f..449ae0e1 100644 --- a/src/config.c +++ b/src/config.c @@ -234,7 +234,7 @@ Config_Text(FILE * ConfigFile) char s[FILEPATH_LEN_MAX]; char s2[FILEPATH_LEN_MAX]; - int i1; + int i1, r, g, b; TextClass *tc = NULL; TextState *ts = NULL; int fields; @@ -439,13 +439,19 @@ Config_Text(FILE * ConfigFile) break; case TEXT_FG_COL: if (ts) - sscanf(s, "%*s %i %i %i", &ts->fg_col.r, &ts->fg_col.g, - &ts->fg_col.b); + { + r = g = b = 0; + sscanf(s, "%*s %i %i %i", &r, &g, &b); + ESetColor(&ts->fg_col, r, g, b); + } break; case TEXT_BG_COL: if (ts) - sscanf(s, "%*s %i %i %i", &ts->bg_col.r, &ts->bg_col.g, - &ts->bg_col.b); + { + r = g = b = 0; + sscanf(s, "%*s %i %i %i", &r, &g, &b); + ESetColor(&ts->bg_col, r, g, b); + } break; default: Alert(_ @@ -1654,8 +1660,8 @@ static void Config_Desktop(FILE * ConfigFile) { /* this sets desktop settings */ - ImlibColor icl; Background *bg = 0; + XColor xclr; char s[FILEPATH_LEN_MAX]; char s1[FILEPATH_LEN_MAX]; char s2[FILEPATH_LEN_MAX]; @@ -1669,9 +1675,7 @@ Config_Desktop(FILE * ConfigFile) ColorModifierClass *cm = NULL; int fields; - icl.r = 0; - icl.g = 0; - icl.b = 0; + ESetColor(&xclr, 0, 0, 0); while (GetLine(s, sizeof(s), ConfigFile)) { @@ -1737,7 +1741,7 @@ Config_Desktop(FILE * ConfigFile) } if (ok) { - bg = CreateDesktopBG(name, &icl, bg1, i1, i2, i3, + bg = CreateDesktopBG(name, &xclr, bg1, i1, i2, i3, i4, i5, i6, bg2, j1, j2, j3, j4, j5); AddItem(bg, bg->name, 0, LIST_TYPE_BACKGROUND); @@ -1785,11 +1789,13 @@ Config_Desktop(FILE * ConfigFile) { if ((desks.desk[atoi(s2)].bg == NULL) || (mode.user_bg)) { - if ((prImlibData) && (atoi(s2) == 0)) +#if !USE_IMLIB2 + if ((prImlib_Context) && (atoi(s2) == 0)) bg = NULL; +#endif if (!bg) { - bg = CreateDesktopBG(name, &icl, bg1, i1, i2, + bg = CreateDesktopBG(name, &xclr, bg1, i1, i2, i3, i4, i5, i6, bg2, j1, j2, j3, j4, j5); AddItem(bg, bg->name, 0, LIST_TYPE_BACKGROUND); @@ -1802,8 +1808,10 @@ Config_Desktop(FILE * ConfigFile) { SetDesktopBg(atoi(s2), bg); } - if ((prImlibData) && (atoi(s2) == 0)) +#if !USE_IMLIB2 + if ((prImlib_Context) && (atoi(s2) == 0)) bg = NULL; +#endif } } } @@ -1824,21 +1832,21 @@ Config_Desktop(FILE * ConfigFile) { SetDesktopBg(atoi(s2), bg); } - if ((prImlibData) && (atoi(s2) == 0)) +#if !USE_IMLIB2 + if ((prImlib_Context) && (atoi(s2) == 0)) bg = NULL; +#endif } } } } break; case BG_RGB: - sscanf(s, "%4000s %d %d %d", s1, &icl.r, &icl.g, &icl.b); + i1 = i2 = i3 = 0; + sscanf(s, "%4000s %d %d %d", s1, &i1, &i2, &i3); + ESetColor(&xclr, i1, i2, i3); if (ignore) - { - bg->bg.solid.r = icl.r; - bg->bg.solid.g = icl.g; - bg->bg.solid.b = icl.b; - } + bg->bg.solid = xclr; break; case BG_BG1: sscanf(s, "%4000s %4000s %d %d %d %d %d %d", s1, s2, &i1, &i2, @@ -1909,21 +1917,17 @@ Config_Desktop(FILE * ConfigFile) static void Config_ECursor(FILE * ConfigFile) { - ImlibColor icl, icl2; + XColor xclr, xclr2; char s[FILEPATH_LEN_MAX]; char s2[FILEPATH_LEN_MAX]; - int ii1; + int ii1, r, g, b; char *file = NULL, *name = NULL; int native_id = -1; ECursor *ec = NULL; int fields; - icl.r = 0; - icl.g = 0; - icl.b = 0; - icl2.r = 255; - icl2.g = 255; - icl2.b = 255; + ESetColor(&xclr, 0, 0, 0); + ESetColor(&xclr2, 255, 255, 255); while (GetLine(s, sizeof(s), ConfigFile)) { @@ -1948,7 +1952,7 @@ Config_ECursor(FILE * ConfigFile) switch (ii1) { case CONFIG_CLOSE: - ec = CreateECursor(name, file, native_id, &icl, &icl2); + ec = CreateECursor(name, file, native_id, &xclr, &xclr2); if (ec) AddItem(ec, ec->name, 0, LIST_TYPE_ECURSOR); if (name) @@ -1963,10 +1967,14 @@ Config_ECursor(FILE * ConfigFile) name = duplicate(s2); break; case CURS_BG_RGB: - sscanf(s, "%4000s %d %d %d", s2, &icl.r, &icl.g, &icl.b); + EGetColor(&xclr, &r, &g, &b); + sscanf(s, "%4000s %d %d %d", s2, &r, &g, &b); + ESetColor(&xclr, r, g, b); break; case CURS_FG_RGB: - sscanf(s, "%4000s %d %d %d", s2, &icl2.r, &icl2.g, &icl2.b); + EGetColor(&xclr, &r, &g, &b); + sscanf(s, "%4000s %d %d %d", s2, &r, &g, &b); + ESetColor(&xclr, r, g, b); break; case XBM_FILE: file = duplicate(s2); @@ -2382,7 +2390,7 @@ Config_ImageClass(FILE * ConfigFile) char s4[FILEPATH_LEN_MAX]; char s5[FILEPATH_LEN_MAX]; - ICToRead->border = Emalloc(sizeof(ImlibBorder)); + ICToRead->border = Emalloc(sizeof(Imlib_Border)); sscanf(s, "%4000s %4000s %4000s %4000s %4000s", s1, s2, s3, s4, s5); @@ -3818,7 +3826,7 @@ SaveUserControlConfig(FILE * autosavefile) ActionClass *ac; Action *aa; int i, num, flags, j; - int a, b; + int a, b, r, g; EDBUG(5, "SaveUserControlConfig"); if (autosavefile) @@ -4142,8 +4150,8 @@ SaveUserControlConfig(FILE * autosavefile) { fprintf(autosavefile, "5 999\n"); fprintf(autosavefile, "100 %s\n", bglist[i]->name); - fprintf(autosavefile, "560 %d %d %d\n", bglist[i]->bg.solid.r, - bglist[i]->bg.solid.g, bglist[i]->bg.solid.b); + EGetColor(&(bglist[i]->bg.solid), &r, &g, &b); + fprintf(autosavefile, "560 %d %d %d\n", r, g, b); if ((bglist[i]->bg.file) && (!bglist[i]->bg.real_file)) bglist[i]->bg.real_file = FindFile(bglist[i]->bg.file); if ((bglist[i]->top.file) && (!bglist[i]->top.real_file)) diff --git a/src/cursors.c b/src/cursors.c index 6dcdc2f8..aacd3272 100644 --- a/src/cursors.c +++ b/src/cursors.c @@ -23,17 +23,14 @@ #include "E.h" ECursor * -CreateECursor(char *name, char *image, int native_id, - ImlibColor * fg, ImlibColor * bg) +CreateECursor(char *name, char *image, int native_id, XColor * fg, XColor * bg) { Cursor curs; - XColor xfg, xbg; Pixmap pmap, mask; int xh, yh; unsigned int w, h, ww, hh; char *img, msk[FILEPATH_LEN_MAX]; ECursor *ec; - int r, g, b; if ((!name) || (!image && native_id == -1)) return NULL; @@ -59,22 +56,12 @@ CreateECursor(char *name, char *image, int native_id, Efree(img); return NULL; } - r = fg->r; - g = fg->g; - b = fg->b; - xfg.red = (fg->r << 8) | (fg->r); - xfg.green = (fg->g << 8) | (fg->g); - xfg.blue = (fg->b << 8) | (fg->b); - xfg.pixel = Imlib_best_color_match(pImlibData, &r, &g, &b); - r = bg->r; - g = bg->g; - b = bg->b; - xbg.red = (bg->r << 8) | (bg->r); - xbg.green = (bg->g << 8) | (bg->g); - xbg.blue = (bg->b << 8) | (bg->b); - xbg.pixel = Imlib_best_color_match(pImlibData, &r, &g, &b); + + EAllocColor(fg); + EAllocColor(bg); + curs = 0; - curs = XCreatePixmapCursor(disp, pmap, mask, &xfg, &xbg, xh, yh); + curs = XCreatePixmapCursor(disp, pmap, mask, fg, bg, xh, yh); EFreePixmap(disp, pmap); EFreePixmap(disp, mask); Efree(img); @@ -87,8 +74,10 @@ CreateECursor(char *name, char *image, int native_id, ec = Emalloc(sizeof(ECursor)); ec->name = duplicate(name); ec->file = duplicate(image); +#if 0 /* Not used */ ec->fg = *fg; ec->bg = *bg; +#endif ec->cursor = curs; ec->ref_count = 0; ec->inroot = 0; diff --git a/src/desktops.c b/src/desktops.c index 5de6a834..98b9e65f 100644 --- a/src/desktops.c +++ b/src/desktops.c @@ -36,11 +36,11 @@ GetUniqueBGString(Background * bg) /* cyrillic symbols from 866 page correctly handled instead of eng. capitals */ #endif + int r, g, b; int n1, n2, n3, n4, n5, f1, f2, f3, f4, f5, f6; - n1 = (bg->bg.solid.r << 24) | (bg->bg.solid.g << 16) | (bg->bg.solid. - b << 8) | (bg->bg. - tile << 7) + EGetColor(&(bg->bg.solid), &r, &g, &b); + n1 = (r << 24) | (g << 16) | (b << 8) | (bg->bg.tile << 7) | (bg->bg.keep_aspect << 6) | (bg->top.keep_aspect << 5); n2 = (bg->bg.xjust << 16) | (bg->bg.yjust); n3 = (bg->bg.xperc << 16) | (bg->bg.yperc); @@ -295,6 +295,26 @@ SlideWindowTo(Window win, int fx, int fy, int tx, int ty, int speed) EDBUG_RETURN_; } +static void +FreeBGimages(Background * bg) +{ + if (bg->bg.im) + { + imlib_context_set_image(bg->bg.im); + imlib_free_image(); + bg->bg.im = NULL; + } + if (bg->top.im) + { + imlib_context_set_image(bg->top.im); + imlib_free_image(); + bg->top.im = NULL; + } + if (bg->pmap) + imlib_free_pixmap_and_mask(bg->pmap); + bg->pmap = 0; +} + void KeepBGimages(Background * bg, char onoff) { @@ -305,15 +325,7 @@ KeepBGimages(Background * bg, char onoff) else { bg->keepim = 0; - if (bg->bg.im) - Imlib_destroy_image(pImlibData, bg->bg.im); - bg->bg.im = NULL; - if (bg->top.im) - Imlib_destroy_image(pImlibData, bg->top.im); - bg->top.im = NULL; - if (bg->pmap) - Imlib_free_pixmap(pImlibData, bg->pmap); - bg->pmap = 0; + FreeBGimages(bg); } } @@ -322,20 +334,15 @@ RemoveImagesFromBG(Background * bg) { if (bg->bg.file) Efree(bg->bg.file); + bg->bg.file = NULL; + if (bg->bg.real_file) Efree(bg->bg.real_file); - bg->bg.file = NULL; bg->bg.real_file = NULL; - if (bg->bg.im) - Imlib_destroy_image(pImlibData, bg->bg.im); - bg->bg.im = NULL; - if (bg->top.im) - Imlib_destroy_image(pImlibData, bg->top.im); - bg->top.im = NULL; + + FreeBGimages(bg); + bg->keepim = 0; - if (bg->pmap) - Imlib_free_pixmap(pImlibData, bg->pmap); - bg->pmap = 0; } void @@ -358,95 +365,59 @@ FreeDesktopBG(Background * bg) EDBUG_RETURN_; } - if (bg->bg.file) - Efree(bg->bg.file); - if (bg->bg.real_file) - Efree(bg->bg.real_file); - if (bg->bg.im) - Imlib_destroy_image(pImlibData, bg->bg.im); - if (bg->top.file) - Efree(bg->top.file); - if (bg->top.real_file) - Efree(bg->top.real_file); - if (bg->top.im) - Imlib_destroy_image(pImlibData, bg->top.im); - if (bg->pmap) - Imlib_free_pixmap(pImlibData, bg->pmap); + RemoveImagesFromBG(bg); + if (bg->name) Efree(bg->name); + Efree(bg); EDBUG_RETURN_; } Background * -CreateDesktopBG(char *name, ImlibColor * solid, char *bg, char tile, +CreateDesktopBG(char *name, XColor * solid, char *bg, char tile, char keep_aspect, int xjust, int yjust, int xperc, int yperc, char *top, char tkeep_aspect, int txjust, int tyjust, int txperc, int typerc) { - ImlibData *imd; Background *d; EDBUG(6, "CreateDesktopBG"); - if (prImlibData) - { - imd = prImlibData; - } - else - { - imd = pImlibData; - } - d = Emalloc(sizeof(Background)); if (!d) EDBUG_RETURN(NULL); d->name = duplicate(name); d->pmap = 0; d->last_viewed = 0; - d->bg.solid.r = 160; - d->bg.solid.g = 160; - d->bg.solid.b = 160; - d->bg.file = NULL; - d->bg.real_file = NULL; - d->bg.im = NULL; - d->bg.tile = 1; - d->bg.keep_aspect = 1; - d->bg.xjust = 512; - d->bg.yjust = 512; - d->bg.xperc = 1024; - d->bg.yperc = 1024; - d->top.file = NULL; - d->top.real_file = NULL; - d->top.im = NULL; - d->top.keep_aspect = 1; - d->top.xjust = 512; - d->top.yjust = 512; - d->top.xperc = 0; - d->top.yperc = 0; + + ESetColor(&(d->bg.solid), 160, 160, 160); if (solid) - { - d->bg.solid.r = solid->r; - d->bg.solid.g = solid->g; - d->bg.solid.b = solid->b; - } + d->bg.solid = *solid; d->bg.file = NULL; if (bg) d->bg.file = duplicate(bg); + d->bg.real_file = NULL; + d->bg.im = NULL; d->bg.tile = tile; d->bg.keep_aspect = keep_aspect; d->bg.xjust = xjust; d->bg.yjust = yjust; d->bg.xperc = xperc; d->bg.yperc = yperc; + + d->top.file = NULL; if (top) d->top.file = duplicate(top); + d->top.real_file = NULL; + d->top.im = NULL; d->top.keep_aspect = tkeep_aspect; d->top.xjust = txjust; d->top.yjust = tyjust; d->top.xperc = txperc; d->top.yperc = typerc; + d->cmclass = NULL; d->keepim = 0; d->ref_count = 0; @@ -466,29 +437,25 @@ void RefreshDesktop(int num) { Background *dsk; - ImlibData *imd; EDBUG(4, "RefreshDesktop"); num = num % ENLIGHTENMENT_CONF_NUM_DESKTOPS; if (!desks.desk[num].viewable) EDBUG_RETURN_; + dsk = desks.desk[num].bg; if (!dsk) EDBUG_RETURN_; - if ((prImlibData) && (num == 0)) - imd = prImlibData; - else - imd = pImlibData; - SetBackgroundTo(imd, desks.desk[num].win, dsk, 1); + SetBackgroundTo(desks.desk[num].win, dsk, 1); EDBUG_RETURN_; } void -SetBackgroundTo(ImlibData * imd, Window win, Background * dsk, char setbg) +SetBackgroundTo(Window win, Background * dsk, char setbg) { - int r, g, b, w, h, x, y, ww, hh; + int w, h, x, y, ww, hh; unsigned int rw, rh; Pixmap pmap, mask, dpmap; GC gc; @@ -501,25 +468,26 @@ SetBackgroundTo(ImlibData * imd, Window win, Background * dsk, char setbg) if (!WinExists(win)) EDBUG_RETURN_; + + IMLIB1_SET_CONTEXT(win == root.win); + GetWinWH(win, &rw, &rh); depth = GetWinDepth(win); - if ((depth != imd->x.depth) && (prImlibData) - && (depth == prImlibData->x.depth)) - imd = prImlibData; - r = dsk->bg.solid.r; - g = dsk->bg.solid.g; - b = dsk->bg.solid.b; - dsk->bg.solid.pixel = Imlib_best_color_match(imd, &r, &g, &b); - pmap = 0; + + EAllocColor(&dsk->bg.solid); + pmap = mask = 0; gc = 0; w = 0; h = 0; hasbg = 0; hasfg = 0; - rt = Imlib_get_render_type(pImlibData); + rt = imlib_context_get_dither(); if (desks.hiqualitybg) - Imlib_set_render_type(imd, RT_DITHER_TRUECOL); + { + imlib_context_set_dither(1); +// imlib_context_set_anti_alias(1); + } dpmap = dsk->pmap; if (!setbg) @@ -544,47 +512,55 @@ SetBackgroundTo(ImlibData * imd, Window win, Background * dsk, char setbg) { if (!dsk->bg.real_file) dsk->bg.real_file = FindFile(dsk->bg.file); - dsk->bg.im = ELoadImageImlibData(imd, dsk->bg.real_file); + dsk->bg.im = ELoadImage(dsk->bg.real_file); } } + if (dsk->top.file) { if (!dsk->top.im) { if (!dsk->top.real_file) dsk->top.real_file = FindFile(dsk->top.file); - dsk->top.im = ELoadImageImlibData(imd, dsk->top.real_file); + dsk->top.im = ELoadImage(dsk->top.real_file); } } + if (cm) { cm->ref_count++; +#if !USE_IMLIB2 if (dsk->top.im) { - Imlib_set_image_red_curve(pImlibData, dsk->top.im, + Imlib_set_image_red_curve(pImlib_Context, dsk->top.im, cm->red.map); - Imlib_set_image_green_curve(pImlibData, dsk->top.im, + Imlib_set_image_green_curve(pImlib_Context, dsk->top.im, cm->green.map); - Imlib_set_image_blue_curve(pImlibData, dsk->top.im, + Imlib_set_image_blue_curve(pImlib_Context, dsk->top.im, cm->blue.map); } if (dsk->bg.im) { - Imlib_set_image_red_curve(pImlibData, dsk->bg.im, + Imlib_set_image_red_curve(pImlib_Context, dsk->bg.im, cm->red.map); - Imlib_set_image_green_curve(pImlibData, dsk->bg.im, + Imlib_set_image_green_curve(pImlib_Context, dsk->bg.im, cm->green.map); - Imlib_set_image_blue_curve(pImlibData, dsk->bg.im, + Imlib_set_image_blue_curve(pImlib_Context, dsk->bg.im, cm->blue.map); } +#endif } } + if (dsk->top.im) hasfg = 1; if (dsk->bg.im) hasbg = 1; + if ((hasfg) && (hasbg)) { + imlib_context_set_image(dsk->bg.im); + if (dsk->bg.xperc > 0) { w = (rw * dsk->bg.xperc) >> 10; @@ -592,10 +568,11 @@ SetBackgroundTo(ImlibData * imd, Window win, Background * dsk, char setbg) else { if (!setbg) - w = (dsk->bg.im->rgb_width * rw) / root.w; + w = (imlib_image_get_width() * rw) / root.w; else - w = dsk->bg.im->rgb_width; + w = imlib_image_get_width(); } + if (dsk->bg.yperc > 0) { h = (rh * dsk->bg.yperc) >> 10; @@ -604,33 +581,40 @@ SetBackgroundTo(ImlibData * imd, Window win, Background * dsk, char setbg) { if (!setbg) { - h = (dsk->bg.im->rgb_height * rh) / root.h; + h = (imlib_image_get_height() * rh) / root.h; } else { - h = dsk->bg.im->rgb_height; + h = imlib_image_get_height(); } } + if (w <= 0) w = 1; if (h <= 0) h = 1; + if (dsk->bg.keep_aspect) { if (dsk->bg.yperc <= 0) { if (((w << 10) / h) != - ((dsk->bg.im->rgb_width << 10) / dsk->bg.im->rgb_height)) - h = ((w * dsk->bg.im->rgb_height) / dsk->bg.im->rgb_width); + ((imlib_image_get_width() << 10) / + imlib_image_get_height())) + h = ((w * imlib_image_get_height()) / + imlib_image_get_width()); } else { if (((h << 10) / w) != - ((dsk->bg.im->rgb_height << 10) / dsk->bg.im->rgb_width)) - w = ((h * dsk->bg.im->rgb_width) / dsk->bg.im->rgb_height); + ((imlib_image_get_height() << 10) / + imlib_image_get_width())) + w = ((h * imlib_image_get_width()) / + imlib_image_get_height()); } } - dpmap = ECreatePixmap(disp, win, rw, rh, imd->x.depth); + + dpmap = ECreatePixmap(disp, win, rw, rh, depth); gc = XCreateGC(disp, dpmap, 0, &gcv); if (!dsk->bg.tile) { @@ -639,8 +623,7 @@ SetBackgroundTo(ImlibData * imd, Window win, Background * dsk, char setbg) } x = ((rw - w) * dsk->bg.xjust) >> 10; y = ((rh - h) * dsk->bg.yjust) >> 10; - Imlib_render(imd, dsk->bg.im, w, h); - pmap = Imlib_move_image(imd, dsk->bg.im); + imlib_render_pixmaps_for_whole_image_at_size(&pmap, &mask, w, h); XSetTile(disp, gc, pmap); XSetTSOrigin(disp, gc, x, y); XSetFillStyle(disp, gc, FillTiled); @@ -652,7 +635,9 @@ SetBackgroundTo(ImlibData * imd, Window win, Background * dsk, char setbg) { XFillRectangle(disp, dpmap, gc, 0, 0, rw, rh); } - Imlib_free_pixmap(imd, pmap); + imlib_free_pixmap_and_mask(pmap); + + imlib_context_set_image(dsk->top.im); if (dsk->top.xperc > 0) { @@ -662,11 +647,11 @@ SetBackgroundTo(ImlibData * imd, Window win, Background * dsk, char setbg) { if (!setbg) { - ww = (dsk->top.im->rgb_width * rw) / root.w; + ww = (imlib_image_get_width() * rw) / root.w; } else { - ww = dsk->top.im->rgb_width; + ww = imlib_image_get_width(); } } if (dsk->top.yperc > 0) @@ -677,11 +662,11 @@ SetBackgroundTo(ImlibData * imd, Window win, Background * dsk, char setbg) { if (!setbg) { - hh = (dsk->top.im->rgb_height * rh) / root.h; + hh = (imlib_image_get_height() * rh) / root.h; } else { - hh = dsk->top.im->rgb_height; + hh = imlib_image_get_height(); } } if (ww <= 0) @@ -693,23 +678,23 @@ SetBackgroundTo(ImlibData * imd, Window win, Background * dsk, char setbg) if (dsk->top.yperc <= 0) { if (((ww << 10) / hh) != - ((dsk->top.im->rgb_width << 10) / - dsk->top.im->rgb_height)) - hh = ((ww * dsk->top.im->rgb_height) / - dsk->top.im->rgb_width); + ((imlib_image_get_width() << 10) / + imlib_image_get_height())) + hh = + ((ww * imlib_image_get_height()) / + imlib_image_get_width()); } else { if (((hh << 10) / ww) != - ((dsk->top.im->rgb_height << 10) / - dsk->top.im->rgb_width)) - ww = ((hh * dsk->top.im->rgb_width) / - dsk->top.im->rgb_height); + ((imlib_image_get_height() << 10) / + imlib_image_get_width())) + ww = + ((hh * imlib_image_get_width()) / + imlib_image_get_height()); } } - Imlib_render(imd, dsk->top.im, ww, hh); - pmap = Imlib_move_image(imd, dsk->top.im); - mask = Imlib_move_mask(imd, dsk->top.im); + imlib_render_pixmaps_for_whole_image_at_size(&pmap, &mask, ww, hh); x = ((rw - ww) * dsk->top.xjust) >> 10; y = ((rh - hh) * dsk->top.yjust) >> 10; XSetTile(disp, gc, pmap); @@ -721,45 +706,54 @@ SetBackgroundTo(ImlibData * imd, Window win, Background * dsk, char setbg) XSetClipOrigin(disp, gc, x, y); } XFillRectangle(disp, dpmap, gc, x, y, ww, hh); - Imlib_free_pixmap(imd, pmap); + imlib_free_pixmap_and_mask(pmap); } else if (hasbg) { + imlib_context_set_image(dsk->bg.im); + if (dsk->bg.xperc > 0) w = (rw * dsk->bg.xperc) >> 10; else { if (!setbg) - w = (dsk->bg.im->rgb_width * rw) / root.w; + w = (imlib_image_get_width() * rw) / root.w; else - w = dsk->bg.im->rgb_width; + w = imlib_image_get_width(); } + if (dsk->bg.yperc > 0) h = (rh * dsk->bg.yperc) >> 10; else { if (!setbg) - h = (dsk->bg.im->rgb_height * rh) / root.h; + h = (imlib_image_get_height() * rh) / root.h; else - h = dsk->bg.im->rgb_height; + h = imlib_image_get_height(); } + if (w <= 0) w = 1; if (h <= 0) h = 1; + if (dsk->bg.keep_aspect) { if (dsk->bg.yperc <= 0) { if (((w << 10) / h) != - ((dsk->bg.im->rgb_width << 10) / dsk->bg.im->rgb_height)) - h = ((w * dsk->bg.im->rgb_height) / dsk->bg.im->rgb_width); + ((imlib_image_get_width() << 10) / + imlib_image_get_height())) + h = ((w * imlib_image_get_height()) / + imlib_image_get_width()); } else { if (((h << 10) / w) != - ((dsk->bg.im->rgb_height << 10) / dsk->bg.im->rgb_width)) - w = ((h * dsk->bg.im->rgb_width) / dsk->bg.im->rgb_height); + ((imlib_image_get_height() << 10) / + imlib_image_get_width())) + w = ((h * imlib_image_get_width()) / + imlib_image_get_height()); } } dpmap = 0; @@ -771,14 +765,14 @@ SetBackgroundTo(ImlibData * imd, Window win, Background * dsk, char setbg) { if ((x != 0) || (y != 0)) { - dpmap = ECreatePixmap(disp, win, w, h, imd->x.depth); + dpmap = ECreatePixmap(disp, win, w, h, depth); gc = XCreateGC(disp, dpmap, 0, &gcv); } } else if ((x != 0) || (y != 0) || ((int)rw != (int)w) || ((int)rh != (int)h)) { - dpmap = ECreatePixmap(disp, win, rw, rh, imd->x.depth); + dpmap = ECreatePixmap(disp, win, rw, rh, depth); gc = XCreateGC(disp, dpmap, 0, &gcv); XSetForeground(disp, gc, dsk->bg.solid.pixel); XFillRectangle(disp, dpmap, gc, 0, 0, rw, rh); @@ -788,19 +782,18 @@ SetBackgroundTo(ImlibData * imd, Window win, Background * dsk, char setbg) { if (dsk->bg.tile) { - dpmap = ECreatePixmap(disp, win, w, h, imd->x.depth); + dpmap = ECreatePixmap(disp, win, w, h, depth); gc = XCreateGC(disp, dpmap, 0, &gcv); } else { - dpmap = ECreatePixmap(disp, win, rw, rh, imd->x.depth); + dpmap = ECreatePixmap(disp, win, rw, rh, depth); gc = XCreateGC(disp, dpmap, 0, &gcv); XSetForeground(disp, gc, dsk->bg.solid.pixel); XFillRectangle(disp, dpmap, gc, 0, 0, rw, rh); } } - Imlib_render(imd, dsk->bg.im, w, h); - pmap = Imlib_move_image(imd, dsk->bg.im); + imlib_render_pixmaps_for_whole_image_at_size(&pmap, &mask, w, h); if (dpmap) { XSetTile(disp, gc, pmap); @@ -814,18 +807,20 @@ SetBackgroundTo(ImlibData * imd, Window win, Background * dsk, char setbg) { XFillRectangle(disp, dpmap, gc, x, y, w, h); } - Imlib_free_pixmap(imd, pmap); + imlib_free_pixmap_and_mask(pmap); } else dpmap = pmap; } else if (hasfg) { - dpmap = ECreatePixmap(disp, win, rw, rh, imd->x.depth); + dpmap = ECreatePixmap(disp, win, rw, rh, depth); gc = XCreateGC(disp, dpmap, 0, &gcv); XSetForeground(disp, gc, dsk->bg.solid.pixel); XFillRectangle(disp, dpmap, gc, 0, 0, rw, rh); + imlib_context_set_image(dsk->top.im); + if (dsk->top.xperc > 0) { ww = (rw * dsk->top.xperc) >> 10; @@ -834,11 +829,11 @@ SetBackgroundTo(ImlibData * imd, Window win, Background * dsk, char setbg) { if (!setbg) { - ww = (dsk->top.im->rgb_width * rw) / root.w; + ww = (imlib_image_get_width() * rw) / root.w; } else { - ww = dsk->top.im->rgb_width; + ww = imlib_image_get_width(); } } @@ -850,11 +845,11 @@ SetBackgroundTo(ImlibData * imd, Window win, Background * dsk, char setbg) { if (!setbg) { - hh = (dsk->top.im->rgb_height * rh) / root.h; + hh = (imlib_image_get_height() * rh) / root.h; } else { - hh = dsk->top.im->rgb_height; + hh = imlib_image_get_height(); } } if (ww <= 0) @@ -866,23 +861,23 @@ SetBackgroundTo(ImlibData * imd, Window win, Background * dsk, char setbg) if (dsk->top.yperc <= 0) { if (((ww << 10) / hh) != - ((dsk->top.im->rgb_width << 10) / - dsk->top.im->rgb_height)) - hh = ((ww * dsk->top.im->rgb_height) / - dsk->top.im->rgb_width); + ((imlib_image_get_width() << 10) / + imlib_image_get_height())) + hh = + ((ww * imlib_image_get_height()) / + imlib_image_get_width()); } else { if (((hh << 10) / ww) != - ((dsk->top.im->rgb_height << 10) / - dsk->top.im->rgb_width)) - ww = ((hh * dsk->top.im->rgb_width) / - dsk->top.im->rgb_height); + ((imlib_image_get_height() << 10) / + imlib_image_get_width())) + ww = + ((hh * imlib_image_get_width()) / + imlib_image_get_height()); } } - Imlib_render(imd, dsk->top.im, ww, hh); - pmap = Imlib_move_image(imd, dsk->top.im); - mask = Imlib_move_mask(imd, dsk->top.im); + imlib_render_pixmaps_for_whole_image_at_size(&pmap, &mask, ww, hh); x = ((rw - ww) * dsk->top.xjust) >> 10; y = ((rh - hh) * dsk->top.yjust) >> 10; XSetTile(disp, gc, pmap); @@ -894,16 +889,22 @@ SetBackgroundTo(ImlibData * imd, Window win, Background * dsk, char setbg) XSetClipOrigin(disp, gc, x, y); } XFillRectangle(disp, dpmap, gc, x, y, ww, hh); - Imlib_free_pixmap(imd, pmap); + imlib_free_pixmap_and_mask(pmap); } if (!dsk->keepim) { if (dsk->top.im) - Imlib_destroy_image(imd, dsk->top.im); + { + imlib_context_set_image(dsk->top.im); + imlib_free_image(); + dsk->top.im = NULL; + } if (dsk->bg.im) - Imlib_destroy_image(imd, dsk->bg.im); - dsk->top.im = NULL; - dsk->bg.im = NULL; + { + imlib_context_set_image(dsk->bg.im); + imlib_free_image(); + dsk->bg.im = NULL; + } } if (setbg) { @@ -928,7 +929,7 @@ SetBackgroundTo(ImlibData * imd, Window win, Background * dsk, char setbg) XSetTSOrigin(disp, gc, 0, 0); XSetFillStyle(disp, gc, FillTiled); XFillRectangle(disp, win, gc, 0, 0, rw, rh); - Imlib_free_pixmap(imd, dpmap); + imlib_free_pixmap_and_mask(dpmap); } else { @@ -941,12 +942,15 @@ SetBackgroundTo(ImlibData * imd, Window win, Background * dsk, char setbg) } XSync(disp, False); } + if (gc) XFreeGC(disp, gc); - Imlib_set_render_type(imd, rt); + + imlib_context_set_dither(rt); + + IMLIB1_SET_CONTEXT(0); EDBUG_RETURN_; - } void @@ -2160,7 +2164,6 @@ DesktopAccounting() time_t now; int i, j, num; Background **lst; - ImlibData *imd = 0; EDBUG(3, "DesktopAccounting"); now = time(NULL); @@ -2169,39 +2172,30 @@ DesktopAccounting() if ((desks.desk[i].bg) && (desks.desk[i].viewable)) desks.desk[i].bg->last_viewed = now; } + lst = (Background **) ListItemType(&num, LIST_TYPE_BACKGROUND); if (lst) { for (i = 0; i < num; i++) { - if (lst[i]->pmap) + if ((lst[i]->pmap == 0) || + ((now - lst[i]->last_viewed) <= mode.desktop_bg_timeout)) + continue; + + IMLIB1_SET_CONTEXT(lst[i] == desks.desk[0].bg); + imlib_free_pixmap_and_mask(lst[i]->pmap); + lst[i]->pmap = 0; + + for (j = 0; j < ENLIGHTENMENT_CONF_NUM_DESKTOPS; j++) { - if ((now - lst[i]->last_viewed) > mode.desktop_bg_timeout) - { - imd = pImlibData; - for (j = 0; j < ENLIGHTENMENT_CONF_NUM_DESKTOPS; j++) - { - if (desks.desk[j].bg == lst[i]) - { - if ((prImlibData) && (j == 0)) - imd = prImlibData; - else - imd = pImlibData; - j = ENLIGHTENMENT_CONF_NUM_DESKTOPS; - } - } - Imlib_free_pixmap(imd, lst[i]->pmap); - lst[i]->pmap = 0; - for (j = 0; j < ENLIGHTENMENT_CONF_NUM_DESKTOPS; j++) - { - if ((desks.desk[j].bg == lst[i]) - && (!desks.desk[j].viewable)) - SetBG(desks.desk[j].win, 0, 0); - } - } + if ((desks.desk[j].bg == lst[i]) && (!desks.desk[j].viewable)) + SetBG(desks.desk[j].win, 0, 0); } + } Efree(lst); + IMLIB1_SET_CONTEXT(0); } + EDBUG_RETURN_; } diff --git a/src/dialog.c b/src/dialog.c index be9fe02f..a42f63fb 100644 --- a/src/dialog.c +++ b/src/dialog.c @@ -136,7 +136,7 @@ struct _ditem void *data; ImageClass *iclass; TextClass *tclass; - ImlibBorder padding; + Imlib_Border padding; char fill_h; char fill_v; int align_h; @@ -220,9 +220,7 @@ DialogRealizeTClassDefault(void) d_tc_default->norm.normal = CreateTextState(); d_tc_default->norm.normal->fontname = duplicate("-*-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*"); - d_tc_default->norm.normal->fg_col.r = 0; - d_tc_default->norm.normal->fg_col.g = 0; - d_tc_default->norm.normal->fg_col.b = 0; + ESetColor(&(d_tc_default->norm.normal->fg_col), 0, 0, 0); } } @@ -235,111 +233,51 @@ DialogRealizeIClassDefault(void) d_ic_default->name = NULL; d_ic_default->norm.normal = CreateImageState(); - d_ic_default->norm.normal->hihi.r = 255; - d_ic_default->norm.normal->hihi.g = 255; - d_ic_default->norm.normal->hihi.b = 255; - d_ic_default->norm.normal->hi.r = 220; - d_ic_default->norm.normal->hi.g = 220; - d_ic_default->norm.normal->hi.b = 220; - d_ic_default->norm.normal->bg.r = 160; - d_ic_default->norm.normal->bg.g = 160; - d_ic_default->norm.normal->bg.b = 160; - d_ic_default->norm.normal->lo.r = 100; - d_ic_default->norm.normal->lo.g = 100; - d_ic_default->norm.normal->lo.b = 100; - d_ic_default->norm.normal->lolo.r = 0; - d_ic_default->norm.normal->lolo.g = 0; - d_ic_default->norm.normal->lolo.b = 0; + ESetColor(&(d_ic_default->norm.normal->hihi), 255, 255, 255); + ESetColor(&(d_ic_default->norm.normal->hi), 220, 220, 220); + ESetColor(&(d_ic_default->norm.normal->bg), 160, 160, 160); + ESetColor(&(d_ic_default->norm.normal->lo), 100, 100, 100); + ESetColor(&(d_ic_default->norm.normal->lolo), 0, 0, 0); d_ic_default->norm.normal->bevelstyle = BEVEL_NEXT; d_ic_default->norm.hilited = CreateImageState(); - d_ic_default->norm.hilited->hihi.r = 255; - d_ic_default->norm.hilited->hihi.g = 255; - d_ic_default->norm.hilited->hihi.b = 255; - d_ic_default->norm.hilited->hi.r = 240; - d_ic_default->norm.hilited->hi.g = 240; - d_ic_default->norm.hilited->hi.b = 240; - d_ic_default->norm.hilited->bg.r = 200; - d_ic_default->norm.hilited->bg.g = 200; - d_ic_default->norm.hilited->bg.b = 200; - d_ic_default->norm.hilited->lo.r = 160; - d_ic_default->norm.hilited->lo.g = 160; - d_ic_default->norm.hilited->lo.b = 160; - d_ic_default->norm.hilited->lolo.r = 0; - d_ic_default->norm.hilited->lolo.g = 0; - d_ic_default->norm.hilited->lolo.b = 0; + ESetColor(&(d_ic_default->norm.hilited->hihi), 255, 255, 255); + ESetColor(&(d_ic_default->norm.hilited->hi), 240, 240, 240); + ESetColor(&(d_ic_default->norm.hilited->bg), 200, 200, 200); + ESetColor(&(d_ic_default->norm.hilited->lo), 160, 160, 160); + ESetColor(&(d_ic_default->norm.hilited->lolo), 0, 0, 0); d_ic_default->norm.hilited->bevelstyle = BEVEL_NEXT; d_ic_default->norm.clicked = CreateImageState(); - d_ic_default->norm.clicked->hihi.r = 0; - d_ic_default->norm.clicked->hihi.g = 0; - d_ic_default->norm.clicked->hihi.b = 0; - d_ic_default->norm.clicked->hi.r = 100; - d_ic_default->norm.clicked->hi.g = 100; - d_ic_default->norm.clicked->hi.b = 100; - d_ic_default->norm.clicked->bg.r = 160; - d_ic_default->norm.clicked->bg.g = 160; - d_ic_default->norm.clicked->bg.b = 160; - d_ic_default->norm.clicked->lo.r = 220; - d_ic_default->norm.clicked->lo.g = 220; - d_ic_default->norm.clicked->lo.b = 220; - d_ic_default->norm.clicked->lolo.r = 255; - d_ic_default->norm.clicked->lolo.g = 255; - d_ic_default->norm.clicked->lolo.b = 255; + ESetColor(&(d_ic_default->norm.clicked->hihi), 0, 0, 0); + ESetColor(&(d_ic_default->norm.clicked->hi), 100, 100, 100); + ESetColor(&(d_ic_default->norm.clicked->bg), 160, 160, 160); + ESetColor(&(d_ic_default->norm.clicked->lo), 220, 220, 220); + ESetColor(&(d_ic_default->norm.clicked->lolo), 255, 255, 255); d_ic_default->norm.clicked->bevelstyle = BEVEL_NEXT; d_ic_default->active.normal = CreateImageState(); - d_ic_default->active.normal->hihi.r = 0; - d_ic_default->active.normal->hihi.g = 0; - d_ic_default->active.normal->hihi.b = 0; - d_ic_default->active.normal->hi.r = 100; - d_ic_default->active.normal->hi.g = 100; - d_ic_default->active.normal->hi.b = 100; - d_ic_default->active.normal->bg.r = 160; - d_ic_default->active.normal->bg.g = 160; - d_ic_default->active.normal->bg.b = 160; - d_ic_default->active.normal->lo.r = 220; - d_ic_default->active.normal->lo.g = 220; - d_ic_default->active.normal->lo.b = 220; - d_ic_default->active.normal->lolo.r = 255; - d_ic_default->active.normal->lolo.g = 255; - d_ic_default->active.normal->lolo.b = 255; + ESetColor(&(d_ic_default->active.normal->hihi), 0, 0, 0); + ESetColor(&(d_ic_default->active.normal->hi), 100, 100, 100); + ESetColor(&(d_ic_default->active.normal->bg), 160, 160, 160); + ESetColor(&(d_ic_default->active.normal->lo), 220, 220, 220); + ESetColor(&(d_ic_default->active.normal->lolo), 255, 255, 255); d_ic_default->active.normal->bevelstyle = BEVEL_NEXT; d_ic_default->active.hilited = CreateImageState(); - d_ic_default->active.hilited->hihi.r = 0; - d_ic_default->active.hilited->hihi.g = 0; - d_ic_default->active.hilited->hihi.b = 0; - d_ic_default->active.hilited->hi.r = 100; - d_ic_default->active.hilited->hi.g = 100; - d_ic_default->active.hilited->hi.b = 100; - d_ic_default->active.hilited->bg.r = 160; - d_ic_default->active.hilited->bg.g = 160; - d_ic_default->active.hilited->bg.b = 160; - d_ic_default->active.hilited->lo.r = 220; - d_ic_default->active.hilited->lo.g = 220; - d_ic_default->active.hilited->lo.b = 220; - d_ic_default->active.hilited->lolo.r = 255; - d_ic_default->active.hilited->lolo.g = 255; - d_ic_default->active.hilited->lolo.b = 255; + ESetColor(&(d_ic_default->active.hilited->hihi), 0, 0, 0); + ESetColor(&(d_ic_default->active.hilited->hi), 100, 100, 100); + ESetColor(&(d_ic_default->active.hilited->bg), 160, 160, 160); + ESetColor(&(d_ic_default->active.hilited->lo), 220, 220, 220); + ESetColor(&(d_ic_default->active.hilited->lolo), 255, 255, 255); d_ic_default->active.hilited->bevelstyle = BEVEL_NEXT; d_ic_default->active.clicked = CreateImageState(); - d_ic_default->active.clicked->hihi.r = 0; - d_ic_default->active.clicked->hihi.g = 0; - d_ic_default->active.clicked->hihi.b = 0; - d_ic_default->active.clicked->hi.r = 100; - d_ic_default->active.clicked->hi.g = 100; - d_ic_default->active.clicked->hi.b = 100; - d_ic_default->active.clicked->bg.r = 160; - d_ic_default->active.clicked->bg.g = 160; - d_ic_default->active.clicked->bg.b = 160; - d_ic_default->active.clicked->lo.r = 220; - d_ic_default->active.clicked->lo.g = 220; - d_ic_default->active.clicked->lo.b = 220; - d_ic_default->active.clicked->lolo.r = 255; - d_ic_default->active.clicked->lolo.g = 255; - d_ic_default->active.clicked->lolo.b = 255; + ESetColor(&(d_ic_default->active.clicked->hihi), 0, 0, 0); + ESetColor(&(d_ic_default->active.clicked->hi), 100, 100, 100); + ESetColor(&(d_ic_default->active.clicked->bg), 160, 160, 160); + ESetColor(&(d_ic_default->active.clicked->lo), 220, 220, 220); + ESetColor(&(d_ic_default->active.clicked->lolo), 255, 255, 255); d_ic_default->active.clicked->bevelstyle = BEVEL_NEXT; d_ic_default->padding.left = 8; @@ -1182,14 +1120,15 @@ DialogRealizeItem(Dialog * d, DItem * di) } if (di->item.slider.ic_base->norm.normal->im_file) { - ImlibImage *im; + Imlib_Image *im; im = ELoadImage(di->item.slider.ic_base->norm.normal->im_file); if (im) { - di->item.slider.base_orig_w = im->rgb_width; - di->item.slider.base_orig_h = im->rgb_height; - Imlib_destroy_image(pImlibData, im); + imlib_context_set_image(im); + di->item.slider.base_orig_w = imlib_image_get_width(); + di->item.slider.base_orig_h = imlib_image_get_height(); + imlib_free_image(); } } if (di->item.slider.ic_base) @@ -1220,14 +1159,15 @@ DialogRealizeItem(Dialog * d, DItem * di) if (di->item.slider.ic_knob->norm.normal->im_file) { - ImlibImage *im; + Imlib_Image *im; im = ELoadImage(di->item.slider.ic_knob->norm.normal->im_file); if (im) { - di->item.slider.knob_orig_w = im->rgb_width; - di->item.slider.knob_orig_h = im->rgb_height; - Imlib_destroy_image(pImlibData, im); + imlib_context_set_image(im); + di->item.slider.knob_orig_w = imlib_image_get_width(); + di->item.slider.knob_orig_h = imlib_image_get_height(); + imlib_free_image(); } } if (!di->item.slider.ic_border) @@ -1249,15 +1189,16 @@ DialogRealizeItem(Dialog * d, DItem * di) { if (di->item.slider.ic_border->norm.normal->im_file) { - ImlibImage *im; + Imlib_Image *im; im = ELoadImage(di->item.slider.ic_border->norm. normal->im_file); if (im) { - di->item.slider.border_orig_w = im->rgb_width; - di->item.slider.border_orig_h = im->rgb_height; - Imlib_destroy_image(pImlibData, im); + imlib_context_set_image(im); + di->item.slider.border_orig_w = imlib_image_get_width(); + di->item.slider.border_orig_h = imlib_image_get_height(); + imlib_free_image(); di->item.slider.border_win = ECreateWindow(d->win, -20, -20, 2, 2, 0); EMapWindow(disp, di->item.slider.border_win); @@ -1314,14 +1255,15 @@ DialogRealizeItem(Dialog * d, DItem * di) case DITEM_CHECKBUTTON: if (di->iclass->norm.normal->im_file) { - ImlibImage *im; + Imlib_Image *im; im = ELoadImage(di->iclass->norm.normal->im_file); if (im) { - di->item.check_button.check_orig_w = im->rgb_width; - di->item.check_button.check_orig_h = im->rgb_height; - Imlib_destroy_image(pImlibData, im); + imlib_context_set_image(im); + di->item.check_button.check_orig_w = imlib_image_get_width(); + di->item.check_button.check_orig_h = imlib_image_get_height(); + imlib_free_image(); } } TextSize(di->tclass, 0, 0, STATE_NORMAL, di->item.check_button.text, @@ -1348,17 +1290,19 @@ DialogRealizeItem(Dialog * d, DItem * di) break; case DITEM_IMAGE: { - ImlibImage *im; + Imlib_Image *im; im = ELoadImage(di->item.image.image); if (im) { - iw = im->rgb_width; - ih = im->rgb_height; + imlib_context_set_image(im); + iw = imlib_image_get_width(); + ih = imlib_image_get_height(); di->win = ECreateWindow(d->win, 0, 0, iw, ih, 0); EMapWindow(disp, di->win); - Imlib_apply_image(pImlibData, im, di->win); - Imlib_destroy_image(pImlibData, im); + imlib_context_set_drawable(di->win); + imlib_render_image_on_drawable(0, 0); + imlib_free_image(); } } di->w = iw; @@ -1375,14 +1319,15 @@ DialogRealizeItem(Dialog * d, DItem * di) case DITEM_RADIOBUTTON: if (di->iclass->norm.normal->im_file) { - ImlibImage *im; + Imlib_Image *im; im = ELoadImage(di->iclass->norm.normal->im_file); if (im) { - di->item.radio_button.radio_orig_w = im->rgb_width; - di->item.radio_button.radio_orig_h = im->rgb_height; - Imlib_destroy_image(pImlibData, im); + imlib_context_set_image(im); + di->item.radio_button.radio_orig_w = imlib_image_get_width(); + di->item.radio_button.radio_orig_h = imlib_image_get_height(); + imlib_free_image(); } } TextSize(di->tclass, 0, 0, STATE_NORMAL, di->item.radio_button.text, diff --git a/src/draw.c b/src/draw.c index 74cf74ea..0fcb7674 100644 --- a/src/draw.c +++ b/src/draw.c @@ -48,6 +48,7 @@ HandleDrawQueue() (DrawQueue *) RemoveItem(NULL, 0, LIST_FINDBY_NONE, LIST_TYPE_DRAW))) { already = 0; + if (dq->shape_propagate) { for (i = 0; i < num; i++) @@ -286,18 +287,20 @@ ECreatePixImg(Window win, int w, int h) int bpp; PixImg *pi; - if (pImlibData->x.depth <= 8) + if (root.depth <= 8) bpp = 1; - else if (pImlibData->x.depth <= 16) + else if (root.depth <= 16) bpp = 2; - else if (pImlibData->x.depth <= 24) + else if (root.depth <= 24) bpp = 3; else bpp = 4; - if ((pImlibData->max_shm) && ((bpp * w * h) > pImlibData->max_shm)) +#if !USE_IMLIB2 + if ((pImlib_Context->max_shm) && ((bpp * w * h) > pImlib_Context->max_shm)) return NULL; - if ((!pImlibData->x.shm) || (!pImlibData->x.shmp)) + if ((!pImlib_Context->x.shm) || (!pImlib_Context->x.shmp)) return NULL; +#endif pi = Emalloc(sizeof(PixImg)); if (!pi) @@ -561,7 +564,7 @@ EBlendPixImg(EWin * ewin, PixImg * s1, PixImg * s2, PixImg * dst, int x, int y, } break; case 16: - if (pImlibData->x.render_depth != 15) + if (IC_RenderDepth() != 15) { for (j = 0; j < h; j++) { @@ -570,32 +573,20 @@ EBlendPixImg(EWin * ewin, PixImg * s1, PixImg * s2, PixImg * dst, int x, int y, ptr1 = (unsigned int *)(s1->xim->data + ((x) * - ((s1->xim-> - bits_per_pixel) >> 3)) + ((j + - y) * - s1-> - xim-> - bytes_per_line)); + ((s1->xim->bits_per_pixel) >> 3)) + + ((j + y) * s1->xim->bytes_per_line)); ptr2 = (unsigned int *)(s2->xim->data + ((ox) * - ((s2->xim-> - bits_per_pixel) >> 3)) + ((j + - oy) - * - s2-> - xim-> - bytes_per_line)); + ((s2->xim->bits_per_pixel) >> 3)) + + ((j + + oy) * s2->xim->bytes_per_line)); ptr3 = (unsigned int *)(dst->xim->data + ((ox) * - ((dst->xim-> - bits_per_pixel) >> 3)) + ((j + - oy) - * - dst-> - xim-> - bytes_per_line)); + ((dst->xim->bits_per_pixel) >> 3)) + + ((j + + oy) * dst->xim->bytes_per_line)); if (!(w & 0x1)) { for (i = 0; i < w; i += 2) @@ -923,18 +914,21 @@ DrawEwinShape(EWin * ewin, int md, int x, int y, int w, int h, char firstlast) md = 0; if (md == 5) { - if (pImlibData->x.depth <= 8) + if (root.depth <= 8) bpp = 1; - else if (pImlibData->x.depth <= 16) + else if (root.depth <= 16) bpp = 2; - else if (pImlibData->x.depth <= 24) + else if (root.depth <= 24) bpp = 3; else bpp = 4; - if ((prImlibData) - || ((pImlibData->max_shm) && ((bpp * w * h) > pImlibData->max_shm)) - || ((!pImlibData->x.shm) || (!pImlibData->x.shmp))) +#if !USE_IMLIB2 + if ((prImlib_Context) || + (pImlib_Context->max_shm && + ((bpp * w * h) > pImlib_Context->max_shm)) || + ((!pImlib_Context->x.shm) || (!pImlib_Context->x.shmp))) md = 0; +#endif } pw = w; ph = h; @@ -1357,34 +1351,31 @@ DrawEwinShape(EWin * ewin, int md, int x, int y, int w, int h, char firstlast) EDBUG_RETURN_; } -ImlibImage * +Imlib_Image * ELoadImage(char *file) { - EDBUG(5, "ELoadImage"); - EDBUG_RETURN(ELoadImageImlibData(pImlibData, file)); -} - -ImlibImage * -ELoadImageImlibData(ImlibData * imd, char *file) -{ - ImlibImage *im; + Imlib_Image *im; char *f = NULL; - EDBUG(5, "ELoadImageImlibData"); + EDBUG(5, "ELoadImage"); + if (!file) EDBUG_RETURN(NULL); + if (file[0] == '/') { - EDBUG_RETURN(Imlib_load_image(imd, file)); + im = imlib_load_image(file); + EDBUG_RETURN(im); } - else - f = FindFile(file); + + f = FindFile(file); if (f) { - im = Imlib_load_image(imd, f); + im = imlib_load_image(f); Efree(f); EDBUG_RETURN(im); } + EDBUG_RETURN(NULL); } diff --git a/src/evhandlers.c b/src/evhandlers.c index 8a13a415..b8dfe567 100644 --- a/src/evhandlers.c +++ b/src/evhandlers.c @@ -1764,7 +1764,7 @@ HandleMouseDown(XEvent * ev) EMoveResizeWindow(disp, p->hi_win, px + wx, py + wy, ww, wh); ESetWindowBackgroundPixmap(disp, p->hi_win, - ewin->mini_pmap); + ewin->mini_pmm.pmap); EMapRaised(disp, p->hi_win); GrabThePointer(p->hi_win); p->hi_visible = 1; diff --git a/src/fx.c b/src/fx.c index 26703431..2b10f653 100644 --- a/src/fx.c +++ b/src/fx.c @@ -262,14 +262,10 @@ FX_ripple_timeout(int val, void *data) XGCValues gcv; fx_ripple_win = desks.desk[desks.current].win; - if ((desks.current == 0) && (prImlibData)) - fx_ripple_above = - ECreatePixmap(disp, fx_ripple_win, root.w, fx_ripple_waterh * 2, - prImlibData->x.depth); - else - fx_ripple_above = - ECreatePixmap(disp, fx_ripple_win, root.w, fx_ripple_waterh * 2, - pImlibData->x.depth); + + fx_ripple_above = + ECreatePixmap(disp, fx_ripple_win, root.w, fx_ripple_waterh * 2, + GetWinDepth(fx_ripple_win)); if (gc) XFreeGC(disp, gc); if (gc1) @@ -415,7 +411,8 @@ FX_raindrops_timeout(int val, void *data) { XGCValues gcv; - if (!pImlibData->x.shm) +#if !USE_IMLIB2 + if (!pImlib_Context->x.shm) { DIALOG_OK(_("Unable to display raindrops"), _("\n" @@ -431,7 +428,7 @@ FX_raindrops_timeout(int val, void *data) "and editing it, enabling shared memory.\n" "\n")); return; } - if (!pImlibData->x.shmp) + if (!pImlib_Context->x.shmp) { DIALOG_OK(_("Unable to display raindrops"), _("\n" @@ -446,6 +443,7 @@ FX_raindrops_timeout(int val, void *data) "and editing it, enabling shared pixmaps.\n" "\n")); return; } +#endif FX_raindrops_info(); @@ -733,14 +731,10 @@ FX_Wave_timeout(int val, void *data) XGCValues gcv; fx_wave_win = desks.desk[desks.current].win; - if ((desks.current == 0) && (prImlibData)) - fx_wave_above = - XCreatePixmap(disp, fx_wave_win, root.w, FX_WAVE_WATERH * 2, - prImlibData->x.depth); - else - fx_wave_above = - XCreatePixmap(disp, fx_wave_win, root.w, FX_WAVE_WATERH * 2, - pImlibData->x.depth); + + fx_wave_above = + XCreatePixmap(disp, fx_wave_win, root.w, FX_WAVE_WATERH * 2, + GetWinDepth(fx_wave_win)); if (gc) XFreeGC(disp, gc); if (gc1) @@ -885,7 +879,6 @@ FX_Waves_Pause(void) static Window fx_imagespinner_win = 0; static int fx_imagespinner_count = 3; -static ImlibData *fx_imagespinner_imd = NULL; static char *fx_imagespinner_params = NULL; static void @@ -912,13 +905,9 @@ FX_imagespinner_timeout(int val, void *data) if (!fx_imagespinner_win) { fx_imagespinner_win = desks.desk[desks.current].win; - if ((desks.current == 0) && (prImlibData)) - fx_imagespinner_imd = prImlibData; - else - fx_imagespinner_imd = pImlibData; - FX_imagespinner_info(); } + /* do stuff here */ string = getword(fx_imagespinner_params, fx_imagespinner_count); if (!string) @@ -926,24 +915,28 @@ FX_imagespinner_timeout(int val, void *data) fx_imagespinner_count = 3; string = getword(fx_imagespinner_params, fx_imagespinner_count); } + fx_imagespinner_count++; if (string) { - ImlibImage *im; + Imlib_Image *im; - im = ELoadImageImlibData(fx_imagespinner_imd, string); + IMLIB1_SET_CONTEXT(desks.current == 0); + + im = ELoadImage(string); if (im) { int x, y, w, h; - w = im->rgb_width; - h = im->rgb_height; + imlib_context_set_image(im); + w = imlib_image_get_width(); + h = imlib_image_get_height(); sscanf(fx_imagespinner_params, "%*s %i %i ", &x, &y); x = ((root.w * x) >> 10) - ((w * x) >> 10); y = ((root.h * y) >> 10) - ((h * y) >> 10); - Imlib_paste_image(fx_imagespinner_imd, im, fx_imagespinner_win, x, - y, w, h); - Imlib_destroy_image(fx_imagespinner_imd, im); + imlib_context_set_drawable(fx_imagespinner_win); + imlib_render_image_on_drawable_at_size(x, y, w, h); + imlib_free_image(); } Efree(string); } @@ -966,10 +959,6 @@ void FX_ImageSpinner_Desk(void) { fx_imagespinner_win = desks.desk[desks.current].win; - if ((desks.current == 0) && (prImlibData)) - fx_imagespinner_imd = prImlibData; - else - fx_imagespinner_imd = pImlibData; } void diff --git a/src/globals.c b/src/globals.c index 6d1e342d..659db33e 100644 --- a/src/globals.c +++ b/src/globals.c @@ -34,9 +34,14 @@ int master_screen; int display_screens; int single_screen_mode; Display *disp; -ImlibData *pImlibData; -ImlibData *prImlibData; +#if !USE_IMLIB2 +ImlibData *pImlib_Context; +ImlibData *prImlib_Context; +ImlibData *pI1Ctx; +ImlibImage *pIcImg; +Drawable vIcDrw; +#endif #if USE_FNLIB FnlibData *pFnlibData; #endif diff --git a/src/iclass.c b/src/iclass.c index ebb0b0a8..a415dd3a 100644 --- a/src/iclass.c +++ b/src/iclass.c @@ -53,7 +53,7 @@ CreateIclass() } -void +static void FreeImageState(ImageState * i) { @@ -63,7 +63,11 @@ FreeImageState(ImageState * i) Efree(i->real_file); if (i->im) - Imlib_destroy_image(pImlibData, i->im); + { + imlib_context_set_image(i->im); + imlib_free_image(); + i->im = NULL; + } if (i->transp) Efree(i->transp); if (i->border) @@ -76,7 +80,7 @@ FreeImageState(ImageState * i) } -void +static void FreeImageStateArray(ImageStateArray * isa) { @@ -148,21 +152,11 @@ CreateImageState() is->transp = NULL; is->border = NULL; is->pixmapfillstyle = FILL_STRETCH; - is->bg.r = 160; - is->bg.g = 160; - is->bg.b = 160; - is->hi.r = 200; - is->hi.g = 200; - is->hi.b = 200; - is->lo.r = 120; - is->lo.g = 120; - is->lo.b = 120; - is->hihi.r = 255; - is->hihi.g = 255; - is->hihi.b = 255; - is->lolo.r = 64; - is->lolo.g = 64; - is->lolo.b = 64; + ESetColor(&(is->bg), 160, 160, 160); + ESetColor(&(is->hi), 200, 200, 200); + ESetColor(&(is->lo), 120, 120, 120); + ESetColor(&(is->hihi), 255, 255, 255); + ESetColor(&(is->lolo), 64, 64, 64); is->bevelstyle = BEVEL_NONE; is->colmod = NULL; @@ -173,40 +167,18 @@ CreateImageState() void ImageStatePopulate(ImageState * is) { - int r, g, b; - EDBUG(6, "ImageStatePopulate"); if (!is) EDBUG_RETURN_; - r = is->bg.r; - g = is->bg.g; - b = is->bg.b; - is->bg.pixel = Imlib_best_color_match(pImlibData, &r, &g, &b); - - r = is->hi.r; - g = is->hi.g; - b = is->hi.b; - is->hi.pixel = Imlib_best_color_match(pImlibData, &r, &g, &b); - - r = is->lo.r; - g = is->lo.g; - b = is->lo.b; - is->lo.pixel = Imlib_best_color_match(pImlibData, &r, &g, &b); - - r = is->hihi.r; - g = is->hihi.g; - b = is->hihi.b; - is->hihi.pixel = Imlib_best_color_match(pImlibData, &r, &g, &b); - - r = is->lolo.r; - g = is->lolo.g; - b = is->lolo.b; - is->lolo.pixel = Imlib_best_color_match(pImlibData, &r, &g, &b); + EAllocColor(&is->bg); + EAllocColor(&is->hi); + EAllocColor(&is->lo); + EAllocColor(&is->hihi); + EAllocColor(&is->lolo); EDBUG_RETURN_; - } void @@ -503,16 +475,70 @@ IclassPopulate(ImageClass * iclass) } +static ImageState * +IclassGetImageState1(ImageStateArray * pisa, int state) +{ + ImageState *is; + + switch (state) + { + case STATE_NORMAL: + is = pisa->normal; + break; + case STATE_HILITED: + is = pisa->hilited; + break; + case STATE_CLICKED: + is = pisa->clicked; + break; + case STATE_DISABLED: + is = pisa->disabled; + break; + default: + is = NULL; + break; + } + + return is; +} + +static ImageState * +IclassGetImageState2(ImageClass * iclass, int state, int active, int sticky) +{ + ImageState *is; + + if (active) + { + if (sticky) + is = IclassGetImageState1(&iclass->sticky_active, state); + else + is = IclassGetImageState1(&iclass->active, state); + } + else + { + if (sticky) + is = IclassGetImageState1(&iclass->sticky, state); + else + is = IclassGetImageState1(&iclass->norm, state); + } + + return is; +} + 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"); if ((!iclass) || (!win)) EDBUG_RETURN_; + if (w < 0) GetWinWH(win, (unsigned int *)&w, (unsigned int *)&h); if ((w < 0) || (h < 0)) @@ -545,464 +571,58 @@ IclassApply(ImageClass * iclass, Window win, int w, int h, int active, AddItem(dq, "DRAW", dq->win, LIST_TYPE_DRAW); EDBUG_RETURN_; } - if (iclass->external) - EDBUG_RETURN_; - - is = NULL; - - if (active) - { - if (!sticky) - { - switch (state) - { - case STATE_NORMAL: - is = iclass->active.normal; - break; - case STATE_HILITED: - is = iclass->active.hilited; - break; - case STATE_CLICKED: - is = iclass->active.clicked; - break; - case STATE_DISABLED: - is = iclass->active.disabled; - break; - default: - break; - } - } - else - { - switch (state) - { - case STATE_NORMAL: - is = iclass->sticky_active.normal; - break; - case STATE_HILITED: - is = iclass->sticky_active.hilited; - break; - case STATE_CLICKED: - is = iclass->sticky_active.clicked; - break; - case STATE_DISABLED: - is = iclass->sticky_active.disabled; - break; - default: - break; - } - } - } - else if (sticky) - { - switch (state) - { - case STATE_NORMAL: - is = iclass->sticky.normal; - break; - case STATE_HILITED: - is = iclass->sticky.hilited; - break; - case STATE_CLICKED: - is = iclass->sticky.clicked; - break; - case STATE_DISABLED: - is = iclass->sticky.disabled; - break; - default: - break; - } - } - else - { - switch (state) - { - case STATE_NORMAL: - is = iclass->norm.normal; - break; - case STATE_HILITED: - is = iclass->norm.hilited; - break; - case STATE_CLICKED: - is = iclass->norm.clicked; - break; - case STATE_DISABLED: - is = iclass->norm.disabled; - break; - default: - break; - } - } - - if (is) - { - XGCValues gcv; - GC gc; - Pixmap pmap, mask; - - if (!expose) - { - if (is->im_file) - { - /* has bg pixmap */ - if (!is->im) - { - /* not loaded, load and setup */ - if (!is->real_file) - is->real_file = FindFile(is->im_file); - is->im = ELoadImage(is->real_file); - if (is->border) - Imlib_set_image_border(pImlibData, is->im, - is->border); - if (is->transp) - Imlib_set_image_shape(pImlibData, is->im, is->transp); -/* disabled - no idea what causes this but it causes a memory leak somewhere */ -/* and thus will be disabled - there is no time to debug this any further */ -/* if (is->colmod) - * { - * Imlib_set_image_red_curve(pImlibData, is->im, - * is->colmod->red.map); - * Imlib_set_image_green_curve(pImlibData, is->im, - * is->colmod->green.map); - * Imlib_set_image_blue_curve(pImlibData, is->im, - * is->colmod->blue.map); - * } - */ - } - if (is->im) - { - /* if image, render */ - if (is->pixmapfillstyle == FILL_STRETCH) - { - Imlib_render(pImlibData, is->im, w, h); - pmap = Imlib_move_image(pImlibData, is->im); - mask = Imlib_move_mask(pImlibData, is->im); - if (pmap) - { - ESetWindowBackgroundPixmap(disp, win, pmap); - EShapeCombineMask(disp, win, ShapeBounding, 0, - 0, mask, ShapeSet); - Imlib_free_pixmap(pImlibData, 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 = is->im->rgb_width; - if (is->pixmapfillstyle & FILL_TILE_V) - ph = is->im->rgb_height; - if (is->pixmapfillstyle & FILL_INT_TILE_H) - { - cw = w / is->im->rgb_width; - if (cw * is->im->rgb_width < w) - cw++; - if (cw < 1) - cw = 1; - pw = w / cw; - } - if (is->pixmapfillstyle & FILL_INT_TILE_V) - { - ch = h / is->im->rgb_height; - if (ch * is->im->rgb_height < h) - ch++; - if (ch < 1) - ch = 1; - ph = h / ch; - } - Imlib_render(pImlibData, is->im, pw, ph); - pmap = Imlib_move_image(pImlibData, is->im); - mask = Imlib_move_mask(pImlibData, is->im); - 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(pImlibData, 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_destroy_image(pImlibData, is->im); - is->im = NULL; - } - } - } - XClearWindow(disp, win); - /* if there is a bevel to draw, draw it */ - if (is->bevelstyle != BEVEL_NONE) - { - 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; - } - XFreeGC(disp, gc); - } - } - EDBUG_RETURN_; -} - -void -IclassApplyCopy(ImageClass * iclass, Window win, int w, int h, int active, - int sticky, int state, Pixmap * pret, Pixmap * mret) -{ - ImageState *is; - - EDBUG(4, "IclassApplyCopy"); - if ((!iclass) || (!win) || (w < 1) || (h < 1) || (!pret)) - EDBUG_RETURN_; - - *pret = 0; - if (mret) - *mret = 0; if (iclass->external) EDBUG_RETURN_; - is = NULL; - if (active) - { - if (!sticky) - { - switch (state) - { - case STATE_NORMAL: - is = iclass->active.normal; - break; - case STATE_HILITED: - is = iclass->active.hilited; - break; - case STATE_CLICKED: - is = iclass->active.clicked; - break; - case STATE_DISABLED: - is = iclass->active.disabled; - break; - default: - break; - } - } - else - { - switch (state) - { - case STATE_NORMAL: - is = iclass->sticky_active.normal; - break; - case STATE_HILITED: - is = iclass->sticky_active.hilited; - break; - case STATE_CLICKED: - is = iclass->sticky_active.clicked; - break; - case STATE_DISABLED: - is = iclass->sticky_active.disabled; - break; - default: - break; - } - } - } - else if (sticky) - { - switch (state) - { - case STATE_NORMAL: - is = iclass->sticky.normal; - break; - case STATE_HILITED: - is = iclass->sticky.hilited; - break; - case STATE_CLICKED: - is = iclass->sticky.clicked; - break; - case STATE_DISABLED: - is = iclass->sticky.disabled; - break; - default: - break; - } - } - else - { - switch (state) - { - case STATE_NORMAL: - is = iclass->norm.normal; - break; - case STATE_HILITED: - is = iclass->norm.hilited; - break; - case STATE_CLICKED: - is = iclass->norm.clicked; - break; - case STATE_DISABLED: - is = iclass->norm.disabled; - break; - default: - break; - } - } + is = IclassGetImageState2(iclass, state, active, sticky); + if (!is) + EDBUG_RETURN_; - if (is) + imlib_context_set_drawable(win); + if (!expose) { - XGCValues gcv; - GC gc; - if (is->im_file) { /* has bg pixmap */ if (!is->im) - { - ImageStateRealize(is); - } + ImageStateRealize(is); + if (is->im) { + imlib_context_set_image(is->im); + /* if image, render */ if (is->pixmapfillstyle == FILL_STRETCH) { - Imlib_render(pImlibData, is->im, w, h); - *pret = Imlib_copy_image(pImlibData, is->im); - if (mret) - *mret = Imlib_copy_mask(pImlibData, is->im); - /* if unloadable - then unload */ - if ((is->unloadable) || (mode.memory_paranoia)) + imlib_render_pixmaps_for_whole_image_at_size(&pmap, + &mask, w, + h); + if (pmap) { - Imlib_destroy_image(pImlibData, is->im); - is->im = NULL; + ESetWindowBackgroundPixmap(disp, win, pmap); + EShapeCombineMask(disp, win, ShapeBounding, 0, + 0, mask, ShapeSet); + imlib_free_pixmap_and_mask(pmap); } - EDBUG_RETURN_; } else { int cw, ch, pw, ph; - Pixmap pmap, mask, tp = 0, tm = 0; + Pixmap tm = 0; GC gc; XGCValues gcv; pw = w; ph = h; if (is->pixmapfillstyle & FILL_TILE_H) - pw = is->im->rgb_width; + pw = imlib_image_get_width(); if (is->pixmapfillstyle & FILL_TILE_V) - ph = is->im->rgb_height; + ph = imlib_image_get_height(); if (is->pixmapfillstyle & FILL_INT_TILE_H) { - cw = w / is->im->rgb_width; - if (cw * is->im->rgb_width < w) + cw = w / imlib_image_get_width(); + if (cw * imlib_image_get_width() < w) cw++; if (cw < 1) cw = 1; @@ -1010,188 +630,452 @@ IclassApplyCopy(ImageClass * iclass, Window win, int w, int h, int active, } if (is->pixmapfillstyle & FILL_INT_TILE_V) { - ch = h / is->im->rgb_height; - if (ch * is->im->rgb_height < h) + ch = h / imlib_image_get_height(); + if (ch * imlib_image_get_height() < h) ch++; if (ch < 1) ch = 1; ph = h / ch; } - Imlib_render(pImlibData, is->im, pw, ph); - pmap = Imlib_move_image(pImlibData, is->im); - mask = Imlib_move_mask(pImlibData, is->im); - tp = ECreatePixmap(disp, win, w, h, pImlibData->x.depth); - if ((mret) && (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 ((mret) && (mask)) + 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); } - *pret = tp; - if (mret) - *mret = tm; - Imlib_free_pixmap(pImlibData, pmap); - /* if unloadable - then unload */ - if ((is->unloadable) || (mode.memory_paranoia)) - { - Imlib_destroy_image(pImlibData, is->im); - is->im = NULL; - } - EDBUG_RETURN_; + ESetWindowBackgroundPixmap(disp, win, pmap); + imlib_free_pixmap_and_mask(pmap); } } } - /* if there is a bevel to draw, draw it */ - if (is->bevelstyle != BEVEL_NONE) + if (!is->im) + /* bg color */ + ESetWindowBackground(disp, win, is->bg.pixel); + else if (is->im_file) { - *pret = ECreatePixmap(disp, win, w, h, pImlibData->x.depth); - gc = XCreateGC(disp, *pret, 0, &gcv); - /* bg color */ - XSetForeground(disp, gc, is->bg.pixel); - XFillRectangle(disp, *pret, gc, 0, 0, w, h); - switch (is->bevelstyle) + /* if unloadable - then unload */ + if ((is->unloadable) || (mode.memory_paranoia)) { - case BEVEL_AMIGA: - XSetForeground(disp, gc, is->hihi.pixel); - XDrawLine(disp, *pret, gc, 0, 0, w - 2, 0); - XDrawLine(disp, *pret, gc, 0, 0, 0, h - 2); - XSetForeground(disp, gc, is->lolo.pixel); - XDrawLine(disp, *pret, gc, 1, h - 1, w - 1, h - 1); - XDrawLine(disp, *pret, gc, w - 1, 1, w - 1, h - 1); - break; - case BEVEL_MOTIF: - XSetForeground(disp, gc, is->hi.pixel); - XDrawLine(disp, *pret, gc, 0, 0, w - 1, 0); - XDrawLine(disp, *pret, gc, 0, 0, 0, h - 1); - XDrawLine(disp, *pret, gc, 1, 1, w - 2, 1); - XDrawLine(disp, *pret, gc, 1, 1, 1, h - 2); - XSetForeground(disp, gc, is->lo.pixel); - XDrawLine(disp, *pret, gc, 0, h - 1, w - 1, h - 1); - XDrawLine(disp, *pret, gc, w - 1, 1, w - 1, h - 1); - XDrawLine(disp, *pret, gc, 1, h - 2, w - 2, h - 2); - XDrawLine(disp, *pret, gc, w - 2, 2, w - 2, h - 2); - break; - case BEVEL_NEXT: - XSetForeground(disp, gc, is->hihi.pixel); - XDrawLine(disp, *pret, gc, 0, 0, w - 1, 0); - XDrawLine(disp, *pret, gc, 0, 0, 0, h - 1); - XSetForeground(disp, gc, is->hi.pixel); - XDrawLine(disp, *pret, gc, 1, 1, w - 2, 1); - XDrawLine(disp, *pret, gc, 1, 1, 1, h - 2); - XSetForeground(disp, gc, is->lolo.pixel); - XDrawLine(disp, *pret, gc, 1, h - 1, w - 1, h - 1); - XDrawLine(disp, *pret, gc, w - 1, 1, w - 1, h - 1); - XSetForeground(disp, gc, is->lo.pixel); - XDrawLine(disp, *pret, gc, 2, h - 2, w - 2, h - 2); - XDrawLine(disp, *pret, gc, w - 2, 2, w - 2, h - 2); - break; - case BEVEL_DOUBLE: - XSetForeground(disp, gc, is->hi.pixel); - XDrawLine(disp, *pret, gc, 0, 0, w - 2, 0); - XDrawLine(disp, *pret, gc, 0, 0, 0, h - 2); - XSetForeground(disp, gc, is->lo.pixel); - XDrawLine(disp, *pret, gc, 1, 1, w - 3, 1); - XDrawLine(disp, *pret, gc, 1, 1, 1, h - 3); - XSetForeground(disp, gc, is->lo.pixel); - XDrawLine(disp, *pret, gc, 1, h - 1, w - 1, h - 1); - XDrawLine(disp, *pret, gc, w - 1, 1, w - 1, h - 1); - XSetForeground(disp, gc, is->hi.pixel); - XDrawLine(disp, *pret, gc, 2, h - 2, w - 2, h - 2); - XDrawLine(disp, *pret, gc, w - 2, 2, w - 2, h - 2); - break; - case BEVEL_WIDEDOUBLE: - XSetForeground(disp, gc, is->hihi.pixel); - XDrawLine(disp, *pret, gc, 0, 0, w - 1, 0); - XDrawLine(disp, *pret, gc, 0, 0, 0, h - 1); - XSetForeground(disp, gc, is->hi.pixel); - XDrawLine(disp, *pret, gc, 1, 1, w - 2, 1); - XDrawLine(disp, *pret, gc, 1, 1, 1, h - 2); - XDrawLine(disp, *pret, gc, 3, h - 4, w - 4, h - 4); - XDrawLine(disp, *pret, gc, w - 4, 3, w - 4, h - 4); - XSetForeground(disp, gc, is->lolo.pixel); - XDrawLine(disp, *pret, gc, 1, h - 1, w - 1, h - 1); - XDrawLine(disp, *pret, gc, w - 1, 1, w - 1, h - 1); - XSetForeground(disp, gc, is->lo.pixel); - XDrawLine(disp, *pret, gc, 2, h - 2, w - 2, h - 2); - XDrawLine(disp, *pret, gc, w - 2, 2, w - 2, h - 2); - XDrawLine(disp, *pret, gc, 3, 3, w - 4, 3); - XDrawLine(disp, *pret, gc, 3, 3, 3, h - 4); - break; - case BEVEL_THINPOINT: - XSetForeground(disp, gc, is->hi.pixel); - XDrawLine(disp, *pret, gc, 0, 0, w - 2, 0); - XDrawLine(disp, *pret, gc, 0, 0, 0, h - 2); - XSetForeground(disp, gc, is->lo.pixel); - XDrawLine(disp, *pret, gc, 1, h - 1, w - 1, h - 1); - XDrawLine(disp, *pret, gc, w - 1, 1, w - 1, h - 1); - XSetForeground(disp, gc, is->hihi.pixel); - XDrawLine(disp, *pret, gc, 0, 0, 1, 0); - XDrawLine(disp, *pret, gc, 0, 0, 0, 1); - XSetForeground(disp, gc, is->lolo.pixel); - XDrawLine(disp, *pret, gc, w - 2, h - 1, w - 1, h - 1); - XDrawLine(disp, *pret, gc, w - 1, h - 2, w - 1, h - 1); - XSync(disp, False); - break; - case BEVEL_THICKPOINT: - XSetForeground(disp, gc, is->hi.pixel); - XDrawRectangle(disp, *pret, gc, 0, 0, w - 1, h - 1); - break; - default: - break; + imlib_free_image(); + is->im = NULL; } - XFreeGC(disp, gc); } } + XClearWindow(disp, win); + /* if there is a bevel to draw, draw it */ + if (is->bevelstyle != BEVEL_NONE) + { + 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; + } + XFreeGC(disp, gc); + } EDBUG_RETURN_; +} +void +IclassApplyCopy(ImageClass * iclass, Window win, int w, int h, int active, + int sticky, int state, PmapMask * pmm, int make_mask) +{ + ImageState *is; + XGCValues gcv; + GC gc; + + EDBUG(4, "IclassApplyCopy"); + if ((!iclass) || (!win) || (w < 1) || (h < 1) || (!pmm)) + EDBUG_RETURN_; + + pmm->pmap = 0; + pmm->mask = 0; + + if (iclass->external) + EDBUG_RETURN_; + + is = IclassGetImageState2(iclass, state, active, sticky); + if (!is) + EDBUG_RETURN_; + + imlib_context_set_drawable(win); + + if (is->im_file) + { + /* 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; + + 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_; + } + } + } + + /* TBD should we return here ? */ + + /* if there is a bevel to draw, draw it */ + if (is->bevelstyle != BEVEL_NONE) + { + Pixmap pmap; + + if (pmm->pmap) + printf("IclassApplyCopy: Hmm... pmm->pmap already set\n"); + + pmap = ECreatePixmap(disp, win, w, h, root.depth); + pmm->type = 0; + pmm->pmap = pmap; + pmm->mask = 0; + + gc = XCreateGC(disp, pmap, 0, &gcv); + /* 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; + } + XFreeGC(disp, gc); + } + + EDBUG_RETURN_; } void ImageStateRealize(ImageState * is) { - if (is) + if (is == NULL || is->im_file == NULL) + return; + + /* has bg pixmap */ + if (is->im) + return; + + /* not loaded, load and setup */ + if (!is->real_file) + is->real_file = FindFile(is->im_file); + + is->im = ELoadImage(is->real_file); + imlib_context_set_image(is->im); + if (is->im == NULL) + printf + ("ImageStateRealize: Hmmm... is->im is NULL (im_file=%s real_file=%s\n", + is->im_file, is->real_file); + + if (is->border) + 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) { - if (is->im_file) - { - /* has bg pixmap */ - if (!is->im) - { - /* not loaded, load and setup */ - if (!is->real_file) - is->real_file = FindFile(is->im_file); - is->im = ELoadImage(is->real_file); - if (is->border) - Imlib_set_image_border(pImlibData, is->im, is->border); - if (is->transp) - Imlib_set_image_shape(pImlibData, is->im, is->transp); - if (is->colmod) - { - Imlib_set_image_red_curve(pImlibData, is->im, - is->colmod->red.map); - Imlib_set_image_green_curve(pImlibData, is->im, - is->colmod->green.map); - Imlib_set_image_blue_curve(pImlibData, is->im, - is->colmod->blue.map); - } - } - } + Imlib_set_image_red_curve(pImlib_Context, is->im, is->colmod->red.map); + Imlib_set_image_green_curve(pImlib_Context, is->im, + is->colmod->green.map); + Imlib_set_image_blue_curve(pImlib_Context, is->im, + is->colmod->blue.map); + } +#endif +} + +/* + */ +void +FreePmapMask(PmapMask * pmm) +{ + + /* type !=0: Created by imlib_render_pixmaps_for_whole_image... */ + if (pmm->pmap) + { + if (pmm->type == 0) + EFreePixmap(disp, pmm->pmap); + else + imlib_free_pixmap_and_mask(pmm->pmap); + pmm->pmap = 0; + } + + if (pmm->mask) + { + if (pmm->type == 0) + EFreePixmap(disp, pmm->mask); +#if !USE_IMLIB2 + else + imlib_free_pixmap_and_mask(pmm->mask); +#endif + pmm->mask = 0; } } diff --git a/src/iconify.c b/src/iconify.c index d125b8a8..217c0003 100644 --- a/src/iconify.c +++ b/src/iconify.c @@ -419,7 +419,7 @@ CreateIconbox(char *name) ib->arrow2_win = ECreateWindow(ib->win, 122, 26, 6, 6, 0); ib->scrollbar_win = ECreateWindow(ib->scroll_win, 122, 26, 6, 6, 0); ib->scrollbarknob_win = ECreateWindow(ib->scrollbar_win, -20, -20, 4, 4, 0); - ib->pmap = ECreatePixmap(disp, ib->icon_win, 128, 32, pImlibData->x.depth); + ib->pmap = ECreatePixmap(disp, ib->icon_win, 128, 32, root.depth); XSelectInput(disp, ib->icon_win, EnterWindowMask | LeaveWindowMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask); @@ -640,18 +640,20 @@ IB_SnapEWin(EWin * ewin) w = 4; if (h < 4) h = 4; - ewin->icon_pmap_w = w; - ewin->icon_pmap_h = h; - ewin->icon_pmap = ECreatePixmap(disp, ewin->win, w, h, pImlibData->x.depth); - PagerScaleRect(ewin->icon_pmap, ewin->win, 0, 0, 0, 0, ewin->w, ewin->h, w, - h); + + ewin->icon_pmm.type = 0; + ewin->icon_w = w; + ewin->icon_h = h; + ewin->icon_pmm.pmap = ECreatePixmap(disp, ewin->win, w, h, root.depth); + PagerScaleRect(ewin->icon_pmm.pmap, ewin->win, 0, 0, 0, 0, ewin->w, ewin->h, + w, h); r = EShapeGetRectangles(disp, ewin->win, ShapeBounding, &rn, &ord); - ewin->icon_mask = ECreatePixmap(disp, ewin->win, w, h, 1); - gc = XCreateGC(disp, ewin->icon_mask, 0, &gcv); + ewin->icon_pmm.mask = ECreatePixmap(disp, ewin->win, w, h, 1); + gc = XCreateGC(disp, ewin->icon_pmm.mask, 0, &gcv); if (r) { XSetForeground(disp, gc, 0); - XFillRectangle(disp, ewin->icon_mask, gc, 0, 0, w, h); + XFillRectangle(disp, ewin->icon_pmm.mask, gc, 0, 0, w, h); XSetForeground(disp, gc, 1); for (i = 0; i < rn; i++) { @@ -665,25 +667,20 @@ IB_SnapEWin(EWin * ewin) ww = 4; if (hh < 4) hh = 4; - XFillRectangle(disp, ewin->icon_mask, gc, x, y, ww, hh); + XFillRectangle(disp, ewin->icon_pmm.mask, gc, x, y, ww, hh); } XFree(r); } else { XSetForeground(disp, gc, 1); - XFillRectangle(disp, ewin->icon_mask, gc, 0, 0, w, h); + XFillRectangle(disp, ewin->icon_pmm.mask, gc, 0, 0, w, h); } + XFreeGC(disp, gc); - if ((ewin->icon_pmap_w < 1) || (ewin->icon_pmap_h < 1)) - { - if (ewin->icon_pmap) - Imlib_free_pixmap(pImlibData, ewin->icon_pmap); - if (ewin->icon_mask) - Imlib_free_pixmap(pImlibData, ewin->icon_mask); - ewin->icon_pmap = 0; - ewin->icon_mask = 0; - } + + if ((ewin->icon_w < 1) || (ewin->icon_h < 1)) + FreePmapMask(&ewin->icon_pmm); } void @@ -696,73 +693,63 @@ IB_GetAppIcon(EWin * ewin) if (!ewin->client.icon_pmap) return; + w = 0; h = 0; EGetGeometry(disp, ewin->client.icon_pmap, &rt, &x, &y, &w, &h, &bw, &depth); - ewin->icon_pmap_w = (int)w; - ewin->icon_pmap_h = (int)h; - ewin->icon_pmap = ECreatePixmap(disp, root.win, w, h, root.depth); + + ewin->icon_pmm.type = 0; + ewin->icon_w = (int)w; + ewin->icon_h = (int)h; + ewin->icon_pmm.pmap = ECreatePixmap(disp, root.win, w, h, root.depth); if (ewin->client.icon_mask) - ewin->icon_mask = ECreatePixmap(disp, root.win, w, h, 1); + ewin->icon_pmm.mask = ECreatePixmap(disp, root.win, w, h, 1); + if (depth == 1) { GC gc; XGCValues gcv; - int r, g, b; - gc = XCreateGC(disp, ewin->icon_pmap, 0, &gcv); - r = 255; - g = 255; - b = 255; - XSetForeground(disp, gc, - Imlib_best_color_match(pImlibData, &r, &g, &b)); - XFillRectangle(disp, ewin->icon_pmap, gc, 0, 0, w, h); - r = 0; - g = 0; - b = 0; + gc = XCreateGC(disp, ewin->icon_pmm.pmap, 0, &gcv); + XSetForeground(disp, gc, WhitePixel(disp, root.scr)); + XFillRectangle(disp, ewin->icon_pmm.pmap, gc, 0, 0, w, h); XSetClipOrigin(disp, gc, 0, 0); XSetClipMask(disp, gc, ewin->client.icon_pmap); - XSetForeground(disp, gc, - Imlib_best_color_match(pImlibData, &r, &g, &b)); - XFillRectangle(disp, ewin->icon_pmap, gc, 0, 0, w, h); + XSetForeground(disp, gc, BlackPixel(disp, root.scr)); + XFillRectangle(disp, ewin->icon_pmm.pmap, gc, 0, 0, w, h); XFreeGC(disp, gc); } else - EPastePixmap(ewin->icon_pmap, ewin->client.icon_pmap, 0, 0, w, h); + EPastePixmap(ewin->icon_pmm.pmap, ewin->client.icon_pmap, 0, 0, w, h); + if (ewin->client.icon_mask) - EPastePixmap(ewin->icon_mask, ewin->client.icon_mask, 0, 0, w, h); - if ((ewin->icon_pmap_w < 1) || (ewin->icon_pmap_h < 1)) - { - if (ewin->icon_pmap) - Imlib_free_pixmap(pImlibData, ewin->icon_pmap); - if (ewin->icon_mask) - Imlib_free_pixmap(pImlibData, ewin->icon_mask); - ewin->icon_pmap = 0; - ewin->icon_mask = 0; - } + EPastePixmap(ewin->icon_pmm.mask, ewin->client.icon_mask, 0, 0, w, h); + + if ((ewin->icon_w < 1) || (ewin->icon_h < 1)) + FreePmapMask(&ewin->icon_pmm); } void IB_PasteDefaultBase(Drawable d, int x, int y, int w, int h) { ImageClass *ic; - Pixmap p, m; + PmapMask pmm; /* get the base pixmap */ ic = FindItem("DEFAULT_ICON_BUTTON", 0, LIST_FINDBY_NAME, LIST_TYPE_ICLASS); if (!ic) return; - IclassApplyCopy(ic, d, w, h, 0, 0, STATE_NORMAL, &p, &m); - PastePixmap(disp, d, p, m, x, y); - Imlib_free_pixmap(pImlibData, p); - Imlib_free_pixmap(pImlibData, m); + + IclassApplyCopy(ic, d, w, h, 0, 0, STATE_NORMAL, &pmm, 1); + PastePixmap(disp, d, pmm.pmap, pmm.mask, x, y); + FreePmapMask(&pmm); } void IB_PasteDefaultBaseMask(Drawable d, int x, int y, int w, int h) { ImageClass *ic; - Pixmap p, m; + PmapMask pmm; GC gc; XGCValues gcv; @@ -770,11 +757,11 @@ IB_PasteDefaultBaseMask(Drawable d, int x, int y, int w, int h) ic = FindItem("DEFAULT_ICON_BUTTON", 0, LIST_FINDBY_NAME, LIST_TYPE_ICLASS); if (!ic) return; - IclassApplyCopy(ic, d, w, h, 0, 0, STATE_NORMAL, &p, &m); - if (m) + + IclassApplyCopy(ic, d, w, h, 0, 0, STATE_NORMAL, &pmm, 1); + if (pmm.mask) { - PasteMask(disp, d, m, x, y, w, h); - Imlib_free_pixmap(pImlibData, m); + PasteMask(disp, d, pmm.mask, x, y, w, h); } else { @@ -783,7 +770,7 @@ IB_PasteDefaultBaseMask(Drawable d, int x, int y, int w, int h) XFillRectangle(disp, d, gc, x, y, w, h); XFreeGC(disp, gc); } - Imlib_free_pixmap(pImlibData, p); + FreePmapMask(&pmm); } void @@ -792,58 +779,56 @@ IB_GetEIcon(EWin * ewin) /* get the icon defined for this window in E's iconf match file */ Icondef *idef; ImageClass *ic; + Imlib_Image *im; + int w, h, mw, mh; + Iconbox *ib; - idef = - IB_MatchIcondef(ewin->client.title, ewin->client.name, - ewin->client.class); + idef = IB_MatchIcondef(ewin->client.title, ewin->client.name, + ewin->client.class); if (!idef) return; - { - ImlibImage *im; - im = ELoadImage(idef->icon_file); - if (im) - { - int w, h, mw, mh; - Iconbox *ib; + im = ELoadImage(idef->icon_file); + if (!im) + return; - w = im->rgb_width; - h = im->rgb_height; - ib = SelectIconboxForEwin(ewin); - if (ib) - { - mw = ib->iconsize; - mh = ib->iconsize; - if (ib->draw_icon_base) - { - ic = FindItem("DEFAULT_ICON_BUTTON", 0, LIST_FINDBY_NAME, - LIST_TYPE_ICLASS); - if (ic) - { - mw -= ic->padding.left + ic->padding.right; - mh -= ic->padding.top + ic->padding.bottom; - } - } - if (mw < w) - { - h = (mw * h) / w; - w = mw; - } - if (mh < h) - { - w = (mh * w) / h; - h = mh; - } - } - Imlib_render(pImlibData, im, w, h); - ewin->icon_pmap = Imlib_copy_image(pImlibData, im); - ewin->icon_mask = Imlib_copy_mask(pImlibData, im); - ewin->icon_pmap_w = w; - ewin->icon_pmap_h = h; - Imlib_destroy_image(pImlibData, im); - } - } + imlib_context_set_image(im); + w = imlib_image_get_width(); + h = imlib_image_get_height(); + ib = SelectIconboxForEwin(ewin); + if (ib) + { + mw = ib->iconsize; + mh = ib->iconsize; + if (ib->draw_icon_base) + { + ic = FindItem("DEFAULT_ICON_BUTTON", 0, LIST_FINDBY_NAME, + LIST_TYPE_ICLASS); + if (ic) + { + mw -= ic->padding.left + ic->padding.right; + mh -= ic->padding.top + ic->padding.bottom; + } + } + if (mw < w) + { + h = (mw * h) / w; + w = mw; + } + if (mh < h) + { + w = (mh * w) / h; + h = mh; + } + } + + imlib_render_pixmaps_for_whole_image_at_size(&ewin->icon_pmm.pmap, + &ewin->icon_pmm.mask, w, h); + ewin->icon_pmm.type = 1; + ewin->icon_w = w; + ewin->icon_h = h; + imlib_free_image(); } void @@ -1160,36 +1145,31 @@ void UpdateAppIcon(EWin * ewin, int imode) { /* free whatever we had before */ - if (ewin->icon_pmap) - Imlib_free_pixmap(pImlibData, ewin->icon_pmap); - if (ewin->icon_mask) - Imlib_free_pixmap(pImlibData, ewin->icon_mask); - ewin->icon_pmap = 0; - ewin->icon_mask = 0; + FreePmapMask(&ewin->icon_pmm); switch (imode) { case 0: /* snap first - if fails try app, then e */ - if (!ewin->icon_pmap) + if (!ewin->icon_pmm.pmap) { if (ewin->shaded) InstantUnShadeEwin(ewin); RaiseEwin(ewin); IB_SnapEWin(ewin); } - if (!ewin->icon_pmap) + if (!ewin->icon_pmm.pmap) IB_GetAppIcon(ewin); - if (!ewin->icon_pmap) + if (!ewin->icon_pmm.pmap) IB_GetEIcon(ewin); break; case 1: /* try app first, then e, then snap */ - if (!ewin->icon_pmap) + if (!ewin->icon_pmm.pmap) IB_GetAppIcon(ewin); - if (!ewin->icon_pmap) + if (!ewin->icon_pmm.pmap) IB_GetEIcon(ewin); - if (!ewin->icon_pmap) + if (!ewin->icon_pmm.pmap) { if (ewin->shaded) InstantUnShadeEwin(ewin); @@ -1199,9 +1179,9 @@ UpdateAppIcon(EWin * ewin, int imode) break; case 2: /* try E first, then snap */ - if (!ewin->icon_pmap) + if (!ewin->icon_pmm.pmap) IB_GetEIcon(ewin); - if (!ewin->icon_pmap) + if (!ewin->icon_pmm.pmap) { if (ewin->shaded) InstantUnShadeEwin(ewin); @@ -1229,12 +1209,12 @@ IB_CalcMax(Iconbox * ib) w = 8; h = 8; ewin = ib->icons[i]; - if (!ewin->icon_pmap) + if (!ewin->icon_pmm.pmap) UpdateAppIcon(ewin, ib->icon_mode); - if (ewin->icon_pmap) + if (ewin->icon_pmm.pmap) { - w = ewin->icon_pmap_w; - h = ewin->icon_pmap_h; + w = ewin->icon_w; + h = ewin->icon_h; } if (ib->draw_icon_base) { @@ -1293,12 +1273,12 @@ IB_FindIcon(Iconbox * ib, int px, int py) w = 8; h = 8; ewin = ib->icons[i]; - if (!ewin->icon_pmap) + if (!ewin->icon_pmm.pmap) UpdateAppIcon(ewin, ib->icon_mode); - if (ewin->icon_pmap) + if (ewin->icon_pmm.pmap) { - w = ewin->icon_pmap_w; - h = ewin->icon_pmap_h; + w = ewin->icon_w; + h = ewin->icon_h; xx = x; yy = y; if (ib->orientation) @@ -1869,6 +1849,43 @@ IB_FixPos(Iconbox * ib) } +static void +IB_RedrawIconboxAux1(Iconbox * ib, ImageClass * ic) +{ + int iw, ih; + + if (!ib->nobg) + { + if (ic) + { + PmapMask pmm; + + GetWinWH(ib->icon_win, (unsigned int *)&iw, (unsigned int *)&ih); + IclassApplyCopy(ic, ib->icon_win, iw, ih, 0, 0, STATE_NORMAL, + &pmm, 1); + EShapeCombineMask(disp, ib->icon_win, ShapeBounding, 0, 0, + pmm.mask, ShapeSet); + PastePixmap(disp, ib->pmap, pmm.pmap, pmm.mask, 0, 0); + FreePmapMask(&pmm); + } + /* Else what ? */ + } + else + { + GC gc; + XGCValues gcv; + Pixmap m; + + GetWinWH(ib->icon_win, (unsigned int *)&iw, (unsigned int *)&ih); + m = ECreatePixmap(disp, ib->icon_win, iw, ih, 1); + gc = XCreateGC(disp, m, 0, &gcv); + XSetForeground(disp, gc, 0); + XFillRectangle(disp, m, gc, 0, 0, iw, ih); + XFreeGC(disp, gc); + EFreePixmap(disp, m); + } +} + void RedrawIconbox(Iconbox * ib) { @@ -2051,8 +2068,7 @@ RedrawIconbox(Iconbox * ib) EResizeWindow(disp, ib->win, w, h); ICCCM_Configure(ib->ewin); EFreePixmap(disp, ib->pmap); - ib->pmap = - ECreatePixmap(disp, ib->icon_win, w, h, pImlibData->x.depth); + ib->pmap = ECreatePixmap(disp, ib->icon_win, w, h, root.depth); } ib->w = w; ib->h = h; @@ -2115,37 +2131,8 @@ RedrawIconbox(Iconbox * ib) ic = FindItem("ICONBOX_VERTICAL", 0, LIST_FINDBY_NAME, LIST_TYPE_ICLASS); - if (!ib->nobg) - { - if (ic) - { - Pixmap pmap = 0, mask = 0; - int iw, ih; - GetWinWH(ib->icon_win, (unsigned int *)&iw, - (unsigned int *)&ih); - IclassApplyCopy(ic, ib->icon_win, iw, ih, 0, 0, STATE_NORMAL, - &pmap, &mask); - EShapeCombineMask(disp, ib->icon_win, ShapeBounding, 0, 0, - mask, ShapeSet); - PastePixmap(disp, ib->pmap, pmap, mask, 0, 0); - Imlib_free_pixmap(pImlibData, pmap); - Imlib_free_pixmap(pImlibData, mask); - } - } - else - { - int iw, ih; - GC gc; - XGCValues gcv; - - GetWinWH(ib->icon_win, (unsigned int *)&iw, (unsigned int *)&ih); - m = ECreatePixmap(disp, ib->icon_win, iw, ih, 1); - gc = XCreateGC(disp, m, 0, &gcv); - XSetForeground(disp, gc, 0); - XFillRectangle(disp, m, gc, 0, 0, iw, ih); - XFreeGC(disp, gc); - } + IB_RedrawIconboxAux1(ib, ic); y = -ib->pos; x = 0; @@ -2162,12 +2149,12 @@ RedrawIconbox(Iconbox * ib) w = 8; h = 8; ewin = ib->icons[i]; - if (!ewin->icon_pmap) + if (!ewin->icon_pmm.pmap) UpdateAppIcon(ewin, ib->icon_mode); - if (ewin->icon_pmap) + if (ewin->icon_pmm.pmap) { - w = ewin->icon_pmap_w; - h = ewin->icon_pmap_h; + w = ewin->icon_w; + h = ewin->icon_h; if (ib->draw_icon_base) { IB_PasteDefaultBase(ib->pmap, x, y, ib->iconsize, @@ -2177,15 +2164,16 @@ RedrawIconbox(Iconbox * ib) ib->iconsize); } if (ib->draw_icon_base) - PastePixmap(disp, ib->pmap, ewin->icon_pmap, - ewin->icon_mask, x + ((ib->iconsize - w) / 2), + PastePixmap(disp, ib->pmap, ewin->icon_pmm.pmap, + ewin->icon_pmm.mask, + x + ((ib->iconsize - w) / 2), y + ((ib->iconsize - h) / 2)); else - PastePixmap(disp, ib->pmap, ewin->icon_pmap, - ewin->icon_mask, x + ((ib->iconsize - w) / 2), - y); + PastePixmap(disp, ib->pmap, ewin->icon_pmm.pmap, + ewin->icon_pmm.mask, + x + ((ib->iconsize - w) / 2), y); if (ib->nobg) - PasteMask(disp, m, ewin->icon_mask, + PasteMask(disp, m, ewin->icon_pmm.mask, x + ((ib->iconsize - w) / 2), y, w, h); } if (ib->draw_icon_base) @@ -2243,37 +2231,8 @@ RedrawIconbox(Iconbox * ib) ic = FindItem("ICONBOX_HORIZONTAL", 0, LIST_FINDBY_NAME, LIST_TYPE_ICLASS); - if (!ib->nobg) - { - if (ic) - { - Pixmap pmap = 0, mask = 0; - int iw, ih; - GetWinWH(ib->icon_win, (unsigned int *)&iw, - (unsigned int *)&ih); - IclassApplyCopy(ic, ib->icon_win, iw, ih, 0, 0, STATE_NORMAL, - &pmap, &mask); - EShapeCombineMask(disp, ib->icon_win, ShapeBounding, 0, 0, - mask, ShapeSet); - PastePixmap(disp, ib->pmap, pmap, mask, 0, 0); - Imlib_free_pixmap(pImlibData, pmap); - Imlib_free_pixmap(pImlibData, mask); - } - } - else - { - int iw, ih; - GC gc; - XGCValues gcv; - - GetWinWH(ib->icon_win, (unsigned int *)&iw, (unsigned int *)&ih); - m = ECreatePixmap(disp, ib->icon_win, iw, ih, 1); - gc = XCreateGC(disp, m, 0, &gcv); - XSetForeground(disp, gc, 0); - XFillRectangle(disp, m, gc, 0, 0, iw, ih); - XFreeGC(disp, gc); - } + IB_RedrawIconboxAux1(ib, ic); x = -ib->pos; y = 0; @@ -2290,12 +2249,12 @@ RedrawIconbox(Iconbox * ib) w = 8; h = 8; ewin = ib->icons[i]; - if (!ewin->icon_pmap) + if (!ewin->icon_pmm.pmap) UpdateAppIcon(ewin, ib->icon_mode); - if (ewin->icon_pmap) + if (ewin->icon_pmm.pmap) { - w = ewin->icon_pmap_w; - h = ewin->icon_pmap_h; + w = ewin->icon_w; + h = ewin->icon_h; if (ib->draw_icon_base) { IB_PasteDefaultBase(ib->pmap, x, y, ib->iconsize, @@ -2305,15 +2264,16 @@ RedrawIconbox(Iconbox * ib) ib->iconsize); } if (ib->draw_icon_base) - PastePixmap(disp, ib->pmap, ewin->icon_pmap, - ewin->icon_mask, x + ((ib->iconsize - w) / 2), + PastePixmap(disp, ib->pmap, ewin->icon_pmm.pmap, + ewin->icon_pmm.mask, + x + ((ib->iconsize - w) / 2), y + ((ib->iconsize - h) / 2)); else - PastePixmap(disp, ib->pmap, ewin->icon_pmap, - ewin->icon_mask, x, + PastePixmap(disp, ib->pmap, ewin->icon_pmm.pmap, + ewin->icon_pmm.mask, x, y + ((ib->iconsize - h) / 2)); if (ib->nobg) - PasteMask(disp, m, ewin->icon_mask, x, + PasteMask(disp, m, ewin->icon_pmm.mask, x, y + ((ib->iconsize - h) / 2), w, h); } if (ib->draw_icon_base) @@ -2347,7 +2307,7 @@ IconboxResize(Iconbox * ib, int w, int h) return; EResizeWindow(disp, ib->win, w, h); EFreePixmap(disp, ib->pmap); - ib->pmap = ECreatePixmap(disp, ib->icon_win, w, h, pImlibData->x.depth); + ib->pmap = ECreatePixmap(disp, ib->icon_win, w, h, root.depth); ib->w = w; ib->h = h; RedrawIconbox(ib); diff --git a/src/init.c b/src/init.c index af2d6ffb..fe43d688 100644 --- a/src/init.c +++ b/src/init.c @@ -38,7 +38,6 @@ SetupFallbackClasses(void) ActionClass *ac; Action *a; Background *bg; - ImlibColor icl; TextClass *tc; EDBUG(5, "SetupFallbackClasses"); @@ -60,111 +59,51 @@ SetupFallbackClasses(void) ic = CreateIclass(); ic->name = duplicate("__FALLBACK_ICLASS"); ic->norm.normal = CreateImageState(); - ic->norm.normal->hihi.r = 255; - ic->norm.normal->hihi.g = 255; - ic->norm.normal->hihi.b = 255; - ic->norm.normal->hi.r = 255; - ic->norm.normal->hi.g = 255; - ic->norm.normal->hi.b = 255; - ic->norm.normal->bg.r = 160; - ic->norm.normal->bg.g = 160; - ic->norm.normal->bg.b = 160; - ic->norm.normal->lo.r = 0; - ic->norm.normal->lo.g = 0; - ic->norm.normal->lo.b = 0; - ic->norm.normal->lolo.r = 0; - ic->norm.normal->lolo.g = 0; - ic->norm.normal->lolo.b = 0; + ESetColor(&(ic->norm.normal->hihi), 255, 255, 255); + ESetColor(&(ic->norm.normal->hi), 255, 255, 255); + ESetColor(&(ic->norm.normal->bg), 160, 160, 160); + ESetColor(&(ic->norm.normal->lo), 0, 0, 0); + ESetColor(&(ic->norm.normal->lolo), 0, 0, 0); ic->norm.normal->bevelstyle = BEVEL_AMIGA; ic->norm.hilited = CreateImageState(); - ic->norm.hilited->hihi.r = 255; - ic->norm.hilited->hihi.g = 255; - ic->norm.hilited->hihi.b = 255; - ic->norm.hilited->hi.r = 255; - ic->norm.hilited->hi.g = 255; - ic->norm.hilited->hi.b = 255; - ic->norm.hilited->bg.r = 192; - ic->norm.hilited->bg.g = 192; - ic->norm.hilited->bg.b = 192; - ic->norm.hilited->lo.r = 0; - ic->norm.hilited->lo.g = 0; - ic->norm.hilited->lo.b = 0; - ic->norm.hilited->lolo.r = 0; - ic->norm.hilited->lolo.g = 0; - ic->norm.hilited->lolo.b = 0; + ESetColor(&(ic->norm.hilited->hihi), 255, 255, 255); + ESetColor(&(ic->norm.hilited->hi), 255, 255, 255); + ESetColor(&(ic->norm.hilited->bg), 192, 192, 192); + ESetColor(&(ic->norm.hilited->lo), 0, 0, 0); + ESetColor(&(ic->norm.hilited->lolo), 0, 0, 0); ic->norm.hilited->bevelstyle = BEVEL_AMIGA; ic->norm.clicked = CreateImageState(); - ic->norm.clicked->hihi.r = 0; - ic->norm.clicked->hihi.g = 0; - ic->norm.clicked->hihi.b = 0; - ic->norm.clicked->hi.r = 0; - ic->norm.clicked->hi.g = 0; - ic->norm.clicked->hi.b = 0; - ic->norm.clicked->bg.r = 192; - ic->norm.clicked->bg.g = 192; - ic->norm.clicked->bg.b = 192; - ic->norm.clicked->lo.r = 255; - ic->norm.clicked->lo.g = 255; - ic->norm.clicked->lo.b = 255; - ic->norm.clicked->lolo.r = 255; - ic->norm.clicked->lolo.g = 255; - ic->norm.clicked->lolo.b = 255; + ESetColor(&(ic->norm.clicked->hihi), 0, 0, 0); + ESetColor(&(ic->norm.clicked->hi), 0, 0, 0); + ESetColor(&(ic->norm.clicked->bg), 192, 192, 192); + ESetColor(&(ic->norm.clicked->lo), 255, 255, 255); + ESetColor(&(ic->norm.clicked->lolo), 255, 255, 255); ic->norm.clicked->bevelstyle = BEVEL_AMIGA; ic->active.normal = CreateImageState(); - ic->active.normal->hihi.r = 255; - ic->active.normal->hihi.g = 255; - ic->active.normal->hihi.b = 255; - ic->active.normal->hi.r = 255; - ic->active.normal->hi.g = 255; - ic->active.normal->hi.b = 255; - ic->active.normal->bg.r = 180; - ic->active.normal->bg.g = 140; - ic->active.normal->bg.b = 160; - ic->active.normal->lo.r = 0; - ic->active.normal->lo.g = 0; - ic->active.normal->lo.b = 0; - ic->active.normal->lolo.r = 0; - ic->active.normal->lolo.g = 0; - ic->active.normal->lolo.b = 0; + ESetColor(&(ic->active.normal->hihi), 255, 255, 255); + ESetColor(&(ic->active.normal->hi), 255, 255, 255); + ESetColor(&(ic->active.normal->bg), 180, 140, 160); + ESetColor(&(ic->active.normal->lo), 0, 0, 0); + ESetColor(&(ic->active.normal->lolo), 0, 0, 0); ic->active.normal->bevelstyle = BEVEL_AMIGA; ic->active.hilited = CreateImageState(); - ic->active.hilited->hihi.r = 255; - ic->active.hilited->hihi.g = 255; - ic->active.hilited->hihi.b = 255; - ic->active.hilited->hi.r = 255; - ic->active.hilited->hi.g = 255; - ic->active.hilited->hi.b = 255; - ic->active.hilited->bg.r = 230; - ic->active.hilited->bg.g = 190; - ic->active.hilited->bg.b = 210; - ic->active.hilited->lo.r = 0; - ic->active.hilited->lo.g = 0; - ic->active.hilited->lo.b = 0; - ic->active.hilited->lolo.r = 0; - ic->active.hilited->lolo.g = 0; - ic->active.hilited->lolo.b = 0; + ESetColor(&(ic->active.hilited->hihi), 255, 255, 255); + ESetColor(&(ic->active.hilited->hi), 255, 255, 255); + ESetColor(&(ic->active.hilited->bg), 230, 190, 210); + ESetColor(&(ic->active.hilited->lo), 0, 0, 0); + ESetColor(&(ic->active.hilited->lolo), 0, 0, 0); ic->active.hilited->bevelstyle = BEVEL_AMIGA; ic->active.clicked = CreateImageState(); - ic->active.clicked->hihi.r = 0; - ic->active.clicked->hihi.g = 0; - ic->active.clicked->hihi.b = 0; - ic->active.clicked->hi.r = 0; - ic->active.clicked->hi.g = 0; - ic->active.clicked->hi.b = 0; - ic->active.clicked->bg.r = 230; - ic->active.clicked->bg.g = 190; - ic->active.clicked->bg.b = 210; - ic->active.clicked->lo.r = 255; - ic->active.clicked->lo.g = 255; - ic->active.clicked->lo.b = 255; - ic->active.clicked->lolo.r = 255; - ic->active.clicked->lolo.g = 255; - ic->active.clicked->lolo.b = 255; + ESetColor(&(ic->active.clicked->hihi), 0, 0, 0); + ESetColor(&(ic->active.clicked->hi), 0, 0, 0); + ESetColor(&(ic->active.clicked->bg), 230, 190, 210); + ESetColor(&(ic->active.clicked->lo), 255, 255, 255); + ESetColor(&(ic->active.clicked->lolo), 255, 255, 255); ic->active.clicked->bevelstyle = BEVEL_AMIGA; IclassPopulate(ic); @@ -188,7 +127,7 @@ SetupFallbackClasses(void) AddItem(b, b->name, 0, LIST_TYPE_BORDER); /* create a fallback background in case no background is found */ - bg = CreateDesktopBG("NONE", &icl, NULL, 0, 0, 0, 0, 0, 0, NULL, 0, 0, 0, 0, + bg = CreateDesktopBG("NONE", NULL, NULL, 0, 0, 0, 0, 0, 0, NULL, 0, 0, 0, 0, 0); AddItem(bg, bg->name, 0, LIST_TYPE_BACKGROUND); @@ -198,9 +137,7 @@ SetupFallbackClasses(void) tc->norm.normal = CreateTextState(); tc->norm.normal->fontname = duplicate("-*-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*"); - tc->norm.normal->fg_col.r = 0; - tc->norm.normal->fg_col.g = 0; - tc->norm.normal->fg_col.b = 0; + ESetColor(&(tc->norm.normal->fg_col), 0, 0, 0); AddItem(tc, tc->name, 0, LIST_TYPE_TCLASS); EDBUG_RETURN_; diff --git a/src/ipc.c b/src/ipc.c index 20d59a7c..f95f9c2e 100644 --- a/src/ipc.c +++ b/src/ipc.c @@ -1070,6 +1070,7 @@ IPC_Background(char *params, Client * c) char type[FILEPATH_LEN_MAX]; char valu[FILEPATH_LEN_MAX]; Background *bg = NULL; + int r, g, b; buf[0] = 0; @@ -1093,6 +1094,7 @@ IPC_Background(char *params, Client * c) if (bg) { + EGetColor(&(bg->bg.solid), &r, &g, &b); Esnprintf(buf, sizeof(buf), "%s ref_count %u\n" " bg.solid\t %i %i %i \n" " bg.file\t %s \ttop.file\t %s \n" @@ -1102,13 +1104,12 @@ IPC_Background(char *params, Client * c) " bg.yjust\t %i \ttop.yjust\t %i \n" " bg.xperc\t %i \ttop.xperc\t %i \n" " bg.yperc\t %i \ttop.yperc\t %i \n", bg->name, - bg->ref_count, bg->bg.solid.r, bg->bg.solid.g, - bg->bg.solid.b, bg->bg.file, bg->top.file, - bg->bg.tile, bg->bg.keep_aspect, - bg->top.keep_aspect, bg->bg.xjust, - bg->top.xjust, bg->bg.yjust, bg->top.yjust, - bg->bg.xperc, bg->top.xperc, bg->bg.yperc, - bg->top.yperc); + bg->ref_count, r, g, b, + bg->bg.file, bg->top.file, bg->bg.tile, + bg->bg.keep_aspect, bg->top.keep_aspect, + bg->bg.xjust, bg->top.xjust, bg->bg.yjust, + bg->top.yjust, bg->bg.xperc, bg->top.xperc, + bg->bg.yperc, bg->top.yperc); } else Esnprintf(buf, sizeof(buf), @@ -1136,7 +1137,7 @@ IPC_Background(char *params, Client * c) word(params, 3, valu); if (!strcmp(type, "bg.solid")) { - char R[3], G[3], B[3]; + char R[3], G[3], B[3]; /* Crash ??? */ R[0] = 0; G[0] = 0; @@ -1146,9 +1147,8 @@ IPC_Background(char *params, Client * c) word(params, 4, G); word(params, 5, B); - bg->bg.solid.r = atoi(R); - bg->bg.solid.g = atoi(G); - bg->bg.solid.b = atoi(B); + ESetColor(&(bg->bg.solid), atoi(R), atoi(G), + atoi(B)); } else if (!strcmp(type, "bg.file")) { @@ -1225,8 +1225,8 @@ IPC_Background(char *params, Client * c) { if (bg->ref_count == 0) { - RemoveItem(name, 0, LIST_FINDBY_NAME, - LIST_TYPE_BACKGROUND); + RemoveItem(name, 0, + LIST_FINDBY_NAME, LIST_TYPE_BACKGROUND); FreeDesktopBG(bg); } else @@ -1725,7 +1725,7 @@ IPC_ImageClass(char *params, Client * c) word(params, 3, param3); p = (Pixmap) strtol(param3, (char **)NULL, 0); - Imlib_free_pixmap(pImlibData, p); + imlib_free_pixmap_and_mask(p); } else if (!strcmp(param2, "get_padding")) { @@ -1751,7 +1751,7 @@ IPC_ImageClass(char *params, Client * c) LIST_TYPE_ICLASS); if (iclass) { - ImlibImage *im = NULL; + Imlib_Image *im = NULL; if (iclass->norm.normal->im_file) { @@ -1759,14 +1759,16 @@ IPC_ImageClass(char *params, Client * c) iclass->norm.normal->real_file = FindFile(iclass->norm.normal->im_file); if (iclass->norm.normal->real_file) - im = Imlib_load_image(pImlibData, - iclass->norm. - normal->real_file); + im = + imlib_load_image(iclass->norm.normal-> + real_file); if (im) { + imlib_context_set_image(im); Esnprintf(buf, sizeof(buf), "%i %i", - im->rgb_width, im->rgb_height); - Imlib_destroy_image(pImlibData, im); + imlib_image_get_width(), + imlib_image_get_height()); + imlib_free_image(); } else Esnprintf(buf, sizeof(buf), @@ -1819,7 +1821,6 @@ IPC_ImageClass(char *params, Client * c) else if (!strcmp(param2, "apply_copy")) { ImageClass *iclass; - Pixmap pmap = 0, mask = 0; iclass = (ImageClass *) FindItem(param1, 0, LIST_FINDBY_NAME, @@ -1846,16 +1847,19 @@ IPC_ImageClass(char *params, Client * c) "Error: missing width and/or height"); else { + PmapMask pmm; + w = (int)strtol(atword(params, 5), (char **)NULL, 0); h = (int)strtol(hptr, (char **)NULL, 0); pq = queue_up; queue_up = 0; - IclassApplyCopy(iclass, win, w, h, 0, 0, st, &pmap, - &mask); + IclassApplyCopy(iclass, win, w, h, 0, 0, st, &pmm, + 1); queue_up = pq; - Esnprintf(buf, sizeof(buf), "0x%08x 0x%08x", pmap, - mask); + Esnprintf(buf, sizeof(buf), "0x%08x 0x%08x", + pmm.pmap, pmm.mask); +/* FreePmapMask(&pmm); ??? */ } } } diff --git a/src/main.c b/src/main.c index 314d4bac..f5c0bd51 100644 --- a/src/main.c +++ b/src/main.c @@ -257,13 +257,14 @@ main(int argc, char **argv) RefreshDesktop(0); if (mode.sound) { - ApplySclass(FindItem - ("SOUND_STARTUP", 0, LIST_FINDBY_NAME, LIST_TYPE_SCLASS)); - DestroySclass(RemoveItem - ("SOUND_STARTUP", 0, LIST_FINDBY_NAME, LIST_TYPE_SCLASS)); + ApplySclass(FindItem("SOUND_STARTUP", 0, + LIST_FINDBY_NAME, LIST_TYPE_SCLASS)); + DestroySclass(RemoveItem("SOUND_STARTUP", 0, + LIST_FINDBY_NAME, LIST_TYPE_SCLASS)); } /* toss down the dragbar and related */ InitDesktopControls(); + /* then draw all the buttons that belong on the desktop */ blst = (Button **) ListItemTypeID(&num, LIST_TYPE_BUTTON, 0); if (blst) @@ -275,6 +276,7 @@ main(int argc, char **argv) } Efree(blst); } + HintsInit(); SessionInit(); ShowDesktopControls(); @@ -356,17 +358,18 @@ main(int argc, char **argv) desks.slidein = ps; } XSync(disp, False); + /* if we didn't have an external window piped to us, we'll do some stuff */ if (!mode.mapslide) CreateStartupDisplay(0); - if ((bg = - RemoveItem("STARTUP_BACKGROUND_SIDEWAYS", 0, LIST_FINDBY_NAME, - LIST_TYPE_BACKGROUND))) + + if ((bg = RemoveItem("STARTUP_BACKGROUND_SIDEWAYS", 0, + LIST_FINDBY_NAME, LIST_TYPE_BACKGROUND))) FreeDesktopBG(bg); - if ((bg = - RemoveItem("STARTUP_BACKGROUND", 0, LIST_FINDBY_NAME, - LIST_TYPE_BACKGROUND))) + if ((bg = RemoveItem("STARTUP_BACKGROUND", 0, + LIST_FINDBY_NAME, LIST_TYPE_BACKGROUND))) FreeDesktopBG(bg); + #ifdef SIGCONT for (i = 0; i < child_count; i++) kill(e_children[i], SIGCONT); diff --git a/src/menus.c b/src/menus.c index 63c5b70c..b234b506 100644 --- a/src/menus.c +++ b/src/menus.c @@ -280,6 +280,7 @@ ShowMenu(Menu * m, char noshow) EDBUG(5, "ShowMenu"); if ((m->num <= 0) || (!m->style)) EDBUG_RETURN_; + if (m->stuck) { Button *button; @@ -308,6 +309,7 @@ ShowMenu(Menu * m, char noshow) } if (!m->win) RealizeMenu(m); + ewin = FindEwinByMenu(m); if (ewin) { @@ -430,8 +432,10 @@ ShowMenu(Menu * m, char noshow) ewin->dialog = NULL; } m->stuck = 0; + if (!FindMenu(m->win)) AddItem(m, m->name, m->win, LIST_TYPE_MENU); + { Button *button; EWin *ewin99; @@ -456,6 +460,7 @@ ShowMenu(Menu * m, char noshow) } } } + EDBUG_RETURN_; } @@ -507,12 +512,12 @@ CreateMenuItem(char *text, ImageClass * iclass, int action_id, mi->child = child; mi->state = STATE_NORMAL; mi->win = 0; - mi->pmap[0] = 0; - mi->pmap[1] = 0; - mi->pmap[2] = 0; - mi->mask[0] = 0; - mi->mask[1] = 0; - mi->mask[2] = 0; + mi->pmm[0].pmap = 0; + mi->pmm[1].pmap = 0; + mi->pmm[2].pmap = 0; + mi->pmm[0].mask = 0; + mi->pmm[1].mask = 0; + mi->pmm[2].mask = 0; mi->icon_win = 0; mi->icon_w = 0; mi->icon_h = 0; @@ -538,8 +543,8 @@ CreateMenu(void) m->num = 0; m->items = NULL; m->win = 0; - m->pmap = 0; - m->mask = 0; + m->pmm.pmap = 0; + m->pmm.mask = 0; m->stuck = 0; m->parent = NULL; m->sel_item = NULL; @@ -586,12 +591,7 @@ DestroyMenu(Menu * m) if (m->items[i]->params) Efree(m->items[i]->params); for (j = 0; j < 3; j++) - { - if (m->items[i]->pmap[j]) - Imlib_free_pixmap(pImlibData, m->items[i]->pmap[j]); - if (m->items[i]->mask[j]) - Imlib_free_pixmap(pImlibData, m->items[i]->mask[j]); - } + FreePmapMask(&(m->items[i]->pmm[j])); if (m->items[i]->icon_iclass) m->items[i]->icon_iclass->ref_count--; if (m->items[i]) @@ -632,12 +632,7 @@ EmptyMenu(Menu * m) if (m->items[i]->params) Efree(m->items[i]->params); for (j = 0; j < 3; j++) - { - if (m->items[i]->pmap[j]) - Imlib_free_pixmap(pImlibData, m->items[i]->pmap[j]); - if (m->items[i]->mask[j]) - Imlib_free_pixmap(pImlibData, m->items[i]->mask[j]); - } + FreePmapMask(&(m->items[i]->pmm[j])); if (m->items[i]->win) EDestroyWindow(disp, m->items[i]->win); if (m->items[i]) @@ -700,7 +695,7 @@ RealizeMenu(Menu * m) int i, maxh = 0, maxw = 0, maxx1, maxx2, w, h, x, y, r, mmw, mmh; unsigned int iw, ih; - ImlibImage *im; + Imlib_Image *im; XSetWindowAttributes att; XTextProperty xtp; char pq, has_i, has_s; @@ -708,8 +703,10 @@ RealizeMenu(Menu * m) EDBUG(5, "RealizeMenu"); if (!m->style) EDBUG_RETURN_; + if (!m->win) m->win = ECreateWindow(root.win, 0, 0, 1, 1, 0); + if (m->title) { xtp.encoding = XA_STRING; @@ -728,6 +725,7 @@ RealizeMenu(Menu * m) att.event_mask = ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask; + for (i = 0; i < m->num; i++) { if (m->items[i]->child) @@ -752,19 +750,21 @@ RealizeMenu(Menu * m) im = ELoadImage(m->items[i]->icon_iclass->norm.normal->im_file); if (im) { + imlib_context_set_image(im); m->items[i]->icon_win = - ECreateWindow(m->items[i]->win, 0, 0, im->rgb_width, - im->rgb_height, 0); + ECreateWindow(m->items[i]->win, 0, 0, + imlib_image_get_width(), + imlib_image_get_height(), 0); EMapWindow(disp, m->items[i]->icon_win); XChangeWindowAttributes(disp, m->items[i]->icon_win, CWEventMask, &att); - m->items[i]->icon_w = im->rgb_width; - m->items[i]->icon_h = im->rgb_height; - if (im->rgb_height > maxh) - maxh = im->rgb_height; - if (im->rgb_width > maxx2) - maxx2 = im->rgb_width; - Imlib_destroy_image(pImlibData, im); + m->items[i]->icon_w = imlib_image_get_width(); + m->items[i]->icon_h = imlib_image_get_height(); + if (imlib_image_get_height() > maxh) + maxh = imlib_image_get_height(); + if (imlib_image_get_width() > maxx2) + maxx2 = imlib_image_get_width(); + imlib_free_image(); } else m->items[i]->icon_iclass = NULL; @@ -892,12 +892,14 @@ RealizeMenu(Menu * m) mmh += m->style->bg_iclass->padding.bottom; } EResizeWindow(disp, m->win, mmw, mmh); + if (!m->style->use_item_bg) { IclassApplyCopy(m->style->bg_iclass, m->win, mmw, mmh, 0, 0, - STATE_NORMAL, &(m->pmap), &(m->mask)); - ESetWindowBackgroundPixmap(disp, m->win, m->pmap); - EShapeCombineMask(disp, m->win, ShapeBounding, 0, 0, m->mask, ShapeSet); + STATE_NORMAL, &m->pmm, 1); + ESetWindowBackgroundPixmap(disp, m->win, m->pmm.pmap); + EShapeCombineMask(disp, m->win, ShapeBounding, 0, 0, m->pmm.mask, + ShapeSet); for (i = 0; i < m->num; i++) DrawMenuItem(m, m->items[i], 0); } @@ -907,6 +909,7 @@ RealizeMenu(Menu * m) DrawMenuItem(m, m->items[i], 0); PropagateShapes(m->win); } + queue_up = pq; EDBUG_RETURN_; } @@ -919,12 +922,14 @@ DrawMenuItem(Menu * m, MenuItem * mi, char shape) unsigned int w, h; int x, y; char pq; - Pixmap pmap, mask; + PmapMask *mi_pmm; EDBUG(5, "DrawMenuItem"); pq = queue_up; queue_up = 0; - if (!mi->pmap[(int)(mi->state)]) + + mi_pmm = &(mi->pmm[(int)(mi->state)]); + if (!mi_pmm->pmap) { if (mi->text) { @@ -932,32 +937,30 @@ DrawMenuItem(Menu * m, MenuItem * mi, char shape) GetWinXY(mi->win, &x, &y); if (!m->style->use_item_bg) { - mi->pmap[(int)(mi->state)] = - ECreatePixmap(disp, mi->win, w, h, pImlibData->x.depth); - gc = XCreateGC(disp, m->pmap, 0, &gcv); - XCopyArea(disp, m->pmap, mi->pmap[(int)(mi->state)], gc, x, y, - w, h, 0, 0); - mi->mask[(int)(mi->state)] = None; + mi_pmm->type = 0; + mi_pmm->pmap = ECreatePixmap(disp, mi->win, w, h, root.depth); + gc = XCreateGC(disp, m->pmm.pmap, 0, &gcv); + XCopyArea(disp, m->pmm.pmap, mi_pmm->pmap, gc, x, y, w, h, 0, + 0); + mi_pmm->mask = None; if ((mi->state != STATE_NORMAL) || (mi->child)) { - pmap = 0; - mask = 0; + PmapMask pmm; + if (mi->child) IclassApplyCopy(m->style->sub_iclass, mi->win, w, h, - 0, 0, mi->state, &pmap, &mask); + 0, 0, mi->state, &pmm, 1); else IclassApplyCopy(m->style->item_iclass, mi->win, w, h, - 0, 0, mi->state, &pmap, &mask); - if (mask) + 0, 0, mi->state, &pmm, 1); + if (pmm.mask) { - XSetClipMask(disp, gc, mask); + XSetClipMask(disp, gc, pmm.mask); XSetClipOrigin(disp, gc, 0, 0); } - XCopyArea(disp, pmap, mi->pmap[(int)(mi->state)], gc, 0, - 0, w, h, 0, 0); - Imlib_free_pixmap(pImlibData, pmap); - if (mask) - Imlib_free_pixmap(pImlibData, mask); + XCopyArea(disp, pmm.pmap, mi_pmm->pmap, gc, 0, 0, w, h, + 0, 0); + FreePmapMask(&pmm); } XFreeGC(disp, gc); } @@ -965,26 +968,26 @@ DrawMenuItem(Menu * m, MenuItem * mi, char shape) { if (mi->child) IclassApplyCopy(m->style->sub_iclass, mi->win, w, h, 0, 0, - mi->state, &(mi->pmap[(int)(mi->state)]), - &(mi->mask[(int)(mi->state)])); + mi->state, mi_pmm, 1); else IclassApplyCopy(m->style->item_iclass, mi->win, w, h, 0, 0, - mi->state, &(mi->pmap[(int)(mi->state)]), - &(mi->mask[(int)(mi->state)])); + mi->state, mi_pmm, 1); } } } + if ((m->style->tclass) && (mi->text)) { - TextDraw(m->style->tclass, mi->pmap[(int)(mi->state)], 0, 0, mi->state, + TextDraw(m->style->tclass, mi_pmm->pmap, 0, 0, mi->state, mi->text, mi->text_x, mi->text_y, mi->text_w, mi->text_h, 17, m->style->tclass->justification); } + if (mi->text) { - ESetWindowBackgroundPixmap(disp, mi->win, mi->pmap[(int)(mi->state)]); - EShapeCombineMask(disp, mi->win, ShapeBounding, 0, 0, - mi->mask[(int)(mi->state)], ShapeSet); + ESetWindowBackgroundPixmap(disp, mi->win, mi_pmm->pmap); + EShapeCombineMask(disp, mi->win, ShapeBounding, 0, 0, mi_pmm->mask, + ShapeSet); XClearWindow(disp, mi->win); } else @@ -1014,8 +1017,10 @@ DrawMenuItem(Menu * m, MenuItem * mi, char shape) mi->state, 0); } } + if ((shape) && (m->style->use_item_bg)) PropagateShapes(m->win); + queue_up = pq; EDBUG_RETURN_; } @@ -1095,15 +1100,15 @@ CreateMenuFromDirectory(char *name, MenuStyle * ms, char *dir) LIST_TYPE_BACKGROUND); if (!bg) { - ImlibImage *im; + Imlib_Image *im; word(s, 2, s2); Esnprintf(ss, sizeof(ss), "%s/%s", dir, s2); - im = Imlib_load_image(pImlibData, ss); + im = imlib_load_image(ss); if (im) { - ImlibImage *im2; - ImlibColor icl; + Imlib_Image *im2; + XColor xclr; char tile = 1, keep_asp = 0; int width, height; int scalex = 0, scaley = 0; @@ -1114,24 +1119,32 @@ CreateMenuFromDirectory(char *name, MenuStyle * ms, char *dir) Esnprintf(s2, sizeof(s2), "%s/cached/img/%s", UserCacheDir(), s3); - width = im->rgb_width; - height = im->rgb_height; + imlib_context_set_image(im); + width = imlib_image_get_width(); + height = imlib_image_get_height(); h2 = maxh; - w2 = (im->rgb_width * h2) / im->rgb_height; + w2 = + (imlib_image_get_width() * h2) / + imlib_image_get_height(); if (w2 > maxw) { w2 = maxw; - h2 = (im->rgb_height * w2) / - im->rgb_width; + h2 = + (imlib_image_get_height() * w2) / + imlib_image_get_width(); } - im2 = - Imlib_clone_scaled_image(pImlibData, im, w2, - h2); - Imlib_save_image_to_ppm(pImlibData, im2, s2); - Imlib_changed_image(pImlibData, im2); - Imlib_changed_image(pImlibData, im); - Imlib_kill_image(pImlibData, im2); - Imlib_kill_image(pImlibData, im); + im2 = imlib_create_cropped_scaled_image(0, 0, + imlib_image_get_width + (), + imlib_image_get_height + (), w2, + h2); + imlib_free_image_and_decache(); + imlib_context_set_image(im2); + imlib_image_set_format("ppm"); + imlib_save_image(s2); + imlib_free_image_and_decache(); + scr_asp = (root.w << 16) / root.h; im_asp = (width << 16) / height; if (width == height) @@ -1180,10 +1193,8 @@ CreateMenuFromDirectory(char *name, MenuStyle * ms, char *dir) tile = 0; keep_asp = 1; } - icl.r = 0; - icl.g = 0; - icl.b = 0; - bg = CreateDesktopBG(s3, &icl, ss, tile, + ESetColor(&xclr, 0, 0, 0); + bg = CreateDesktopBG(s3, &xclr, ss, tile, keep_asp, justx, justy, scalex, scaley, NULL, 0, 0, 0, 0, 0); @@ -1323,13 +1334,13 @@ CreateMenuFromDirectory(char *name, MenuStyle * ms, char *dir) LIST_TYPE_BACKGROUND); if (!bg) { - ImlibImage *im; + Imlib_Image *im; - im = Imlib_load_image(pImlibData, ss); + im = imlib_load_image(ss); if (im) { - ImlibImage *im2; - ImlibColor icl; + Imlib_Image *im2; + XColor xclr; char tile = 1, keep_asp = 0; int width, height, scalex = 0, scaley = 0; @@ -1338,22 +1349,31 @@ CreateMenuFromDirectory(char *name, MenuStyle * ms, char *dir) Esnprintf(s2, sizeof(s2), "%s/cached/img/%s", UserCacheDir(), s3); - width = im->rgb_width; - height = im->rgb_height; + imlib_context_set_image(im); + width = imlib_image_get_width(); + height = imlib_image_get_height(); h2 = maxh; - w2 = (im->rgb_width * h2) / im->rgb_height; + w2 = + (imlib_image_get_width() * h2) / + imlib_image_get_height(); if (w2 > maxw) { w2 = maxw; - h2 = (im->rgb_height * w2) / im->rgb_width; + h2 = + (imlib_image_get_height() * w2) / + imlib_image_get_width(); } - im2 = - Imlib_clone_scaled_image(pImlibData, im, w2, h2); - Imlib_save_image_to_ppm(pImlibData, im2, s2); - Imlib_changed_image(pImlibData, im2); - Imlib_changed_image(pImlibData, im); - Imlib_kill_image(pImlibData, im2); - Imlib_kill_image(pImlibData, im); + im2 = imlib_create_cropped_scaled_image(0, 0, + imlib_image_get_width + (), + imlib_image_get_height + (), w2, h2); + imlib_free_image_and_decache(); + imlib_context_set_image(im2); + imlib_image_set_format("ppm"); + imlib_save_image(s2); + imlib_free_image_and_decache(); + scr_asp = (root.w << 16) / root.h; im_asp = (width << 16) / height; if (width == height) @@ -1392,10 +1412,8 @@ CreateMenuFromDirectory(char *name, MenuStyle * ms, char *dir) tile = 0; keep_asp = 1; } - icl.r = 0; - icl.g = 0; - icl.b = 0; - bg = CreateDesktopBG(s3, &icl, ss, tile, keep_asp, + ESetColor(&xclr, 0, 0, 0); + bg = CreateDesktopBG(s3, &xclr, ss, tile, keep_asp, 512, 512, scalex, scaley, NULL, 0, 0, 0, 0, 0); AddItem(bg, bg->name, 0, LIST_TYPE_BACKGROUND); diff --git a/src/pager.c b/src/pager.c index 0e564ae2..d513aa98 100644 --- a/src/pager.c +++ b/src/pager.c @@ -43,6 +43,7 @@ PagerScaleLine(Pixmap dest, Window src, int dx, int dy, int sw, int pw, int sy, gcv.subwindow_mode = IncludeInferiors; gc = XCreateGC(disp, src, GCSubwindowMode, &gcv); } + p_grab = ECreatePixImg(dest, sw, 1); if (p_grab) { @@ -107,6 +108,7 @@ PagerScaleLine(Pixmap dest, Window src, int dx, int dy, int sw, int pw, int sy, return; } } + if (HIQ) { int v1, v2, v3, v4, difx; @@ -125,7 +127,7 @@ PagerScaleLine(Pixmap dest, Window src, int dx, int dy, int sw, int pw, int sy, xim3 = px_buf; } difx = (sw / pw) / 2; - switch (pImlibData->x.render_depth) + switch (IC_RenderDepth()) { case 24: case 32: @@ -522,9 +524,10 @@ CreatePager(void) if ((!did_dialog) && (SNAP)) { - if (pImlibData->x.shm) +#if !USE_IMLIB2 + if (pImlib_Context->x.shm) { - if (!pImlibData->x.shmp) + if (!pImlib_Context->x.shmp) { if (XShmPixmapFormat(disp) != ZPixmap) { @@ -569,6 +572,7 @@ CreatePager(void) "in your Imlib config, if you disabled it, or disable Pager\n" "snapshots.\n" "\n")); } +#endif did_dialog = 1; } GetAreaSize(&ax, &ay); @@ -583,9 +587,8 @@ CreatePager(void) p->dw = ((48 * root.w) / root.h); p->dh = 48; p->win = ECreateWindow(root.win, 0, 0, p->w, p->h, 0); - p->pmap = ECreatePixmap(disp, p->win, p->w, p->h, pImlibData->x.depth); - p->bgpmap = - ECreatePixmap(disp, p->win, p->w / ax, p->h / ay, pImlibData->x.depth); + p->pmap = ECreatePixmap(disp, p->win, p->w, p->h, root.depth); + p->bgpmap = ECreatePixmap(disp, p->win, p->w / ax, p->h / ay, root.depth); ESetWindowBackgroundPixmap(disp, p->win, p->pmap); XSelectInput(disp, p->win, ButtonPressMask | ButtonReleaseMask | PointerMotionMask); @@ -629,9 +632,8 @@ PagerResize(Pager * p, int w, int h) p->h = h; p->dw = w / ax; p->dh = h / ay; - p->pmap = ECreatePixmap(disp, p->win, p->w, p->h, pImlibData->x.depth); - p->bgpmap = - ECreatePixmap(disp, p->win, p->w / ax, p->h / ay, pImlibData->x.depth); + p->pmap = ECreatePixmap(disp, p->win, p->w, p->h, root.depth); + p->bgpmap = ECreatePixmap(disp, p->win, p->w / ax, p->h / ay, root.depth); if (p->visible) PagerRedraw(p, 1); ESetWindowBackgroundPixmap(disp, p->win, p->pmap); @@ -857,16 +859,11 @@ PagerEwinUpdateMini(Pager * p, EWin * ewin) h = 1; if ((ewin->mini_w != w) || (ewin->mini_h != h)) { + FreePmapMask(&ewin->mini_pmm); + ewin->mini_w = w; ewin->mini_h = h; - if (ewin->mini_pmap) - EFreePixmap(disp, ewin->mini_pmap); - if (ewin->mini_mask) - EFreePixmap(disp, ewin->mini_mask); - ewin->mini_pmap = 0; - ewin->mini_mask = 0; - if ((ewin->desktop != desks.current) || (ewin->area_x != cx) || (ewin->area_y != cy) || (!SNAP)) { @@ -875,24 +872,30 @@ PagerEwinUpdateMini(Pager * p, EWin * ewin) ic = FindItem("PAGER_WIN", 0, LIST_FINDBY_NAME, LIST_TYPE_ICLASS); if (ic) IclassApplyCopy(ic, ewin->win, w, h, 0, 0, STATE_NORMAL, - &(ewin->mini_pmap), &(ewin->mini_mask)); + &ewin->mini_pmm, 1); } else { - ewin->mini_pmap = ECreatePixmap(disp, p->win, w, h, root.depth); - PagerScaleRect(ewin->mini_pmap, ewin->win, 0, 0, 0, 0, ewin->w, + ewin->mini_pmm.type = 0; + ewin->mini_pmm.pmap = + ECreatePixmap(disp, p->win, w, h, root.depth); + PagerScaleRect(ewin->mini_pmm.pmap, ewin->win, 0, 0, 0, 0, ewin->w, ewin->h, w, h); } } + if (p->hi_ewin == ewin) { - ImlibImage *im; + Imlib_Image *im; + imlib_context_set_drawable(ewin->mini_pmm.pmap); im = - Imlib_create_image_from_drawable(pImlibData, ewin->mini_pmap, 0, 0, - 0, ewin->mini_w, ewin->mini_h); - Imlib_apply_image(pImlibData, im, p->hi_win); - Imlib_kill_image(pImlibData, im); + imlib_create_image_from_drawable(0, 0, 0, ewin->mini_w, ewin->mini_h, + 0); + imlib_context_set_image(im); + imlib_context_set_drawable(p->hi_win); + imlib_render_image_on_drawable(0, 0); + imlib_free_image_and_decache(); } } @@ -920,31 +923,31 @@ PagerEwinUpdateFromPager(Pager * p, EWin * ewin) h = ((ewin->h) * (p->h / ay)) / root.h; if (!gc) gc = XCreateGC(disp, p->pmap, 0, &gcv); + if ((ewin->mini_w != w) || (ewin->mini_h != h)) - { - if (ewin->mini_pmap) - EFreePixmap(disp, ewin->mini_pmap); - if (ewin->mini_mask) - EFreePixmap(disp, ewin->mini_mask); - ewin->mini_pmap = 0; - ewin->mini_mask = 0; - } - if (!ewin->mini_pmap) + FreePmapMask(&ewin->mini_pmm); + + if (!ewin->mini_pmm.pmap) { ewin->mini_w = w; ewin->mini_h = h; - ewin->mini_pmap = ECreatePixmap(disp, p->win, w, h, root.depth); + ewin->mini_pmm.type = 0; + ewin->mini_pmm.pmap = ECreatePixmap(disp, p->win, w, h, root.depth); } - XCopyArea(disp, p->pmap, ewin->mini_pmap, gc, x, y, w, h, 0, 0); + XCopyArea(disp, p->pmap, ewin->mini_pmm.pmap, gc, x, y, w, h, 0, 0); + if (p->hi_ewin == ewin) { - ImlibImage *im; + Imlib_Image *im; + imlib_context_set_drawable(ewin->mini_pmm.pmap); im = - Imlib_create_image_from_drawable(pImlibData, ewin->mini_pmap, 0, 0, - 0, ewin->mini_w, ewin->mini_h); - Imlib_apply_image(pImlibData, im, p->hi_win); - Imlib_kill_image(pImlibData, im); + imlib_create_image_from_drawable(0, 0, 0, ewin->mini_w, ewin->mini_h, + 0); + imlib_context_set_image(im); + imlib_context_set_drawable(p->hi_win); + imlib_render_image_on_drawable(0, 0); + imlib_free_image_and_decache(); } } @@ -954,7 +957,6 @@ PagerRedraw(Pager * p, char newbg) int i, x, y, ax, ay, cx, cy; GC gc; XGCValues gcv; - int c1, c2, r, g, b; if (!mode.show_pagers) return; @@ -989,14 +991,6 @@ PagerRedraw(Pager * p, char newbg) GetAreaSize(&ax, &ay); cx = desks.desk[p->desktop].current_area_x; cy = desks.desk[p->desktop].current_area_y; - r = 0; - g = 0; - b = 0; - c1 = Imlib_best_color_match(pImlibData, &r, &g, &b); - r = 255; - g = 255; - b = 255; - c2 = Imlib_best_color_match(pImlibData, &r, &g, &b); gc = XCreateGC(disp, p->pmap, 0, &gcv); if (gc) { @@ -1005,13 +999,15 @@ PagerRedraw(Pager * p, char newbg) if (!SNAP) { ImageClass *ic = NULL; + PmapMask pmm; EFreePixmap(disp, p->bgpmap); ic = FindItem("PAGER_BACKGROUND", 0, LIST_FINDBY_NAME, LIST_TYPE_ICLASS); if (ic) IclassApplyCopy(ic, p->win, p->w / ax, p->h / ay, 0, 0, - STATE_NORMAL, &(p->bgpmap), NULL); + STATE_NORMAL, &pmm, 0); + p->bgpmap = pmm.pmap; } else { @@ -1019,7 +1015,8 @@ PagerRedraw(Pager * p, char newbg) { char s[4096]; char *uniq; - ImlibImage *im; + Imlib_Image *im; + Pixmap mask; uniq = GetUniqueBGString(desks.desk[p->desktop].bg); Esnprintf(s, sizeof(s), "%s/cached/pager/%s.%i.%i.%s", @@ -1028,34 +1025,40 @@ PagerRedraw(Pager * p, char newbg) (p->h / ay), uniq); Efree(uniq); - im = Imlib_load_image(pImlibData, s); + im = imlib_load_image(s); if (im) { EFreePixmap(disp, p->bgpmap); - Imlib_render(pImlibData, im, (p->w / ax), - (p->h / ay)); - p->bgpmap = Imlib_copy_image(pImlibData, im); - Imlib_destroy_image(pImlibData, im); + imlib_context_set_image(im); + imlib_render_pixmaps_for_whole_image_at_size(&p-> + bgpmap, + &mask, + (p->w / + ax), + (p->h / + ay)); + imlib_free_image(); } else { - SetBackgroundTo(pImlibData, p->bgpmap, + SetBackgroundTo(p->bgpmap, desks.desk[p->desktop].bg, 0); + imlib_context_set_drawable(p->bgpmap); im = - Imlib_create_image_from_drawable(pImlibData, - p->bgpmap, 0, 0, - 0, (p->w / ax), - (p->h / ay)); - Imlib_save_image_to_ppm(pImlibData, im, s); - Imlib_changed_image(pImlibData, im); - Imlib_kill_image(pImlibData, im); + imlib_create_image_from_drawable(0, 0, 0, + (p->w / ax), + (p->h / ay), 0); + imlib_context_set_image(im); + imlib_image_set_format("ppm"); + imlib_save_image(s); + imlib_free_image_and_decache(); } } else { - XSetForeground(disp, gc, c1); + XSetForeground(disp, gc, BlackPixel(disp, root.scr)); XDrawRectangle(disp, p->bgpmap, gc, 0, 0, p->dw, p->dh); - XSetForeground(disp, gc, c2); + XSetForeground(disp, gc, WhitePixel(disp, root.scr)); XFillRectangle(disp, p->bgpmap, gc, 1, 1, p->dw - 2, p->dh - 2); } @@ -1080,24 +1083,24 @@ PagerRedraw(Pager * p, char newbg) ww = ((ewin->w) * (p->w / ax)) / root.w; wh = ((ewin->h) * (p->h / ay)) / root.h; PagerEwinUpdateMini(p, ewin); - if (ewin->mini_pmap) + if (ewin->mini_pmm.pmap) { - if (ewin->mini_mask) + if (ewin->mini_pmm.mask) { - XSetClipMask(disp, gc, ewin->mini_mask); + XSetClipMask(disp, gc, ewin->mini_pmm.mask); XSetClipOrigin(disp, gc, wx, wy); } - XCopyArea(disp, ewin->mini_pmap, p->pmap, gc, 0, 0, ww, - wh, wx, wy); - if (ewin->mini_mask) + XCopyArea(disp, ewin->mini_pmm.pmap, p->pmap, gc, 0, 0, + ww, wh, wx, wy); + if (ewin->mini_pmm.mask) XSetClipMask(disp, gc, None); } else { - XSetForeground(disp, gc, c1); + XSetForeground(disp, gc, BlackPixel(disp, root.scr)); XDrawRectangle(disp, p->pmap, gc, wx - 1, wy - 1, ww + 1, wh + 1); - XSetForeground(disp, gc, c2); + XSetForeground(disp, gc, WhitePixel(disp, root.scr)); XFillRectangle(disp, p->pmap, gc, wx, wy, ww, wh); } } @@ -1452,29 +1455,31 @@ PagerShowHi(Pager * p, EWin * ewin, int x, int y, int w, int h) ic = FindItem("PAGER_WIN", 0, LIST_FINDBY_NAME, LIST_TYPE_ICLASS); EMoveResizeWindow(disp, p->hi_win, x, y, w, h); EMapRaised(disp, p->hi_win); - if (ewin->mini_pmap) + if (ewin->mini_pmm.pmap) { - ImlibImage *im; + Imlib_Image *im; int xx, yy, ww, hh, i; + imlib_context_set_drawable(ewin->mini_pmm.pmap); im = - Imlib_create_image_from_drawable(pImlibData, ewin->mini_pmap, 0, - 0, 0, ewin->mini_w, - ewin->mini_h); + imlib_create_image_from_drawable(0, 0, 0, ewin->mini_w, + ewin->mini_h, 0); if (w > h) { for (i = w; i < (w * 2); i++) { - Pixmap pmap; + Pixmap pmap, mask; ww = i; hh = (i * h) / w; xx = x + ((w - ww) / 2); yy = y + ((h - hh) / 2); - Imlib_render(pImlibData, im, ww, hh); - pmap = Imlib_move_image(pImlibData, im); + imlib_context_set_image(im); + imlib_render_pixmaps_for_whole_image_at_size(&pmap, + &mask, ww, + hh); ESetWindowBackgroundPixmap(disp, p->hi_win, pmap); - Imlib_free_pixmap(pImlibData, pmap); + imlib_free_pixmap_and_mask(pmap); EMoveResizeWindow(disp, p->hi_win, xx, yy, ww, hh); XClearWindow(disp, p->hi_win); { @@ -1484,7 +1489,7 @@ PagerShowHi(Pager * p, EWin * ewin, int x, int y, int w, int h) if ((px < x) || (py < y) || (px >= (x + w)) || (py >= (y + h))) { - Imlib_kill_image(pImlibData, im); + imlib_free_image_and_decache(); EUnmapWindow(disp, p->hi_win); goto exit; } @@ -1495,16 +1500,18 @@ PagerShowHi(Pager * p, EWin * ewin, int x, int y, int w, int h) { for (i = h; i < (h * 2); i++) { - Pixmap pmap; + Pixmap pmap, mask; ww = (i * w) / h; hh = i; xx = x + ((w - ww) / 2); yy = y + ((h - hh) / 2); - Imlib_render(pImlibData, im, ww, hh); - pmap = Imlib_move_image(pImlibData, im); + imlib_context_set_image(im); + imlib_render_pixmaps_for_whole_image_at_size(&pmap, + &mask, ww, + hh); ESetWindowBackgroundPixmap(disp, p->hi_win, pmap); - Imlib_free_pixmap(pImlibData, pmap); + imlib_free_pixmap_and_mask(pmap); EMoveResizeWindow(disp, p->hi_win, xx, yy, ww, hh); XClearWindow(disp, p->hi_win); { @@ -1514,7 +1521,7 @@ PagerShowHi(Pager * p, EWin * ewin, int x, int y, int w, int h) if ((px < x) || (py < y) || (px >= (x + w)) || (py >= (y + h))) { - Imlib_kill_image(pImlibData, im); + imlib_free_image_and_decache(); EUnmapWindow(disp, p->hi_win); goto exit; } @@ -1523,8 +1530,10 @@ PagerShowHi(Pager * p, EWin * ewin, int x, int y, int w, int h) } EMoveResizeWindow(disp, p->hi_win, x - (w / 2), y - (h / 2), w * 2, h * 2); - Imlib_apply_image(pImlibData, im, p->hi_win); - Imlib_kill_image(pImlibData, im); + imlib_context_set_image(im); + imlib_context_set_drawable(p->hi_win); + imlib_render_image_on_drawable(0, 0); + imlib_free_image_and_decache(); } else if (ic) { @@ -1589,17 +1598,8 @@ PagerShowHi(Pager * p, EWin * ewin, int x, int y, int w, int h) Pixmap pmap; GC gc = 0; XGCValues gcv; - int c1, c2, r, g, b; int xx, yy, ww, hh, i; - r = 0; - g = 0; - b = 0; - c1 = Imlib_best_color_match(pImlibData, &r, &g, &b); - r = 255; - g = 255; - b = 255; - c2 = Imlib_best_color_match(pImlibData, &r, &g, &b); pmap = ECreatePixmap(disp, p->hi_win, w * 2, h * 2, root.depth); ESetWindowBackgroundPixmap(disp, p->hi_win, pmap); if (!gc) @@ -1612,9 +1612,9 @@ PagerShowHi(Pager * p, EWin * ewin, int x, int y, int w, int h) hh = (i * h) / w; xx = x + ((w - ww) / 2); yy = y + ((h - hh) / 2); - XSetForeground(disp, gc, c1); + XSetForeground(disp, gc, BlackPixel(disp, root.scr)); XFillRectangle(disp, pmap, gc, 0, 0, ww, hh); - XSetForeground(disp, gc, c2); + XSetForeground(disp, gc, WhitePixel(disp, root.scr)); XFillRectangle(disp, pmap, gc, 1, 1, ww - 2, hh - 2); EMoveResizeWindow(disp, p->hi_win, xx, yy, ww, hh); XClearWindow(disp, p->hi_win); @@ -1640,9 +1640,9 @@ PagerShowHi(Pager * p, EWin * ewin, int x, int y, int w, int h) hh = i; xx = x + ((w - ww) / 2); yy = y + ((h - hh) / 2); - XSetForeground(disp, gc, c1); + XSetForeground(disp, gc, BlackPixel(disp, root.scr)); XFillRectangle(disp, pmap, gc, 0, 0, ww, hh); - XSetForeground(disp, gc, c2); + XSetForeground(disp, gc, WhitePixel(disp, root.scr)); XFillRectangle(disp, pmap, gc, 1, 1, ww - 2, hh - 2); EMoveResizeWindow(disp, p->hi_win, xx, yy, ww, hh); XClearWindow(disp, p->hi_win); diff --git a/src/settings.c b/src/settings.c index 3cce9a85..1f1a97bf 100644 --- a/src/settings.c +++ b/src/settings.c @@ -1071,7 +1071,7 @@ CB_DesktopDisplayRedraw(int val, void *data) pmap = ECreatePixmap(disp, wins[i], 64, 48, root.depth); ESetWindowBackgroundPixmap(disp, wins[i], pmap); - SetBackgroundTo(pImlibData, pmap, desks.desk[i].bg, 0); + SetBackgroundTo(pmap, desks.desk[i].bg, 0); EFreePixmap(disp, pmap); } } @@ -1261,7 +1261,7 @@ CB_AreaDisplayRedraw(int val, void *data) if (!called) { ImageClass *ic; - Pixmap pmap; + PmapMask pmm; ic = FindItem("SETTINGS_AREA_AREA", 0, LIST_FINDBY_NAME, LIST_TYPE_ICLASS); @@ -1272,9 +1272,9 @@ CB_AreaDisplayRedraw(int val, void *data) LIST_TYPE_ICLASS); if (ic) { - IclassApplyCopy(ic, awin, 18, 14, 0, 0, STATE_NORMAL, &pmap, NULL); - ESetWindowBackgroundPixmap(disp, awin, pmap); - Imlib_free_pixmap(pImlibData, pmap); + IclassApplyCopy(ic, awin, 18, 14, 0, 0, STATE_NORMAL, &pmm, 0); + ESetWindowBackgroundPixmap(disp, awin, pmm.pmap); + FreePmapMask(&pmm); } XClearWindow(disp, awin); called = 1; @@ -2460,9 +2460,7 @@ CB_ConfigureBG(int val, void *data) mode.desktop_bg_timeout = tmp_bg_timeout; desks.hiqualitybg = tmp_hiq; mode.user_bg = tmp_userbg; - tmp_bg->bg.solid.r = tmp_bg_r; - tmp_bg->bg.solid.g = tmp_bg_g; - tmp_bg->bg.solid.b = tmp_bg_b; + ESetColor(&(tmp_bg->bg.solid), tmp_bg_r, tmp_bg_g, tmp_bg_b); tmp_bg->bg.tile = tmp_bg_tile; tmp_bg->bg.keep_aspect = tmp_bg_keep_aspect; tmp_bg->bg.xjust = tmp_bg_xjust; @@ -2471,9 +2469,6 @@ CB_ConfigureBG(int val, void *data) tmp_bg->bg.yperc = 1024 - tmp_bg_yperc; if (!tmp_bg_image) RemoveImagesFromBG(tmp_bg); - if (tmp_bg->pmap) - Imlib_free_pixmap(pImlibData, tmp_bg->pmap); - tmp_bg->pmap = 0; for (i = 0; i < ENLIGHTENMENT_CONF_NUM_DESKTOPS; i++) { if (desks.desk[i].bg == tmp_bg) @@ -2491,17 +2486,19 @@ CB_ConfigureBG(int val, void *data) } { char s[4096]; - ImlibImage *im; + Imlib_Image *im; Pixmap p2; Esnprintf(s, sizeof(s), "%s/cached/bgsel/%s", UserCacheDir(), tmp_bg->name); p2 = ECreatePixmap(disp, root.win, 64, 48, root.depth); - SetBackgroundTo(pImlibData, p2, tmp_bg, 0); - im = - Imlib_create_image_from_drawable(pImlibData, p2, 0, 0, 0, 64, 48); - Imlib_save_image_to_ppm(pImlibData, im, s); - Imlib_kill_image(pImlibData, im); + SetBackgroundTo(p2, tmp_bg, 0); + imlib_context_set_drawable(p2); + im = imlib_create_image_from_drawable(0, 0, 0, 64, 48, 0); + imlib_context_set_image(im); + imlib_image_set_format("ppm"); + imlib_save_image(s); + imlib_free_image_and_decache(); EFreePixmap(disp, p2); BG_RedrawView(1); } @@ -2536,20 +2533,18 @@ CB_DesktopMiniDisplayRedraw(int val, void *data) DItem *di; Window win; Pixmap pmap; - ImlibColor icl; + XColor xclr; di = (DItem *) data; win = DialogItemAreaGetWindow(di); DialogItemAreaGetSize(di, &w, &h); - icl.r = tmp_bg_r; - icl.g = tmp_bg_g; - icl.b = tmp_bg_b; + ESetColor(&xclr, tmp_bg_r, tmp_bg_g, tmp_bg_b); if (!tbg) { if (!tmp_bg_image) tbg = - CreateDesktopBG("TEMP", &icl, NULL, tmp_bg_tile, + CreateDesktopBG("TEMP", &xclr, NULL, tmp_bg_tile, tmp_bg_keep_aspect, tmp_bg_xjust, 1024 - tmp_bg_yjust, tmp_bg_xperc, 1024 - tmp_bg_yperc, tmp_bg->top.file, @@ -2558,7 +2553,7 @@ CB_DesktopMiniDisplayRedraw(int val, void *data) tmp_bg->top.yperc); else tbg = - CreateDesktopBG("TEMP", &icl, tmp_bg->bg.file, tmp_bg_tile, + CreateDesktopBG("TEMP", &xclr, tmp_bg->bg.file, tmp_bg_tile, tmp_bg_keep_aspect, tmp_bg_xjust, 1024 - tmp_bg_yjust, tmp_bg_xperc, 1024 - tmp_bg_yperc, tmp_bg->top.file, @@ -2569,10 +2564,8 @@ CB_DesktopMiniDisplayRedraw(int val, void *data) else { if (tbg->pmap) - Imlib_free_pixmap(pImlibData, tbg->pmap); - tbg->bg.solid.r = tmp_bg_r; - tbg->bg.solid.g = tmp_bg_g; - tbg->bg.solid.b = tmp_bg_b; + imlib_free_pixmap_and_mask(tbg->pmap); + ESetColor(&(tbg->bg.solid), tmp_bg_r, tmp_bg_g, tmp_bg_b); if (tbg->bg.file) Efree(tbg->bg.file); tbg->bg.file = NULL; @@ -2581,8 +2574,11 @@ CB_DesktopMiniDisplayRedraw(int val, void *data) else { if (tbg->bg.im) - Imlib_destroy_image(pImlibData, tbg->bg.im); - tbg->bg.im = NULL; + { + imlib_context_set_image(tbg->bg.im); + imlib_free_image(); + tbg->bg.im = NULL; + } } if (tbg->bg.real_file) Efree(tbg->bg.real_file); @@ -2597,7 +2593,7 @@ CB_DesktopMiniDisplayRedraw(int val, void *data) KeepBGimages(tbg, 1); pmap = ECreatePixmap(disp, win, w, h, root.depth); ESetWindowBackgroundPixmap(disp, win, pmap); - SetBackgroundTo(pImlibData, pmap, tbg, 0); + SetBackgroundTo(pmap, tbg, 0); XClearWindow(disp, win); EFreePixmap(disp, pmap); val = 0; @@ -2627,9 +2623,7 @@ BG_DoDialog(void) DialogItemTextSetText(bg_filename, s); DialogDrawItems(bg_sel_dialog, bg_filename, 0, 0, 99999, 99999); - tmp_bg_r = tmp_bg->bg.solid.r; - tmp_bg_g = tmp_bg->bg.solid.g; - tmp_bg_b = tmp_bg->bg.solid.b; + EGetColor(&(tmp_bg->bg.solid), &tmp_bg_r, &tmp_bg_g, &tmp_bg_b); tmp_bg_tile = tmp_bg->bg.tile; tmp_bg_keep_aspect = tmp_bg->bg.keep_aspect; tmp_bg_xjust = tmp_bg->bg.xjust; @@ -2659,15 +2653,13 @@ static void CB_ConfigureNewBG(int val, void *data) { char s[1024]; - ImlibColor icl; + XColor xclr; Background *bg; int lower, upper; Esnprintf(s, sizeof(s), "__NEWBG_%i\n", time(NULL)); - icl.r = tmp_bg_r; - icl.g = tmp_bg_g; - icl.b = tmp_bg_b; - bg = CreateDesktopBG(s, &icl, tmp_bg->bg.file, tmp_bg_tile, + ESetColor(&xclr, tmp_bg_r, tmp_bg_g, tmp_bg_b); + bg = CreateDesktopBG(s, &xclr, tmp_bg->bg.file, tmp_bg_tile, tmp_bg_keep_aspect, tmp_bg_xjust, 1024 - tmp_bg_yjust, tmp_bg_xperc, 1024 - tmp_bg_yperc, tmp_bg->top.file, tmp_bg->top.keep_aspect, tmp_bg->top.xjust, @@ -2841,113 +2833,115 @@ BG_RedrawView(char nuke_old) Background **bglist; int w, h; Window win; + int x; + Pixmap pmap; + GC gc; + XGCValues gcv; win = DialogItemAreaGetWindow(bg_sel); DialogItemAreaGetSize(bg_sel, &w, &h); bglist = (Background **) ListItemType(&num, LIST_TYPE_BACKGROUND); - if (bglist) + if (!bglist) + goto exit; + + pmap = ECreatePixmap(disp, win, w, h, root.depth); + gc = XCreateGC(disp, pmap, 0, &gcv); + XSetForeground(disp, gc, BlackPixel(disp, root.scr)); + XFillRectangle(disp, pmap, gc, 0, 0, w, h); + ESetWindowBackgroundPixmap(disp, win, pmap); + x = -(tmp_bg_sel_sliderval * (64 + 8) / 4); + if (x < (w - ((64 + 8) * num))) + x = w - ((64 + 8) * num); + for (i = 0; i < num; i++) { - int x; - Pixmap pmap; - GC gc; - XGCValues gcv; - - pmap = ECreatePixmap(disp, win, w, h, root.depth); - gc = XCreateGC(disp, pmap, 0, &gcv); - XSetForeground(disp, gc, BlackPixel(disp, root.scr)); - XFillRectangle(disp, pmap, gc, 0, 0, w, h); - ESetWindowBackgroundPixmap(disp, win, pmap); - x = -(tmp_bg_sel_sliderval * (64 + 8) / 4); - if (x < (w - ((64 + 8) * num))) - x = w - ((64 + 8) * num); - for (i = 0; i < num; i++) + if (((x + 64 + 8) >= 0) && (x < w)) { - if (((x + 64 + 8) >= 0) && (x < w)) + Pixmap p2; + ImageClass *ic; + Imlib_Image *im; + char s[4096]; + + ic = FindItem("DIALOG_BUTTON", 0, LIST_FINDBY_NAME, + LIST_TYPE_ICLASS); + if (ic) { - Pixmap p2; - ImageClass *ic; - ImlibImage *im; - char s[4096]; + PmapMask pmm; - ic = FindItem("DIALOG_BUTTON", 0, LIST_FINDBY_NAME, - LIST_TYPE_ICLASS); - if (ic) - { - Pixmap pbg; - - if (i == tmp_bg_selected) - IclassApplyCopy(ic, pmap, 64 + 8, 48 + 8, 0, 0, - STATE_CLICKED, &pbg, NULL); - else - IclassApplyCopy(ic, pmap, 64 + 8, 48 + 8, 0, 0, - STATE_NORMAL, &pbg, NULL); - XCopyArea(disp, pbg, pmap, gc, 0, 0, 64 + 8, 48 + 8, x, - 0); - Imlib_free_pixmap(pImlibData, pbg); - } - if (!strcmp(bglist[i]->name, "NONE")) - { - TextClass *tc; - - tc = FindItem("DIALOG", 0, LIST_FINDBY_NAME, - LIST_TYPE_TCLASS); - if (tc) - { - int tw, th; - - TextSize(tc, 0, 0, STATE_NORMAL, - _("No\nBackground"), &tw, &th, 17); - TextDraw(tc, pmap, 0, 0, STATE_NORMAL, - _("No\nBackground"), x + 4, - 4 + ((48 - th) / 2), 64, 48, 17, 512); - } - } + if (i == tmp_bg_selected) + IclassApplyCopy(ic, pmap, 64 + 8, 48 + 8, 0, 0, + STATE_CLICKED, &pmm, 0); else + IclassApplyCopy(ic, pmap, 64 + 8, 48 + 8, 0, 0, + STATE_NORMAL, &pmm, 0); + XCopyArea(disp, pmm.pmap, pmap, gc, 0, 0, 64 + 8, 48 + 8, x, + 0); + FreePmapMask(&pmm); + } + + if (!strcmp(bglist[i]->name, "NONE")) + { + TextClass *tc; + + tc = FindItem("DIALOG", 0, LIST_FINDBY_NAME, + LIST_TYPE_TCLASS); + if (tc) + { + int tw, th; + + TextSize(tc, 0, 0, STATE_NORMAL, + _("No\nBackground"), &tw, &th, 17); + TextDraw(tc, pmap, 0, 0, STATE_NORMAL, + _("No\nBackground"), x + 4, + 4 + ((48 - th) / 2), 64, 48, 17, 512); + } + } + else + { + Esnprintf(s, sizeof(s), "%s/cached/bgsel/%s", + UserCacheDir(), bglist[i]->name); + im = ELoadImage(s); + if (!im) { Esnprintf(s, sizeof(s), "%s/cached/bgsel/%s", UserCacheDir(), bglist[i]->name); - im = ELoadImage(s); - if (!im) + p2 = ECreatePixmap(disp, pmap, 64, 48, root.depth); + SetBackgroundTo(p2, bglist[i], 0); + XCopyArea(disp, p2, pmap, gc, 0, 0, 64, 48, x + 4, 4); + imlib_context_set_drawable(p2); + im = + imlib_create_image_from_drawable(0, 0, 0, 64, 48, 0); + imlib_context_set_image(im); + imlib_image_set_format("ppm"); + imlib_save_image(s); + imlib_free_image_and_decache(); + EFreePixmap(disp, p2); + } + else + { + if (nuke_old) { - Esnprintf(s, sizeof(s), "%s/cached/bgsel/%s", - UserCacheDir(), bglist[i]->name); - p2 = - ECreatePixmap(disp, pmap, 64, 48, - pImlibData->x.depth); - SetBackgroundTo(pImlibData, p2, bglist[i], 0); - XCopyArea(disp, p2, pmap, gc, 0, 0, 64, 48, x + 4, - 4); - im = - Imlib_create_image_from_drawable(pImlibData, p2, - 0, 0, 0, 64, - 48); - Imlib_save_image_to_ppm(pImlibData, im, s); - Imlib_kill_image(pImlibData, im); - EFreePixmap(disp, p2); + imlib_context_set_image(im); + imlib_free_image_and_decache(); + im = ELoadImage(s); } - else + if (im) { - if (nuke_old) - { - Imlib_changed_image(pImlibData, im); - Imlib_kill_image(pImlibData, im); - im = ELoadImage(s); - } - if (im) - { - Imlib_paste_image(pImlibData, im, pmap, x + 4, - 4, 64, 48); - Imlib_destroy_image(pImlibData, im); - } + imlib_context_set_image(im); + imlib_context_set_drawable(pmap); + imlib_render_image_on_drawable_at_size(x + 4, 4, 64, + 48); + imlib_free_image(); } } } - x += (64 + 8); } - XFreeGC(disp, gc); - EFreePixmap(disp, pmap); - Efree(bglist); + x += (64 + 8); } + XFreeGC(disp, gc); + EFreePixmap(disp, pmap); + Efree(bglist); + + exit: XClearWindow(disp, win); } @@ -3295,9 +3289,7 @@ SettingsBackground(Background * bg) tmp_bg_image = 0; tmp_bg->keepim = 1; - tmp_bg_r = bg->bg.solid.r; - tmp_bg_g = bg->bg.solid.g; - tmp_bg_b = bg->bg.solid.b; + EGetColor(&(bg->bg.solid), &tmp_bg_r, &tmp_bg_g, &tmp_bg_b); tmp_bg_tile = bg->bg.tile; tmp_bg_keep_aspect = bg->bg.keep_aspect; tmp_bg_xjust = bg->bg.xjust; diff --git a/src/setup.c b/src/setup.c index 835be51b..64c9b646 100644 --- a/src/setup.c +++ b/src/setup.c @@ -231,9 +231,28 @@ SetupX() */ /* record the event base for shape change events */ event_base_shape = shape_event_base; + /* initialise imlib */ - pImlibData = Imlib_init(disp); - if (!pImlibData) +#if USE_IMLIB2 + root.win = DefaultRootWindow(disp); + root.vis = DefaultVisual(disp, root.scr); + root.depth = DefaultDepth(disp, root.scr); + root.cmap = DefaultColormap(disp, root.scr); + + imlib_set_cache_size(2048 * 1024); + imlib_set_font_cache_size(512 * 1024); + imlib_set_color_usage(128); + + imlib_context_set_dither(1); + + imlib_context_set_display(disp); + imlib_context_set_visual(root.vis); + imlib_context_set_colormap(root.cmap); + imlib_context_set_dither_mask(0); +#else + pImlib_Context = Imlib_init(disp); + IMLIB1_SET_CONTEXT(0); + if (!pImlib_Context) { ASSIGN_ALERT(_("Imlib initialisation error"), "", "", _("Quit Enlightenment")); @@ -245,7 +264,7 @@ SetupX() EExit((void *)1); } #if USE_FNLIB - pFnlibData = Fnlib_init(pImlibData); + pFnlibData = Fnlib_init(pImlib_Context); if (!pFnlibData) { ASSIGN_ALERT(_("X server setup error"), "", "", @@ -258,13 +277,10 @@ SetupX() EExit((void *)1); } #endif - root.win = pImlibData->x.root; - root.vis = Imlib_get_visual(pImlibData); - root.depth = pImlibData->x.depth; - root.cmap = Imlib_get_colormap(pImlibData); - root.w = DisplayWidth(disp, root.scr); - root.h = DisplayHeight(disp, root.scr); - root.focuswin = ECreateFocusWindow(root.win, -100, -100, 5, 5); + root.win = pImlib_Context->x.root; + root.vis = Imlib_get_visual(pImlib_Context); + root.depth = pImlib_Context->x.depth; + root.cmap = Imlib_get_colormap(pImlib_Context); /* warn, if necessary about visual problems */ if (DefaultVisual(disp, root.scr) != root.vis) { @@ -272,12 +288,16 @@ SetupX() p.flags = PARAMS_VISUALID; p.visualid = XVisualIDFromVisual(DefaultVisual(disp, root.scr)); - prImlibData = Imlib_init_with_params(disp, &p); + prImlib_Context = Imlib_init_with_params(disp, &p); } else { - prImlibData = NULL; + prImlib_Context = NULL; } +#endif + root.w = DisplayWidth(disp, root.scr); + root.h = DisplayHeight(disp, root.scr); + root.focuswin = ECreateFocusWindow(root.win, -100, -100, 5, 5); /* just in case - set them up again */ /* set up an error handler for then E would normally have fatal X errors */ XSetErrorHandler((XErrorHandler) EHandleXError); @@ -654,15 +674,12 @@ MakeExtInitWin(void) XGCValues gcv; GC gc; Pixmap pmap; - Atom a, aa; + Atom a; CARD32 val; - int format_ret, i; - unsigned long bytes_after, num_ret; + int i; Window *retval; XSetWindowAttributes attr; - ImlibData *imd; - a = XInternAtom(disp, "ENLIGHTENMENT_RESTART_SCREEN", False); XSync(disp, False); if (fork()) @@ -670,6 +687,10 @@ MakeExtInitWin(void) UngrabX(); for (;;) { + Atom aa; + int format_ret; + unsigned long bytes_after, num_ret; + retval = NULL; XGetWindowProperty(disp, root.win, a, 0, 0x7fffffff, True, XA_CARDINAL, &aa, &format_ret, &num_ret, @@ -694,7 +715,18 @@ MakeExtInitWin(void) d2 = XOpenDisplay(DisplayString(disp)); close(ConnectionNumber(disp)); XGrabServer(d2); - imd = Imlib_init(d2); +#if USE_IMLIB2 + imlib_set_cache_size(2048 * 1024); + imlib_set_font_cache_size(512 * 1024); + imlib_set_color_usage(128); + + imlib_context_set_display(d2); + imlib_context_set_visual(DefaultVisual(d2, DefaultScreen(d2))); + imlib_context_set_colormap(DefaultColormap(d2, DefaultScreen(d2))); +#else + pImlib_Context = Imlib_init(d2); +#endif + IMLIB1_SET_CONTEXT(0); attr.backing_store = NotUseful; attr.override_redirect = True; attr.colormap = root.cmap; @@ -722,7 +754,8 @@ MakeExtInitWin(void) XUngrabServer(d2); XSync(d2, False); - if (!imd) +#if !USE_IMLIB2 + if (!pImlib_Context) { i = 0; for (;;) @@ -743,11 +776,12 @@ MakeExtInitWin(void) } } else +#endif { Window w2, ww; char *f, s[1024]; Pixmap pmap, mask; - ImlibImage *im; + Imlib_Image *im; struct timeval tv; int dd, x, y; unsigned int mm; @@ -784,27 +818,29 @@ MakeExtInitWin(void) f = FindFile(s); im = NULL; if (f) - im = Imlib_load_image(imd, f); - - if (f) - Efree(f); + { + im = imlib_load_image(f); + Efree(f); + } if (im) { - Imlib_render(imd, im, im->rgb_width, im->rgb_height); - pmap = Imlib_move_image(imd, im); - mask = Imlib_move_mask(imd, im); - Imlib_destroy_image(imd, im); + imlib_context_set_image(im); + imlib_context_set_drawable(w2); + imlib_render_pixmaps_for_whole_image(&pmap, &mask); EShapeCombineMask(d2, w2, ShapeBounding, 0, 0, mask, ShapeSet); ESetWindowBackgroundPixmap(d2, w2, pmap); - Imlib_free_pixmap(imd, pmap); + imlib_free_pixmap_and_mask(pmap); XClearWindow(d2, w2); XQueryPointer(d2, win, &ww, &ww, &dd, &dd, &x, &y, &mm); - EMoveResizeWindow(d2, w2, x - (im->rgb_width / 2), - y - (im->rgb_height / 2), im->rgb_width, - im->rgb_height); + EMoveResizeWindow(d2, w2, + x - imlib_image_get_width() / 2, + y - imlib_image_get_height() / 2, + imlib_image_get_width(), + imlib_image_get_height()); EMapWindow(d2, w2); + imlib_free_image(); } tv.tv_sec = 0; tv.tv_usec = 50000; diff --git a/src/startup.c b/src/startup.c index a1502491..1efe461e 100644 --- a/src/startup.c +++ b/src/startup.c @@ -220,10 +220,10 @@ CreateStartupDisplay(char start) IclassApply(ic, b1, root.w, desks.dragbar_width, 0, 0, 0, 0); IclassApply(ic, b2, root.w, desks.dragbar_width, 0, 0, 0, 0); queue_up = pq; - SetBackgroundTo(pImlibData, win1, bg, 1); - SetBackgroundTo(pImlibData, win2, bg, 1); + SetBackgroundTo(win1, bg, 1); + SetBackgroundTo(win2, bg, 1); if (bg->pmap) - Imlib_free_pixmap(pImlibData, bg->pmap); + imlib_free_pixmap_and_mask(bg->pmap); bg->pmap = 0; init_win1 = w1; init_win2 = w2; diff --git a/src/text.c b/src/text.c index ac6b7391..0f428e69 100644 --- a/src/text.c +++ b/src/text.c @@ -22,10 +22,10 @@ */ #include "E.h" -void TextDrawRotTo(Window win, Drawable * drawable, int x, int y, +static void TextDrawRotTo(Window win, Drawable * drawable, int x, int y, int w, int h, TextState * ts); -void TextDrawRotBack(Window win, Drawable drawable, int x, int y, +static void TextDrawRotBack(Window win, Drawable drawable, int x, int y, int w, int h, TextState * ts); TextState * @@ -330,7 +330,6 @@ TextDraw(TextClass * tclass, Window win, int active, int sticky, int state, int xx, yy; XGCValues gcv; static GC gc = 0; - int r, g, b; int textwidth_limit, offset_x, offset_y; Pixmap drawable; @@ -438,50 +437,29 @@ TextDraw(TextClass * tclass, Window win, int active, int sticky, int state, if (ts->effect == 1) { - r = ts->bg_col.r; - g = ts->bg_col.g; - b = ts->bg_col.b; - XSetForeground(disp, gc, - Imlib_best_color_match(pImlibData, &r, &g, - &b)); + EAllocColor(&ts->bg_col); + XSetForeground(disp, gc, ts->bg_col.pixel); EFont_draw_string(disp, drawable, gc, offset_x + 1, offset_y + 1, lines[i], ts->efont, - Imlib_get_visual(pImlibData), - Imlib_get_colormap(pImlibData)); + root.vis, root.cmap); } else if (ts->effect == 2) { - r = ts->bg_col.r; - g = ts->bg_col.g; - b = ts->bg_col.b; - XSetForeground(disp, gc, - Imlib_best_color_match(pImlibData, &r, &g, - &b)); + EAllocColor(&ts->bg_col); + XSetForeground(disp, gc, ts->bg_col.pixel); EFont_draw_string(disp, drawable, gc, offset_x - 1, offset_y, - lines[i], ts->efont, - Imlib_get_visual(pImlibData), - Imlib_get_colormap(pImlibData)); + lines[i], ts->efont, root.vis, root.cmap); EFont_draw_string(disp, drawable, gc, offset_x + 1, offset_y, - lines[i], ts->efont, - Imlib_get_visual(pImlibData), - Imlib_get_colormap(pImlibData)); + lines[i], ts->efont, root.vis, root.cmap); EFont_draw_string(disp, drawable, gc, offset_x, offset_y - 1, - lines[i], ts->efont, - Imlib_get_visual(pImlibData), - Imlib_get_colormap(pImlibData)); + lines[i], ts->efont, root.vis, root.cmap); EFont_draw_string(disp, drawable, gc, offset_x, offset_y + 1, - lines[i], ts->efont, - Imlib_get_visual(pImlibData), - Imlib_get_colormap(pImlibData)); + lines[i], ts->efont, root.vis, root.cmap); } - r = ts->fg_col.r; - g = ts->fg_col.g; - b = ts->fg_col.b; - XSetForeground(disp, gc, - Imlib_best_color_match(pImlibData, &r, &g, &b)); + EAllocColor(&ts->fg_col); + XSetForeground(disp, gc, ts->fg_col.pixel); EFont_draw_string(disp, drawable, gc, offset_x, offset_y, lines[i], - ts->efont, Imlib_get_visual(pImlibData), - Imlib_get_colormap(pImlibData)); + ts->efont, root.vis, root.cmap); TextDrawRotBack(win, drawable, xx - 1, yy - 1 - ascent, wid + 2, ascent + descent + 2, ts); @@ -602,23 +580,15 @@ TextDraw(TextClass * tclass, Window win, int active, int sticky, int state, if (ts->effect == 1) { - r = ts->bg_col.r; - g = ts->bg_col.g; - b = ts->bg_col.b; - XSetForeground(disp, gc, - Imlib_best_color_match(pImlibData, &r, &g, - &b)); + EAllocColor(&ts->bg_col); + XSetForeground(disp, gc, ts->bg_col.pixel); XmbDrawString(disp, drawable, ts->xfontset, gc, offset_x + 1, offset_y + 1, lines[i], strlen(lines[i])); } else if (ts->effect == 2) { - r = ts->bg_col.r; - g = ts->bg_col.g; - b = ts->bg_col.b; - XSetForeground(disp, gc, - Imlib_best_color_match(pImlibData, &r, &g, - &b)); + EAllocColor(&ts->bg_col); + XSetForeground(disp, gc, ts->bg_col.pixel); XmbDrawString(disp, drawable, ts->xfontset, gc, offset_x - 1, offset_y, lines[i], strlen(lines[i])); XmbDrawString(disp, drawable, ts->xfontset, gc, offset_x + 1, @@ -628,11 +598,8 @@ TextDraw(TextClass * tclass, Window win, int active, int sticky, int state, XmbDrawString(disp, drawable, ts->xfontset, gc, offset_x, offset_y + 1, lines[i], strlen(lines[i])); } - r = ts->fg_col.r; - g = ts->fg_col.g; - b = ts->fg_col.b; - XSetForeground(disp, gc, - Imlib_best_color_match(pImlibData, &r, &g, &b)); + EAllocColor(&ts->fg_col); + XSetForeground(disp, gc, ts->fg_col.pixel); XmbDrawString(disp, drawable, ts->xfontset, gc, offset_x, offset_y, lines[i], strlen(lines[i])); @@ -708,23 +675,15 @@ TextDraw(TextClass * tclass, Window win, int active, int sticky, int state, if (ts->effect == 1) { - r = ts->bg_col.r; - g = ts->bg_col.g; - b = ts->bg_col.b; - XSetForeground(disp, gc, - Imlib_best_color_match(pImlibData, &r, &g, - &b)); + EAllocColor(&ts->bg_col); + XSetForeground(disp, gc, ts->bg_col.pixel); XDrawString(disp, drawable, gc, offset_x + 1, offset_y + 1, lines[i], strlen(lines[i])); } else if (ts->effect == 2) { - r = ts->bg_col.r; - g = ts->bg_col.g; - b = ts->bg_col.b; - XSetForeground(disp, gc, - Imlib_best_color_match(pImlibData, &r, &g, - &b)); + EAllocColor(&ts->bg_col); + XSetForeground(disp, gc, ts->bg_col.pixel); XDrawString(disp, drawable, gc, offset_x - 1, offset_y, lines[i], strlen(lines[i])); XDrawString(disp, drawable, gc, offset_x + 1, offset_y, @@ -734,11 +693,8 @@ TextDraw(TextClass * tclass, Window win, int active, int sticky, int state, XDrawString(disp, drawable, gc, offset_x, offset_y + 1, lines[i], strlen(lines[i])); } - r = ts->fg_col.r; - g = ts->fg_col.g; - b = ts->fg_col.b; - XSetForeground(disp, gc, - Imlib_best_color_match(pImlibData, &r, &g, &b)); + EAllocColor(&ts->fg_col); + XSetForeground(disp, gc, ts->fg_col.pixel); XDrawString(disp, drawable, gc, offset_x, offset_y, lines[i], strlen(lines[i])); @@ -816,23 +772,15 @@ TextDraw(TextClass * tclass, Window win, int active, int sticky, int state, if (ts->effect == 1) { - r = ts->bg_col.r; - g = ts->bg_col.g; - b = ts->bg_col.b; - XSetForeground(disp, gc, - Imlib_best_color_match(pImlibData, &r, &g, - &b)); + EAllocColor(&ts->bg_col); + XSetForeground(disp, gc, ts->bg_col.pixel); XDrawString16(disp, drawable, gc, offset_x + 1, offset_y + 1, (XChar2b *) lines[i], strlen(lines[i]) / 2); } else if (ts->effect == 2) { - r = ts->bg_col.r; - g = ts->bg_col.g; - b = ts->bg_col.b; - XSetForeground(disp, gc, - Imlib_best_color_match(pImlibData, &r, &g, - &b)); + EAllocColor(&ts->bg_col); + XSetForeground(disp, gc, ts->bg_col.pixel); XDrawString16(disp, drawable, gc, offset_x - 1, offset_y, (XChar2b *) lines[i], strlen(lines[i]) / 2); XDrawString16(disp, drawable, gc, offset_y + 1, offset_y, @@ -842,11 +790,8 @@ TextDraw(TextClass * tclass, Window win, int active, int sticky, int state, XDrawString16(disp, drawable, gc, offset_x, offset_y + 1, (XChar2b *) lines[i], strlen(lines[i]) / 2); } - r = ts->fg_col.r; - g = ts->fg_col.g; - b = ts->fg_col.b; - XSetForeground(disp, gc, - Imlib_best_color_match(pImlibData, &r, &g, &b)); + EAllocColor(&ts->fg_col); + XSetForeground(disp, gc, ts->fg_col.pixel); XDrawString16(disp, drawable, gc, offset_x, offset_y, (XChar2b *) lines[i], strlen(lines[i]) / 2); @@ -865,80 +810,84 @@ void TextDrawRotTo(Window win, Drawable * drawable, int x, int y, int w, int h, TextState * ts) { - ImlibImage *ii = NULL; + Imlib_Image *ii = NULL; int win_x, win_y; unsigned int win_w, win_h, win_b, win_d; switch (ts->style.orientation) { case FONT_TO_UP: - ii = Imlib_create_image_from_drawable(pImlibData, win, 0, y, x, h, w); - Imlib_rotate_image(pImlibData, ii, 1); - Imlib_flip_image_horizontal(pImlibData, ii); - Imlib_paste_image(pImlibData, ii, *drawable, 0, 0, w, h); + imlib_context_set_drawable(win); + ii = imlib_create_image_from_drawable(0, y, x, h, w, 0); + imlib_context_set_image(ii); + imlib_image_orientate(1); + imlib_context_set_drawable(*drawable); + imlib_render_image_on_drawable_at_size(0, 0, w, h); break; case FONT_TO_DOWN: EGetGeometry(disp, win, &(root.win), &win_x, &win_y, &win_w, &win_h, &win_b, &win_d); - ii = - Imlib_create_image_from_drawable(pImlibData, win, 0, win_w - y - h, - x, h, w); - Imlib_rotate_image(pImlibData, ii, -1); - Imlib_flip_image_vertical(pImlibData, ii); - Imlib_paste_image(pImlibData, ii, *drawable, 0, 0, w, h); + imlib_context_set_drawable(win); + ii = imlib_create_image_from_drawable(0, win_w - y - h, x, h, w, 0); + imlib_context_set_image(ii); + imlib_image_orientate(3); + imlib_context_set_drawable(*drawable); + imlib_render_image_on_drawable_at_size(0, 0, w, h); break; case FONT_TO_LEFT: /* Holy carumba! That's for yoga addicts, maybe .... */ - ii = Imlib_create_image_from_drawable(pImlibData, win, 0, x, y, w, h); - Imlib_flip_image_vertical(pImlibData, ii); - Imlib_flip_image_horizontal(pImlibData, ii); - Imlib_paste_image(pImlibData, ii, *drawable, 0, 0, w, h); + imlib_context_set_drawable(win); + ii = imlib_create_image_from_drawable(0, x, y, w, h, 0); + imlib_context_set_image(ii); + imlib_image_orientate(2); + imlib_context_set_drawable(*drawable); + imlib_render_image_on_drawable_at_size(0, 0, w, h); break; default: break; } if (ii) - Imlib_destroy_image(pImlibData, ii); + imlib_free_image(); } void TextDrawRotBack(Window win, Pixmap drawable, int x, int y, int w, int h, TextState * ts) { - ImlibImage *ii = NULL; + Imlib_Image *ii = NULL; int win_x, win_y; unsigned int win_w, win_h, win_b, win_d; switch (ts->style.orientation) { case FONT_TO_UP: - ii = - Imlib_create_image_from_drawable(pImlibData, drawable, 0, 0, 0, w, - h); - Imlib_rotate_image(pImlibData, ii, -1); - Imlib_flip_image_vertical(pImlibData, ii); - Imlib_paste_image(pImlibData, ii, win, y, x, h, w); + imlib_context_set_drawable(drawable); + ii = imlib_create_image_from_drawable(0, 0, 0, w, h, 0); + imlib_context_set_image(ii); + imlib_image_orientate(3); + imlib_context_set_drawable(win); + imlib_render_image_on_drawable_at_size(y, x, h, w); break; case FONT_TO_DOWN: + imlib_context_set_drawable(drawable); EGetGeometry(disp, win, &(root.win), &win_x, &win_y, &win_w, &win_h, &win_b, &win_d); - ii = - Imlib_create_image_from_drawable(pImlibData, drawable, 0, 0, 0, w, - h); - Imlib_rotate_image(pImlibData, ii, 1); - Imlib_flip_image_horizontal(pImlibData, ii); - Imlib_paste_image(pImlibData, ii, win, win_w - y - h, x, h, w); + ii = imlib_create_image_from_drawable(0, 0, 0, w, h, 0); + imlib_context_set_image(ii); + imlib_image_orientate(1); + imlib_context_set_drawable(win); + imlib_render_image_on_drawable_at_size(win_w - y - h, x, h, w); break; case FONT_TO_LEFT: /* Holy carumba! That's for yoga addicts, maybe .... */ - ii = - Imlib_create_image_from_drawable(pImlibData, drawable, 0, 0, 0, w, - h); - Imlib_flip_image_vertical(pImlibData, ii); - Imlib_flip_image_horizontal(pImlibData, ii); - Imlib_paste_image(pImlibData, ii, win, x, y, w, h); + imlib_context_set_drawable(drawable); + ii = imlib_create_image_from_drawable(0, 0, 0, w, h, 0); + imlib_context_set_image(ii); + imlib_image_orientate(2); + imlib_context_set_drawable(win); + imlib_render_image_on_drawable_at_size(x, y, w, h); break; default: break; } if (ii) - Imlib_destroy_image(pImlibData, ii); + imlib_free_image(); } diff --git a/src/tooltips.c b/src/tooltips.c index dd8b53a1..33b615ae 100644 --- a/src/tooltips.c +++ b/src/tooltips.c @@ -85,11 +85,12 @@ ShowToolTip(ToolTip * tt, char *text, ActionClass * ac, int x, int y) int ww, hh, adx, ady, dist; int headline_h = 0, headline_w = 0, icons_width = 0, labels_width = 0, double_w = 0, temp_w, temp_h; - ImlibImage *im; + Imlib_Image *im; char pq; int *heights = NULL; ImageClass *ic = NULL; int cols[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + Pixmap pmap, mask; EDBUG(5, "ShowToolTip"); if (!tt) @@ -227,10 +228,11 @@ ShowToolTip(ToolTip * tt, char *text, ActionClass * ac, int x, int y) { if (ic->norm.normal->im) { - if (cols[1] < ic->norm.normal->im->rgb_width) - cols[1] = ic->norm.normal->im->rgb_width; - if (ic->norm.normal->im->rgb_height > temp_h) - temp_h = ic->norm.normal->im->rgb_height; + imlib_context_set_image(ic->norm.normal->im); + if (cols[1] < imlib_image_get_width()) + cols[1] = imlib_image_get_width(); + if (imlib_image_get_height() > temp_h) + temp_h = imlib_image_get_height(); } } if (ac->list[i]->modifiers) @@ -252,10 +254,11 @@ ShowToolTip(ToolTip * tt, char *text, ActionClass * ac, int x, int y) ImageStateRealize(ic->norm.normal); if (ic->norm.normal->im) { - if (cols[2] < ic->norm.normal->im->rgb_width) - cols[2] = ic->norm.normal->im->rgb_width; - if (ic->norm.normal->im->rgb_height > temp_h) - temp_h = ic->norm.normal->im->rgb_height; + imlib_context_set_image(ic->norm.normal->im); + if (cols[2] < imlib_image_get_width()) + cols[2] = imlib_image_get_width(); + if (imlib_image_get_height() > temp_h) + temp_h = imlib_image_get_height(); } } if (ac->list[i]->modifiers & LockMask) @@ -275,10 +278,11 @@ ShowToolTip(ToolTip * tt, char *text, ActionClass * ac, int x, int y) ImageStateRealize(ic->norm.normal); if (ic->norm.normal->im) { - if (cols[3] < ic->norm.normal->im->rgb_width) - cols[3] = ic->norm.normal->im->rgb_width; - if (ic->norm.normal->im->rgb_height > temp_h) - temp_h = ic->norm.normal->im->rgb_height; + imlib_context_set_image(ic->norm.normal->im); + if (cols[3] < imlib_image_get_width()) + cols[3] = imlib_image_get_width(); + if (imlib_image_get_height() > temp_h) + temp_h = imlib_image_get_height(); } } if (ac->list[i]->modifiers & ControlMask) @@ -298,10 +302,11 @@ ShowToolTip(ToolTip * tt, char *text, ActionClass * ac, int x, int y) ImageStateRealize(ic->norm.normal); if (ic->norm.normal->im) { - if (cols[4] < ic->norm.normal->im->rgb_width) - cols[4] = ic->norm.normal->im->rgb_width; - if (ic->norm.normal->im->rgb_height > temp_h) - temp_h = ic->norm.normal->im->rgb_height; + imlib_context_set_image(ic->norm.normal->im); + if (cols[4] < imlib_image_get_width()) + cols[4] = imlib_image_get_width(); + if (imlib_image_get_height() > temp_h) + temp_h = imlib_image_get_height(); } } if (ac->list[i]->modifiers & Mod1Mask) @@ -321,10 +326,11 @@ ShowToolTip(ToolTip * tt, char *text, ActionClass * ac, int x, int y) ImageStateRealize(ic->norm.normal); if (ic->norm.normal->im) { - if (cols[5] < ic->norm.normal->im->rgb_width) - cols[5] = ic->norm.normal->im->rgb_width; - if (ic->norm.normal->im->rgb_height > temp_h) - temp_h = ic->norm.normal->im->rgb_height; + imlib_context_set_image(ic->norm.normal->im); + if (cols[5] < imlib_image_get_width()) + cols[5] = imlib_image_get_width(); + if (imlib_image_get_height() > temp_h) + temp_h = imlib_image_get_height(); } } if (ac->list[i]->modifiers & Mod2Mask) @@ -344,10 +350,11 @@ ShowToolTip(ToolTip * tt, char *text, ActionClass * ac, int x, int y) ImageStateRealize(ic->norm.normal); if (ic->norm.normal->im) { - if (cols[6] < ic->norm.normal->im->rgb_width) - cols[6] = ic->norm.normal->im->rgb_width; - if (ic->norm.normal->im->rgb_height > temp_h) - temp_h = ic->norm.normal->im->rgb_height; + imlib_context_set_image(ic->norm.normal->im); + if (cols[6] < imlib_image_get_width()) + cols[6] = imlib_image_get_width(); + if (imlib_image_get_height() > temp_h) + temp_h = imlib_image_get_height(); } } if (ac->list[i]->modifiers & Mod3Mask) @@ -367,10 +374,11 @@ ShowToolTip(ToolTip * tt, char *text, ActionClass * ac, int x, int y) ImageStateRealize(ic->norm.normal); if (ic->norm.normal->im) { - if (cols[7] < ic->norm.normal->im->rgb_width) - cols[7] = ic->norm.normal->im->rgb_width; - if (ic->norm.normal->im->rgb_height > temp_h) - temp_h = ic->norm.normal->im->rgb_height; + imlib_context_set_image(ic->norm.normal->im); + if (cols[7] < imlib_image_get_width()) + cols[7] = imlib_image_get_width(); + if (imlib_image_get_height() > temp_h) + temp_h = imlib_image_get_height(); } } if (ac->list[i]->modifiers & Mod4Mask) @@ -390,10 +398,11 @@ ShowToolTip(ToolTip * tt, char *text, ActionClass * ac, int x, int y) ImageStateRealize(ic->norm.normal); if (ic->norm.normal->im) { - if (cols[8] < ic->norm.normal->im->rgb_width) - cols[8] = ic->norm.normal->im->rgb_width; - if (ic->norm.normal->im->rgb_height > temp_h) - temp_h = ic->norm.normal->im->rgb_height; + imlib_context_set_image(ic->norm.normal->im); + if (cols[8] < imlib_image_get_width()) + cols[8] = imlib_image_get_width(); + if (imlib_image_get_height() > temp_h) + temp_h = imlib_image_get_height(); } } if (ac->list[i]->modifiers & Mod5Mask) @@ -413,10 +422,11 @@ ShowToolTip(ToolTip * tt, char *text, ActionClass * ac, int x, int y) ImageStateRealize(ic->norm.normal); if (ic->norm.normal->im) { - if (cols[9] < ic->norm.normal->im->rgb_width) - cols[9] = ic->norm.normal->im->rgb_width; - if (ic->norm.normal->im->rgb_height > temp_h) - temp_h = ic->norm.normal->im->rgb_height; + imlib_context_set_image(ic->norm.normal->im); + if (cols[9] < imlib_image_get_width()) + cols[9] = imlib_image_get_width(); + if (imlib_image_get_height() > temp_h) + temp_h = imlib_image_get_height(); } } } @@ -448,9 +458,10 @@ ShowToolTip(ToolTip * tt, char *text, ActionClass * ac, int x, int y) iy = 0; if (im) { - iw = im->rgb_width; - ih = im->rgb_height; - Imlib_destroy_image(pImlibData, im); + imlib_context_set_image(im); + iw = imlib_image_get_width(); + ih = imlib_image_get_height(); + imlib_free_image(); } w += iw; if (h < ih) @@ -594,335 +605,217 @@ ShowToolTip(ToolTip * tt, char *text, ActionClass * ac, int x, int y) for (i = 0; i < ac->num; i++) { x = xx + iw; - if (ac->list[i]->tooltipstring) + if (!ac->list[i]->tooltipstring) + continue; + + if (ac->list[i]->event == EVENT_DOUBLE_DOWN) { - if (ac->list[i]->event == EVENT_DOUBLE_DOWN) + TextDraw(tt->tclass, tt->win, 0, 0, STATE_NORMAL, "2x", + xx + iw - double_w, y, double_w, heights[i], 17, 0); + } + + if (ac->list[i]->anybutton) + { + ic = FindItem("TOOLTIP_MOUSEBUTTON_ANY", 0, + LIST_FINDBY_NAME, LIST_TYPE_ICLASS); + if (ic) + if (ic->norm.normal->im) + { + imlib_context_set_image(ic->norm.normal->im); + imlib_render_pixmaps_for_whole_image(&pmap, &mask); + PastePixmap(disp, tt->win, pmap, mask, x, y); + x += imlib_image_get_width(); + } + } + else + switch (ac->list[i]->button) + { + case 1: + ic = FindItem("TOOLTIP_MOUSEBUTTON_1", 0, + LIST_FINDBY_NAME, LIST_TYPE_ICLASS); + if (ic) + if (ic->norm.normal->im) + { + imlib_context_set_image(ic->norm.normal->im); + imlib_render_pixmaps_for_whole_image(&pmap, &mask); + PastePixmap(disp, tt->win, pmap, mask, x, y); + x += imlib_image_get_width(); + } + break; + case 2: + ic = FindItem("TOOLTIP_MOUSEBUTTON_2", 0, + LIST_FINDBY_NAME, LIST_TYPE_ICLASS); + if (ic) + if (ic->norm.normal->im) + { + imlib_context_set_image(ic->norm.normal->im); + imlib_render_pixmaps_for_whole_image(&pmap, &mask); + PastePixmap(disp, tt->win, pmap, mask, x, y); + x += imlib_image_get_width(); + } + break; + case 3: + ic = FindItem("TOOLTIP_MOUSEBUTTON_3", 0, + LIST_FINDBY_NAME, LIST_TYPE_ICLASS); + if (ic) + if (ic->norm.normal->im) + { + imlib_context_set_image(ic->norm.normal->im); + imlib_render_pixmaps_for_whole_image(&pmap, &mask); + PastePixmap(disp, tt->win, pmap, mask, x, y); + x += imlib_image_get_width(); + } + break; + case 4: + ic = FindItem("TOOLTIP_MOUSEBUTTON_4", 0, + LIST_FINDBY_NAME, LIST_TYPE_ICLASS); + if (ic) + if (ic->norm.normal->im) + { + imlib_context_set_image(ic->norm.normal->im); + imlib_render_pixmaps_for_whole_image(&pmap, &mask); + PastePixmap(disp, tt->win, pmap, mask, x, y); + x += imlib_image_get_width(); + } + break; + case 5: + ic = FindItem("TOOLTIP_MOUSEBUTTON_5", 0, + LIST_FINDBY_NAME, LIST_TYPE_ICLASS); + if (ic) + if (ic->norm.normal->im) + { + imlib_context_set_image(ic->norm.normal->im); + imlib_render_pixmaps_for_whole_image(&pmap, &mask); + PastePixmap(disp, tt->win, pmap, mask, x, y); + x += imlib_image_get_width(); + } + break; + default: + break; + } + + if (ac->list[i]->modifiers) + { + if (ac->list[i]->modifiers & ShiftMask) { - TextDraw(tt->tclass, tt->win, 0, 0, STATE_NORMAL, "2x", - xx + iw - double_w, y, double_w, heights[i], 17, - 0); - } - if (ac->list[i]->anybutton) - { - ic = FindItem("TOOLTIP_MOUSEBUTTON_ANY", 0, + ic = FindItem("TOOLTIP_KEY_SHIFT", 0, LIST_FINDBY_NAME, LIST_TYPE_ICLASS); if (ic) if (ic->norm.normal->im) { - Imlib_render(pImlibData, ic->norm.normal->im, - ic->norm.normal->im->rgb_width, - ic->norm.normal->im->rgb_height); - PastePixmap(disp, tt->win, - Imlib_copy_image(pImlibData, - ic->norm. - normal->im), - Imlib_copy_mask(pImlibData, - ic->norm.normal->im), - x, y); - x += ic->norm.normal->im->rgb_width; + imlib_context_set_image(ic->norm.normal->im); + imlib_render_pixmaps_for_whole_image(&pmap, + &mask); + PastePixmap(disp, tt->win, pmap, mask, x, y); + x += imlib_image_get_width(); } } - else - switch (ac->list[i]->button) - { - case 1: - ic = FindItem("TOOLTIP_MOUSEBUTTON_1", 0, - LIST_FINDBY_NAME, LIST_TYPE_ICLASS); - if (ic) - if (ic->norm.normal->im) - { - Imlib_render(pImlibData, ic->norm.normal->im, - ic->norm.normal->im->rgb_width, - ic->norm.normal->im->rgb_height); - PastePixmap(disp, tt->win, - Imlib_copy_image(pImlibData, - ic->norm. - normal->im), - Imlib_copy_mask(pImlibData, - ic->norm. - normal->im), x, - y); - x += ic->norm.normal->im->rgb_width; - } - break; - case 2: - ic = FindItem("TOOLTIP_MOUSEBUTTON_2", 0, - LIST_FINDBY_NAME, LIST_TYPE_ICLASS); - if (ic) - if (ic->norm.normal->im) - { - Imlib_render(pImlibData, ic->norm.normal->im, - ic->norm.normal->im->rgb_width, - ic->norm.normal->im->rgb_height); - PastePixmap(disp, tt->win, - Imlib_copy_image(pImlibData, - ic->norm. - normal->im), - Imlib_copy_mask(pImlibData, - ic->norm. - normal->im), x, - y); - x += ic->norm.normal->im->rgb_width; - } - break; - case 3: - ic = FindItem("TOOLTIP_MOUSEBUTTON_3", 0, - LIST_FINDBY_NAME, LIST_TYPE_ICLASS); - if (ic) - if (ic->norm.normal->im) - { - Imlib_render(pImlibData, ic->norm.normal->im, - ic->norm.normal->im->rgb_width, - ic->norm.normal->im->rgb_height); - PastePixmap(disp, tt->win, - Imlib_copy_image(pImlibData, - ic->norm. - normal->im), - Imlib_copy_mask(pImlibData, - ic->norm. - normal->im), x, - y); - x += ic->norm.normal->im->rgb_width; - } - break; - case 4: - ic = FindItem("TOOLTIP_MOUSEBUTTON_4", 0, - LIST_FINDBY_NAME, LIST_TYPE_ICLASS); - if (ic) - if (ic->norm.normal->im) - { - Imlib_render(pImlibData, ic->norm.normal->im, - ic->norm.normal->im->rgb_width, - ic->norm.normal->im->rgb_height); - PastePixmap(disp, tt->win, - Imlib_copy_image(pImlibData, - ic->norm. - normal->im), - Imlib_copy_mask(pImlibData, - ic->norm. - normal->im), x, - y); - x += ic->norm.normal->im->rgb_width; - } - break; - case 5: - ic = FindItem("TOOLTIP_MOUSEBUTTON_5", 0, - LIST_FINDBY_NAME, LIST_TYPE_ICLASS); - if (ic) - if (ic->norm.normal->im) - { - Imlib_render(pImlibData, ic->norm.normal->im, - ic->norm.normal->im->rgb_width, - ic->norm.normal->im->rgb_height); - PastePixmap(disp, tt->win, - Imlib_copy_image(pImlibData, - ic->norm. - normal->im), - Imlib_copy_mask(pImlibData, - ic->norm. - normal->im), x, - y); - x += ic->norm.normal->im->rgb_width; - } - break; - default: - break; - } - - if (ac->list[i]->modifiers) + if (ac->list[i]->modifiers & LockMask) { - if (ac->list[i]->modifiers & ShiftMask) - { - ic = FindItem("TOOLTIP_KEY_SHIFT", 0, - LIST_FINDBY_NAME, LIST_TYPE_ICLASS); - if (ic) - if (ic->norm.normal->im) - { - Imlib_render(pImlibData, - ic->norm.normal->im, - ic->norm.normal->im->rgb_width, - ic->norm.normal->im-> - rgb_height); - PastePixmap(disp, tt->win, - Imlib_copy_image(pImlibData, - ic->norm. - normal->im), - Imlib_copy_mask(pImlibData, - ic->norm. - normal->im), x, - y); - x += ic->norm.normal->im->rgb_width; - } - } - if (ac->list[i]->modifiers & LockMask) - { - ic = FindItem("TOOLTIP_KEY_LOCK", 0, - LIST_FINDBY_NAME, LIST_TYPE_ICLASS); - if (ic) - if (ic->norm.normal->im) - { - Imlib_render(pImlibData, - ic->norm.normal->im, - ic->norm.normal->im->rgb_width, - ic->norm.normal->im-> - rgb_height); - PastePixmap(disp, tt->win, - Imlib_copy_image(pImlibData, - ic->norm. - normal->im), - Imlib_copy_mask(pImlibData, - ic->norm. - normal->im), x, - y); - x += ic->norm.normal->im->rgb_width; - } - } - if (ac->list[i]->modifiers & ControlMask) - { - ic = FindItem("TOOLTIP_KEY_CTRL", 0, - LIST_FINDBY_NAME, LIST_TYPE_ICLASS); - if (ic) - if (ic->norm.normal->im) - { - Imlib_render(pImlibData, - ic->norm.normal->im, - ic->norm.normal->im->rgb_width, - ic->norm.normal->im-> - rgb_height); - PastePixmap(disp, tt->win, - Imlib_copy_image(pImlibData, - ic->norm. - normal->im), - Imlib_copy_mask(pImlibData, - ic->norm. - normal->im), x, - y); - x += ic->norm.normal->im->rgb_width; - } - } - if (ac->list[i]->modifiers & Mod1Mask) - { - ic = FindItem("TOOLTIP_KEY_MOD1", 0, - LIST_FINDBY_NAME, LIST_TYPE_ICLASS); - if (ic) - if (ic->norm.normal->im) - { - Imlib_render(pImlibData, - ic->norm.normal->im, - ic->norm.normal->im->rgb_width, - ic->norm.normal->im-> - rgb_height); - PastePixmap(disp, tt->win, - Imlib_copy_image(pImlibData, - ic->norm. - normal->im), - Imlib_copy_mask(pImlibData, - ic->norm. - normal->im), x, - y); - x += ic->norm.normal->im->rgb_width; - } - } - if (ac->list[i]->modifiers & Mod2Mask) - { - ic = FindItem("TOOLTIP_KEY_MOD2", 0, - LIST_FINDBY_NAME, LIST_TYPE_ICLASS); - if (ic) - if (ic->norm.normal->im) - { - Imlib_render(pImlibData, - ic->norm.normal->im, - ic->norm.normal->im->rgb_width, - ic->norm.normal->im-> - rgb_height); - PastePixmap(disp, tt->win, - Imlib_copy_image(pImlibData, - ic->norm. - normal->im), - Imlib_copy_mask(pImlibData, - ic->norm. - normal->im), x, - y); - x += ic->norm.normal->im->rgb_width; - } - } - if (ac->list[i]->modifiers & Mod3Mask) - { - ic = FindItem("TOOLTIP_KEY_MOD3", 0, - LIST_FINDBY_NAME, LIST_TYPE_ICLASS); - if (ic) - if (ic->norm.normal->im) - { - Imlib_render(pImlibData, - ic->norm.normal->im, - ic->norm.normal->im->rgb_width, - ic->norm.normal->im-> - rgb_height); - PastePixmap(disp, tt->win, - Imlib_copy_image(pImlibData, - ic->norm. - normal->im), - Imlib_copy_mask(pImlibData, - ic->norm. - normal->im), x, - y); - x += ic->norm.normal->im->rgb_width; - } - } - if (ac->list[i]->modifiers & Mod4Mask) - { - ic = FindItem("TOOLTIP_KEY_MOD4", 0, - LIST_FINDBY_NAME, LIST_TYPE_ICLASS); - if (ic) - if (ic->norm.normal->im) - { - Imlib_render(pImlibData, - ic->norm.normal->im, - ic->norm.normal->im->rgb_width, - ic->norm.normal->im-> - rgb_height); - PastePixmap(disp, tt->win, - Imlib_copy_image(pImlibData, - ic->norm. - normal->im), - Imlib_copy_mask(pImlibData, - ic->norm. - normal->im), x, - y); - x += ic->norm.normal->im->rgb_width; - } - } - if (ac->list[i]->modifiers & Mod5Mask) - { - ic = FindItem("TOOLTIP_KEY_MOD5", 0, - LIST_FINDBY_NAME, LIST_TYPE_ICLASS); - if (ic) - if (ic->norm.normal->im) - { - Imlib_render(pImlibData, - ic->norm.normal->im, - ic->norm.normal->im->rgb_width, - ic->norm.normal->im-> - rgb_height); - PastePixmap(disp, tt->win, - Imlib_copy_image(pImlibData, - ic->norm. - normal->im), - Imlib_copy_mask(pImlibData, - ic->norm. - normal->im), x, - y); - x += ic->norm.normal->im->rgb_width; - } - } + ic = FindItem("TOOLTIP_KEY_LOCK", 0, + LIST_FINDBY_NAME, LIST_TYPE_ICLASS); + if (ic) + if (ic->norm.normal->im) + { + imlib_context_set_image(ic->norm.normal->im); + imlib_render_pixmaps_for_whole_image(&pmap, + &mask); + PastePixmap(disp, tt->win, pmap, mask, x, y); + x += imlib_image_get_width(); + } + } + if (ac->list[i]->modifiers & ControlMask) + { + ic = FindItem("TOOLTIP_KEY_CTRL", 0, + LIST_FINDBY_NAME, LIST_TYPE_ICLASS); + if (ic) + if (ic->norm.normal->im) + { + imlib_context_set_image(ic->norm.normal->im); + imlib_render_pixmaps_for_whole_image(&pmap, + &mask); + PastePixmap(disp, tt->win, pmap, mask, x, y); + x += imlib_image_get_width(); + } + } + if (ac->list[i]->modifiers & Mod1Mask) + { + ic = FindItem("TOOLTIP_KEY_MOD1", 0, + LIST_FINDBY_NAME, LIST_TYPE_ICLASS); + if (ic) + if (ic->norm.normal->im) + { + imlib_context_set_image(ic->norm.normal->im); + imlib_render_pixmaps_for_whole_image(&pmap, + &mask); + PastePixmap(disp, tt->win, pmap, mask, x, y); + x += imlib_image_get_width(); + } + } + if (ac->list[i]->modifiers & Mod2Mask) + { + ic = FindItem("TOOLTIP_KEY_MOD2", 0, + LIST_FINDBY_NAME, LIST_TYPE_ICLASS); + if (ic) + if (ic->norm.normal->im) + { + imlib_context_set_image(ic->norm.normal->im); + imlib_render_pixmaps_for_whole_image(&pmap, + &mask); + PastePixmap(disp, tt->win, pmap, mask, x, y); + x += imlib_image_get_width(); + } + } + if (ac->list[i]->modifiers & Mod3Mask) + { + ic = FindItem("TOOLTIP_KEY_MOD3", 0, + LIST_FINDBY_NAME, LIST_TYPE_ICLASS); + if (ic) + if (ic->norm.normal->im) + { + imlib_context_set_image(ic->norm.normal->im); + imlib_render_pixmaps_for_whole_image(&pmap, + &mask); + PastePixmap(disp, tt->win, pmap, mask, x, y); + x += imlib_image_get_width(); + } + } + if (ac->list[i]->modifiers & Mod4Mask) + { + ic = FindItem("TOOLTIP_KEY_MOD4", 0, + LIST_FINDBY_NAME, LIST_TYPE_ICLASS); + if (ic) + if (ic->norm.normal->im) + { + imlib_context_set_image(ic->norm.normal->im); + imlib_render_pixmaps_for_whole_image(&pmap, + &mask); + PastePixmap(disp, tt->win, pmap, mask, x, y); + x += imlib_image_get_width(); + } + } + if (ac->list[i]->modifiers & Mod5Mask) + { + ic = FindItem("TOOLTIP_KEY_MOD5", 0, + LIST_FINDBY_NAME, LIST_TYPE_ICLASS); + if (ic) + if (ic->norm.normal->im) + { + imlib_context_set_image(ic->norm.normal->im); + imlib_render_pixmaps_for_whole_image(&pmap, + &mask); + PastePixmap(disp, tt->win, pmap, mask, x, y); + x += imlib_image_get_width(); + } } - - TextDraw(tt->tclass, tt->win, 0, 0, STATE_NORMAL, - ac->list[i]->tooltipstring, - tt->iclass->padding.left + icons_width + iw, y, - labels_width, heights[i], 17, 0); - y += heights[i]; } + + TextDraw(tt->tclass, tt->win, 0, 0, STATE_NORMAL, + ac->list[i]->tooltipstring, + tt->iclass->padding.left + icons_width + iw, y, + labels_width, heights[i], 17, 0); + y += heights[i]; + } } diff --git a/src/ttfont.c b/src/ttfont.c index 590ad106..304ac011 100644 --- a/src/ttfont.c +++ b/src/ttfont.c @@ -849,7 +849,7 @@ EFont_draw_string(Display * disp, Drawable win, GC gc, int x, int y, char *text, { if (xatt.depth == 16) { - if (pImlibData->x.render_depth == 15) + if (IC_RenderDepth() == 15) merge_text_15(xim, rmap, clipx, clipy, col); else merge_text_16(xim, rmap, clipx, clipy, col);