diff --git a/configure.in b/configure.in index d887ade4..f26f6be7 100644 --- a/configure.in +++ b/configure.in @@ -191,7 +191,7 @@ echo "Warning: No ales were found in your refrigerator." echo " We highly suggest that you rectify this situation immediately." ]) -edocdata=`ls -1 $srcdir/dox/E-docs | egrep -v '(Makefile|CVS|^e|^misc|\.sh$)'` +edocdata=`ls -1 $srcdir/dox/E-docs | egrep -v '(Makefile|CVS|^misc|\.sh$)'` edocexec=`ls -1 $srcdir/dox/E-docs | egrep '\.sh$'` edocdata=`echo $edocdata` edocexec=`echo $edocexec` diff --git a/dox/exit1.xpm b/dox/E-docs/exit1.xpm similarity index 100% rename from dox/exit1.xpm rename to dox/E-docs/exit1.xpm diff --git a/dox/exit2.xpm b/dox/E-docs/exit2.xpm similarity index 100% rename from dox/exit2.xpm rename to dox/E-docs/exit2.xpm diff --git a/dox/next1.xpm b/dox/E-docs/next1.xpm similarity index 100% rename from dox/next1.xpm rename to dox/E-docs/next1.xpm diff --git a/dox/next2.xpm b/dox/E-docs/next2.xpm similarity index 100% rename from dox/next2.xpm rename to dox/E-docs/next2.xpm diff --git a/dox/prev1.xpm b/dox/E-docs/prev1.xpm similarity index 100% rename from dox/prev1.xpm rename to dox/E-docs/prev1.xpm diff --git a/dox/prev2.xpm b/dox/E-docs/prev2.xpm similarity index 100% rename from dox/prev2.xpm rename to dox/E-docs/prev2.xpm diff --git a/dox/title.xpm b/dox/E-docs/title.xpm similarity index 100% rename from dox/title.xpm rename to dox/E-docs/title.xpm diff --git a/dox/Makefile.am b/dox/Makefile.am index 52b29f7f..3419a77b 100644 --- a/dox/Makefile.am +++ b/dox/Makefile.am @@ -10,13 +10,6 @@ dox_SOURCES = \ ttfont.c \ text.c \ dox.c \ - title.xpm \ - prev1.xpm \ - prev2.xpm \ - next1.xpm \ - next2.xpm \ - exit1.xpm \ - exit2.xpm \ dox.h LDADD = $(TTF_LIBS) $(FNLIB_LIBS) $(IMLIB_LIBS) $(XINERAMA_LIBS) -lm diff --git a/dox/dox.c b/dox/dox.c index f801c52e..7d428151 100644 --- a/dox/dox.c +++ b/dox/dox.c @@ -36,10 +36,6 @@ #include #endif -#include -#if USE_FNLIB -#include -#endif #include #include #include @@ -80,26 +76,24 @@ typedef struct _mwmhints { INT32 inputMode; } MWMHints; -#include "title.xpm" -#include "prev1.xpm" -#include "prev2.xpm" -#include "next1.xpm" -#include "next2.xpm" -#include "exit1.xpm" -#include "exit2.xpm" - Display *disp; -ImlibData *pImlibData; +Root root; + +#if !USE_IMLIB2 +ImlibData *pI1Ctx; +ImlibImage *pIcImg; +Drawable vIcDrw; +#endif #if USE_FNLIB FnlibData *pFnlibData; #endif Window win_main, win_title, win_exit, win_next, win_prev, win_text, win_cover; int w, h, t; -ImlibImage *im_text; -ImlibImage *im_title; -ImlibImage *im_prev1, *im_prev2; -ImlibImage *im_next1, *im_next2; -ImlibImage *im_exit1, *im_exit2; +Imlib_Image *im_text; +Imlib_Image *im_title; +Imlib_Image *im_prev1, *im_prev2; +Imlib_Image *im_next1, *im_next2; +Imlib_Image *im_exit1, *im_exit2; char *docdir; Window CreateWindow(Window parent, int x, int y, int ww, int hh); @@ -117,7 +111,7 @@ Window CreateWindow(Window parent, int x, int y, int ww, int hh) attr.backing_store = NotUseful; attr.override_redirect = False; - attr.colormap = Imlib_get_colormap(pImlibData); + attr.colormap = root.cmap; attr.border_pixel = 0; attr.background_pixel = 0; attr.save_under = False; @@ -126,8 +120,8 @@ Window CreateWindow(Window parent, int x, int y, int ww, int hh) mwm.decorations = 0; mwm.inputMode = 0; /* a = XInternAtom(disp, "_MOTIF_WM_HINTS", False); */ - win = XCreateWindow(disp, parent, x, y, ww, hh, 0, pImlibData->x.depth, - InputOutput, Imlib_get_visual(pImlibData), + win = XCreateWindow(disp, parent, x, y, ww, hh, 0, root.depth, + InputOutput, root.vis, CWOverrideRedirect | CWSaveUnder | CWBackingStore | CWColormap | CWBackPixel | CWBorderPixel, &attr); XSetWindowBackground(disp, win, 0); @@ -147,6 +141,46 @@ Window CreateWindow(Window parent, int x, int y, int ww, int hh) return win; } +static Imlib_Image * +LoadImage(const char *file) +{ + Imlib_Image *im; + char tmp[4096]; + + sprintf(tmp, "%s/E-docs/%s", ENLIGHTENMENT_ROOT, file); + findLocalizedFile(tmp); + im = imlib_load_image(tmp); + + return im; +} + +static void +ApplyImage1(Window win, Imlib_Image *im) +{ + Pixmap pmap = 0, mask = 0; + + imlib_context_set_image(im); + imlib_context_set_drawable(win); + imlib_render_pixmaps_for_whole_image(&pmap, &mask); + XSetWindowBackgroundPixmap(disp, win, pmap); + IMLIB_FREE_PIXMAP_AND_MASK(pmap, mask); +} + +static void +ApplyImage2(Window win, Imlib_Image *im) +{ + imlib_context_set_image(im); + imlib_context_set_drawable(win); + imlib_render_image_on_drawable(0, 0); +} + +#if USE_IMLIB2 +#define ApplyImage3(win, im) \ + XClearWindow(disp, win) +#else +#define ApplyImage3 ApplyImage2 +#endif + #define FREE_LINKS \ ll = l; \ while (ll) \ @@ -188,8 +222,10 @@ int main(int argc, char **argv) char *s, *docfile = NULL; Pixmap draw = 0; Link *l = NULL, *ll = NULL; - ImlibBorder ibd; + Imlib_Border ibd; +#if !USE_IMLIB2 ImlibInitParams params; +#endif int *page_hist = NULL; int page_hist_len = 1; int page_hist_pos = 0; @@ -215,27 +251,34 @@ int main(int argc, char **argv) /* I dont want any internationalisation of my numeric input & output */ setlocale(LC_NUMERIC, "C"); + root.scr = DefaultScreen(disp); +#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_color_usage(128); + + imlib_context_set_display(disp); + imlib_context_set_visual(root.vis); + imlib_context_set_colormap(root.cmap); + imlib_context_set_dither(1); + imlib_context_set_dither_mask(0); +#else params.flags = PARAMS_IMAGECACHESIZE | PARAMS_PIXMAPCACHESIZE; params.imagecachesize = (w * h * 3 * 2); params.pixmapcachesize = (w * h * 3 * 2 * 8); - pImlibData = Imlib_init_with_params(disp, ¶ms); - Imlib_set_render_type(pImlibData, RT_DITHER_TRUECOL); -#if USE_FNLIB - pFnlibData = Fnlib_init(pImlibData); + pI1Ctx = Imlib_init_with_params(disp, ¶ms); + Imlib_set_render_type(pI1Ctx, RT_DITHER_TRUECOL); + root.win = pI1Ctx->x.root; + root.vis = Imlib_get_visual(pI1Ctx); + root.depth = pI1Ctx->x.depth; + root.cmap = Imlib_get_colormap(pI1Ctx); +#endif +#if USE_FNLIB + pFnlibData = Fnlib_init(pI1Ctx); #endif - - im_title = Imlib_create_image_from_xpm_data(pImlibData, title_xpm); - ibd.left = 50; - ibd.right = 2; - ibd.top = 2; - ibd.bottom = 2; - Imlib_set_image_border(pImlibData, im_title, &ibd); - im_prev1 = Imlib_create_image_from_xpm_data(pImlibData, prev1_xpm); - im_prev2 = Imlib_create_image_from_xpm_data(pImlibData, prev2_xpm); - im_next1 = Imlib_create_image_from_xpm_data(pImlibData, next1_xpm); - im_next2 = Imlib_create_image_from_xpm_data(pImlibData, next2_xpm); - im_exit1 = Imlib_create_image_from_xpm_data(pImlibData, exit1_xpm); - im_exit2 = Imlib_create_image_from_xpm_data(pImlibData, exit2_xpm); if (argc < 2) { printf("usage:\n" @@ -243,6 +286,7 @@ int main(int argc, char **argv) argv[0]); exit(1); } + docdir = "."; docfile = "MAIN"; for (i = 1; i < argc; i++) { @@ -260,6 +304,20 @@ int main(int argc, char **argv) sprintf(s, "%s/%s", docdir, docfile); findLocalizedFile(s); + im_title = LoadImage("title.xpm"); + imlib_context_set_image(im_title); + ibd.left = 50; + ibd.right = 2; + ibd.top = 2; + ibd.bottom = 2; + imlib_image_set_border(&ibd); + im_prev1 = LoadImage("prev1.xpm"); + im_prev2 = LoadImage("prev2.xpm"); + im_next1 = LoadImage("next1.xpm"); + im_next2 = LoadImage("next2.xpm"); + im_exit1 = LoadImage("exit1.xpm"); + im_exit2 = LoadImage("exit2.xpm"); + #ifndef __EMX__ f = fopen(s, "r"); #else @@ -301,7 +359,7 @@ int main(int argc, char **argv) int num; XineramaScreenInfo *screens; - XQueryPointer(disp, pImlibData->x.root, &rt, &ch, &pointer_x, &pointer_y, + XQueryPointer(disp, root.win, &rt, &ch, &pointer_x, &pointer_y, &d, &d, &ud); screens = XineramaQueryScreens(disp, &num); @@ -326,32 +384,35 @@ int main(int argc, char **argv) } #endif - win_main = CreateWindow(pImlibData->x.root, wx, wy, w, h + t); - win_title = CreateWindow(win_main, 0, 0, (w - 64 - 64 - t), t); - win_prev = CreateWindow(win_main, (w - 64 - 64 - t), 0, 64, t); + win_main = CreateWindow(root.win, wx, wy, w, h + t); + win_title = XCreateSimpleWindow(disp, win_main, 0, 0, (w - 64 - 64 - t), t, 0, 0, 0); + win_prev = XCreateSimpleWindow(disp, win_main, (w - 64 - 64 - t), 0, 64, t, 0, 0, 0); + win_next = XCreateSimpleWindow(disp, win_main, (w - 64 - 64 - t) + 64, 0, 64, t, 0, 0, 0); + win_exit = XCreateSimpleWindow(disp, win_main, (w - 64 - 64 - t) + 64 + 64, 0, t, t, 0, 0, 0); + win_text = XCreateSimpleWindow(disp, win_main, 0, t, w, h, 0, 0, 0); XSelectInput(disp, win_prev, ButtonPressMask | ButtonReleaseMask); - win_next = CreateWindow(win_main, (w - 64 - 64 - t) + 64, 0, 64, t); XSelectInput(disp, win_next, ButtonPressMask | ButtonReleaseMask); - win_exit = CreateWindow(win_main, (w - 64 - 64 - t) + 64 + 64, 0, t, t); XSelectInput(disp, win_exit, ButtonPressMask | ButtonReleaseMask); - win_text = CreateWindow(win_main, 0, t, w, h); XSelectInput(disp, win_text, ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyReleaseMask | PointerMotionMask); - draw = XCreatePixmap(disp, win_text, w, h, pImlibData->x.depth); - XSetWindowBackgroundPixmap(disp, win_text, draw); - Imlib_apply_image(pImlibData, im_title, win_title); - Imlib_apply_image(pImlibData, im_exit1, win_exit); - Imlib_apply_image(pImlibData, im_next1, win_next); - Imlib_apply_image(pImlibData, im_prev1, win_prev); + + draw = XCreatePixmap(disp, win_text, w, h, root.depth); + + ApplyImage1(win_title, im_title); + ApplyImage1(win_prev, im_prev1); + ApplyImage1(win_next, im_next1); + ApplyImage1(win_exit, im_exit1); l = RenderPage(draw, pagenum, w, h); + UPDATE_NOW; - XMapWindow(disp, win_text); - XMapWindow(disp, win_exit); - XMapWindow(disp, win_next); - XMapWindow(disp, win_prev); XMapWindow(disp, win_title); + XMapWindow(disp, win_prev); + XMapWindow(disp, win_next); + XMapWindow(disp, win_exit); + XMapWindow(disp, win_text); XMapWindow(disp, win_main); + XSync(disp, False); page_hist = malloc(sizeof(int)); @@ -409,11 +470,11 @@ int main(int argc, char **argv) break; case ButtonPress: if (ev.xbutton.window == win_prev) - Imlib_apply_image(pImlibData, im_prev2, win_prev); + ApplyImage2(win_prev, im_prev2); else if (ev.xbutton.window == win_next) - Imlib_apply_image(pImlibData, im_next2, win_next); + ApplyImage2(win_next, im_next2); else if (ev.xbutton.window == win_exit) - Imlib_apply_image(pImlibData, im_exit2, win_exit); + ApplyImage2(win_exit, im_exit2); else { int x, y; @@ -499,7 +560,7 @@ int main(int argc, char **argv) break; case ButtonRelease: if (ev.xbutton.window == win_prev) { - Imlib_apply_image(pImlibData, im_prev1, win_prev); + ApplyImage3(win_prev, im_prev1); FREE_LINKS; page_hist_pos--; if (page_hist_pos < 0) @@ -510,7 +571,7 @@ int main(int argc, char **argv) } else if (ev.xbutton.window == win_next) { int prev_pagenum; - Imlib_apply_image(pImlibData, im_next1, win_next); + ApplyImage3(win_next, im_next1); prev_pagenum = pagenum; pagenum++; pagenum = FixPage(pagenum); @@ -529,7 +590,7 @@ int main(int argc, char **argv) UPDATE; } } else if (ev.xbutton.window == win_exit) { - Imlib_apply_image(pImlibData, im_exit1, win_exit); + ApplyImage3(win_exit, im_exit1); exit(0); } break; @@ -553,14 +614,17 @@ int main(int argc, char **argv) GC gc; XGCValues gcv; int r, g, b; + XColor xclr; if (pl != ll) { if (pl) { UPDATE_NOW; } GetLinkColors(pagenum, &r, &g, &b); + ESetColor(&xclr, r, g, b); + EAllocColor(&xclr); gc = XCreateGC(disp, win_text, 0, &gcv); - XSetForeground(disp, gc, Imlib_best_color_match(pImlibData, &r, &g, &b)); + XSetForeground(disp, gc, xclr.pixel); XDrawRectangle(disp, win_text, gc, ll->x, ll->y, ll->w, ll->h); XFreeGC(disp, gc); diff --git a/dox/dox.h b/dox/dox.h index 64e68d20..a67d14fe 100644 --- a/dox/dox.h +++ b/dox/dox.h @@ -33,10 +33,6 @@ #include #include #include -#include -#if USE_FNLIB -#include -#endif #include #include #include @@ -63,6 +59,118 @@ #include #endif +#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 + #define FILEPATH_LEN_MAX 4096 @@ -88,6 +196,18 @@ putenv(envvar);\ } + +typedef struct _root +{ + Window win; + Visual *vis; + int depth; + Colormap cmap; + int scr; + int w, h; +} +Root; + typedef struct _efont { TT_Engine engine; @@ -110,8 +230,8 @@ typedef struct _textstate FnlibStyle style; FnlibFont *font; #endif - ImlibColor fg_col; - ImlibColor bg_col; + XColor fg_col; + XColor bg_col; int effect; Efont *efont; XFontStruct *xfont; @@ -252,7 +372,7 @@ void GetLinkColors(int page_num, int *r, int *g, int *b); Link *RenderPage(Window win, int page_num, int w, int h); extern Display *disp; -extern ImlibData *pImlibData; +extern Root root; #if USE_FNLIB extern FnlibData *pFnlibData; #endif diff --git a/dox/format.c b/dox/format.c index b58fdf13..1446d21c 100644 --- a/dox/format.c +++ b/dox/format.c @@ -515,7 +515,7 @@ RenderPage(Window win, int page_num, int w, int h) int x, y; int justification = 0; int firstp = 1; - ImlibImage *im; + Imlib_Image *im; int wastext = 0; ts.fontname = NULL; @@ -526,12 +526,8 @@ RenderPage(Window win, int page_num, int w, int h) ts.style.spacing = 0; ts.font = NULL; #endif - ts.fg_col.r = 0; - ts.fg_col.g = 0; - ts.fg_col.b = 0; - ts.bg_col.r = 0; - ts.bg_col.g = 0; - ts.bg_col.b = 0; + ESetColor(&ts.fg_col, 0, 0, 0); + ESetColor(&ts.bg_col, 0, 0, 0); ts.effect = 0; ts.efont = NULL; ts.xfont = NULL; @@ -549,11 +545,13 @@ RenderPage(Window win, int page_num, int w, int h) sprintf(tmp, "%s/%s", docdir, pg->background); findLocalizedFile(tmp); - im = Imlib_load_image(pImlibData, tmp); + im = imlib_load_image(tmp); if (im) { - Imlib_paste_image(pImlibData, im, win, 0, 0, w, h); - Imlib_destroy_image(pImlibData, im); + imlib_context_set_image(im); + imlib_context_set_drawable(win); + imlib_render_image_on_drawable_at_size(0, 0, w, h); + imlib_free_image(); } } for (i = 0; i < pg->count; i++) @@ -574,14 +572,16 @@ RenderPage(Window win, int page_num, int w, int h) char tmp[4096]; sprintf(tmp, "%s/%s", docdir, img->src); - im = Imlib_load_image(pImlibData, tmp); + im = imlib_load_image(tmp); if (im) { - img->w = im->rgb_width; - img->h = im->rgb_height; - Imlib_paste_image(pImlibData, im, win, img->x, img->y, - im->rgb_width, im->rgb_height); - Imlib_destroy_image(pImlibData, im); + imlib_context_set_image(im); + img->w = imlib_image_get_width(); + img->h = imlib_image_get_height(); + imlib_context_set_drawable(win); + imlib_render_image_on_drawable_at_size(img->x, img->y, + img->w, img->h); + imlib_free_image(); } if (img->link) { @@ -615,12 +615,8 @@ RenderPage(Window win, int page_num, int w, int h) Fnlib_free_font(pFnlibData, ts.font); ts.font = NULL; #endif - ts.fg_col.r = 0; - ts.fg_col.g = 0; - ts.fg_col.b = 0; - ts.bg_col.r = 0; - ts.bg_col.g = 0; - ts.bg_col.b = 0; + ESetColor(&ts.fg_col, 0, 0, 0); + ESetColor(&ts.bg_col, 0, 0, 0); ts.effect = 0; if (ts.efont) Efont_free(ts.efont); @@ -634,9 +630,7 @@ RenderPage(Window win, int page_num, int w, int h) ts.xfontset_ascent = 0; ts.height = 0; ts.fontname = fn->face; - ts.fg_col.r = fn->r; - ts.fg_col.g = fn->g; - ts.fg_col.b = fn->b; + ESetColor(&ts.fg_col, fn->r, fn->g, fn->b); TextStateLoadFont(&ts); break; case P: @@ -915,20 +909,15 @@ RenderPage(Window win, int page_num, int w, int h) if (link > 1) { int rr, gg, bb; - int r, g, b; int extra; GC gc; XGCValues gcv; gc = XCreateGC(disp, win, 0, &gcv); - rr = ts.fg_col.r; - gg = ts.fg_col.g; - bb = ts.fg_col.b; - r = ts.fg_col.r = pg->linkr; - g = ts.fg_col.g = pg->linkg; - b = ts.fg_col.b = pg->linkb; - XSetForeground(disp, gc, - Imlib_best_color_match(pImlibData, &r, &g, &b)); + EGetColor(&ts.fg_col, &rr, &gg, &bb); + ESetColor(&ts.fg_col, pg->linkr, pg->linkg, pg->linkb); + EAllocColor(&ts.fg_col); + XSetForeground(disp, gc, ts.fg_col.pixel); TextSize(&ts, txt_disp, &tw, &th, 17); extra = ((xspace - tw) * justification) >> 10; TextDraw(&ts, win, link_txt, x + off + lx + extra, y, @@ -939,9 +928,7 @@ RenderPage(Window win, int page_num, int w, int h) y + ts.xfontset_ascent, x + off + lx + lw + extra, y + ts.xfontset_ascent); - ts.fg_col.r = rr; - ts.fg_col.g = gg; - ts.fg_col.b = bb; + ESetColor(&ts.fg_col, rr, gg, bb); link = 0; XFreeGC(disp, gc); { diff --git a/dox/text.c b/dox/text.c index 76c8a8cd..1b61d558 100644 --- a/dox/text.c +++ b/dox/text.c @@ -289,40 +289,28 @@ TextDraw(TextState * ts, Window win, char *text, xx = x + (((w - wid) * justification) >> 10); 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, win, gc, xx + 1, yy + 1, - lines[i], ts->efont, Imlib_get_visual(pImlibData), - Imlib_get_colormap(pImlibData)); + lines[i], ts->efont, 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, win, gc, xx - 1, yy, - lines[i], ts->efont, Imlib_get_visual(pImlibData), - Imlib_get_colormap(pImlibData)); + lines[i], ts->efont, root.vis, root.cmap); EFont_draw_string(disp, win, gc, xx + 1, yy, - lines[i], ts->efont, Imlib_get_visual(pImlibData), - Imlib_get_colormap(pImlibData)); + lines[i], ts->efont, root.vis, root.cmap); EFont_draw_string(disp, win, gc, xx, yy - 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, win, gc, xx, yy + 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, win, gc, xx, yy, - lines[i], ts->efont, Imlib_get_visual(pImlibData), - Imlib_get_colormap(pImlibData)); + lines[i], ts->efont, root.vis, root.cmap); yy += ascent + descent; } } @@ -338,19 +326,15 @@ TextDraw(TextState * ts, Window win, char *text, xx = x + (((w - ret2.width) * justification) >> 10); 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, win, ts->xfontset, gc, xx + 1, yy + 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, win, ts->xfontset, gc, xx - 1, yy, lines[i], strlen(lines[i])); XmbDrawString(disp, win, ts->xfontset, gc, xx + 1, yy, @@ -360,10 +344,8 @@ TextDraw(TextState * ts, Window win, char *text, XmbDrawString(disp, win, ts->xfontset, gc, xx, yy + 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, win, ts->xfontset, gc, xx, yy, lines[i], strlen(lines[i])); yy += ret2.height; @@ -383,19 +365,15 @@ TextDraw(TextState * ts, Window win, char *text, xx = x + (((w - wid) * justification) >> 10); 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, win, gc, xx + 1, yy + 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, win, gc, xx - 1, yy, lines[i], strlen(lines[i])); XDrawString(disp, win, gc, xx + 1, yy, @@ -405,10 +383,8 @@ TextDraw(TextState * ts, Window win, char *text, XDrawString(disp, win, gc, xx, yy + 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, win, gc, xx, yy, lines[i], strlen(lines[i])); yy += ts->xfont->ascent + ts->xfont->descent; @@ -428,19 +404,15 @@ TextDraw(TextState * ts, Window win, char *text, xx = x + (((w - wid) * justification) >> 10); 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, win, gc, xx + 1, yy + 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, win, gc, xx - 1, yy, (XChar2b *) lines[i], strlen(lines[i]) / 2); XDrawString16(disp, win, gc, xx + 1, yy, @@ -450,10 +422,8 @@ TextDraw(TextState * ts, Window win, char *text, XDrawString16(disp, win, gc, xx, yy + 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, win, gc, xx, yy, (XChar2b *) lines[i], strlen(lines[i]) / 2); yy += ts->xfont->ascent + ts->xfont->descent;