EColor->COLOR32

SVN revision: 42460
This commit is contained in:
Kim Woelders 2009-09-13 13:45:34 +00:00
parent 56fb9970d4
commit bfefc200cd
14 changed files with 161 additions and 177 deletions

View File

@ -49,7 +49,7 @@ struct _background {
char *name;
Pixmap pmap;
time_t last_viewed;
EColor bg_solid;
unsigned int bg_solid;
char bg_tile;
BgPart bg;
BgPart top;
@ -76,7 +76,7 @@ BackgroundGetUniqueString(const Background * bg)
int r, g, b;
int n1, n2, n3, n4, n5, f1, f2, f3, f4, f5, f6;
GET_COLOR(&(bg->bg_solid), r, g, b);
COLOR32_TO_RGB(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);
@ -282,8 +282,8 @@ BackgroundDelete(Background * bg)
#endif /* ENABLE_DIALOGS */
static Background *
BackgroundCreate(const char *name, EColor * solid, const char *bgn, char tile,
char keep_aspect, int xjust, int yjust, int xperc,
BackgroundCreate(const char *name, unsigned int solid, const char *bgn,
char tile, char keep_aspect, int xjust, int yjust, int xperc,
int yperc, const char *top, char tkeep_aspect, int txjust,
int tyjust, int txperc, int typerc)
{
@ -293,13 +293,15 @@ BackgroundCreate(const char *name, EColor * solid, const char *bgn, char tile,
if (!bg)
return NULL;
if (!name)
{
name = "NONE";
bg->external = 1;
}
bg->name = Estrdup(name);
SET_COLOR(&(bg->bg_solid), 160, 160, 160);
if (solid)
bg->bg_solid = *solid;
else
bg->external = 1;
COLOR32_FROM_RGB(bg->bg_solid, 160, 160, 160);
bg->bg_solid = solid;
if (bgn)
bg->bg.file = Estrdup(bgn);
bg->bg_tile = tile;
@ -356,9 +358,7 @@ BackgroundCmp(Background * bg, Background * bgx)
else if (bg->top.file || bgx->top.file)
return 1;
if ((bg->bg_solid.red != bgx->bg_solid.red) ||
(bg->bg_solid.green != bgx->bg_solid.green) ||
(bg->bg_solid.blue != bgx->bg_solid.blue))
if (bg->bg_solid != bgx->bg_solid)
return 1;
if (bg->bg_tile != bgx->bg_tile)
return 1;
@ -400,20 +400,16 @@ BackgroundInvalidate(Background * bg, int refresh)
}
static int
BackgroundModify(Background * bg, EColor * solid, const char *bgn, char tile,
char keep_aspect, int xjust, int yjust, int xperc,
BackgroundModify(Background * bg, unsigned int solid, const char *bgn,
char tile, char keep_aspect, int xjust, int yjust, int xperc,
int yperc, const char *top, char tkeep_aspect, int txjust,
int tyjust, int txperc, int typerc)
{
int updated = 0;
if (solid->red != bg->bg_solid.red)
if (solid != bg->bg_solid)
updated = 1;
if (solid->green != bg->bg_solid.green)
updated = 1;
if (solid->blue != bg->bg_solid.blue)
updated = 1;
bg->bg_solid = *solid;
bg->bg_solid = solid;
if ((bg->bg.file) && (bgn))
{
@ -576,22 +572,24 @@ BackgroundRealize(Background * bg, Win win, Drawable draw, unsigned int rw,
if (!hasbg && !hasfg)
{
unsigned int pixel;
/* Solid color only */
EAllocColor(WinGetCmap(VROOT), &bg->bg_solid);
pixel = EAllocColor(WinGetCmap(VROOT), bg->bg_solid);
if (!is_win)
{
gc = EXCreateGC(draw, 0, NULL);
XSetClipMask(disp, gc, 0);
XSetFillStyle(disp, gc, FillSolid);
XSetForeground(disp, gc, bg->bg_solid.pixel);
XSetForeground(disp, gc, pixel);
XFillRectangle(disp, draw, gc, 0, 0, rw, rh);
EXFreeGC(gc);
}
if (ppmap)
*ppmap = None;
if (ppixel)
*ppixel = bg->bg_solid.pixel;
*ppixel = pixel;
return;
}
@ -650,8 +648,7 @@ BackgroundRealize(Background * bg, Win win, Drawable draw, unsigned int rw,
if (!hasbg || !bg->bg_tile)
{
/* Fill solid */
EImageFill(im, 0, 0, rw, rh, bg->bg_solid.red, bg->bg_solid.green,
bg->bg_solid.blue, 255);
EImageFill(im, 0, 0, rw, rh, bg->bg_solid);
}
if (hasbg)
{
@ -753,7 +750,7 @@ BrackgroundCreateFromImage(const char *bgid, const char *file,
{
Background *bg;
EImage *im, *im2;
EColor color;
unsigned int color;
char tile = 1, keep_asp = 0;
int width, height;
int scalex = 0, scaley = 0;
@ -852,9 +849,9 @@ BrackgroundCreateFromImage(const char *bgid, const char *file,
keep_asp = 1;
}
SET_COLOR(&color, 0, 0, 0);
COLOR32_FROM_RGB(color, 0, 0, 0);
bg = BackgroundCreate(bgid, &color, file, tile,
bg = BackgroundCreate(bgid, color, file, tile,
keep_asp, justx, justy,
scalex, scaley, NULL, 0, 0, 0, 0, 0);
@ -966,7 +963,7 @@ BackgroundGetInfoString1(const Background * bg, char *buf, int len)
{
int r, g, b;
GET_COLOR(&(bg->bg_solid), r, g, b);
COLOR32_TO_RGB(bg->bg_solid, r, g, b);
Esnprintf(buf, len,
"%s ref_count %u keepim %u\n"
" bg.solid\t %i %i %i \n"
@ -991,7 +988,7 @@ BackgroundGetInfoString2(const Background * bg, char *buf, int len)
{
int r, g, b;
GET_COLOR(&(bg->bg_solid), r, g, b);
COLOR32_TO_RGB(bg->bg_solid, r, g, b);
Esnprintf(buf, len,
"%s %i %i %i %s %i %i %i %i %i %i %s %i %i %i %i %i",
bg->name, r, g, b, S(bg->bg.file), bg->bg_tile,
@ -1064,7 +1061,7 @@ BackgroundsConfigLoad(FILE * fs)
{
int err = 0;
Background *bg = 0;
EColor color;
unsigned int color;
char s[FILEPATH_LEN_MAX];
char s2[FILEPATH_LEN_MAX];
int ii1;
@ -1077,7 +1074,7 @@ BackgroundsConfigLoad(FILE * fs)
char ignore = 0;
int desk;
SET_COLOR(&color, 0, 0, 0);
COLOR32_FROM_RGB(color, 0, 0, 0);
while (GetLine(s, sizeof(s), fs))
{
@ -1086,7 +1083,7 @@ BackgroundsConfigLoad(FILE * fs)
{
case CONFIG_CLOSE:
if (!ignore && !bg && name)
bg = BackgroundCreate(name, &color, bg1, i1, i2, i3, i4, i5,
bg = BackgroundCreate(name, color, bg1, i1, i2, i3, i4, i5,
i6, bg2, j1, j2, j3, j4, j5);
goto done;
@ -1110,7 +1107,7 @@ BackgroundsConfigLoad(FILE * fs)
case BG_DESKNUM:
if (!ignore && !bg && name)
bg = BackgroundCreate(name, &color, bg1, i1, i2, i3, i4, i5,
bg = BackgroundCreate(name, color, bg1, i1, i2, i3, i4, i5,
i6, bg2, j1, j2, j3, j4, j5);
if (!bg)
break;
@ -1139,7 +1136,7 @@ BackgroundsConfigLoad(FILE * fs)
case BG_RGB:
r = g = b = 0;
sscanf(s, "%*s %d %d %d", &r, &g, &b);
SET_COLOR(&color, r, g, b);
COLOR32_FROM_RGB(color, r, g, b);
if (ignore)
bg->bg_solid = color;
break;
@ -1238,7 +1235,7 @@ BackgroundsConfigSave(void)
fprintf(fs, "5 999\n");
fprintf(fs, "100 %s\n", bg->name);
GET_COLOR(&(bg->bg_solid), r, g, b);
COLOR32_TO_RGB(bg->bg_solid, r, g, b);
fprintf(fs, "560 %d %d %d\n", r, g, b);
if ((bg->bg.file) && (!bg->bg.real_file))
@ -1367,8 +1364,7 @@ BackgroundsSighan(int sig, void *prm __UNUSED__)
EDirMake(EDirUserCache(), "cached/bgsel");
EDirMake(EDirUserCache(), "cached/img");
/* create a fallback background in case no background is found */
BackgroundCreate("NONE", NULL, NULL, 0, 0, 0, 0, 0, 0, NULL, 0, 0, 0, 0,
0);
BackgroundCreate(NULL, 0, NULL, 0, 0, 0, 0, 0, 0, NULL, 0, 0, 0, 0, 0);
break;
case ESIGNAL_CONFIGURE:
@ -1439,7 +1435,7 @@ CB_ConfigureBG(Dialog * d __UNUSED__, int val, void *data __UNUSED__)
Conf.backgrounds.user = tmp_userbg;
Conf.hints.set_xroot_info_on_root_window = tmp_root_hint;
SET_COLOR(&(tmp_bg->bg_solid), tmp_bg_r, tmp_bg_g, tmp_bg_b);
COLOR32_FROM_RGB(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;
@ -1468,7 +1464,7 @@ CB_DesktopMiniDisplayRedraw(Dialog * d __UNUSED__, int val __UNUSED__,
int w, h;
DItem *di;
Win win;
EColor color;
unsigned int color;
const char *fbg, *ffg;
if (!tmp_bg)
@ -1481,8 +1477,8 @@ CB_DesktopMiniDisplayRedraw(Dialog * d __UNUSED__, int val __UNUSED__,
pmap = EGetWindowBackgroundPixmap(win);
fbg = (tmp_bg_image) ? BackgroundGetBgFile(tmp_bg) : NULL;
ffg = (tmp_bg_image) ? BackgroundGetFgFile(tmp_bg) : NULL;
SET_COLOR(&color, tmp_bg_r, tmp_bg_g, tmp_bg_b);
bg = BackgroundCreate("TEMP", &color,
COLOR32_FROM_RGB(color, tmp_bg_r, tmp_bg_g, tmp_bg_b);
bg = BackgroundCreate("TEMP", color,
fbg, tmp_bg_tile, tmp_bg_keep_aspect,
tmp_bg_xjust, tmp_bg_yjust,
tmp_bg_xperc, tmp_bg_yperc,
@ -1501,7 +1497,7 @@ BG_GetValues(void)
{
tmp_bg_image = (tmp_bg->bg.file) ? 1 : 0;
GET_COLOR(&(tmp_bg->bg_solid), tmp_bg_r, tmp_bg_g, tmp_bg_b);
COLOR32_TO_RGB(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;
@ -1567,14 +1563,14 @@ CB_ConfigureNewBG(Dialog * d __UNUSED__, int val __UNUSED__,
void *data __UNUSED__)
{
char s[1024];
EColor color;
unsigned int color;
int lower, upper;
Esnprintf(s, sizeof(s), "__NEWBG_%i", (unsigned)time(NULL));
SET_COLOR(&color, tmp_bg_r, tmp_bg_g, tmp_bg_b);
COLOR32_FROM_RGB(color, tmp_bg_r, tmp_bg_g, tmp_bg_b);
tmp_bg = BackgroundCreate(s, &color,
tmp_bg = BackgroundCreate(s, color,
tmp_bg->bg.file, tmp_bg_tile, tmp_bg_keep_aspect,
tmp_bg_xjust, tmp_bg_yjust,
tmp_bg_xperc, tmp_bg_yperc,
@ -2257,7 +2253,7 @@ BackgroundSet1(const char *name, const char *params)
char type[FILEPATH_LEN_MAX];
int len, value;
Background *bg;
EColor color;
unsigned int color;
if (!p || !p[0])
return;
@ -2265,8 +2261,8 @@ BackgroundSet1(const char *name, const char *params)
bg = BackgroundFind(name);
if (!bg)
{
SET_COLOR(&color, 0, 0, 0);
bg = BackgroundCreate(name, &color, NULL, 0, 0, 0,
COLOR32_FROM_RGB(color, 0, 0, 0);
bg = BackgroundCreate(name, color, NULL, 0, 0, 0,
0, 0, 0, NULL, 0, 0, 0, 0, 0);
if (!bg)
{
@ -2287,7 +2283,7 @@ BackgroundSet1(const char *name, const char *params)
r = g = b = 0;
sscanf(p, "%i %i %i", &r, &g, &b);
SET_COLOR(&(bg->bg_solid), r, g, b);
COLOR32_FROM_RGB(bg->bg_solid, r, g, b);
}
else if (!strcmp(type, "bg.file"))
{
@ -2354,7 +2350,7 @@ static void
BackgroundSet2(const char *name, const char *params)
{
Background *bg;
EColor color;
unsigned int color;
unsigned int i;
int r, g, b;
char bgf[FILEPATH_LEN_MAX], topf[FILEPATH_LEN_MAX];
@ -2372,18 +2368,18 @@ BackgroundSet2(const char *name, const char *params)
&r, &g, &b,
bgf, &tile, &keep_aspect, &xjust, &yjust, &xperc, &yperc,
topf, &tkeep_aspect, &txjust, &tyjust, &txperc, &typerc);
SET_COLOR(&color, r, g, b);
COLOR32_FROM_RGB(color, r, g, b);
bg = BackgroundFind(name);
if (bg)
{
BackgroundModify(bg, &color, bgf, tile, keep_aspect, xjust,
BackgroundModify(bg, color, bgf, tile, keep_aspect, xjust,
yjust, xperc, yperc, topf, tkeep_aspect,
txjust, tyjust, txperc, typerc);
}
else
{
bg = BackgroundCreate(name, &color, bgf, tile, keep_aspect, xjust,
bg = BackgroundCreate(name, color, bgf, tile, keep_aspect, xjust,
yjust, xperc, yperc, topf, tkeep_aspect,
txjust, tyjust, txperc, typerc);
}

View File

@ -1128,7 +1128,7 @@ ContainerDraw(Container * ct)
/* Start out with blank image */
im = EImageCreate(ib_w0, ib_h0);
EImageSetHasAlpha(im, 1);
EImageFill(im, 0, 0, ib_w0, ib_h0, 0, 0, 0, 0);
EImageFill(im, 0, 0, ib_w0, ib_h0, 0);
}
for (i = 0; i < ct->num_objs; i++)

View File

@ -40,11 +40,9 @@ struct _ecursor {
static Ecore_List *cursor_list = NULL;
#define ColorToPixel(ec) (0xff000000 + (ec->red << 16) + (ec->green <<8) + ec->blue)
static Cursor
ECreatePixmapCursor(Pixmap cpmap, Pixmap cmask, unsigned int w, unsigned int h,
int xh, int yh, EColor * fg, EColor * bg)
int xh, int yh, unsigned int fg, unsigned int bg)
{
Cursor curs;
@ -66,8 +64,8 @@ ECreatePixmapCursor(Pixmap cpmap, Pixmap cmask, unsigned int w, unsigned int h,
gcv.fill_style = FillOpaqueStippled;
gcv.stipple = cpmap;
gcv.clip_mask = cmask;
gcv.foreground = ColorToPixel(fg);
gcv.background = ColorToPixel(bg);
gcv.foreground = fg;
gcv.background = bg;
XChangeGC(disp, gc,
GCForeground | GCBackground | GCFillStyle | GCStipple | GCClipMask,
&gcv);
@ -82,8 +80,10 @@ ECreatePixmapCursor(Pixmap cpmap, Pixmap cmask, unsigned int w, unsigned int h,
#else
XColor fgxc, bgxc;
EAllocXColor(WinGetCmap(VROOT), &fgxc, fg);
EAllocXColor(WinGetCmap(VROOT), &bgxc, bg);
COLOR32_TO_RGB16(fg, fgxc.red, fgxc.green, fgxc.blue);
COLOR32_TO_RGB16(bg, bgxc.red, bgxc.green, bgxc.blue);
XAllocColor(disp, WinGetCmap(VROOT), &fgxc);
XAllocColor(disp, WinGetCmap(VROOT), &bgxc);
curs = XCreatePixmapCursor(disp, cpmap, cmask, &fgxc, &bgxc, xh, yh);
w = h = 0;
@ -93,7 +93,7 @@ ECreatePixmapCursor(Pixmap cpmap, Pixmap cmask, unsigned int w, unsigned int h,
static ECursor *
ECursorCreate(const char *name, const char *image, int native_id,
EColor * fg, EColor * bg)
unsigned int fg, unsigned int bg)
{
Cursor curs;
Pixmap pmap, mask;
@ -218,7 +218,7 @@ static int
ECursorConfigLoad(FILE * fs)
{
int err = 0;
EColor clr, clr2;
unsigned int clr, clr2;
char s[FILEPATH_LEN_MAX];
char s2[FILEPATH_LEN_MAX];
char *p2;
@ -227,8 +227,8 @@ ECursorConfigLoad(FILE * fs)
char file[FILEPATH_LEN_MAX], *pfile;
int native_id = -1;
SET_COLOR(&clr, 0, 0, 0);
SET_COLOR(&clr2, 255, 255, 255);
COLOR32_FROM_RGB(clr, 0, 0, 0);
COLOR32_FROM_RGB(clr2, 255, 255, 255);
pname = pfile = NULL;
@ -242,13 +242,13 @@ ECursorConfigLoad(FILE * fs)
i2 = atoi(s2);
if (i2 != CONFIG_OPEN)
goto done;
SET_COLOR(&clr, 0, 0, 0);
SET_COLOR(&clr2, 255, 255, 255);
COLOR32_FROM_RGB(clr, 0, 0, 0);
COLOR32_FROM_RGB(clr2, 255, 255, 255);
pname = pfile = NULL;
native_id = -1;
break;
case CONFIG_CLOSE:
ECursorCreate(pname, pfile, native_id, &clr, &clr2);
ECursorCreate(pname, pfile, native_id, clr, clr2);
err = 0;
break;
@ -264,12 +264,12 @@ ECursorConfigLoad(FILE * fs)
case CURS_BG_RGB:
r = g = b = 0;
sscanf(p2, "%d %d %d", &r, &g, &b);
SET_COLOR(&clr, r, g, b);
COLOR32_FROM_RGB(clr, r, g, b);
break;
case CURS_FG_RGB:
r = g = b = 255;
sscanf(p2, "%d %d %d", &r, &g, &b);
SET_COLOR(&clr2, r, g, b);
COLOR32_FROM_RGB(clr2, r, g, b);
break;
case XBM_FILE:
strcpy(file, s2);

View File

@ -141,25 +141,18 @@ static Font font = None; /* Used in mode 1 (technical) */
rl[3].x = (_x)+(_w)-1; rl[3].y = (_y)+1; rl[3].width = 1; rl[3].height = (_h)-2; \
} while(0)
#define _R(x) (((x) >> 16) & 0xff)
#define _G(x) (((x) >> 8) & 0xff)
#define _B(x) (((x) ) & 0xff)
static unsigned int
_ShapeGetColor(void)
{
static char color_valid = 0;
static unsigned int color_value = 0;
static unsigned int color_pixel;
EColor color;
if (color_valid && color_value == Conf.movres.color)
goto done;
color_value = Conf.movres.color;
SET_COLOR(&color, _R(color_value), _G(color_value), _B(color_value));
EAllocColor(WinGetCmap(VROOT), &color);
color_pixel = color.pixel;
color_pixel = EAllocColor(WinGetCmap(VROOT), color_value);
color_valid = 1;
done:

View File

@ -232,9 +232,12 @@ EImageGetData(EImage * im)
}
void
EImageFill(EImage * im, int x, int y, int w, int h, int r, int g, int b, int a)
EImageFill(EImage * im, int x, int y, int w, int h, unsigned int color)
{
int a, r, g, b;
imlib_context_set_image(im);
COLOR32_TO_ARGB(color, a, r, g, b);
imlib_context_set_color(r, g, b, a);
imlib_context_set_blend(0);
imlib_image_fill_rectangle(x, y, w, h);

View File

@ -62,8 +62,8 @@ int EImageHasAlpha(EImage * im);
void EImageGetSize(EImage * im, int *pw, int *ph);
void *EImageGetData(EImage * im);
void EImageFill(EImage * im, int x, int y, int w, int h, int r,
int g, int b, int a);
void EImageFill(EImage * im, int x, int y, int w, int h,
unsigned int color);
void EImageOrientate(EImage * im, int orientation);
void EImageBlend(EImage * im, EImage * src, int flags,

View File

@ -45,7 +45,8 @@ struct _imagestate {
char rotate;
EImage *im;
EImageBorder *border;
EColor bg, hi, lo, hihi, lolo;
unsigned int bg, hi, lo, hihi, lolo;
unsigned int bg_pixel, hi_pixel, lo_pixel, hihi_pixel, lolo_pixel;
};
typedef struct {
@ -175,11 +176,11 @@ ImagestateColorsSetGray(ImageState * is,
unsigned int hihi, unsigned int hi,
unsigned int bg, unsigned int lo, unsigned int lolo)
{
SET_COLOR(&(is->hihi), hihi, hihi, hihi);
SET_COLOR(&(is->hi), hi, hi, hi);
SET_COLOR(&(is->bg), bg, bg, bg);
SET_COLOR(&(is->lo), lo, lo, lo);
SET_COLOR(&(is->lolo), lolo, lolo, lolo);
COLOR32_FROM_RGB(is->hihi, hihi, hihi, hihi);
COLOR32_FROM_RGB(is->hi, hi, hi, hi);
COLOR32_FROM_RGB(is->bg, bg, bg, bg);
COLOR32_FROM_RGB(is->lo, lo, lo, lo);
COLOR32_FROM_RGB(is->lolo, lolo, lolo, lolo);
}
static ImageState *
@ -233,11 +234,11 @@ ImagestateColorsAlloc(ImageState * is)
if (!is || is->got_colors)
return;
EAllocColor(WinGetCmap(VROOT), &is->bg);
EAllocColor(WinGetCmap(VROOT), &is->hi);
EAllocColor(WinGetCmap(VROOT), &is->lo);
EAllocColor(WinGetCmap(VROOT), &is->hihi);
EAllocColor(WinGetCmap(VROOT), &is->lolo);
is->bg_pixel = EAllocColor(WinGetCmap(VROOT), is->bg);
is->hi_pixel = EAllocColor(WinGetCmap(VROOT), is->hi);
is->lo_pixel = EAllocColor(WinGetCmap(VROOT), is->lo);
is->hihi_pixel = EAllocColor(WinGetCmap(VROOT), is->hihi);
is->lolo_pixel = EAllocColor(WinGetCmap(VROOT), is->lolo);
is->got_colors = 1;
}
@ -582,24 +583,15 @@ ImageclassConfigLoad(FILE * fs)
is->rotate = strtoul(s2, NULL, 0);
continue;
case ICLASS_BEVEL:
#define _R(x) (((x) >> 16) & 0xff)
#define _G(x) (((x) >> 8) & 0xff)
#define _B(x) (((x) ) & 0xff)
#define INT_TO_COLOR(xc, rgb) \
do { (&(xc))->red = _R(rgb); (&(xc))->green = _G(rgb); (&(xc))->blue = _B(rgb); } while(0)
{
int n, bevel, hihi, hi, bg, lo, lolo;
int n, bevel;
n = sscanf(p2, "%i %i %i %i %i %i",
&bevel, &hihi, &hi, &bg, &lo, &lolo);
&bevel, &is->hihi, &is->hi, &is->bg, &is->lo,
&is->lolo);
if (n < 6)
goto not_ok;
is->bevelstyle = bevel;
INT_TO_COLOR(is->hihi, hihi);
INT_TO_COLOR(is->hi, hi);
INT_TO_COLOR(is->bg, bg);
INT_TO_COLOR(is->lo, lo);
INT_TO_COLOR(is->lolo, lolo);
}
continue;
default:
@ -995,87 +987,87 @@ ImagestateDrawBevel(ImageState * is, Drawable win, GC gc,
switch (is->bevelstyle)
{
case BEVEL_AMIGA:
XSetForeground(disp, gc, is->hihi.pixel);
XSetForeground(disp, gc, is->hihi_pixel);
LINE(0, 0, w - 2, 0);
LINE(0, 0, 0, h - 2);
XSetForeground(disp, gc, is->lolo.pixel);
XSetForeground(disp, gc, is->lolo_pixel);
LINE(1, h - 1, w - 1, h - 1);
LINE(w - 1, 1, w - 1, h - 1);
break;
case BEVEL_MOTIF:
XSetForeground(disp, gc, is->hi.pixel);
XSetForeground(disp, gc, is->hi_pixel);
LINE(0, 0, w - 1, 0);
LINE(0, 0, 0, h - 1);
LINE(1, 1, w - 2, 1);
LINE(1, 1, 1, h - 2);
XSetForeground(disp, gc, is->lo.pixel);
XSetForeground(disp, gc, is->lo_pixel);
LINE(0, h - 1, w - 1, h - 1);
LINE(w - 1, 1, w - 1, h - 1);
LINE(1, h - 2, w - 2, h - 2);
LINE(w - 2, 2, w - 2, h - 2);
break;
case BEVEL_NEXT:
XSetForeground(disp, gc, is->hihi.pixel);
XSetForeground(disp, gc, is->hihi_pixel);
LINE(0, 0, w - 1, 0);
LINE(0, 0, 0, h - 1);
XSetForeground(disp, gc, is->hi.pixel);
XSetForeground(disp, gc, is->hi_pixel);
LINE(1, 1, w - 2, 1);
LINE(1, 1, 1, h - 2);
XSetForeground(disp, gc, is->lolo.pixel);
XSetForeground(disp, gc, is->lolo_pixel);
LINE(1, h - 1, w - 1, h - 1);
LINE(w - 1, 1, w - 1, h - 1);
XSetForeground(disp, gc, is->lo.pixel);
XSetForeground(disp, gc, is->lo_pixel);
LINE(2, h - 2, w - 2, h - 2);
LINE(w - 2, 2, w - 2, h - 2);
break;
case BEVEL_DOUBLE:
XSetForeground(disp, gc, is->hi.pixel);
XSetForeground(disp, gc, is->hi_pixel);
LINE(0, 0, w - 2, 0);
LINE(0, 0, 0, h - 2);
XSetForeground(disp, gc, is->lo.pixel);
XSetForeground(disp, gc, is->lo_pixel);
LINE(1, 1, w - 3, 1);
LINE(1, 1, 1, h - 3);
XSetForeground(disp, gc, is->lo.pixel);
XSetForeground(disp, gc, is->lo_pixel);
LINE(1, h - 1, w - 1, h - 1);
LINE(w - 1, 1, w - 1, h - 1);
XSetForeground(disp, gc, is->hi.pixel);
XSetForeground(disp, gc, is->hi_pixel);
LINE(2, h - 2, w - 2, h - 2);
LINE(w - 2, 2, w - 2, h - 2);
break;
case BEVEL_WIDEDOUBLE:
XSetForeground(disp, gc, is->hihi.pixel);
XSetForeground(disp, gc, is->hihi_pixel);
LINE(0, 0, w - 1, 0);
LINE(0, 0, 0, h - 1);
XSetForeground(disp, gc, is->hi.pixel);
XSetForeground(disp, gc, is->hi_pixel);
LINE(1, 1, w - 2, 1);
LINE(1, 1, 1, h - 2);
LINE(3, h - 4, w - 4, h - 4);
LINE(w - 4, 3, w - 4, h - 4);
XSetForeground(disp, gc, is->lolo.pixel);
XSetForeground(disp, gc, is->lolo_pixel);
LINE(1, h - 1, w - 1, h - 1);
LINE(w - 1, 1, w - 1, h - 1);
XSetForeground(disp, gc, is->lo.pixel);
XSetForeground(disp, gc, is->lo_pixel);
LINE(2, h - 2, w - 2, h - 2);
LINE(w - 2, 2, w - 2, h - 2);
LINE(3, 3, w - 4, 3);
LINE(3, 3, 3, h - 4);
break;
case BEVEL_THINPOINT:
XSetForeground(disp, gc, is->hi.pixel);
XSetForeground(disp, gc, is->hi_pixel);
LINE(0, 0, w - 2, 0);
LINE(0, 0, 0, h - 2);
XSetForeground(disp, gc, is->lo.pixel);
XSetForeground(disp, gc, is->lo_pixel);
LINE(1, h - 1, w - 1, h - 1);
LINE(w - 1, 1, w - 1, h - 1);
XSetForeground(disp, gc, is->hihi.pixel);
XSetForeground(disp, gc, is->hihi_pixel);
LINE(0, 0, 1, 0);
LINE(0, 0, 0, 1);
XSetForeground(disp, gc, is->lolo.pixel);
XSetForeground(disp, gc, is->lolo_pixel);
LINE(w - 2, h - 1, w - 1, h - 1);
LINE(w - 1, h - 2, w - 1, h - 1);
break;
case BEVEL_THICKPOINT:
XSetForeground(disp, gc, is->hi.pixel);
XSetForeground(disp, gc, is->hi_pixel);
RECT(x, y, w - 1, h - 1);
break;
default:
@ -1092,7 +1084,7 @@ ImagestateDrawNoImg(ImageState * is, Drawable draw, int x, int y, int w, int h)
gc = EXCreateGC(draw, 0, NULL);
XSetFillStyle(disp, gc, FillSolid);
XSetForeground(disp, gc, is->bg.pixel);
XSetForeground(disp, gc, is->bg_pixel);
XFillRectangle(disp, draw, gc, x, y, w, h);
if (is->bevelstyle != BEVEL_NONE)
ImagestateDrawBevel(is, draw, gc, x, y, w, h);
@ -1191,7 +1183,7 @@ ITApply(Win win, ImageClass * ic, ImageState * is,
if (is->bevelstyle == BEVEL_NONE && !text)
{
ESetWindowBackground(win, is->bg.pixel);
ESetWindowBackground(win, is->bg_pixel);
}
else
{
@ -1351,17 +1343,17 @@ ImageclassGetFallback(void)
ic->active.normal = ImagestateCreate(NULL);
ImagestateColorsSetGray(ic->active.normal, 255, 255, 0, 0, 0);
SET_COLOR(&(ic->active.normal->bg), 180, 140, 160);
COLOR32_FROM_RGB(ic->active.normal->bg, 180, 140, 160);
ic->active.normal->bevelstyle = BEVEL_AMIGA;
ic->active.hilited = ImagestateCreate(NULL);
ImagestateColorsSetGray(ic->active.hilited, 255, 255, 0, 0, 0);
SET_COLOR(&(ic->active.hilited->bg), 230, 190, 210);
COLOR32_FROM_RGB(ic->active.hilited->bg, 230, 190, 210);
ic->active.hilited->bevelstyle = BEVEL_AMIGA;
ic->active.clicked = ImagestateCreate(NULL);
ImagestateColorsSetGray(ic->active.clicked, 0, 0, 0, 255, 255);
SET_COLOR(&(ic->active.clicked->bg), 230, 190, 210);
COLOR32_FROM_RGB(ic->active.clicked->bg, 230, 190, 210);
ic->active.clicked->bevelstyle = BEVEL_AMIGA;
ic->padding.left = 4;

View File

@ -330,12 +330,12 @@ TextclassConfigLoad(FILE * fs)
case TEXT_FG_COL:
r = g = b = 0;
sscanf(s, "%*s %i %i %i", &r, &g, &b);
SET_COLOR(&ts->fg_col, r, g, b);
COLOR32_FROM_RGB(ts->fg_col, r, g, b);
continue;
case TEXT_BG_COL:
r = g = b = 0;
sscanf(s, "%*s %i %i %i", &r, &g, &b);
SET_COLOR(&ts->bg_col, r, g, b);
COLOR32_FROM_RGB(ts->bg_col, r, g, b);
continue;
default:
ConfigParseError("TextClass", s);
@ -364,7 +364,7 @@ TextclassGetFallback(void)
tc->norm.normal =
TextstateCreate("-*-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*");
SET_COLOR(&(tc->norm.normal->fg_col), 0, 0, 0);
COLOR32_FROM_RGB(tc->norm.normal->fg_col, 0, 0, 0);
TextclassPopulate(tc);
return tc;

View File

@ -60,7 +60,7 @@ typedef struct {
int (*FdcInit) (TextState * ts, Win win, Drawable draw);
void (*FdcFini) (TextState * ts);
void (*FdcSetDrawable) (TextState * ts, unsigned long draw);
void (*FdcSetColor) (TextState * ts, EColor * xc);
void (*FdcSetColor) (TextState * ts, unsigned int color);
} FontOps;
struct _textstate {
@ -72,8 +72,8 @@ struct _textstate {
char orientation;
char effect;
} style;
EColor fg_col;
EColor bg_col;
unsigned int fg_col;
unsigned int bg_col;
void *fdc;
const FontOps *ops;
};
@ -118,6 +118,6 @@ void TextDraw(TextClass * tclass, Win win, Drawable draw,
__EXPORT__ int _xft_FdcInit(TextState * ts, Win win, Drawable draw);
__EXPORT__ void _xft_FdcFini(TextState * ts);
__EXPORT__ void _xft_FdcSetDrawable(TextState * ts, unsigned long draw);
__EXPORT__ void _xft_FdcSetColor(TextState * ts, EColor * xc);
__EXPORT__ void _xft_FdcSetColor(TextState * ts, unsigned int color);
#endif /* _TCLASS_H */

View File

@ -501,12 +501,13 @@ _xfs_FdcSetDrawable(TextState * ts, unsigned long draw)
}
static void
_xfs_FdcSetColor(TextState * ts, EColor * xc)
_xfs_FdcSetColor(TextState * ts, unsigned int color)
{
FontCtxXfs *fdc = (FontCtxXfs *) ts->fdc;
unsigned int pixel;
EAllocColor(WinGetCmap(fdc->win), xc);
XSetForeground(disp, fdc->gc, xc->pixel);
pixel = EAllocColor(WinGetCmap(fdc->win), color);
XSetForeground(disp, fdc->gc, pixel);
}
const FontOps FontOpsXfs = {
@ -605,12 +606,13 @@ _xfont_FdcSetDrawable(TextState * ts, unsigned long draw)
}
static void
_xfont_FdcSetColor(TextState * ts, EColor * xc)
_xfont_FdcSetColor(TextState * ts, unsigned int color)
{
FontCtxXfont *fdc = (FontCtxXfont *) ts->fdc;
unsigned int pixel;
EAllocColor(WinGetCmap(fdc->win), xc);
XSetForeground(disp, fdc->gc, xc->pixel);
pixel = EAllocColor(WinGetCmap(fdc->win), color);
XSetForeground(disp, fdc->gc, pixel);
}
static void
@ -635,18 +637,18 @@ TsTextDraw(TextState * ts, int x, int y, const char *text, int len)
{
if (ts->style.effect == 1)
{
ts->ops->FdcSetColor(ts, &(ts->bg_col));
ts->ops->FdcSetColor(ts, ts->bg_col);
ts->ops->TextDraw(ts, x + 1, y + 1, text, len);
}
else if (ts->style.effect == 2)
{
ts->ops->FdcSetColor(ts, &(ts->bg_col));
ts->ops->FdcSetColor(ts, ts->bg_col);
ts->ops->TextDraw(ts, x - 1, y, text, len);
ts->ops->TextDraw(ts, x + 1, y, text, len);
ts->ops->TextDraw(ts, x, y - 1, text, len);
ts->ops->TextDraw(ts, x, y + 1, text, len);
}
ts->ops->FdcSetColor(ts, &(ts->fg_col));
ts->ops->FdcSetColor(ts, ts->fg_col);
ts->ops->TextDraw(ts, x, y, text, len);
}

View File

@ -151,15 +151,12 @@ _xft_FdcSetDrawable(TextState * ts, unsigned long draw)
}
void
_xft_FdcSetColor(TextState * ts, EColor * ec)
_xft_FdcSetColor(TextState * ts, unsigned int color)
{
FontCtxXft *fdc = (FontCtxXft *) ts->fdc;
XRenderColor xrc;
xrc.red = ec->red << 8;
xrc.green = ec->green << 8;
xrc.blue = ec->blue << 8;
xrc.alpha = 65535;
COLOR32_TO_ARGB16(color, xrc.alpha, xrc.red, xrc.green, xrc.blue);
XftColorAllocValue(disp, WinGetVisual(fdc->win), WinGetCmap(fdc->win),
&xrc, &(fdc->xftc));

View File

@ -178,11 +178,11 @@ _ift_FdcSetDrawable(TextState * ts, unsigned long draw)
}
static void
_ift_FdcSetColor(TextState * ts __UNUSED__, EColor * ec)
_ift_FdcSetColor(TextState * ts, unsigned int color)
{
FontCtxIft *fdc = (FontCtxIft *) ts->fdc;
GET_COLOR(ec, fdc->r, fdc->g, fdc->b);
COLOR32_TO_RGB(color, fdc->r, fdc->g, fdc->b);
}
const FontOps FontOps_ift = {

17
src/x.c
View File

@ -1623,22 +1623,15 @@ EXSendEvent(Window xwin, long event_mask, XEvent * ev)
XSendEvent(disp, xwin, False, event_mask, ev);
}
void
EAllocColor(Colormap cmap, EColor * pec)
unsigned int
EAllocColor(Colormap cmap, unsigned int argb)
{
XColor xc;
EAllocXColor(cmap, &xc, pec);
pec->pixel = xc.pixel;
}
COLOR32_TO_RGB16(argb, xc.red, xc.green, xc.blue);
XAllocColor(disp, cmap, &xc);
void
EAllocXColor(Colormap cmap, XColor * pxc, EColor * pec)
{
pxc->red = pec->red << 8;
pxc->green = pec->green << 8;
pxc->blue = pec->blue << 8;
XAllocColor(disp, cmap, pxc);
return xc.pixel;
}
/*

View File

@ -218,19 +218,27 @@ Pixmap EWindowGetShapePixmap(Win win);
Bool EQueryPointer(Win win, int *px, int *py,
Window * pchild, unsigned int *pmask);
typedef struct {
unsigned long pixel;
unsigned char alpha, red, green, blue;
} EColor;
unsigned int EAllocColor(Colormap cmap, unsigned int argb);
void EAllocColor(Colormap cmap, EColor * pec);
void EAllocXColor(Colormap cmap, XColor * pxc, EColor * pec);
#define _A(x) (((x) >> 24) & 0xff)
#define _R(x) (((x) >> 16) & 0xff)
#define _G(x) (((x) >> 8) & 0xff)
#define _B(x) (((x) ) & 0xff)
#define _A16(x) (((x) >> 16) & 0xff00)
#define _R16(x) (((x) >> 8) & 0xff00)
#define _G16(x) (((x) ) & 0xff00)
#define _B16(x) (((x) << 8) & 0xff00)
#define SET_COLOR(xc, _r, _g, _b) \
do { (xc)->red = _r; (xc)->green = _g; (xc)->blue = _b; } while(0)
#define GET_COLOR(xc, _r, _g, _b) \
do { _r = (xc)->red; _g = (xc)->green; _b = (xc)->blue; } while(0)
#define COLOR32_FROM_RGB(c, r, g, b) \
c = (0xff000000 | (((r) & 0xff) << 16) | (((g) & 0xff) << 8) | ((b) & 0xff))
#define COLOR32_TO_RGB(c, r, g, b) \
do { r = _R(c); g = _G(c); b = _B(c); } while (0)
#define COLOR32_TO_ARGB(c, a, r, g, b) \
do { a = _A(c); r = _R(c); g = _G(c); b = _B(c); } while (0)
#define COLOR32_TO_RGB16(c, r, g, b) \
do { r = _R16(c); g = _G16(c); b = _B16(c); } while (0)
#define COLOR32_TO_ARGB16(c, a, r, g, b) \
do { a = _A16(c); r = _R16(c); g = _G16(c); b = _B16(c); } while (0)
Window EXWindowGetParent(Window xwin);
int EXGetGeometry(Window xwin, Window * root_return,