Imlib2 - Improve on backgrounds.

SVN revision: 7923
This commit is contained in:
Kim Woelders 2003-11-22 00:15:41 +00:00
parent 08d131393b
commit b110adc6e6
8 changed files with 255 additions and 475 deletions

39
src/E.h
View File

@ -1146,33 +1146,26 @@ typedef struct _buttoncontainer
}
Container;
typedef struct
{
char *file;
char *real_file;
Imlib_Image *im;
char keep_aspect;
int xjust, yjust;
int xperc, yperc;
}
BgPart;
typedef struct _background
{
char *name;
Pixmap pmap;
time_t last_viewed;
struct _bg
{
XColor solid;
char *file;
char *real_file;
Imlib_Image *im;
char tile;
char keep_aspect;
int xjust, yjust;
int xperc, yperc;
}
bg;
struct _top
{
char *file;
char *real_file;
Imlib_Image *im;
char keep_aspect;
int xjust, yjust;
int xperc, yperc;
}
top;
XColor bg_solid;
char bg_tile;
BgPart bg;
BgPart top;
ColorModifierClass *cmclass;
char keepim;
unsigned int ref_count;
@ -1775,7 +1768,6 @@ Window ECreateFocusWindow(Window parent, int x, int y, int w,
int h);
void GrabX(void);
void UngrabX(void);
void SetBG(Window win, Pixmap pmap, int color);
void GetWinXY(Window win, int *x, int *y);
void GetWinWH(Window win, unsigned int *w, unsigned int *h);
int GetWinDepth(Window win);
@ -2270,6 +2262,7 @@ void HintsGetWindowHints(EWin * ewin);
void HintsDelWindowHints(EWin * ewin);
void HintsProcessPropertyChange(EWin * ewin, Atom atom_change);
void HintsProcessClientMessage(XClientMessageEvent * event);
void HintsSetRootInfo(Window win, Pixmap pmap, int color);
/* sound.c functions */
Sample *LoadWav(char *file);

View File

@ -995,11 +995,11 @@ HandleComms(XClientMessageEvent * ev)
Esnprintf(buf, sizeof(buf), "(null)");
if (bg)
{
EGetColor(&(bg->bg.solid), &r, &g, &b);
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, r, g, 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,
@ -1007,7 +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, r, g, 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,7 +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, r, g, 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,
@ -1023,7 +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, r, g, 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,
@ -1063,13 +1063,13 @@ HandleComms(XClientMessageEvent * ev)
if (strcmp("(null)", w))
topf = duplicate(w);
if (xclr.red != bg->bg.solid.red)
if (xclr.red != bg->bg_solid.red)
updated = 1;
if (xclr.green != bg->bg.solid.green)
if (xclr.green != bg->bg_solid.green)
updated = 1;
if (xclr.blue != bg->bg.solid.blue)
if (xclr.blue != bg->bg_solid.blue)
updated = 1;
bg->bg.solid = xclr;
bg->bg_solid = xclr;
if ((bg->bg.file) && (bgf))
{
if (strcmp(bg->bg.file, bgf))
@ -1080,7 +1080,7 @@ HandleComms(XClientMessageEvent * ev)
if (bg->bg.file)
Efree(bg->bg.file);
bg->bg.file = bgf;
if ((int)tile != bg->bg.tile)
if ((int)tile != bg->bg_tile)
updated = 1;
if ((int)keep_aspect != bg->bg.keep_aspect)
updated = 1;
@ -1092,7 +1092,7 @@ HandleComms(XClientMessageEvent * ev)
updated = 1;
if (yperc != bg->bg.yperc)
updated = 1;
bg->bg.tile = (char)tile;
bg->bg_tile = (char)tile;
bg->bg.keep_aspect = (char)keep_aspect;
bg->bg.xjust = xjust;
bg->bg.yjust = yjust;

View File

@ -1846,7 +1846,7 @@ Config_Desktop(FILE * ConfigFile)
sscanf(s, "%4000s %d %d %d", s1, &i1, &i2, &i3);
ESetColor(&xclr, i1, i2, i3);
if (ignore)
bg->bg.solid = xclr;
bg->bg_solid = xclr;
break;
case BG_BG1:
sscanf(s, "%4000s %4000s %d %d %d %d %d %d", s1, s2, &i1, &i2,
@ -1867,7 +1867,7 @@ Config_Desktop(FILE * ConfigFile)
bg->top.file = NULL;
}
bg->bg.file = duplicate(s2);
bg->bg.tile = i1;
bg->bg_tile = i1;
bg->bg.keep_aspect = i2;
bg->bg.xjust = i3;
bg->bg.yjust = i4;
@ -4150,7 +4150,7 @@ SaveUserControlConfig(FILE * autosavefile)
{
fprintf(autosavefile, "5 999\n");
fprintf(autosavefile, "100 %s\n", bglist[i]->name);
EGetColor(&(bglist[i]->bg.solid), &r, &g, &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);
@ -4159,7 +4159,7 @@ SaveUserControlConfig(FILE * autosavefile)
if ((bglist[i]->bg.file) && (bglist[i]->bg.real_file))
{
fprintf(autosavefile, "561 %s %d %d %d %d %d %d\n",
bglist[i]->bg.real_file, bglist[i]->bg.tile,
bglist[i]->bg.real_file, bglist[i]->bg_tile,
bglist[i]->bg.keep_aspect, bglist[i]->bg.xjust,
bglist[i]->bg.yjust, bglist[i]->bg.xperc,
bglist[i]->bg.yperc);
@ -4167,7 +4167,7 @@ SaveUserControlConfig(FILE * autosavefile)
else if (bglist[i]->bg.file)
{
fprintf(autosavefile, "561 %s %d %d %d %d %d %d\n",
bglist[i]->bg.file, bglist[i]->bg.tile,
bglist[i]->bg.file, bglist[i]->bg_tile,
bglist[i]->bg.keep_aspect, bglist[i]->bg.xjust,
bglist[i]->bg.yjust, bglist[i]->bg.xperc,
bglist[i]->bg.yperc);

View File

@ -39,8 +39,8 @@ GetUniqueBGString(Background * bg)
int r, g, b;
int n1, n2, n3, n4, n5, f1, f2, f3, f4, f5, f6;
EGetColor(&(bg->bg.solid), &r, &g, &b);
n1 = (r << 24) | (g << 16) | (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);
@ -296,7 +296,7 @@ SlideWindowTo(Window win, int fx, int fy, int tx, int ty, int speed)
}
static void
FreeBGimages(Background * bg)
FreeBGimages(Background * bg, int free_pmap)
{
if (bg->bg.im)
{
@ -310,9 +310,11 @@ FreeBGimages(Background * bg)
imlib_free_image();
bg->top.im = NULL;
}
if (bg->pmap)
imlib_free_pixmap_and_mask(bg->pmap);
bg->pmap = 0;
if (free_pmap && bg->pmap)
{
imlib_free_pixmap_and_mask(bg->pmap);
bg->pmap = 0;
}
}
void
@ -325,7 +327,7 @@ KeepBGimages(Background * bg, char onoff)
else
{
bg->keepim = 0;
FreeBGimages(bg);
FreeBGimages(bg, 0);
}
}
@ -340,7 +342,7 @@ RemoveImagesFromBG(Background * bg)
Efree(bg->bg.real_file);
bg->bg.real_file = NULL;
FreeBGimages(bg);
FreeBGimages(bg, 1);
bg->keepim = 0;
}
@ -392,15 +394,15 @@ CreateDesktopBG(char *name, XColor * solid, char *bg, char tile,
d->pmap = 0;
d->last_viewed = 0;
ESetColor(&(d->bg.solid), 160, 160, 160);
ESetColor(&(d->bg_solid), 160, 160, 160);
if (solid)
d->bg.solid = *solid;
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_tile = tile;
d->bg.keep_aspect = keep_aspect;
d->bg.xjust = xjust;
d->bg.yjust = yjust;
@ -452,17 +454,72 @@ RefreshDesktop(int num)
EDBUG_RETURN_;
}
static void
BgFindImageSize(BgPart * bgp, int rw, int rh, int *pw, int *ph, int setbg)
{
int w, h;
if (bgp->xperc > 0)
{
w = (rw * bgp->xperc) >> 10;
}
else
{
if (!setbg)
w = (imlib_image_get_width() * rw) / root.w;
else
w = imlib_image_get_width();
}
if (bgp->yperc > 0)
{
h = (rh * bgp->yperc) >> 10;
}
else
{
if (!setbg)
{
h = (imlib_image_get_height() * rh) / root.h;
}
else
{
h = imlib_image_get_height();
}
}
if (w <= 0)
w = 1;
if (h <= 0)
h = 1;
if (bgp->keep_aspect)
{
if (bgp->yperc <= 0)
{
if (((w << 10) / h) !=
((imlib_image_get_width() << 10) / imlib_image_get_height()))
h = ((w * imlib_image_get_height()) / imlib_image_get_width());
}
else
{
if (((h << 10) / w) !=
((imlib_image_get_height() << 10) / imlib_image_get_width()))
w = ((h * imlib_image_get_width()) / imlib_image_get_height());
}
}
*pw = w;
*ph = h;
}
void
SetBackgroundTo(Window win, Background * dsk, char setbg)
{
int w, h, x, y, ww, hh;
unsigned int rw, rh;
Pixmap pmap, mask, dpmap;
Pixmap dpmap;
GC gc;
XGCValues gcv;
char hasbg, hasfg;
int rt, depth;
ColorModifierClass *cm;
EDBUG(4, "SetBackgroundTo");
@ -473,14 +530,10 @@ SetBackgroundTo(Window win, Background * dsk, char setbg)
GetWinWH(win, &rw, &rh);
depth = GetWinDepth(win);
imlib_context_set_drawable(win);
EAllocColor(&dsk->bg.solid);
pmap = mask = 0;
EAllocColor(&dsk->bg_solid);
gc = 0;
w = 0;
h = 0;
hasbg = 0;
hasfg = 0;
rt = imlib_context_get_dither();
if (desks.hiqualitybg)
@ -490,41 +543,41 @@ SetBackgroundTo(Window win, Background * dsk, char setbg)
}
dpmap = dsk->pmap;
if (!setbg)
dpmap = 0;
if (!setbg && dpmap)
{
/* Always regenerate if setting non-desktop window (?) */
imlib_free_pixmap_and_mask(dpmap);
dpmap = 0;
}
if (!dpmap)
{
int w, h, x, y;
char hasbg, hasfg;
Pixmap pmap, mask;
ColorModifierClass *cm;
if (dsk->bg.file && !dsk->bg.im)
{
if (!dsk->bg.real_file)
dsk->bg.real_file = FindFile(dsk->bg.file);
dsk->bg.im = ELoadImage(dsk->bg.real_file);
}
if (dsk->top.file && !dsk->top.im)
{
if (!dsk->top.real_file)
dsk->top.real_file = FindFile(dsk->top.file);
dsk->top.im = ELoadImage(dsk->top.real_file);
}
cm = dsk->cmclass;
if (cm)
{
cm->ref_count--;
}
cm->ref_count--;
else
{
cm = (ColorModifierClass *) FindItem("BACKGROUND", 0,
LIST_FINDBY_NAME,
LIST_TYPE_COLORMODIFIER);
}
if (dsk->bg.file)
{
if (!dsk->bg.im)
{
if (!dsk->bg.real_file)
dsk->bg.real_file = FindFile(dsk->bg.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 = ELoadImage(dsk->top.real_file);
}
}
cm = (ColorModifierClass *) FindItem("BACKGROUND", 0,
LIST_FINDBY_NAME,
LIST_TYPE_COLORMODIFIER);
if (cm)
{
@ -550,373 +603,101 @@ SetBackgroundTo(Window win, Background * dsk, char setbg)
}
#endif
}
}
if (dsk->top.im)
hasfg = 1;
if (dsk->bg.im)
hasbg = 1;
hasbg = hasfg = 0;
if (dsk->top.im)
hasfg = 1;
if (dsk->bg.im)
hasbg = 1;
if ((hasfg) && (hasbg))
{
imlib_context_set_image(dsk->bg.im);
w = h = x = y = 0;
if (dsk->bg.xperc > 0)
if (hasbg)
{
w = (rw * dsk->bg.xperc) >> 10;
imlib_context_set_image(dsk->bg.im);
BgFindImageSize(&(dsk->bg), rw, rh, &w, &h, setbg);
x = ((rw - w) * dsk->bg.xjust) >> 10;
y = ((rh - h) * dsk->bg.yjust) >> 10;
imlib_render_pixmaps_for_whole_image_at_size(&pmap, &mask, w, h);
}
if (hasbg && !hasfg && setbg && x == 0 && y == 0 && w == rw && h == rh)
{
/* Put image 1:1 onto the current root window */
dpmap = pmap;
}
else if (hasbg && !hasfg && dsk->bg_tile)
{
/* BG only, tiled */
dpmap = ECreatePixmap(disp, win, w, h, depth);
gc = XCreateGC(disp, dpmap, 0, &gcv);
}
else
{
if (!setbg)
w = (imlib_image_get_width() * rw) / root.w;
else
w = imlib_image_get_width();
}
if (dsk->bg.yperc > 0)
{
h = (rh * dsk->bg.yperc) >> 10;
}
else
{
if (!setbg)
/* The rest that require some more work */
dpmap = ECreatePixmap(disp, win, rw, rh, depth);
gc = XCreateGC(disp, dpmap, 0, &gcv);
if (!dsk->bg_tile)
{
h = (imlib_image_get_height() * rh) / root.h;
}
else
{
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) !=
((imlib_image_get_width() << 10) /
imlib_image_get_height()))
h = ((w * imlib_image_get_height()) /
imlib_image_get_width());
}
else
{
if (((h << 10) / w) !=
((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, depth);
gc = XCreateGC(disp, dpmap, 0, &gcv);
if (!dsk->bg.tile)
{
XSetForeground(disp, gc, dsk->bg.solid.pixel);
XFillRectangle(disp, dpmap, gc, 0, 0, rw, rh);
}
x = ((rw - w) * dsk->bg.xjust) >> 10;
y = ((rh - h) * dsk->bg.yjust) >> 10;
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);
if (!dsk->bg.tile)
{
XFillRectangle(disp, dpmap, gc, x, y, w, h);
}
else
{
XFillRectangle(disp, dpmap, gc, 0, 0, rw, rh);
}
imlib_free_pixmap_and_mask(pmap);
imlib_context_set_image(dsk->top.im);
if (dsk->top.xperc > 0)
{
ww = (rw * dsk->top.xperc) >> 10;
}
else
{
if (!setbg)
{
ww = (imlib_image_get_width() * rw) / root.w;
}
else
{
ww = imlib_image_get_width();
}
}
if (dsk->top.yperc > 0)
{
hh = (rh * dsk->top.yperc) >> 10;
}
else
{
if (!setbg)
{
hh = (imlib_image_get_height() * rh) / root.h;
}
else
{
hh = imlib_image_get_height();
}
}
if (ww <= 0)
ww = 1;
if (hh <= 0)
hh = 1;
if (dsk->top.keep_aspect)
{
if (dsk->top.yperc <= 0)
{
if (((ww << 10) / hh) !=
((imlib_image_get_width() << 10) /
imlib_image_get_height()))
hh =
((ww * imlib_image_get_height()) /
imlib_image_get_width());
}
else
{
if (((hh << 10) / ww) !=
((imlib_image_get_height() << 10) /
imlib_image_get_width()))
ww =
((hh * imlib_image_get_width()) /
imlib_image_get_height());
}
}
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);
XSetTSOrigin(disp, gc, x, y);
XSetFillStyle(disp, gc, FillTiled);
if (mask)
{
XSetClipMask(disp, gc, mask);
XSetClipOrigin(disp, gc, x, y);
}
XFillRectangle(disp, dpmap, gc, x, y, ww, hh);
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 = (imlib_image_get_width() * rw) / root.w;
else
w = imlib_image_get_width();
}
if (dsk->bg.yperc > 0)
h = (rh * dsk->bg.yperc) >> 10;
else
{
if (!setbg)
h = (imlib_image_get_height() * rh) / root.h;
else
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) !=
((imlib_image_get_width() << 10) /
imlib_image_get_height()))
h = ((w * imlib_image_get_height()) /
imlib_image_get_width());
}
else
{
if (((h << 10) / w) !=
((imlib_image_get_height() << 10) /
imlib_image_get_width()))
w = ((h * imlib_image_get_width()) /
imlib_image_get_height());
}
}
dpmap = 0;
x = ((rw - w) * dsk->bg.xjust) >> 10;
y = ((rh - h) * dsk->bg.yjust) >> 10;
if (setbg)
{
if (dsk->bg.tile)
{
if ((x != 0) || (y != 0))
{
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, depth);
gc = XCreateGC(disp, dpmap, 0, &gcv);
XSetForeground(disp, gc, dsk->bg.solid.pixel);
XSetForeground(disp, gc, dsk->bg_solid.pixel);
XFillRectangle(disp, dpmap, gc, 0, 0, rw, rh);
}
}
else
{
if (dsk->bg.tile)
{
dpmap = ECreatePixmap(disp, win, w, h, depth);
gc = XCreateGC(disp, dpmap, 0, &gcv);
}
else
{
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_pixmaps_for_whole_image_at_size(&pmap, &mask, w, h);
if (dpmap)
if (hasbg && dpmap != pmap)
{
XSetTile(disp, gc, pmap);
XSetTSOrigin(disp, gc, x, y);
XSetFillStyle(disp, gc, FillTiled);
if (dsk->bg.tile)
{
XFillRectangle(disp, dpmap, gc, 0, 0, w, h);
}
if (dsk->bg_tile)
XFillRectangle(disp, dpmap, gc, 0, 0, rw, rh);
else
{
XFillRectangle(disp, dpmap, gc, x, y, w, h);
}
imlib_free_pixmap_and_mask(pmap);
}
else
dpmap = pmap;
}
else if (hasfg)
{
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;
}
else
{
if (!setbg)
{
ww = (imlib_image_get_width() * rw) / root.w;
}
else
{
ww = imlib_image_get_width();
}
XFillRectangle(disp, dpmap, gc, x, y, w, h);
IMLIB_FREE_PIXMAP_AND_MASK(pmap, mask);
}
if (dsk->top.yperc > 0)
{
hh = (rh * dsk->top.yperc) >> 10;
}
else
{
if (!setbg)
{
hh = (imlib_image_get_height() * rh) / root.h;
}
else
{
hh = imlib_image_get_height();
}
}
if (ww <= 0)
ww = 1;
if (hh <= 0)
hh = 1;
if (dsk->top.keep_aspect)
{
if (dsk->top.yperc <= 0)
{
if (((ww << 10) / hh) !=
((imlib_image_get_width() << 10) /
imlib_image_get_height()))
hh =
((ww * imlib_image_get_height()) /
imlib_image_get_width());
}
else
{
if (((hh << 10) / ww) !=
((imlib_image_get_height() << 10) /
imlib_image_get_width()))
ww =
((hh * imlib_image_get_width()) /
imlib_image_get_height());
}
}
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);
XSetTSOrigin(disp, gc, x, y);
XSetFillStyle(disp, gc, FillTiled);
if (mask)
{
XSetClipMask(disp, gc, mask);
XSetClipOrigin(disp, gc, x, y);
}
XFillRectangle(disp, dpmap, gc, x, y, ww, hh);
imlib_free_pixmap_and_mask(pmap);
}
if (!dsk->keepim)
{
if (dsk->top.im)
if (hasfg)
{
int ww, hh;
imlib_context_set_image(dsk->top.im);
imlib_free_image();
dsk->top.im = NULL;
}
if (dsk->bg.im)
{
imlib_context_set_image(dsk->bg.im);
imlib_free_image();
dsk->bg.im = NULL;
BgFindImageSize(&(dsk->top), rw, rh, &ww, &hh, setbg);
x = ((rw - ww) * dsk->top.xjust) >> 10;
y = ((rh - hh) * dsk->top.yjust) >> 10;
imlib_render_pixmaps_for_whole_image_at_size(&pmap, &mask, ww, hh);
XSetTile(disp, gc, pmap);
XSetTSOrigin(disp, gc, x, y);
XSetFillStyle(disp, gc, FillTiled);
if (mask)
{
XSetClipMask(disp, gc, mask);
XSetClipOrigin(disp, gc, x, y);
}
XFillRectangle(disp, dpmap, gc, x, y, ww, hh);
IMLIB_FREE_PIXMAP_AND_MASK(pmap, mask);
}
if (!dsk->keepim)
FreeBGimages(dsk, 0);
}
if (setbg)
{
if (dpmap)
{
SetBG(win, dpmap, 0);
HintsSetRootInfo(win, dpmap, 0);
XSetWindowBackgroundPixmap(disp, win, dpmap);
}
else
{
SetBG(win, 0, dsk->bg.solid.pixel);
HintsSetRootInfo(win, 0, dsk->bg_solid.pixel);
XSetWindowBackground(disp, win, dsk->bg_solid.pixel);
}
dsk->pmap = dpmap;
XClearWindow(disp, win);
}
else
{
@ -930,6 +711,7 @@ SetBackgroundTo(Window win, Background * dsk, char setbg)
XSetFillStyle(disp, gc, FillTiled);
XFillRectangle(disp, win, gc, 0, 0, rw, rh);
imlib_free_pixmap_and_mask(dpmap);
dpmap = 0;
}
else
{
@ -937,11 +719,12 @@ SetBackgroundTo(Window win, Background * dsk, char setbg)
gc = XCreateGC(disp, win, 0, &gcv);
XSetClipMask(disp, gc, 0);
XSetFillStyle(disp, gc, FillSolid);
XSetForeground(disp, gc, dsk->bg.solid.pixel);
XSetForeground(disp, gc, dsk->bg_solid.pixel);
XFillRectangle(disp, win, gc, 0, 0, rw, rh);
}
XSync(disp, False);
}
dsk->pmap = dpmap;
if (gc)
XFreeGC(disp, gc);
@ -2189,7 +1972,13 @@ DesktopAccounting()
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);
{
Window win = desks.desk[j].win;
HintsSetRootInfo(win, 0, 0);
XSetWindowBackground(disp, win, 0);
XClearWindow(disp, win);
}
}
}

View File

@ -253,3 +253,34 @@ HintsProcessClientMessage(XClientMessageEvent * event)
XFree(name);
EDBUG_RETURN_;
}
void
HintsSetRootInfo(Window win, Pixmap pmap, int color)
{
static Atom a = 0, aa = 0, aaa = 0;
static Window alive_win = 0;
EDBUG(6, "HintsSetRootInfo");
if (!a)
{
a = XInternAtom(disp, "_XROOTPMAP_ID", False);
aa = XInternAtom(disp, "_XROOTCOLOR_PIXEL", False);
aaa = XInternAtom(disp, "_XROOTWINDOW", False);
}
if (!alive_win)
{
alive_win = ECreateWindow(root.win, -100, -100, 1, 1, 0);
XChangeProperty(disp, alive_win, aaa, XA_WINDOW, 32, PropModeReplace,
(unsigned char *)&alive_win, 1);
XChangeProperty(disp, root.win, aaa, XA_WINDOW, 32, PropModeReplace,
(unsigned char *)&alive_win, 1);
}
XChangeProperty(disp, win, a, XA_PIXMAP, 32, PropModeReplace,
(unsigned char *)&pmap, 1);
XChangeProperty(disp, win, aa, XA_CARDINAL, 32, PropModeReplace,
(unsigned char *)&color, 1);
EDBUG_RETURN_;
}

View File

@ -1094,7 +1094,7 @@ IPC_Background(char *params, Client * c)
if (bg)
{
EGetColor(&(bg->bg.solid), &r, &g, &b);
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"
@ -1105,7 +1105,7 @@ IPC_Background(char *params, Client * c)
" bg.xperc\t %i \ttop.xperc\t %i \n"
" bg.yperc\t %i \ttop.yperc\t %i \n", bg->name,
bg->ref_count, r, g, b,
bg->bg.file, bg->top.file, bg->bg.tile,
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,
@ -1147,7 +1147,7 @@ IPC_Background(char *params, Client * c)
word(params, 4, G);
word(params, 5, B);
ESetColor(&(bg->bg.solid), atoi(R), atoi(G),
ESetColor(&(bg->bg_solid), atoi(R), atoi(G),
atoi(B));
}
else if (!strcmp(type, "bg.file"))
@ -1158,7 +1158,7 @@ IPC_Background(char *params, Client * c)
}
else if (!strcmp(type, "bg.tile"))
{
bg->bg.tile = atoi(valu);
bg->bg_tile = atoi(valu);
}
else if (!strcmp(type, "bg.keep_aspect"))
{

View File

@ -2460,8 +2460,8 @@ CB_ConfigureBG(int val, void *data)
mode.desktop_bg_timeout = tmp_bg_timeout;
desks.hiqualitybg = tmp_hiq;
mode.user_bg = tmp_userbg;
ESetColor(&(tmp_bg->bg.solid), tmp_bg_r, tmp_bg_g, tmp_bg_b);
tmp_bg->bg.tile = tmp_bg_tile;
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;
tmp_bg->bg.yjust = 1024 - tmp_bg_yjust;
@ -2565,7 +2565,7 @@ CB_DesktopMiniDisplayRedraw(int val, void *data)
{
if (tbg->pmap)
imlib_free_pixmap_and_mask(tbg->pmap);
ESetColor(&(tbg->bg.solid), tmp_bg_r, tmp_bg_g, tmp_bg_b);
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;
@ -2583,7 +2583,7 @@ CB_DesktopMiniDisplayRedraw(int val, void *data)
if (tbg->bg.real_file)
Efree(tbg->bg.real_file);
tbg->bg.real_file = NULL;
tbg->bg.tile = tmp_bg_tile;
tbg->bg_tile = tmp_bg_tile;
tbg->bg.keep_aspect = tmp_bg_keep_aspect;
tbg->bg.xjust = tmp_bg_xjust;
tbg->bg.yjust = 1024 - tmp_bg_yjust;
@ -2623,8 +2623,8 @@ BG_DoDialog(void)
DialogItemTextSetText(bg_filename, s);
DialogDrawItems(bg_sel_dialog, bg_filename, 0, 0, 99999, 99999);
EGetColor(&(tmp_bg->bg.solid), &tmp_bg_r, &tmp_bg_g, &tmp_bg_b);
tmp_bg_tile = tmp_bg->bg.tile;
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;
tmp_bg_yjust = 1024 - tmp_bg->bg.yjust;
@ -3199,7 +3199,7 @@ CB_BGSortAttrib(int val, void *data)
Background *bg;
bg = bglist[i];
if ((bg) && (bg->bg.tile) && (bg->bg.xperc == 0)
if ((bg) && (bg->bg_tile) && (bg->bg.xperc == 0)
&& (bg->bg.yperc == 0))
{
AddItem(bg, bg->name, 0, LIST_TYPE_BACKGROUND);
@ -3289,8 +3289,8 @@ SettingsBackground(Background * bg)
tmp_bg_image = 0;
tmp_bg->keepim = 1;
EGetColor(&(bg->bg.solid), &tmp_bg_r, &tmp_bg_g, &tmp_bg_b);
tmp_bg_tile = bg->bg.tile;
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;
tmp_bg_yjust = 1024 - bg->bg.yjust;

33
src/x.c
View File

@ -700,39 +700,6 @@ UngrabX()
EDBUG_RETURN_;
}
void
SetBG(Window win, Pixmap pmap, int color)
{
static Atom a = 0, aa = 0, aaa = 0;
static Window alive_win = 0;
EDBUG(6, "SetBG");
if (!a)
{
a = XInternAtom(disp, "_XROOTPMAP_ID", False);
aa = XInternAtom(disp, "_XROOTCOLOR_PIXEL", False);
aaa = XInternAtom(disp, "_XROOTWINDOW", False);
}
if (!alive_win)
{
alive_win = ECreateWindow(root.win, -100, -100, 1, 1, 0);
XChangeProperty(disp, alive_win, aaa, XA_WINDOW, 32, PropModeReplace,
(unsigned char *)&alive_win, 1);
XChangeProperty(disp, root.win, aaa, XA_WINDOW, 32, PropModeReplace,
(unsigned char *)&alive_win, 1);
}
XChangeProperty(disp, win, a, XA_PIXMAP, 32, PropModeReplace,
(unsigned char *)&pmap, 1);
XChangeProperty(disp, win, aa, XA_CARDINAL, 32, PropModeReplace,
(unsigned char *)&color, 1);
if (pmap)
XSetWindowBackgroundPixmap(disp, win, pmap);
else
XSetWindowBackground(disp, win, color);
XClearWindow(disp, win);
EDBUG_RETURN_;
}
void
GetWinXY(Window win, int *x, int *y)
{