Simplify background code, re-generate backgrounds when enabling transparency.

SVN revision: 9706
This commit is contained in:
Kim Woelders 2004-04-12 08:28:34 +00:00
parent 930c511313
commit 680ccb19ad
14 changed files with 341 additions and 450 deletions

18
src/E.h
View File

@ -1038,6 +1038,7 @@ struct _button
};
#endif /* DECLARE_STRUCT_BUTTON */
#ifdef DECLARE_STRUCT_BACKGROUND
typedef struct
{
char *file;
@ -1062,6 +1063,7 @@ struct _background
char keepim;
unsigned int ref_count;
};
#endif /* DECLARE_STRUCT_BACKGROUND */
typedef struct _desk
{
@ -1648,16 +1650,25 @@ void deleteHint(Window win, Atom atom);
/* backgrounds.c */
char *BackgroundGetUniqueString(Background * bg);
void BackgroundImagesKeep(Background * bg, char onoff);
void BackgroundPixmapFree(Background * bg);
void BackgroundImagesFree(Background * bg, int free_pmap);
void BackgroundImagesKeep(Background * bg, int onoff);
void BackgroundImagesRemove(Background * bg);
void BackgroundDestroy(Background * bg);
int BackgroundDestroy(Background * bg);
void BackgroundDelete(Background * bg);
Background *BackgroundCreate(const char *name, XColor * solid,
const char *bg, 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);
void BackgroundDestroyByName(const char *name);
void BackgroundApply(Background * bg, Window win, int setbg);
void BackgroundIncRefcount(Background * bg);
void BackgroundDecRefcount(Background * bg);
void BackgroundTouch(Background * bg);
const char *BackgroundGetName(const Background * bg);
Pixmap BackgroundGetPixmap(const Background * bg);
void BackgroundsAccounting(void);
void BackgroundsInit(void);
@ -1839,9 +1850,10 @@ void SlideWindowTo(Window win, int fx, int fy, int tx, int ty,
int speed);
void RefreshCurrentDesktop(void);
void RefreshDesktop(int num);
void DesktopsRefresh(void);
void InitDesktopBgs(void);
void InitDesktopControls(void);
void SetDesktopBg(int desk, Background * bg);
void DesktopSetBg(int desk, Background * bg, int refresh);
void ConformEwinToDesktop(EWin * ewin);
int DesktopAt(int x, int y);
void GotoDesktop(int num);

View File

@ -2616,7 +2616,7 @@ doBackgroundSet(EWin * edummy, const void *params)
{
int desk;
Background *bg;
char view, s[1024];
char s[1024];
EDBUG(6, "doBackgroundSet");
@ -2626,29 +2626,13 @@ doBackgroundSet(EWin * edummy, const void *params)
desk = desks.current;
if (sscanf((char *)params, "%1000s %i", s, &desk) < 2)
desk = desks.current;
bg = (Background *) FindItem(s, 0, LIST_FINDBY_NAME, LIST_TYPE_BACKGROUND);
if (!bg)
EDBUG_RETURN(0);
if (desks.desk[desk].bg != bg)
{
char pq;
if (desks.desk[desk].bg)
desks.desk[desk].bg->last_viewed = 0;
view = desks.desk[desk].viewable;
desks.desk[desk].viewable = 0;
BackgroundsAccounting();
desks.desk[desk].viewable = view;
BGSettingsGoTo(bg);
pq = Mode.queue_up;
Mode.queue_up = 0;
SetDesktopBg(desk, bg);
RefreshDesktop(desk);
RedrawPagersForDesktop(desk, 2);
ForceUpdatePagersForDesktop(desk);
Mode.queue_up = pq;
}
DesktopSetBg(desk, bg, 0);
autosave();
EDBUG_RETURN(0);

View File

@ -20,6 +20,7 @@
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#define DECLARE_STRUCT_BACKGROUND
#include "E.h"
#include <time.h>
@ -111,7 +112,17 @@ BackgroundGetUniqueString(Background * bg)
return Estrdup(s);
}
static void
void
BackgroundPixmapFree(Background * bg)
{
if (bg && bg->pmap)
{
imlib_free_pixmap_and_mask(bg->pmap);
bg->pmap = 0;
}
}
void
BackgroundImagesFree(Background * bg, int free_pmap)
{
if (bg->bg.im)
@ -127,14 +138,11 @@ BackgroundImagesFree(Background * bg, int free_pmap)
bg->top.im = NULL;
}
if (free_pmap && bg->pmap)
{
imlib_free_pixmap_and_mask(bg->pmap);
bg->pmap = 0;
}
BackgroundPixmapFree(bg);
}
void
BackgroundImagesKeep(Background * bg, char onoff)
BackgroundImagesKeep(Background * bg, int onoff)
{
if (onoff)
{
@ -158,26 +166,35 @@ BackgroundImagesRemove(Background * bg)
Efree(bg->bg.real_file);
bg->bg.real_file = NULL;
if (bg->top.file)
Efree(bg->top.file);
bg->top.file = NULL;
if (bg->top.real_file)
Efree(bg->top.real_file);
bg->top.real_file = NULL;
BackgroundImagesFree(bg, 1);
bg->keepim = 0;
}
void
int
BackgroundDestroy(Background * bg)
{
EDBUG(6, "BackgroundDestroy");
if (!bg)
EDBUG_RETURN_;
EDBUG_RETURN(-1);
if (bg->ref_count > 0)
{
DialogOK(_("Background Error!"), _("%u references remain\n"),
bg->ref_count);
EDBUG_RETURN_;
EDBUG_RETURN(-1);
}
RemoveItem((char *)bg, 0, LIST_FINDBY_POINTER, LIST_TYPE_BACKGROUND);
BackgroundImagesRemove(bg);
if (bg->name)
@ -185,57 +202,98 @@ BackgroundDestroy(Background * bg)
Efree(bg);
EDBUG_RETURN(0);
}
void
BackgroundDelete(Background * bg)
{
char *f;
EDBUG(6, "BackgroundDelete");
if (BackgroundDestroy(bg))
EDBUG_RETURN_;
/* And delete the actual image files */
if (bg->bg.file)
{
f = FindFile(bg->bg.file);
if (f)
{
E_rm(f);
Efree(f);
}
}
if (bg->top.file)
{
f = FindFile(bg->top.file);
if (f)
{
E_rm(f);
Efree(f);
}
}
EDBUG_RETURN_;
}
Background *
BackgroundCreate(const char *name, XColor * solid, const char *bg, char tile,
BackgroundCreate(const char *name, XColor * 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)
{
Background *d;
Background *bg;
EDBUG(6, "BackgroundCreate");
d = Emalloc(sizeof(Background));
if (!d)
bg = Emalloc(sizeof(Background));
if (!bg)
EDBUG_RETURN(NULL);
d->name = Estrdup(name);
d->pmap = 0;
d->last_viewed = 0;
bg->name = Estrdup(name);
bg->pmap = 0;
bg->last_viewed = 0;
ESetColor(&(d->bg_solid), 160, 160, 160);
ESetColor(&(bg->bg_solid), 160, 160, 160);
if (solid)
d->bg_solid = *solid;
d->bg.file = NULL;
if (bg)
d->bg.file = Estrdup(bg);
d->bg.real_file = NULL;
d->bg.im = NULL;
d->bg_tile = tile;
d->bg.keep_aspect = keep_aspect;
d->bg.xjust = xjust;
d->bg.yjust = yjust;
d->bg.xperc = xperc;
d->bg.yperc = yperc;
bg->bg_solid = *solid;
bg->bg.file = NULL;
if (bgn)
bg->bg.file = Estrdup(bgn);
bg->bg.real_file = NULL;
bg->bg.im = NULL;
bg->bg_tile = tile;
bg->bg.keep_aspect = keep_aspect;
bg->bg.xjust = xjust;
bg->bg.yjust = yjust;
bg->bg.xperc = xperc;
bg->bg.yperc = yperc;
d->top.file = NULL;
bg->top.file = NULL;
if (top)
d->top.file = Estrdup(top);
d->top.real_file = NULL;
d->top.im = NULL;
d->top.keep_aspect = tkeep_aspect;
d->top.xjust = txjust;
d->top.yjust = tyjust;
d->top.xperc = txperc;
d->top.yperc = typerc;
bg->top.file = Estrdup(top);
bg->top.real_file = NULL;
bg->top.im = NULL;
bg->top.keep_aspect = tkeep_aspect;
bg->top.xjust = txjust;
bg->top.yjust = tyjust;
bg->top.xperc = txperc;
bg->top.yperc = typerc;
d->cmclass = NULL;
d->keepim = 0;
d->ref_count = 0;
bg->cmclass = NULL;
bg->keepim = 0;
bg->ref_count = 0;
EDBUG_RETURN(d);
AddItem(bg, bg->name, 0, LIST_TYPE_BACKGROUND);
EDBUG_RETURN(bg);
}
void
BackgroundDestroyByName(const char *name)
{
BackgroundDestroy(FindItem(name, 0, LIST_FINDBY_NAME, LIST_TYPE_BACKGROUND));
}
static void
@ -522,15 +580,56 @@ BackgroundApply(Background * bg, Window win, int setbg)
EDBUG_RETURN_;
}
void
BackgroundIncRefcount(Background * bg)
{
if (bg == NULL)
return;
bg->ref_count++;
}
void
BackgroundDecRefcount(Background * bg)
{
if (bg == NULL)
return;
bg->ref_count--;
if (bg->ref_count <= 0)
bg->last_viewed = 0; /* Clean out asap */
}
void
BackgroundTouch(Background * bg)
{
if (bg == NULL)
return;
bg->last_viewed = time(NULL);
}
const char *
BackgroundGetName(const Background * bg)
{
return (bg) ? bg->name : NULL;
}
Pixmap
BackgroundGetPixmap(const Background * bg)
{
return (bg) ? bg->pmap : None;
}
void
BackgroundsAccounting(void)
{
time_t now;
int i, j, num;
Background **lst;
Window win;
EDBUG(3, "BackgroundsAccounting");
now = time(NULL);
for (i = 0; i < ENLIGHTENMENT_CONF_NUM_DESKTOPS; i++)
{
if ((desks.desk[i].bg) && (desks.desk[i].viewable))
@ -538,34 +637,39 @@ BackgroundsAccounting(void)
}
lst = (Background **) ListItemType(&num, LIST_TYPE_BACKGROUND);
if (lst)
for (i = 0; i < num; i++)
{
for (i = 0; i < num; i++)
/* Skip if no pixmap or not timed out */
if ((lst[i]->pmap == 0) ||
((now - lst[i]->last_viewed) <= Conf.backgrounds.timeout))
continue;
/* Skip if associated with any viewable desktop */
for (j = 0; j < ENLIGHTENMENT_CONF_NUM_DESKTOPS; j++)
if (lst[i] == desks.desk[j].bg && desks.desk[j].viewable)
goto next;
for (j = 0; j < ENLIGHTENMENT_CONF_NUM_DESKTOPS; j++)
{
if ((lst[i]->pmap == 0) ||
((now - lst[i]->last_viewed) <= Conf.backgrounds.timeout))
if (lst[i] != desks.desk[j].bg || desks.desk[j].viewable)
continue;
for (j = 0; j < ENLIGHTENMENT_CONF_NUM_DESKTOPS; j++)
{
if ((desks.desk[j].bg == lst[i]) && (!desks.desk[j].viewable))
{
Window win = desks.desk[j].win;
HintsSetRootInfo(win, 0, 0);
XSetWindowBackground(disp, win, 0);
XClearWindow(disp, win);
IMLIB1_SET_CONTEXT(lst[i] == desks.desk[0].bg);
imlib_free_pixmap_and_mask(lst[i]->pmap);
lst[i]->pmap = 0;
}
}
/* Unviewable desktop - update the virtual root hints */
win = desks.desk[j].win;
HintsSetRootInfo(win, 0, 0);
XSetWindowBackground(disp, win, 0);
XClearWindow(disp, win);
}
Efree(lst);
IMLIB1_SET_CONTEXT(0);
IMLIB1_SET_CONTEXT(lst[i] == desks.desk[0].bg);
BackgroundPixmapFree(lst[i]);
next:
;
}
if (lst)
Efree(lst);
IMLIB1_SET_CONTEXT(0);
EDBUG_RETURN_;
}

View File

@ -20,6 +20,7 @@
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#define DECLARE_STRUCT_BACKGROUND
#include "E.h"
static Window comms_win = 0;
@ -479,43 +480,13 @@ HandleComms(XClientMessageEvent * ev)
}
else if (!strcmp(w, "del_bg"))
{
Background *bg;
int i;
char dodel = 1;
sscanf(s, "%*s %1000s", w);
bg = (Background *) FindItem(w, 0, LIST_FINDBY_NAME,
LIST_TYPE_BACKGROUND);
if (bg)
{
/* check for desktops referencing this bg - if there are - don't */
/* delete it */
for (i = 0; i < ENLIGHTENMENT_CONF_NUM_DESKTOPS; i++)
{
if (desks.desk[i].bg == bg)
dodel = 0;
}
if (dodel)
{
bg = (Background *) RemoveItem(w, 0, LIST_FINDBY_NAME,
LIST_TYPE_BACKGROUND);
if (bg->name)
Efree(bg->name);
if (bg->bg.file)
Efree(bg->bg.file);
if (bg->top.file)
Efree(bg->top.file);
if (bg->pmap)
imlib_free_pixmap_and_mask(bg->pmap);
Efree(bg);
}
}
BackgroundDestroyByName(w);
}
else if (!strcmp(w, "use_bg"))
{
Background *bg;
int i, wd;
char view;
sscanf(s, "%*s %1000s", w);
bg = (Background *) FindItem(w, 0, LIST_FINDBY_NAME,
@ -531,28 +502,7 @@ HandleComms(XClientMessageEvent * ev)
if (w[0])
{
i = atoi(w);
if ((i >= 0) && (i < ENLIGHTENMENT_CONF_NUM_DESKTOPS))
{
if (desks.desk[i].bg)
desks.desk[i].bg->last_viewed = 0;
view = desks.desk[i].viewable;
desks.desk[i].viewable = 0;
BackgroundsAccounting();
desks.desk[i].viewable = view;
desks.desk[i].bg = bg;
if (i < Conf.desks.num)
{
if (desks.desk[i].viewable)
RefreshDesktop(i);
if (i == desks.current)
{
RedrawPagersForDesktop(i, 2);
ForceUpdatePagersForDesktop(i);
}
else
RedrawPagersForDesktop(i, 1);
}
}
DesktopSetBg(i, bg, 1);
}
}
}
@ -560,7 +510,6 @@ HandleComms(XClientMessageEvent * ev)
else if (!strcmp(w, "use_no_bg"))
{
int i, wd;
char view;
wd = 2;
w[0] = ' ';
@ -571,28 +520,7 @@ HandleComms(XClientMessageEvent * ev)
if (w[0])
{
i = atoi(w);
if ((i >= 0) && (i < ENLIGHTENMENT_CONF_NUM_DESKTOPS))
{
if (desks.desk[i].bg)
desks.desk[i].bg->last_viewed = 0;
view = desks.desk[i].viewable;
desks.desk[i].viewable = 0;
BackgroundsAccounting();
desks.desk[i].viewable = view;
desks.desk[i].bg = NULL;
if (i < Conf.desks.num)
{
if (desks.desk[i].viewable)
RefreshDesktop(i);
if (i == desks.current)
{
RedrawPagersForDesktop(i, 2);
ForceUpdatePagersForDesktop(i);
}
else
RedrawPagersForDesktop(i, 1);
}
}
DesktopSetBg(i, NULL, 1);
}
}
}
@ -1134,17 +1062,7 @@ HandleComms(XClientMessageEvent * ev)
for (i = 0; i < ENLIGHTENMENT_CONF_NUM_DESKTOPS; i++)
{
if (desks.desk[i].bg == bg)
{
if (desks.desk[i].viewable)
RefreshDesktop(i);
if (i == desks.current)
{
RedrawPagersForDesktop(i, 2);
ForceUpdatePagersForDesktop(i);
}
else
RedrawPagersForDesktop(i, 1);
}
DesktopSetBg(i, bg, 0);
}
}
}
@ -1166,7 +1084,6 @@ HandleComms(XClientMessageEvent * ev)
Efree(bgf);
if (topf)
Efree(topf);
AddItem(bg, bg->name, 0, LIST_TYPE_BACKGROUND);
}
}
else if (!strcmp(w, "draw_bg_to"))

View File

@ -20,6 +20,7 @@
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#define DECLARE_STRUCT_BACKGROUND
#define DECLARE_STRUCT_BUTTON
#define DECLARE_STRUCT_ICONBOX
#define DECLARE_STRUCT_MENU
@ -1827,7 +1828,6 @@ Config_Desktop(FILE * ConfigFile)
bg = BackgroundCreate(name, &xclr, bg1, i1, i2, i3,
i4, i5, i6, bg2, j1, j2, j3,
j4, j5);
AddItem(bg, bg->name, 0, LIST_TYPE_BACKGROUND);
if (cm)
{
cm->ref_count++;
@ -1882,15 +1882,14 @@ Config_Desktop(FILE * ConfigFile)
bg = BackgroundCreate(name, &xclr, bg1, i1, i2,
i3, i4, i5, i6, bg2, j1,
j2, j3, j4, j5);
AddItem(bg, bg->name, 0, LIST_TYPE_BACKGROUND);
}
if (!strcmp(bg->name, "NONE"))
{
SetDesktopBg(atoi(s2), NULL);
DesktopSetBg(atoi(s2), NULL, 0);
}
else
{
SetDesktopBg(atoi(s2), bg);
DesktopSetBg(atoi(s2), bg, 0);
}
#if !USE_IMLIB2
if ((prImlib_Context) && (atoi(s2) == 0))
@ -1911,11 +1910,11 @@ Config_Desktop(FILE * ConfigFile)
{
if (!strcmp(bg->name, "NONE"))
{
SetDesktopBg(atoi(s2), NULL);
DesktopSetBg(atoi(s2), NULL, 0);
}
else
{
SetDesktopBg(atoi(s2), bg);
DesktopSetBg(atoi(s2), bg, 0);
}
#if !USE_IMLIB2
if ((prImlib_Context) && (atoi(s2) == 0))

View File

@ -65,7 +65,7 @@ ChangeNumberOfDesktops(int quantity)
}
void
ShowDesktopControls()
ShowDesktopControls(void)
{
Button **blst;
int num, i;
@ -81,7 +81,7 @@ ShowDesktopControls()
}
void
ShowDesktopTabs()
ShowDesktopTabs(void)
{
Button **blst;
int num, i;
@ -97,7 +97,7 @@ ShowDesktopTabs()
}
void
HideDesktopTabs()
HideDesktopTabs(void)
{
Button **blst;
int num, i;
@ -218,7 +218,7 @@ SlideWindowTo(Window win, int fx, int fy, int tx, int ty, int speed)
}
void
RefreshCurrentDesktop()
RefreshCurrentDesktop(void)
{
EDBUG(5, "RefreshCurrentDesktop");
RefreshDesktop(desks.current);
@ -245,7 +245,19 @@ RefreshDesktop(int desk)
}
void
InitDesktopBgs()
DesktopsRefresh(void)
{
int i;
for (i = 0; i < ENLIGHTENMENT_CONF_NUM_DESKTOPS; i++)
{
if (desks.desk[i].bg)
DesktopSetBg(i, desks.desk[i].bg, 1);
}
}
void
InitDesktopBgs(void)
{
int i;
Desk *d;
@ -262,10 +274,10 @@ InitDesktopBgs()
d->y = 0;
d->current_area_x = 0;
d->current_area_y = 0;
d->viewable = 0;
if (i == 0)
{
d->win = root.win;
d->viewable = 0;
}
else
{
@ -277,7 +289,6 @@ InitDesktopBgs()
| ButtonMotionMask | PropertyChangeMask |
SubstructureRedirectMask | KeyPressMask |
KeyReleaseMask | PointerMotionMask);
d->viewable = 0;
}
at = XInternAtom(disp, "ENLIGHTENMENT_DESKTOP", False);
XChangeProperty(disp, d->win, at, XA_CARDINAL, 32, PropModeReplace,
@ -293,11 +304,10 @@ InitDesktopBgs()
}
EDBUG_RETURN_;
}
void
InitDesktopControls()
InitDesktopControls(void)
{
int i;
ActionClass *ac, *ac2, *ac3;
@ -564,32 +574,29 @@ InitDesktopControls()
}
void
SetDesktopBg(int desk, Background * bg)
DesktopSetBg(int desk, Background * bg, int refresh)
{
EDBUG(5, "SetDesktopBg");
EDBUG(5, "DesktopSetBg");
if (desk < 0)
EDBUG_RETURN_;
if (desk >= ENLIGHTENMENT_CONF_NUM_DESKTOPS)
if (desk < 0 || desk >= ENLIGHTENMENT_CONF_NUM_DESKTOPS)
EDBUG_RETURN_;
if (desks.desk[desk].bg)
if (refresh)
BackgroundPixmapFree(desks.desk[desk].bg);
if (desks.desk[desk].bg != bg)
{
if (desks.desk[desk].bg != bg)
{
desks.desk[desk].bg->ref_count--;
if (desks.desk[desk].bg->ref_count < 1)
{
desks.desk[desk].bg->last_viewed = 0;
BackgroundsAccounting();
}
if (bg)
bg->ref_count++;
}
if (desks.desk[desk].bg)
BackgroundDecRefcount(desks.desk[desk].bg);
if (bg)
BackgroundIncRefcount(bg);
}
desks.desk[desk].bg = bg;
if (desks.desk[desk].viewable)
RefreshDesktop(desk);
if (desk == desks.current)
{
RedrawPagersForDesktop(desk, 2);
@ -597,6 +604,7 @@ SetDesktopBg(int desk, Background * bg)
}
else
RedrawPagersForDesktop(desk, 1);
EDBUG_RETURN_;
}
@ -836,9 +844,8 @@ MoveDesktop(int desk, int x, int y)
{
for (i = n + 1; i < ENLIGHTENMENT_CONF_NUM_DESKTOPS; i++)
{
if ((desks.desk[desks.order[i]].viewable)
&& (desks.desk[desks.order[i]].bg))
desks.desk[desks.order[i]].bg->last_viewed = time(NULL);
if (desks.desk[desks.order[i]].viewable)
BackgroundTouch(desks.desk[desks.order[i]].bg);
desks.desk[desks.order[i]].viewable = 0;
}
}
@ -876,12 +883,8 @@ MoveDesktop(int desk, int x, int y)
}
else
{
if ((!v) && (desks.desk[desks.order[i]].viewable)
&& (desks.desk[desks.order[i]].bg))
{
desks.desk[desks.order[i]].bg->last_viewed =
time(NULL);
}
if ((!v) && (desks.desk[desks.order[i]].viewable))
BackgroundTouch(desks.desk[desks.order[i]].bg);
desks.desk[desks.order[i]].viewable = v;
}
@ -991,8 +994,8 @@ HideDesktop(int desk)
if (desk == 0)
EDBUG_RETURN_;
if ((desks.desk[desk].viewable) && (desks.desk[desk].bg))
desks.desk[desk].bg->last_viewed = time(NULL);
if (desks.desk[desk].viewable)
BackgroundTouch(desks.desk[desk].bg);
desks.desk[desk].viewable = 0;
EMoveWindow(disp, desks.desk[desk].win, root.w, 0);
@ -1030,7 +1033,7 @@ ShowDesktop(int desk)
}
void
StackDesktops()
StackDesktops(void)
{
EDBUG(2, "StackDesktops");

View File

@ -54,15 +54,21 @@ TransparencyMakeColorModifier(void)
void
TransparencySet(int transparency)
{
int changed;
if (transparency < 0)
transparency = 0;
else if (transparency > 255)
transparency = 255;
changed = Conf.theme.transparency != transparency;
Conf.theme.transparency = transparency;
/* Generate the color modifier tables */
TransparencyMakeColorModifier();
if (changed)
DesktopsRefresh();
}
#else
@ -433,11 +439,9 @@ ImageStateMakePmapMask(ImageState * is, Drawable win, PmapMask * pmm,
if (xx < root.w && yy < root.h && xx + w >= 0 && yy + h >= 0)
{
/* Create the background base image */
bg = root.win;
if ((is->transparent & 0x02) == 0 &&
desks.desk[desks.current].bg
&& desks.desk[desks.current].bg->pmap)
bg = desks.desk[desks.current].bg->pmap;
bg = BackgroundGetPixmap(desks.desk[desks.current].bg);
if ((is->transparent & 0x02) != 0 || bg == None)
bg = root.win;
imlib_context_set_drawable(bg);
ii = imlib_create_image_from_drawable(0, xx, yy, w, h, 1);
imlib_context_set_image(ii);

View File

@ -129,7 +129,6 @@ SetupFallbackClasses(void)
/* create a fallback background in case no background is found */
bg = BackgroundCreate("NONE", NULL, NULL, 0, 0, 0, 0, 0, 0, NULL, 0, 0, 0, 0,
0);
AddItem(bg, bg->name, 0, LIST_TYPE_BACKGROUND);
/* create a fallback textclass in case no textclass is found */
tc = CreateTclass();

View File

@ -20,6 +20,7 @@
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#define DECLARE_STRUCT_BACKGROUND
#include "E.h"
#include "timestamp.h"
#include <ctype.h>
@ -1047,7 +1048,8 @@ IPC_Background(const char *params, Client * c)
{
EGetColor(&(bg->bg_solid), &r, &g, &b);
Esnprintf(buf, sizeof(buf),
"%s ref_count %u\n" " bg.solid\t %i %i %i \n"
"%s ref_count %u keepim %u\n"
" bg.solid\t %i %i %i \n"
" bg.file\t %s \ttop.file\t %s \n"
" bg.tile\t %i \n"
" bg.keep_aspect\t %i \ttop.keep_aspect\t %i \n"
@ -1055,7 +1057,7 @@ IPC_Background(const char *params, Client * c)
" bg.yjust\t %i \ttop.yjust\t %i \n"
" bg.xperc\t %i \ttop.xperc\t %i \n"
" bg.yperc\t %i \ttop.yperc\t %i \n", bg->name,
bg->ref_count, r, g, b,
bg->ref_count, bg->keepim, r, g, b,
bg->bg.file, bg->top.file, bg->bg_tile,
bg->bg.keep_aspect, bg->top.keep_aspect,
bg->bg.xjust, bg->top.xjust, bg->bg.yjust,
@ -1077,7 +1079,6 @@ IPC_Background(const char *params, Client * c)
{
bg = BackgroundCreate(Estrdup(name), NULL, NULL, 0, 0, 0,
0, 0, 0, NULL, 0, 0, 0, 0, 0);
AddItem(bg, bg->name, 0, LIST_TYPE_BACKGROUND);
}
if (!bg)
Esnprintf(buf, sizeof(buf),
@ -1175,11 +1176,7 @@ IPC_Background(const char *params, Client * c)
if (bg)
{
if (bg->ref_count == 0)
{
RemoveItem(name, 0,
LIST_FINDBY_NAME, LIST_TYPE_BACKGROUND);
BackgroundDestroy(bg);
}
BackgroundDestroy(bg);
else
Esnprintf(buf, sizeof(buf),
"Error: ref_count for background '%s' is %u.",

View File

@ -53,7 +53,6 @@ int
main(int argc, char **argv)
{
int i;
Background *bg;
ECursor *ec = NULL;
struct utsname ubuf;
char *str;
@ -344,12 +343,8 @@ main(int argc, char **argv)
if (!Conf.mapslide)
CreateStartupDisplay(0);
if ((bg = RemoveItem("STARTUP_BACKGROUND_SIDEWAYS", 0,
LIST_FINDBY_NAME, LIST_TYPE_BACKGROUND)))
BackgroundDestroy(bg);
if ((bg = RemoveItem("STARTUP_BACKGROUND", 0,
LIST_FINDBY_NAME, LIST_TYPE_BACKGROUND)))
BackgroundDestroy(bg);
BackgroundDestroyByName("STARTUP_BACKGROUND_SIDEWAYS");
BackgroundDestroyByName("STARTUP_BACKGROUND");
#ifdef SIGCONT
for (i = 0; i < child_count; i++)

View File

@ -1125,7 +1125,6 @@ MenuCreateFromDirectory(const char *name, MenuStyle * ms, const char *dir)
keep_asp, justx, justy,
scalex, scaley, NULL, 0,
0, 0, 0, 0);
AddItem(bg, bg->name, 0, LIST_TYPE_BACKGROUND);
}
else
ok = 0;
@ -1336,7 +1335,6 @@ MenuCreateFromDirectory(const char *name, MenuStyle * ms, const char *dir)
bg = BackgroundCreate(s3, &xclr, ss, tile, keep_asp,
512, 512, scalex, scaley,
NULL, 0, 0, 0, 0, 0);
AddItem(bg, bg->name, 0, LIST_TYPE_BACKGROUND);
}
else
ok = 0;

View File

@ -664,8 +664,8 @@ PagerRedraw(Pager * p, char newbg)
BackgroundGetUniqueString(desks.desk[p->desktop].bg);
Esnprintf(s, sizeof(s), "%s/cached/pager/%s.%i.%i.%s",
EDirUserCache(),
desks.desk[p->desktop].bg->name, (p->w / ax),
(p->h / ay), uniq);
BackgroundGetName(desks.desk[p->desktop].bg),
(p->w / ax), (p->h / ay), uniq);
Efree(uniq);
im = imlib_load_image(s);

View File

@ -20,6 +20,7 @@
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#define DECLARE_STRUCT_BACKGROUND
#define DECLARE_STRUCT_ICONBOX
#include "E.h"
#include <time.h>
@ -2426,7 +2427,6 @@ static DItem *bg_mini_disp;
static DItem *bg_filename;
static DItem *tmp_w[10];
static int tmp_bg_sel_sliderval = 0;
static Background *tbg = NULL;
static Background *tmp_bg;
static int tmp_bg_r;
static int tmp_bg_g;
@ -2465,23 +2465,16 @@ CB_ConfigureBG(int val, void *data)
tmp_bg->bg.yjust = 1024 - tmp_bg_yjust;
tmp_bg->bg.xperc = tmp_bg_xperc;
tmp_bg->bg.yperc = 1024 - tmp_bg_yperc;
if (!tmp_bg_image)
BackgroundImagesRemove(tmp_bg);
for (i = 0; i < ENLIGHTENMENT_CONF_NUM_DESKTOPS; i++)
{
if (desks.desk[i].bg == tmp_bg)
{
if (desks.desk[i].viewable)
RefreshDesktop(i);
if (i == desks.current)
{
RedrawPagersForDesktop(i, 2);
ForceUpdatePagersForDesktop(i);
}
else
RedrawPagersForDesktop(i, 1);
}
DesktopSetBg(i, tmp_bg, 0);
}
{
char s[4096];
Imlib_Image *im;
@ -2505,20 +2498,7 @@ CB_ConfigureBG(int val, void *data)
{
BackgroundImagesKeep(tmp_bg, 0);
}
if (tbg)
{
BackgroundDestroy(tbg);
tbg = NULL;
}
BackgroundsAccounting();
autosave();
/* This is kind of a hack - somehow it loses the correct current desktop
* information when we actually open up the dialog box, so this
* should fix the atom which apparently gets clobbered somewhere
* above here
* --Mandrake
*/
RefreshDesktop(desks.current);
data = NULL;
}
@ -2526,88 +2506,65 @@ CB_ConfigureBG(int val, void *data)
static void
CB_DesktopMiniDisplayRedraw(int val, void *data)
{
Background *bg;
int w, h;
DItem *di;
Window win;
Pixmap pmap;
XColor xclr;
const char *fbg, *ffg;
if (!tmp_bg)
return;
di = (DItem *) data;
win = DialogItemAreaGetWindow(di);
DialogItemAreaGetSize(di, &w, &h);
fbg = (tmp_bg_image) ? tmp_bg->bg.file : NULL;
ffg = (tmp_bg_image) ? tmp_bg->top.file : NULL;
ESetColor(&xclr, tmp_bg_r, tmp_bg_g, tmp_bg_b);
if (!tbg)
{
if (!tmp_bg_image)
tbg =
BackgroundCreate("TEMP", &xclr, NULL, tmp_bg_tile,
tmp_bg_keep_aspect, tmp_bg_xjust,
1024 - tmp_bg_yjust, tmp_bg_xperc,
1024 - tmp_bg_yperc, tmp_bg->top.file,
tmp_bg->top.keep_aspect, tmp_bg->top.xjust,
tmp_bg->top.yjust, tmp_bg->top.xperc,
tmp_bg->top.yperc);
else
tbg =
BackgroundCreate("TEMP", &xclr, tmp_bg->bg.file, tmp_bg_tile,
tmp_bg_keep_aspect, tmp_bg_xjust,
1024 - tmp_bg_yjust, tmp_bg_xperc,
1024 - tmp_bg_yperc, tmp_bg->top.file,
tmp_bg->top.keep_aspect, tmp_bg->top.xjust,
tmp_bg->top.yjust, tmp_bg->top.xperc,
tmp_bg->top.yperc);
}
else
{
if (tbg->pmap)
imlib_free_pixmap_and_mask(tbg->pmap);
ESetColor(&(tbg->bg_solid), tmp_bg_r, tmp_bg_g, tmp_bg_b);
if (tbg->bg.file)
Efree(tbg->bg.file);
tbg->bg.file = NULL;
if (tmp_bg_image)
tbg->bg.file = Estrdup(tmp_bg->bg.file);
else
{
if (tbg->bg.im)
{
imlib_context_set_image(tbg->bg.im);
imlib_free_image();
tbg->bg.im = NULL;
}
}
if (tbg->bg.real_file)
Efree(tbg->bg.real_file);
tbg->bg.real_file = NULL;
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;
tbg->bg.xperc = tmp_bg_xperc;
tbg->bg.yperc = 1024 - tmp_bg_yperc;
}
BackgroundImagesKeep(tbg, 1);
bg = BackgroundCreate("TEMP", &xclr, fbg, tmp_bg_tile,
tmp_bg_keep_aspect, tmp_bg_xjust,
1024 - tmp_bg_yjust, tmp_bg_xperc,
1024 - tmp_bg_yperc, ffg,
tmp_bg->top.keep_aspect, tmp_bg->top.xjust,
tmp_bg->top.yjust, tmp_bg->top.xperc,
tmp_bg->top.yperc);
pmap = ECreatePixmap(disp, win, w, h, root.depth);
ESetWindowBackgroundPixmap(disp, win, pmap);
BackgroundApply(tbg, pmap, 0);
BackgroundApply(bg, pmap, 0);
XClearWindow(disp, win);
EFreePixmap(disp, pmap);
BackgroundDestroy(bg);
val = 0;
}
static void
BG_GetValues(void)
{
tmp_bg_image = (tmp_bg->bg.file) ? 1 : 0;
BackgroundImagesKeep(tmp_bg, 1);
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;
tmp_bg_xperc = tmp_bg->bg.xperc;
tmp_bg_yperc = 1024 - tmp_bg->bg.yperc;
}
static void
BG_DoDialog(void)
{
char *stmp;
char s[1024];
if (tmp_bg->bg.file)
tmp_bg_image = 1;
else
tmp_bg_image = 0;
BackgroundImagesKeep(tmp_bg, 1);
BG_GetValues();
if (tmp_bg->bg.file)
stmp = fullfileof(tmp_bg->bg.file);
@ -2620,13 +2577,6 @@ 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;
tmp_bg_keep_aspect = tmp_bg->bg.keep_aspect;
tmp_bg_xjust = tmp_bg->bg.xjust;
tmp_bg_yjust = 1024 - tmp_bg->bg.yjust;
tmp_bg_xperc = tmp_bg->bg.xperc;
tmp_bg_yperc = 1024 - tmp_bg->bg.yperc;
DialogItemSliderSetVal(tmp_w[0], tmp_bg_r);
DialogItemCheckButtonSetState(tmp_w[1], tmp_bg_image);
DialogItemSliderSetVal(tmp_w[2], tmp_bg_g);
@ -2637,11 +2587,7 @@ BG_DoDialog(void)
DialogItemSliderSetVal(tmp_w[7], tmp_bg_yjust);
DialogItemSliderSetVal(tmp_w[8], tmp_bg_yperc);
DialogItemSliderSetVal(tmp_w[9], tmp_bg_xperc);
if (tbg)
{
BackgroundDestroy(tbg);
tbg = NULL;
}
CB_DesktopMiniDisplayRedraw(0, bg_mini_disp);
}
@ -2650,28 +2596,23 @@ CB_ConfigureNewBG(int val, void *data)
{
char s[1024];
XColor xclr;
Background *bg;
int lower, upper;
Esnprintf(s, sizeof(s), "__NEWBG_%i\n", (unsigned)time(NULL));
Esnprintf(s, sizeof(s), "__NEWBG_%i", (unsigned)time(NULL));
ESetColor(&xclr, tmp_bg_r, tmp_bg_g, tmp_bg_b);
bg = BackgroundCreate(s, &xclr, tmp_bg->bg.file, tmp_bg_tile,
tmp_bg_keep_aspect, tmp_bg_xjust, 1024 - tmp_bg_yjust,
tmp_bg_xperc, 1024 - tmp_bg_yperc, tmp_bg->top.file,
tmp_bg->top.keep_aspect, tmp_bg->top.xjust,
tmp_bg->top.yjust, tmp_bg->top.xperc,
tmp_bg->top.yperc);
AddItem(bg, bg->name, 0, LIST_TYPE_BACKGROUND);
tmp_bg = bg;
desks.desk[desks.current].bg = bg;
tmp_bg = BackgroundCreate(s, &xclr, tmp_bg->bg.file, tmp_bg_tile,
tmp_bg_keep_aspect, tmp_bg_xjust,
1024 - tmp_bg_yjust, tmp_bg_xperc,
1024 - tmp_bg_yperc, tmp_bg->top.file,
tmp_bg->top.keep_aspect, tmp_bg->top.xjust,
tmp_bg->top.yjust, tmp_bg->top.xperc,
tmp_bg->top.yperc);
DialogItemSliderGetBounds(bg_sel_slider, &lower, &upper);
upper += 4;
DialogItemSliderSetBounds(bg_sel_slider, lower, upper);
DialogItemSliderSetVal(bg_sel_slider, 0);
DialogDrawItems(bg_sel_dialog, bg_sel_slider, 0, 0, 99999, 99999);
RefreshCurrentDesktop();
RedrawPagersForDesktop(desks.current, 2);
ForceUpdatePagersForDesktop(desks.current);
DesktopSetBg(desks.current, tmp_bg, 0);
BG_RedrawView(0);
autosave();
val = 0;
@ -2696,26 +2637,22 @@ CB_ConfigureRemBG(int val, void *data)
if (slider > upper)
DialogItemSliderSetVal(bg_sel_slider, upper);
bg = NULL;
for (i = 0; i < num; i++)
{
if (bglist[i] == tmp_bg)
{
bg = RemoveItem((char *)tmp_bg, 0, LIST_FINDBY_POINTER,
LIST_TYPE_BACKGROUND);
if (i < (num - 1))
tmp_bg = bglist[i + 1];
bg = bglist[i + 1];
else
tmp_bg = bglist[i - 1];
i = num;
if (bg)
BackgroundDestroy(bg);
BG_DoDialog();
bg = bglist[i - 1];
break;
}
}
desks.desk[desks.current].bg = tmp_bg;
RedrawPagersForDesktop(desks.current, 2);
ForceUpdatePagersForDesktop(desks.current);
RefreshCurrentDesktop();
DesktopSetBg(desks.current, bg, 0);
BackgroundDestroy(tmp_bg);
tmp_bg = bg;
BG_DoDialog();
BG_RedrawView(0);
for (i = 0; i < 10; i++)
DialogDrawItems(bg_sel_dialog, tmp_w[i], 0, 0, 99999, 99999);
@ -2746,50 +2683,23 @@ CB_ConfigureDelBG(int val, void *data)
if (slider > upper)
DialogItemSliderSetVal(bg_sel_slider, upper);
bg = NULL;
for (i = 0; i < num; i++)
{
if (bglist[i] == tmp_bg)
{
bg = RemoveItem((char *)tmp_bg, 0, LIST_FINDBY_POINTER,
LIST_TYPE_BACKGROUND);
if (i < (num - 1))
tmp_bg = bglist[i + 1];
bg = bglist[i + 1];
else
tmp_bg = bglist[i - 1];
i = num;
if (bg)
{
if (bg->bg.file)
{
char *f;
f = FindFile(bg->bg.file);
if (f)
{
E_rm(f);
Efree(f);
}
}
if (bg->top.file)
{
char *f;
f = FindFile(bg->top.file);
if (f)
{
E_rm(f);
Efree(f);
}
}
BackgroundDestroy(bg);
}
BG_DoDialog();
bg = bglist[i - 1];
break;
}
}
desks.desk[desks.current].bg = tmp_bg;
RedrawPagersForDesktop(desks.current, 2);
ForceUpdatePagersForDesktop(desks.current);
RefreshCurrentDesktop();
DesktopSetBg(desks.current, bg, 0);
BackgroundDelete(tmp_bg);
tmp_bg = bg;
BG_DoDialog();
BG_RedrawView(0);
for (i = 0; i < 10; i++)
DialogDrawItems(bg_sel_dialog, tmp_w[i], 0, 0, 99999, 99999);
@ -2989,10 +2899,7 @@ CB_BGAreaEvent(int val, void *data)
BackgroundImagesKeep(tmp_bg, 0);
tmp_bg = bglist[tmp_bg_selected];
BG_DoDialog();
desks.desk[desks.current].bg = tmp_bg;
RedrawPagersForDesktop(desks.current, 2);
ForceUpdatePagersForDesktop(desks.current);
RefreshCurrentDesktop();
DesktopSetBg(desks.current, tmp_bg, 0);
BG_RedrawView(0);
for (x = 0; x < 10; x++)
DialogDrawItems(bg_sel_dialog, tmp_w[x], 0, 0, 99999, 99999);
@ -3073,23 +2980,17 @@ CB_BGPrev(int val, void *data)
int i, num;
bglist = (Background **) ListItemType(&num, LIST_TYPE_BACKGROUND);
if (bglist)
for (i = 0; i < num; i++)
{
for (i = 0; i < num; i++)
if ((bglist[i] == tmp_bg) && (i > 0))
{
if ((bglist[i] == tmp_bg) && (i > 0))
{
desks.desk[desks.current].bg = bglist[i - 1];
BGSettingsGoTo(bglist[i - 1]);
RedrawPagersForDesktop(desks.current, 2);
ForceUpdatePagersForDesktop(desks.current);
RefreshCurrentDesktop();
Efree(bglist);
return;
}
BGSettingsGoTo(bglist[i - 1]);
DesktopSetBg(desks.current, bglist[i - 1], 0);
break;;
}
Efree(bglist);
}
if (bglist)
Efree(bglist);
val = 0;
data = NULL;
}
@ -3101,23 +3002,17 @@ CB_BGNext(int val, void *data)
int i, num;
bglist = (Background **) ListItemType(&num, LIST_TYPE_BACKGROUND);
if (bglist)
for (i = 0; i < num; i++)
{
for (i = 0; i < num; i++)
if ((bglist[i] == tmp_bg) && (i < (num - 1)))
{
if ((bglist[i] == tmp_bg) && (i < (num - 1)))
{
desks.desk[desks.current].bg = bglist[i + 1];
BGSettingsGoTo(bglist[i + 1]);
RedrawPagersForDesktop(desks.current, 2);
ForceUpdatePagersForDesktop(desks.current);
RefreshCurrentDesktop();
Efree(bglist);
return;
}
BGSettingsGoTo(bglist[i + 1]);
DesktopSetBg(desks.current, bglist[i + 1], 0);
break;
}
Efree(bglist);
}
if (bglist)
Efree(bglist);
val = 0;
data = NULL;
}
@ -3272,28 +3167,14 @@ SettingsBackground(Background * bg)
if ((!bg) || ((bg) && (!strcmp(bg->name, "NONE"))))
{
Esnprintf(s, sizeof(s), "__NEWBG_%i\n", (unsigned)time(NULL));
Esnprintf(s, sizeof(s), "__NEWBG_%i", (unsigned)time(NULL));
bg = BackgroundCreate(s, NULL, NULL, 1, 1, 0, 0, 0, 0, NULL, 1,
512, 512, 0, 0);
AddItem(bg, bg->name, 0, LIST_TYPE_BACKGROUND);
/*
* desks.desk[desks.current].bg = bg;
*/
}
tmp_bg = bg;
if (bg->bg.file)
tmp_bg_image = 1;
else
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;
tmp_bg_keep_aspect = bg->bg.keep_aspect;
tmp_bg_xjust = bg->bg.xjust;
tmp_bg_yjust = 1024 - bg->bg.yjust;
tmp_bg_xperc = bg->bg.xperc;
tmp_bg_yperc = 1024 - bg->bg.yperc;
BG_GetValues();
tmp_hiq = Conf.backgrounds.hiquality;
tmp_userbg = Conf.backgrounds.user;
tmp_bg_timeout = Conf.backgrounds.timeout;

View File

@ -218,9 +218,7 @@ CreateStartupDisplay(char start)
Mode.queue_up = pq;
BackgroundApply(bg, win1, 1);
BackgroundApply(bg, win2, 1);
if (bg->pmap)
imlib_free_pixmap_and_mask(bg->pmap);
bg->pmap = 0;
BackgroundImagesFree(bg, 1);
init_win1 = w1;
init_win2 = w2;
EMapRaised(disp, w1);