From: handa Date: Mon, 15 Mar 2004 13:00:30 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=6a873fa618f26d30fb8b86a8e60416b42bcf4455;p=m17n%2Fm17n-lib.git *** empty log message *** --- diff --git a/src/m17n-X.c b/src/m17n-X.c index e357b06..a2ddcb8 100644 --- a/src/m17n-X.c +++ b/src/m17n-X.c @@ -92,23 +92,25 @@ typedef struct GC gc; } RGB_GC; -enum face_gc +enum gc_index { - MFACE_GC_NORMAL, - MFACE_GC_INVERSE, - MFACE_GC_HLINE, - MFACE_GC_BOX_TOP, - MFACE_GC_BOX_BOTTOM, - MFACE_GC_BOX_LEFT, - MFACE_GC_BOX_RIGHT, - MFACE_GCS + GC_INVERSE, + GC_NORMAL = GC_INVERSE + 7, + GC_HLINE, + GC_BOX_TOP, + GC_BOX_BOTTOM, + GC_BOX_LEFT, + GC_BOX_RIGHT, + GC_MAX }; typedef struct { int rgb_fore; int rgb_back; - GC gc[MFACE_GCS + 8]; + /* The first 8 elements are indexed by an intensity for + anti-aliasing. The 2nd to 7th are created on demand. */ + GC gc[GC_MAX]; } GCInfo; struct MWDevice @@ -126,7 +128,7 @@ struct MWDevice Colormap cmap; - GCInfo gc_info; + GC scratch_gc; /** List of pointers to realized faces on the frame. */ MPlist *realized_face_list; @@ -145,6 +147,17 @@ static MSymbol M_iso8859_1, M_iso10646_1; #define FRAME_DISPLAY(frame) (frame->device->display_info->display) #define FRAME_SCREEN(frame) (frame->device->screen_num) +#define DEFAULT_FONT "-misc-fixed-medium-r-normal--*-120-*-*-*-*-iso8859-1" +#define FALLBACK_FONT "-misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-1" + +typedef struct +{ + String font; + String foreground; + String background; + Boolean reverse_video; +} AppData, *AppDataPtr; + static void free_display_info (void *object) { @@ -218,10 +231,10 @@ free_device (void *object) free (MPLIST_VAL (plist)); } M17N_OBJECT_UNREF (device->gc_list); + XFreeGC (device->display_info->display, device->scratch_gc); XFreePixmap (device->display_info->display, device->drawable); M17N_OBJECT_UNREF (device->display_info); - free (object); } @@ -276,6 +289,104 @@ find_modifier_bits (MDisplayInfo *disp_info) XFreeModifiermap (mods); } +static RGB_GC * +get_rgb_gc (MWDevice *device, XColor *xcolor) +{ + int rgb = (((xcolor->red >> 8) << 16) | ((xcolor->green >> 8) << 8) + | (xcolor->blue >> 8)); + MPlist *plist; + RGB_GC *rgb_gc; + unsigned long valuemask = GCForeground; + XGCValues values; + + MPLIST_DO (plist, device->gc_list) + { + rgb_gc = MPLIST_VAL (plist); + + if (rgb_gc->rgb == rgb) + return rgb_gc; + if (rgb_gc->rgb > rgb) + break; + } + + if (! XAllocColor (device->display_info->display, device->cmap, xcolor)) + return NULL; + + rgb_gc = malloc (sizeof (RGB_GC)); + rgb_gc->rgb = rgb; + values.foreground = xcolor->pixel; + rgb_gc->gc = XCreateGC (device->display_info->display, + device->drawable, valuemask, &values); + mplist_push (plist, Mt, rgb_gc); + return rgb_gc; +} + +static GC +get_gc (MFrame *frame, MSymbol color, int for_foreground, int *rgb_ret) +{ + MWDevice *device = frame->device; + XColor xcolor; + RGB_GC *rgb_gc; + + if (color == Mnil) + { + if (frame->rface) + goto no_color; + color = for_foreground ? frame->foreground : frame->background; + } + if (! XParseColor (FRAME_DISPLAY (frame), device->cmap, + msymbol_name (color), &xcolor)) + goto no_color; + rgb_gc = get_rgb_gc (device, &xcolor); + if (! rgb_gc) + goto no_color; + if (rgb_ret) + *rgb_ret = rgb_gc->rgb; + return rgb_gc->gc; + + no_color: + { + GCInfo *info = frame->rface->info; + GC gc; + int rgb; + + if (for_foreground) + rgb = info->rgb_fore, gc = info->gc[GC_NORMAL]; + else + rgb = info->rgb_back, gc = info->gc[GC_INVERSE]; + if (rgb_ret) + *rgb_ret = rgb; + return gc; + } +} + +static GC +get_gc_for_anti_alias (MWDevice *device, GCInfo *info, int intensity) +{ + int rgb_fore, rgb_back; + XColor xcolor; + RGB_GC *rgb_gc; + GC gc; + + if (info->gc[intensity]) + return info->gc[intensity]; + + rgb_fore = info->rgb_fore, rgb_back = info->rgb_back; + xcolor.red = ((((rgb_fore & 0xFF0000) >> 16) * intensity + + ((rgb_back & 0xFF0000) >> 16) * (7 - intensity)) / 7) << 8; + xcolor.green = ((((rgb_fore & 0xFF00) >> 8) * intensity + + ((rgb_back & 0xFF00) >> 8) * (7 - intensity)) / 7) << 8; + xcolor.blue = (((rgb_fore & 0xFF) * intensity + + (rgb_back & 0xFF) * (7 - intensity)) / 7) << 8; + rgb_gc = get_rgb_gc (device, &xcolor); + if (rgb_gc) + gc = rgb_gc->gc; + else + gc =get_gc_for_anti_alias (device, info, + intensity < 4 ? intensity - 1 : intensity + 1); + return (info->gc[intensity] = gc); +} + /** X font handler */ @@ -742,10 +853,9 @@ set_region (MFrame *frame, GC gc, MDrawRegion region) unsigned long valuemask = GCForeground; XCopyGC (FRAME_DISPLAY (frame), gc, valuemask, - frame->device->gc_info.gc[MFACE_GCS]); - XSetRegion (FRAME_DISPLAY (frame), frame->device->gc_info.gc[MFACE_GCS], - region); - return frame->device->gc_info.gc[MFACE_GCS]; + frame->device->scratch_gc); + XSetRegion (FRAME_DISPLAY (frame), frame->device->scratch_gc, region); + return frame->device->scratch_gc; } /* The X font driver function RENDER. */ @@ -757,8 +867,7 @@ xfont_render (MDrawWindow win, int x, int y, MGlyphString *gstring, MRealizedFace *rface = from->rface; Display *display; XChar2b *code; - GC gc = ((GCInfo *) rface->info)->gc[reverse ? MFACE_GC_INVERSE - : MFACE_GC_NORMAL]; + GC gc = ((GCInfo *) rface->info)->gc[reverse ? GC_INVERSE : GC_NORMAL]; MGlyph *g; int i; @@ -1084,15 +1193,6 @@ mwin__fini () M17N_OBJECT_UNREF (device_list); } -typedef struct -{ - String font; - String foreground; - String background; - Boolean reverse_video; -} AppData, *AppDataPtr; - - int mwin__parse_font_name (char *name, MFont *font) { @@ -1175,6 +1275,7 @@ mwin__open_device (MFrame *frame, MPlist *param) XWindowAttributes attr; unsigned depth = 0; MPlist *plist; + AppData app_data; if (param) for (plist = param; (key = mplist_key (plist)) != Mnil; @@ -1275,7 +1376,6 @@ mwin__open_device (MFrame *frame, MPlist *param) { unsigned long valuemask = GCForeground; XGCValues values; - XColor color; M17N_OBJECT (device, free_device, MERROR_WIN); device->display_info = disp_info; @@ -1288,25 +1388,10 @@ mwin__open_device (MFrame *frame, MPlist *param) device->cmap = cmap; device->realized_face_list = mplist (); device->realized_fontset_list = mplist (); - values.foreground = BlackPixel (display, screen_num); - color.pixel = values.foreground; - XQueryColor (display, cmap, &color); - device->gc_info.rgb_fore - = (((color.red >> 8) << 16) | ((color.green >> 8) << 8) - | (color.blue >> 8)); - device->gc_info.gc[MFACE_GC_NORMAL] - = XCreateGC (display, device->drawable, valuemask, &values); - device->gc_info.gc[MFACE_GCS] - = XCreateGC (display, device->drawable, valuemask, &values); - values.foreground = WhitePixel (display, screen_num); - color.pixel = values.foreground; - XQueryColor (display, cmap, &color); - device->gc_info.rgb_back - = (((color.red >> 8) << 16) | ((color.green >> 8) << 8) - | (color.blue >> 8)); - device->gc_info.gc[MFACE_GC_INVERSE] - = XCreateGC (display, device->drawable, valuemask, &values); device->gc_list = mplist (); + values.foreground = BlackPixel (display, screen_num); + device->scratch_gc = XCreateGC (display, device->drawable, + valuemask, &values); } frame->realized_font_list = disp_info->realized_font_list; @@ -1315,11 +1400,9 @@ mwin__open_device (MFrame *frame, MPlist *param) if (widget) { - AppData app_data; XtResource resources[] = { { XtNfont, XtCFont, XtRString, sizeof (String), - XtOffset (AppDataPtr, font), XtRString, - "-misc-fixed-medium-r-normal--*-120-*-*-*-*-iso8859-1" }, + XtOffset (AppDataPtr, font), XtRString, DEFAULT_FONT }, { XtNforeground, XtCForeground, XtRString, sizeof (String), XtOffset (AppDataPtr, foreground), XtRString, "black" }, { XtNbackground, XtCBackground, XtRString, sizeof (String), @@ -1327,52 +1410,56 @@ mwin__open_device (MFrame *frame, MPlist *param) { XtNreverseVideo, XtCReverseVideo, XtRBoolean, sizeof (Boolean), XtOffset (AppDataPtr, reverse_video), XtRImmediate, (caddr_t) FALSE } }; - MFace *face = NULL; - MFont font; - char **names; - int nfonts; XtGetApplicationResources (widget, &app_data, resources, XtNumber (resources), NULL, 0); - names = XListFonts (display, app_data.font, 1, &nfonts); - if (nfonts == 1) - { - if (mwin__parse_font_name (names[0], &font) >= 0) - face = mface_from_font (&font); - else - { - /* The font name does not conform to XLFD. Try to open the - font and get XA_FONT property. */ - XFontStruct *xfont = XLoadQueryFont (display, names[0]); - - if (xfont) - { - unsigned long value; - char *name; - - if (XGetFontProperty (xfont, XA_FONT, &value) - && (name = ((char *) - XGetAtomName (display, (Atom) value)))) - { - if (mwin__parse_font_name (name, &font) >= 0) - face = mface_from_font (&font); - } - XFreeFont (display, xfont); - } - } - XFreeFontNames (names); - } - - if (! face) - face = mface (); - mface_put_prop (face, Mforeground, msymbol (app_data.foreground)); - mface_put_prop (face, Mbackground, msymbol (app_data.background)); - if (app_data.reverse_video == True) - mface_put_prop (face, Mvideomode, Mreverse); - mplist_push (param, Mface, face); - M17N_OBJECT_UNREF (face); + frame->foreground = msymbol (app_data.foreground); + frame->background = msymbol (app_data.background); + frame->videomode = app_data.reverse_video == True ? Mreverse : Mnormal; + } + else + { + app_data.font = DEFAULT_FONT; + frame->foreground = msymbol ("black"); + frame->background = msymbol ("white"); + frame->videomode = Mnormal; } + frame->font = mfont (); + { + int nfonts; + char **names = XListFonts (display, app_data.font, 1, &nfonts); + + if (nfonts > 0) + { + if (mwin__parse_font_name (names[0], frame->font) < 0) + { + /* The font name does not conform to XLFD. Try to open the + font and get XA_FONT property. */ + XFontStruct *xfont = XLoadQueryFont (display, names[0]); + + nfonts = 0; + if (xfont) + { + unsigned long value; + char *name; + + if (XGetFontProperty (xfont, XA_FONT, &value) + && (name = ((char *) + XGetAtomName (display, (Atom) value)))) + { + if (mwin__parse_font_name (name, frame->font) >= 0) + nfonts = 1; + } + XFreeFont (display, xfont); + } + } + XFreeFontNames (names); + } + if (! nfonts) + mwin__parse_font_name (FALLBACK_FONT, frame->font); + } + #ifdef X_SET_ERROR_HANDLER XSetErrorHandler (x_error_handler); XSetIOErrorHandler (x_io_error_handler); @@ -1402,95 +1489,15 @@ mwin__device_get_prop (MWDevice *device, MSymbol key) return NULL; } -struct { - int size, inc, used; - GC *gc_table; -} gc_list; - - -static GC -get_gc (MFrame *frame, MSymbol color, int for_foreground, int *rgb_ret) -{ - MWDevice *device = frame->device; - XColor xcolor; - MPlist *plist; - unsigned long valuemask = GCForeground; - XGCValues values; - GC gc; - RGB_GC *rgb_gc; - int rgb; - - if (color == Mnil) - { - if (for_foreground) - rgb = device->gc_info.rgb_fore, - gc = device->gc_info.gc[MFACE_GC_NORMAL]; - else - rgb = device->gc_info.rgb_back, - gc = device->gc_info.gc[MFACE_GC_INVERSE]; - if (rgb_ret) - *rgb_ret = rgb; - return gc; - } - - if (! XParseColor (FRAME_DISPLAY (frame), device->cmap, - msymbol_name (color), &xcolor)) - goto no_color; - rgb = (((xcolor.red >> 8) << 16) | ((xcolor.green >> 8) << 8) - | (xcolor.blue >> 8)); - if (rgb_ret) - *rgb_ret = rgb; - - MPLIST_DO (plist, device->gc_list) - { - rgb_gc = MPLIST_VAL (plist); - - if (rgb_gc->rgb == rgb) - return rgb_gc->gc; - if (rgb_gc->rgb > rgb) - break; - } - if (! XAllocColor (FRAME_DISPLAY (frame), device->cmap, &xcolor)) - goto no_color; - values.foreground = xcolor.pixel; - gc = XCreateGC (FRAME_DISPLAY (frame), device->drawable, valuemask, &values); - rgb_gc = malloc (sizeof (RGB_GC)); - rgb_gc->rgb = rgb; - rgb_gc->gc = gc; - mplist_push (plist, Mt, rgb_gc); - return gc; - - no_color: - { - GCInfo *info = frame->rface ? frame->rface->info : &device->gc_info; - - if (for_foreground) - { - if (rgb_ret) - *rgb_ret = info->rgb_fore; - gc = info->gc[MFACE_GC_NORMAL]; - } - else - { - if (rgb_ret) - *rgb_ret = info->rgb_back; - gc = info->gc[MFACE_GC_INVERSE]; - } - } - return (gc); -} - - void mwin__realize_face (MRealizedFace *rface) { MFrame *frame; - MSymbol foreground, background; + MSymbol foreground, background, videomode; MFaceHLineProp *hline; MFaceBoxProp *box; MFaceHookFunc func; GCInfo *info; - XColor color; if (rface != rface->ascii_rface) { @@ -1499,46 +1506,60 @@ mwin__realize_face (MRealizedFace *rface) } frame = rface->frame; - foreground = rface->face.property[MFACE_FOREGROUND]; - background = rface->face.property[MFACE_BACKGROUND]; - hline = rface->hline; - box = rface->box; - func = (MFaceHookFunc) rface->face.property[MFACE_HOOK_FUNC]; - MSTRUCT_CALLOC (info, MERROR_WIN); - info->gc[MFACE_GC_NORMAL] = get_gc (frame, foreground, 1, &info->rgb_fore); - info->gc[MFACE_GC_INVERSE] = get_gc (frame, background, 0, &info->rgb_back); - info->gc[MFACE_GCS] = info->gc[MFACE_GC_INVERSE]; - info->gc[MFACE_GCS + 7] = info->gc[MFACE_GC_NORMAL]; + foreground = rface->face.property[MFACE_FOREGROUND]; + background = rface->face.property[MFACE_BACKGROUND]; + videomode = rface->face.property[MFACE_VIDEOMODE]; + if (! videomode) + videomode = frame->videomode; + if (videomode != Mreverse) + { + info->gc[GC_NORMAL] = get_gc (frame, foreground, 1, &info->rgb_fore); + info->gc[GC_INVERSE] = get_gc (frame, background, 0, &info->rgb_back); + } + else + { + info->gc[GC_NORMAL] = get_gc (frame, background, 0, &info->rgb_fore); + info->gc[GC_INVERSE] = get_gc (frame, foreground, 1, &info->rgb_back); + } - if (hline && hline->color != foreground) - info->gc[MFACE_GC_HLINE] = get_gc (frame, hline->color, 1, NULL); + hline = rface->hline; + if (hline) + { + if (hline->color) + info->gc[GC_HLINE] = get_gc (frame, hline->color, 1, NULL); + else + info->gc[GC_HLINE] = info->gc[GC_NORMAL]; + } + box = rface->box; if (box) { if (box->color_top) - info->gc[MFACE_GC_BOX_TOP] = get_gc (frame, box->color_top, 1, NULL); + info->gc[GC_BOX_TOP] = get_gc (frame, box->color_top, 1, NULL); else - info->gc[MFACE_GC_BOX_TOP] = info->gc[MFACE_GC_NORMAL]; + info->gc[GC_BOX_TOP] = info->gc[GC_NORMAL]; if (box->color_left && box->color_left != box->color_top) - info->gc[MFACE_GC_BOX_LEFT] = get_gc (frame, box->color_left, 1, NULL); + info->gc[GC_BOX_LEFT] = get_gc (frame, box->color_left, 1, NULL); else - info->gc[MFACE_GC_BOX_LEFT] = info->gc[MFACE_GC_BOX_TOP]; + info->gc[GC_BOX_LEFT] = info->gc[GC_NORMAL]; if (box->color_bottom && box->color_bottom != box->color_top) - info->gc[MFACE_GC_BOX_BOTTOM] = get_gc (frame, box->color_bottom, 1, NULL); + info->gc[GC_BOX_BOTTOM] = get_gc (frame, box->color_bottom, 1, NULL); else - info->gc[MFACE_GC_BOX_BOTTOM] = info->gc[MFACE_GC_BOX_TOP]; + info->gc[GC_BOX_BOTTOM] = info->gc[GC_NORMAL]; if (box->color_right && box->color_right != box->color_top) - info->gc[MFACE_GC_BOX_RIGHT] = get_gc (frame, box->color_right, 1, NULL); + info->gc[GC_BOX_RIGHT] = get_gc (frame, box->color_right, 1, NULL); else - info->gc[MFACE_GC_BOX_RIGHT] = info->gc[MFACE_GC_BOX_BOTTOM]; + info->gc[GC_BOX_RIGHT] = info->gc[GC_NORMAL]; } rface->info = info; + + func = (MFaceHookFunc) rface->face.property[MFACE_HOOK_FUNC]; if (func) (func) (&(rface->face), rface->info, rface->face.property[MFACE_HOOK_ARG]); } @@ -1547,7 +1568,8 @@ mwin__realize_face (MRealizedFace *rface) void mwin__free_realized_face (MRealizedFace *rface) { - free (rface->info); + if (rface == rface->ascii_rface) + free (rface->info); } @@ -1556,8 +1578,7 @@ mwin__fill_space (MFrame *frame, MDrawWindow win, MRealizedFace *rface, int reverse, int x, int y, int width, int height, MDrawRegion region) { - GC gc = ((GCInfo *) rface->info)->gc[reverse ? MFACE_GC_INVERSE - : MFACE_GC_NORMAL]; + GC gc = ((GCInfo *) rface->info)->gc[reverse ? GC_NORMAL : GC_INVERSE]; if (region) gc = set_region (frame, gc, region); @@ -1574,7 +1595,7 @@ mwin__draw_hline (MFrame *frame, MDrawWindow win, MGlyphString *gstring, { enum MFaceHLineType type = rface->hline->type; GCInfo *info = rface->info; - GC gc; + GC gc = gc = info->gc[GC_HLINE]; int i; y = (type == MFACE_HLINE_BOTTOM @@ -1584,13 +1605,6 @@ mwin__draw_hline (MFrame *frame, MDrawWindow win, MGlyphString *gstring, : type == MFACE_HLINE_STRIKE_THROUGH ? y - ((gstring->ascent + gstring->descent) / 2) : y - gstring->text_ascent); - if (reverse) - gc = info->gc[MFACE_GC_INVERSE]; - else if (info->gc[MFACE_GC_HLINE]) - gc = info->gc[MFACE_GC_HLINE]; - else - gc = info->gc[MFACE_GC_NORMAL]; - if (region) gc = set_region (frame, gc, region); @@ -1617,14 +1631,13 @@ mwin__draw_box (MFrame *frame, MDrawWindow win, MGlyphString *gstring, y1 = y + (gstring->text_descent + rface->box->inner_vmargin + rface->box->width - 1); - gc_top = info->gc[MFACE_GC_BOX_TOP]; - if (! gc_top) - gc_top = info->gc[MFACE_GC_NORMAL]; + gc_top = info->gc[GC_BOX_TOP]; if (region) gc_top = set_region (frame, gc_top, region); - gc_btm = info->gc[MFACE_GC_BOX_BOTTOM]; - if (! gc_btm) + if (info->gc[GC_BOX_TOP] == info->gc[GC_BOX_BOTTOM]) gc_btm = gc_top; + else + gc_btm = info->gc[GC_BOX_BOTTOM]; if (g->type == GLYPH_BOX) { @@ -1640,7 +1653,7 @@ mwin__draw_box (MFrame *frame, MDrawWindow win, MGlyphString *gstring, XDrawLine (display, (Window) win, gc_top, x0, y0 + i, x1, y0 + i); /* Draw the bottom side. */ - if (region) + if (region && gc_btm != gc_top) gc_btm = set_region (frame, gc_btm, region); for (i = 0; i < box->width; i++) XDrawLine (display, (Window) win, gc_btm, x0, y1 - i, x1, y1 - i); @@ -1648,11 +1661,14 @@ mwin__draw_box (MFrame *frame, MDrawWindow win, MGlyphString *gstring, if (g->left_padding > 0) { /* Draw the left side. */ - gc_left = info->gc[MFACE_GC_BOX_LEFT]; - if (! gc_left) + if (info->gc[GC_BOX_LEFT] == info->gc[GC_BOX_TOP]) gc_left = gc_top; - else if (region) - gc_left = set_region (frame, gc_left, region); + else + { + gc_left = info->gc[GC_BOX_LEFT]; + if (region) + gc_left = set_region (frame, gc_left, region); + } for (i = 0; i < rface->box->width; i++) XDrawLine (display, (Window) win, gc_left, x0 + i, y0 + i, x0 + i, y1 - i); @@ -1660,11 +1676,14 @@ mwin__draw_box (MFrame *frame, MDrawWindow win, MGlyphString *gstring, else { /* Draw the right side. */ - gc_right = info->gc[MFACE_GC_BOX_RIGHT]; - if (! gc_right) + if (info->gc[GC_BOX_RIGHT] == info->gc[GC_BOX_TOP]) gc_right = gc_top; - else if (region) - gc_right = set_region (frame, gc_right, region); + else + { + gc_right = info->gc[GC_BOX_RIGHT]; + if (region) + gc_right = set_region (frame, gc_right, region); + } for (i = 0; i < rface->box->width; i++) XDrawLine (display, (Window) win, gc_right, x1 - i, y0 + i, x1 - i, y1 - i); @@ -1678,7 +1697,7 @@ mwin__draw_box (MFrame *frame, MDrawWindow win, MGlyphString *gstring, x, y0 + i, x + width - 1, y0 + i); /* Draw the bottom side. */ - if (region) + if (region && gc_btm != gc_top) gc_btm = set_region (frame, gc_btm, region); for (i = 0; i < box->width; i++) XDrawLine (display, (Window) win, gc_btm, @@ -1695,8 +1714,7 @@ mwin__draw_bitmap (MFrame *frame, MDrawWindow win, MRealizedFace *rface, { Display *display = FRAME_DISPLAY (frame); int i, j; - GC gc = ((GCInfo *) rface->info)->gc[reverse ? MFACE_GC_INVERSE - : MFACE_GC_NORMAL]; + GC gc = ((GCInfo *) rface->info)->gc[reverse ? GC_INVERSE : GC_NORMAL]; if (region) gc = set_region (frame, gc, region); @@ -1708,36 +1726,6 @@ mwin__draw_bitmap (MFrame *frame, MDrawWindow win, MRealizedFace *rface, } -static GC -get_gc_for_anti_alias (MWDevice *device, GCInfo *info, int intensity) -{ - int rgb_fore = info->rgb_fore, rgb_back = info->rgb_back; - XColor color; - - if (intensity == 0) - return info->gc[MFACE_GC_INVERSE]; - if (intensity == 7) - return info->gc[MFACE_GC_NORMAL]; - - color.red = ((((rgb_fore & 0xFF0000) >> 16) * intensity - + ((rgb_back & 0xFF0000) >> 16) * (7 - intensity)) / 7) << 8; - color.green = ((((rgb_fore & 0xFF00) >> 8) * intensity - + ((rgb_back & 0xFF00) >> 8) * (7 - intensity)) / 7) << 8; - color.blue = (((rgb_fore & 0xFF) * intensity - + (rgb_back & 0xFF) * (7 - intensity)) / 7) << 8; - if (XAllocColor (device->display_info->display, device->cmap, &color)) - { - unsigned long valuemask = GCForeground; - XGCValues values; - - values.foreground = color.pixel; - return XCreateGC (device->display_info->display, device->drawable, - valuemask, &values); - } - return get_gc_for_anti_alias (device, info, - (intensity < 4 ? --intensity : ++ intensity)); -} - void mwin__draw_pixmap (MFrame *frame, MDrawWindow win, MRealizedFace *rface, int reverse, int x, int y, @@ -1747,17 +1735,16 @@ mwin__draw_pixmap (MFrame *frame, MDrawWindow win, MRealizedFace *rface, Display *display = FRAME_DISPLAY (frame); GCInfo *info = rface->info; int i, j; - GC gc; for (i = 0; i < height; i++, pmp += row_bytes) for (j = 0; j < width; j++) if (pmp[j]) { int intensity = reverse ? (7 - (pmp[j] >> 5)) : (pmp[j] >> 5); - GC gc = info->gc[MFACE_GCS + intensity]; + GC gc = info->gc[intensity]; if (! gc) - gc = info->gc[MFACE_GCS + intensity] + gc = info->gc[intensity] = get_gc_for_anti_alias (frame->device, info, intensity); if (region) gc = set_region (frame, gc, region); @@ -1851,8 +1838,7 @@ mwin__dump_region (MDrawRegion region) void mwin__verify_region (MFrame *frame, MDrawRegion region) { - set_region (frame, ((GCInfo *) frame->rface->info)->gc[MFACE_GC_NORMAL], - region); + set_region (frame, ((GCInfo *) frame->rface->info)->gc[GC_NORMAL], region); } MDrawWindow @@ -2103,7 +2089,7 @@ mwin__dump_gc (MFrame *frame, MRealizedFace *rface) GCInfo *info = rface->info; int i; - for (i = 0; i <= MFACE_GC_INVERSE; i++) + for (i = 0; i <= GC_INVERSE; i++) { XGetGCValues (display, info->gc[i], valuemask, &values); fprintf (stderr, "GC%d: fore/#%lX back/#%lX", i,