Enlightenment CVS committal

Author  : kwo
Project : e16
Module  : e

Dir     : e16/e/src


Modified Files:
        E.h Makefile.am actions.c comms.c config.c desktops.c events.c 
        init.c ipc.c main.c menus.c pager.c settings.c startup.c 


Log Message:
Background code and namespace shuffle.
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/E.h,v
retrieving revision 1.245
retrieving revision 1.246
diff -u -3 -r1.245 -r1.246
--- E.h 10 Apr 2004 10:43:54 -0000      1.245
+++ E.h 10 Apr 2004 19:36:47 -0000      1.246
@@ -572,6 +572,7 @@
 typedef struct _button Button;
 typedef struct _slideout Slideout;
 typedef struct _soundclass SoundClass;
+typedef struct _background Background;
 
 typedef struct _efont Efont;
 
@@ -1048,7 +1049,7 @@
 }
 BgPart;
 
-typedef struct _background
+struct _background
 {
    char               *name;
    Pixmap              pmap;
@@ -1060,8 +1061,7 @@
    ColorModifierClass *cmclass;
    char                keepim;
    unsigned int        ref_count;
-}
-Background;
+};
 
 typedef struct _desk
 {
@@ -1646,6 +1646,21 @@
 long               *getSimpleHint(Window win, Atom atom);
 void                deleteHint(Window win, Atom atom);
 
+/* backgrounds.c */
+char               *BackgroundGetUniqueString(Background * bg);
+void                BackgroundImagesKeep(Background * bg, char onoff);
+void                BackgroundImagesRemove(Background * bg);
+void                BackgroundDestroy(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                BackgroundApply(Background * bg, Window win, int setbg);
+void                BackgroundsAccounting(void);
+void                BackgroundsInit(void);
+
 /* borders.c */
 #define EWIN_CHANGE_NAME        (1<<0)
 #define EWIN_CHANGE_ICON_NAME   (1<<1)
@@ -1813,7 +1828,6 @@
 void                FreeECursor(ECursor * ec);
 
 /* desktops.c */
-char               *GetUniqueBGString(Background * bg);
 void                ChangeNumberOfDesktops(int quantity);
 void                ShowDesktopControls(void);
 void                ShowDesktopTabs(void);
@@ -1823,18 +1837,8 @@
 void                MoveToDeskBottom(int num);
 void                SlideWindowTo(Window win, int fx, int fy, int tx, int ty,
                                  int speed);
-void                KeepBGimages(Background * bg, char onoff);
-void                RemoveImagesFromBG(Background * bg);
-void                FreeDesktopBG(Background * bg);
-Background         *CreateDesktopBG(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                RefreshCurrentDesktop(void);
 void                RefreshDesktop(int num);
-void                SetBackgroundTo(Window win, Background * dsk, char setbg);
 void                InitDesktopBgs(void);
 void                InitDesktopControls(void);
 void                SetDesktopBg(int desk, Background * bg);
@@ -1855,7 +1859,6 @@
 void                MoveEwinToDesktopAt(EWin * ewin, int num, int x, int y);
 void                GotoDesktopByEwin(EWin * ewin);
 void                FloatEwinAboveDesktops(EWin * ewin);
-void                DesktopAccounting(void);
 
 /* dialog.c */
 Dialog             *DialogCreate(const char *name);
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/Makefile.am,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -3 -r1.35 -r1.36
--- Makefile.am 9 Apr 2004 12:50:26 -0000       1.35
+++ Makefile.am 10 Apr 2004 19:36:48 -0000      1.36
@@ -21,6 +21,7 @@
        areas.c                 \
        arrange.c               \
        atoms.c                 \
+       backgrounds.c           \
        borders.c               \
        buttons.c               \
        clone.c                 \
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/actions.c,v
retrieving revision 1.153
retrieving revision 1.154
diff -u -3 -r1.153 -r1.154
--- actions.c   10 Apr 2004 10:43:55 -0000      1.153
+++ actions.c   10 Apr 2004 19:36:48 -0000      1.154
@@ -2638,7 +2638,7 @@
           desks.desk[desk].bg->last_viewed = 0;
        view = desks.desk[desk].viewable;
        desks.desk[desk].viewable = 0;
-       DesktopAccounting();
+       BackgroundsAccounting();
        desks.desk[desk].viewable = view;
        BGSettingsGoTo(bg);
        pq = Mode.queue_up;
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/comms.c,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -3 -r1.58 -r1.59
--- comms.c     7 Apr 2004 14:32:33 -0000       1.58
+++ comms.c     10 Apr 2004 19:36:48 -0000      1.59
@@ -537,7 +537,7 @@
                               desks.desk[i].bg->last_viewed = 0;
                            view = desks.desk[i].viewable;
                            desks.desk[i].viewable = 0;
-                           DesktopAccounting();
+                           BackgroundsAccounting();
                            desks.desk[i].viewable = view;
                            desks.desk[i].bg = bg;
                            if (i < Conf.desks.num)
@@ -577,7 +577,7 @@
                          desks.desk[i].bg->last_viewed = 0;
                       view = desks.desk[i].viewable;
                       desks.desk[i].viewable = 0;
-                      DesktopAccounting();
+                      BackgroundsAccounting();
                       desks.desk[i].viewable = view;
                       desks.desk[i].bg = NULL;
                       if (i < Conf.desks.num)
@@ -1157,9 +1157,9 @@
             word(s, 13, w);
             if (strcmp("(null)", w))
                topf = Estrdup(w);
-            bg = CreateDesktopBG(name, &xclr, bgf, tile, keep_aspect, xjust,
-                                 yjust, xperc, yperc, topf, tkeep_aspect,
-                                 txjust, tyjust, txperc, typerc);
+            bg = BackgroundCreate(name, &xclr, bgf, tile, keep_aspect, xjust,
+                                  yjust, xperc, yperc, topf, tkeep_aspect,
+                                  txjust, tyjust, txperc, typerc);
             if (name)
                Efree(name);
             if (bgf)
@@ -1178,7 +1178,7 @@
        bg = (Background *) FindItem(w, 0, LIST_FINDBY_NAME,
                                     LIST_TYPE_BACKGROUND);
        if (bg)
-          SetBackgroundTo(win, bg, 0);
+          BackgroundApply(bg, win, 0);
        CommsSend(c, "done");
      }
    else if (!strcmp(w, "set_controls"))
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/config.c,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -3 -r1.99 -r1.100
--- config.c    7 Apr 2004 14:32:33 -0000       1.99
+++ config.c    10 Apr 2004 19:36:48 -0000      1.100
@@ -1824,9 +1824,9 @@
                         }
                       if (ok)
                         {
-                           bg = CreateDesktopBG(name, &xclr, bg1, i1, i2, i3,
-                                                i4, i5, i6, bg2, j1, j2, j3,
-                                                j4, j5);
+                           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)
                              {
@@ -1879,9 +1879,9 @@
 #endif
                            if (!bg)
                              {
-                                bg = CreateDesktopBG(name, &xclr, bg1, i1, i2,
-                                                     i3, i4, i5, i6, bg2, j1,
-                                                     j2, j3, j4, j5);
+                                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"))
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/desktops.c,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -3 -r1.81 -r1.82
--- desktops.c  8 Apr 2004 22:16:31 -0000       1.81
+++ desktops.c  10 Apr 2004 19:36:48 -0000      1.82
@@ -25,94 +25,6 @@
 #include <time.h>
 #include <sys/time.h>
 
-char               *
-GetUniqueBGString(Background * bg)
-{
-   char                s[256];
-   const char         *chmap =
-      "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_";
-   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)
-      | (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);
-   n4 = (bg->top.xjust << 16) | (bg->top.yjust);
-   n5 = (bg->top.xperc << 16) | (bg->top.yperc);
-   f1 = 0;
-   f2 = 0;
-   f3 = 0;
-   f4 = 0;
-   f5 = 0;
-   f6 = 0;
-   if (bg->bg.file)
-     {
-       char               *f;
-
-       f = FindFile(bg->bg.file);
-       if (f)
-         {
-            f1 = fileinode(f);
-            f2 = filedev(f);
-            f3 = (int)moddate(f);
-            Efree(f);
-         }
-     }
-   if (bg->top.file)
-     {
-       char               *f;
-
-       f = FindFile(bg->top.file);
-       if (f)
-         {
-            f4 = fileinode(f);
-            f5 = filedev(f);
-            f6 = (int)moddate(f);
-            Efree(f);
-         }
-     }
-   Esnprintf(s, sizeof(s),
-            "%c%c%c%c%c%c" "%c%c%c%c%c%c" "%c%c%c%c%c%c" "%c%c%c%c%c%c"
-            "%c%c%c%c%c%c" "%c%c%c%c%c%c" "%c%c%c%c%c%c" "%c%c%c%c%c%c"
-            "%c%c%c%c%c%c" "%c%c%c%c%c%c" "%c%c%c%c%c%c",
-            chmap[(n1 >> 0) & 0x3f], chmap[(n1 >> 6) & 0x3f],
-            chmap[(n1 >> 12) & 0x3f], chmap[(n1 >> 18) & 0x3f],
-            chmap[(n1 >> 24) & 0x3f], chmap[(n1 >> 28) & 0x3f],
-            chmap[(n2 >> 0) & 0x3f], chmap[(n2 >> 6) & 0x3f],
-            chmap[(n2 >> 12) & 0x3f], chmap[(n2 >> 18) & 0x3f],
-            chmap[(n2 >> 24) & 0x3f], chmap[(n2 >> 28) & 0x3f],
-            chmap[(n3 >> 0) & 0x3f], chmap[(n3 >> 6) & 0x3f],
-            chmap[(n3 >> 12) & 0x3f], chmap[(n3 >> 18) & 0x3f],
-            chmap[(n3 >> 24) & 0x3f], chmap[(n3 >> 28) & 0x3f],
-            chmap[(n4 >> 0) & 0x3f], chmap[(n4 >> 6) & 0x3f],
-            chmap[(n4 >> 12) & 0x3f], chmap[(n4 >> 18) & 0x3f],
-            chmap[(n4 >> 24) & 0x3f], chmap[(n4 >> 28) & 0x3f],
-            chmap[(n5 >> 0) & 0x3f], chmap[(n5 >> 6) & 0x3f],
-            chmap[(n5 >> 12) & 0x3f], chmap[(n5 >> 18) & 0x3f],
-            chmap[(n5 >> 24) & 0x3f], chmap[(n5 >> 28) & 0x3f],
-            chmap[(f1 >> 0) & 0x3f], chmap[(f1 >> 6) & 0x3f],
-            chmap[(f1 >> 12) & 0x3f], chmap[(f1 >> 18) & 0x3f],
-            chmap[(f1 >> 24) & 0x3f], chmap[(f1 >> 28) & 0x3f],
-            chmap[(f2 >> 0) & 0x3f], chmap[(f2 >> 6) & 0x3f],
-            chmap[(f2 >> 12) & 0x3f], chmap[(f2 >> 18) & 0x3f],
-            chmap[(f2 >> 24) & 0x3f], chmap[(f2 >> 28) & 0x3f],
-            chmap[(f3 >> 0) & 0x3f], chmap[(f3 >> 6) & 0x3f],
-            chmap[(f3 >> 12) & 0x3f], chmap[(f3 >> 18) & 0x3f],
-            chmap[(f3 >> 24) & 0x3f], chmap[(f3 >> 28) & 0x3f],
-            chmap[(f4 >> 0) & 0x3f], chmap[(f4 >> 6) & 0x3f],
-            chmap[(f4 >> 12) & 0x3f], chmap[(f4 >> 18) & 0x3f],
-            chmap[(f4 >> 24) & 0x3f], chmap[(f4 >> 28) & 0x3f],
-            chmap[(f5 >> 0) & 0x3f], chmap[(f5 >> 6) & 0x3f],
-            chmap[(f5 >> 12) & 0x3f], chmap[(f5 >> 18) & 0x3f],
-            chmap[(f5 >> 24) & 0x3f], chmap[(f5 >> 28) & 0x3f],
-            chmap[(f6 >> 0) & 0x3f], chmap[(f6 >> 6) & 0x3f],
-            chmap[(f6 >> 12) & 0x3f], chmap[(f6 >> 18) & 0x3f],
-            chmap[(f6 >> 24) & 0x3f], chmap[(f6 >> 28) & 0x3f]);
-   return Estrdup(s);
-}
-
 void
 ChangeNumberOfDesktops(int quantity)
 {
@@ -305,133 +217,6 @@
    EDBUG_RETURN_;
 }
 
-static void
-FreeBGimages(Background * bg, int free_pmap)
-{
-   if (bg->bg.im)
-     {
-       imlib_context_set_image(bg->bg.im);
-       imlib_free_image();
-       bg->bg.im = NULL;
-     }
-   if (bg->top.im)
-     {
-       imlib_context_set_image(bg->top.im);
-       imlib_free_image();
-       bg->top.im = NULL;
-     }
-   if (free_pmap && bg->pmap)
-     {
-       imlib_free_pixmap_and_mask(bg->pmap);
-       bg->pmap = 0;
-     }
-}
-
-void
-KeepBGimages(Background * bg, char onoff)
-{
-   if (onoff)
-     {
-       bg->keepim = 1;
-     }
-   else
-     {
-       bg->keepim = 0;
-       FreeBGimages(bg, 0);
-     }
-}
-
-void
-RemoveImagesFromBG(Background * bg)
-{
-   if (bg->bg.file)
-      Efree(bg->bg.file);
-   bg->bg.file = NULL;
-
-   if (bg->bg.real_file)
-      Efree(bg->bg.real_file);
-   bg->bg.real_file = NULL;
-
-   FreeBGimages(bg, 1);
-
-   bg->keepim = 0;
-}
-
-void
-FreeDesktopBG(Background * bg)
-{
-   EDBUG(6, "FreeDesktopBG");
-
-   if (!bg)
-      EDBUG_RETURN_;
-
-   if (bg->ref_count > 0)
-     {
-       DialogOK(_("Background Error!"), _("%u references remain\n"),
-                bg->ref_count);
-       EDBUG_RETURN_;
-     }
-
-   RemoveImagesFromBG(bg);
-
-   if (bg->name)
-      Efree(bg->name);
-
-   Efree(bg);
-
-   EDBUG_RETURN_;
-}
-
-Background         *
-CreateDesktopBG(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)
-{
-   Background         *d;
-
-   EDBUG(6, "CreateDesktopBG");
-
-   d = Emalloc(sizeof(Background));
-   if (!d)
-      EDBUG_RETURN(NULL);
-   d->name = Estrdup(name);
-   d->pmap = 0;
-   d->last_viewed = 0;
-
-   ESetColor(&(d->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;
-
-   d->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;
-
-   d->cmclass = NULL;
-   d->keepim = 0;
-   d->ref_count = 0;
-
-   EDBUG_RETURN(d);
-}
-
 void
 RefreshCurrentDesktop()
 {
@@ -443,7 +228,7 @@
 void
 RefreshDesktop(int desk)
 {
-   Background         *dsk;
+   Background         *bg;
 
    EDBUG(4, "RefreshDesktop");
 
@@ -451,295 +236,11 @@
    if (!desks.desk[desk].viewable)
       EDBUG_RETURN_;
 
-   dsk = desks.desk[desk].bg;
-   if (!dsk)
+   bg = desks.desk[desk].bg;
+   if (!bg)
       EDBUG_RETURN_;
 
-   SetBackgroundTo(desks.desk[desk].win, dsk, 1);
-   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)
-{
-   unsigned int        rw, rh;
-   Pixmap              dpmap;
-   GC                  gc;
-   XGCValues           gcv;
-   int                 rt, depth;
-
-   EDBUG(4, "SetBackgroundTo");
-
-   if (!WinExists(win))
-      EDBUG_RETURN_;
-
-   IMLIB1_SET_CONTEXT(win == root.win);
-
-   GetWinWH(win, &rw, &rh);
-   depth = GetWinDepth(win);
-   imlib_context_set_drawable(win);
-
-   EAllocColor(&dsk->bg_solid);
-   gc = 0;
-   rt = imlib_context_get_dither();
-
-   if (Conf.backgrounds.hiquality)
-     {
-       imlib_context_set_dither(1);
-#if 0                          /* ??? */
-       imlib_context_set_anti_alias(1);
-#endif
-     }
-
-   dpmap = dsk->pmap;
-   if (!setbg && dpmap)
-     {
-       /* Always regenerate if setting non-desktop window (?) */
-       imlib_free_pixmap_and_mask(dpmap);
-       dpmap = 0;
-     }
-
-   if (!dpmap)
-     {
-       unsigned 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--;
-       else
-          cm = (ColorModifierClass *) FindItem("BACKGROUND", 0,
-                                               LIST_FINDBY_NAME,
-                                               LIST_TYPE_COLORMODIFIER);
-
-       if (cm)
-         {
-            cm->ref_count++;
-#if !USE_IMLIB2
-            if (dsk->top.im)
-              {
-                 Imlib_set_image_red_curve(pImlib_Context, dsk->top.im,
-                                           cm->red.map);
-                 Imlib_set_image_green_curve(pImlib_Context, dsk->top.im,
-                                             cm->green.map);
-                 Imlib_set_image_blue_curve(pImlib_Context, dsk->top.im,
-                                            cm->blue.map);
-              }
-            if (dsk->bg.im)
-              {
-                 Imlib_set_image_red_curve(pImlib_Context, dsk->bg.im,
-                                           cm->red.map);
-                 Imlib_set_image_green_curve(pImlib_Context, dsk->bg.im,
-                                             cm->green.map);
-                 Imlib_set_image_blue_curve(pImlib_Context, dsk->bg.im,
-                                            cm->blue.map);
-              }
-#endif
-         }
-
-       hasbg = hasfg = 0;
-       if (dsk->top.im)
-          hasfg = 1;
-       if (dsk->bg.im)
-          hasbg = 1;
-
-       w = h = x = y = 0;
-
-       if (hasbg)
-         {
-            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 && !Conf.theme.transparency)
-         {
-            /* BG only, tiled */
-            dpmap = ECreatePixmap(disp, win, w, h, depth);
-            gc = XCreateGC(disp, dpmap, 0, &gcv);
-         }
-       else
-         {
-            /* The rest that require some more work */
-            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);
-              }
-         }
-
-       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, rw, rh);
-            else
-               XFillRectangle(disp, dpmap, gc, x, y, w, h);
-            IMLIB_FREE_PIXMAP_AND_MASK(pmap, mask);
-         }
-
-       if (hasfg)
-         {
-            int                 ww, hh;
-
-            imlib_context_set_image(dsk->top.im);
-
-            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)
-         {
-            HintsSetRootInfo(win, dpmap, 0);
-            XSetWindowBackgroundPixmap(disp, win, dpmap);
-         }
-       else
-         {
-            HintsSetRootInfo(win, 0, dsk->bg_solid.pixel);
-            XSetWindowBackground(disp, win, dsk->bg_solid.pixel);
-         }
-       XClearWindow(disp, win);
-     }
-   else
-     {
-       if (dpmap)
-         {
-            if (!gc)
-               gc = XCreateGC(disp, dpmap, 0, &gcv);
-            XSetClipMask(disp, gc, 0);
-            XSetTile(disp, gc, dpmap);
-            XSetTSOrigin(disp, gc, 0, 0);
-            XSetFillStyle(disp, gc, FillTiled);
-            XFillRectangle(disp, win, gc, 0, 0, rw, rh);
-            imlib_free_pixmap_and_mask(dpmap);
-            dpmap = 0;
-         }
-       else
-         {
-            if (!gc)
-               gc = XCreateGC(disp, win, 0, &gcv);
-            XSetClipMask(disp, gc, 0);
-            XSetFillStyle(disp, gc, FillSolid);
-            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);
-
-   imlib_context_set_dither(rt);
-
-   IMLIB1_SET_CONTEXT(0);
-
+   BackgroundApply(bg, desks.desk[desk].win, 1);
    EDBUG_RETURN_;
 }
 
@@ -1080,7 +581,7 @@
             if (desks.desk[desk].bg->ref_count < 1)
               {
                  desks.desk[desk].bg->last_viewed = 0;
-                 DesktopAccounting();
+                 BackgroundsAccounting();
               }
             if (bg)
                bg->ref_count++;
@@ -1777,51 +1278,3 @@
    EDBUG_RETURN_;
 }
 #endif
-
-void
-DesktopAccounting()
-{
-   time_t              now;
-   int                 i, j, num;
-   Background        **lst;
-
-   EDBUG(3, "DesktopAccounting");
-   now = time(NULL);
-   for (i = 0; i < ENLIGHTENMENT_CONF_NUM_DESKTOPS; i++)
-     {
-       if ((desks.desk[i].bg) && (desks.desk[i].viewable))
-          desks.desk[i].bg->last_viewed = now;
-     }
-
-   lst = (Background **) ListItemType(&num, LIST_TYPE_BACKGROUND);
-   if (lst)
-     {
-       for (i = 0; i < num; i++)
-         {
-            if ((lst[i]->pmap == 0) ||
-                ((now - lst[i]->last_viewed) <= Conf.backgrounds.timeout))
-               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;
-                   }
-              }
-
-         }
-       Efree(lst);
-       IMLIB1_SET_CONTEXT(0);
-     }
-
-   EDBUG_RETURN_;
-}
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/events.c,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -3 -r1.62 -r1.63
--- events.c    8 Apr 2004 12:54:45 -0000       1.62
+++ events.c    10 Apr 2004 19:36:48 -0000      1.63
@@ -41,22 +41,6 @@
 
 char                throw_move_events_away = 0;
 
-static char         diddeskaccount = 1;
-
-static void
-DeskAccountTimeout(int val, void *data)
-{
-   EDBUG(5, "DeskAccountTimeout");
-
-   DesktopAccounting();
-   diddeskaccount = 1;
-   EDBUG_RETURN_;
-   data = NULL;
-   val = 0;
-
-   EDBUG_RETURN_;
-}
-
 void
 EventsInit(void)
 {
@@ -248,12 +232,6 @@
    /* Should not be "global" */
    IconboxesHandleEvent(ev);
 
-   if (diddeskaccount)
-     {
-       DoIn("DESKTOP_ACCOUNTING_TIMEOUT", 30.0, DeskAccountTimeout, 0, NULL);
-       diddeskaccount = 0;
-     }
-
    EDBUG_RETURN_;
 }
 
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/init.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -3 -r1.15 -r1.16
--- init.c      21 Mar 2004 01:41:00 -0000      1.15
+++ init.c      10 Apr 2004 19:36:48 -0000      1.16
@@ -127,8 +127,8 @@
    AddItem(b, b->name, 0, LIST_TYPE_BORDER);
 
    /* create a fallback background in case no background is found */
-   bg = CreateDesktopBG("NONE", NULL, NULL, 0, 0, 0, 0, 0, 0, NULL, 0, 0, 0, 0,
-                       0);
+   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 */
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/ipc.c,v
retrieving revision 1.151
retrieving revision 1.152
diff -u -3 -r1.151 -r1.152
--- ipc.c       9 Apr 2004 13:45:59 -0000       1.151
+++ ipc.c       10 Apr 2004 19:36:48 -0000      1.152
@@ -1075,8 +1075,8 @@
 
                  if (!bg)
                    {
-                      bg = CreateDesktopBG(Estrdup(name), NULL, NULL, 0, 0, 0,
-                                           0, 0, 0, NULL, 0, 0, 0, 0, 0);
+                      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)
@@ -1178,7 +1178,7 @@
                    {
                       RemoveItem(name, 0,
                                  LIST_FINDBY_NAME, LIST_TYPE_BACKGROUND);
-                      FreeDesktopBG(bg);
+                      BackgroundDestroy(bg);
                    }
                  else
                     Esnprintf(buf, sizeof(buf),
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/main.c,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -3 -r1.85 -r1.86
--- main.c      9 Apr 2004 12:59:55 -0000       1.85
+++ main.c      10 Apr 2004 19:36:49 -0000      1.86
@@ -346,10 +346,10 @@
 
    if ((bg = RemoveItem("STARTUP_BACKGROUND_SIDEWAYS", 0,
                        LIST_FINDBY_NAME, LIST_TYPE_BACKGROUND)))
-      FreeDesktopBG(bg);
+      BackgroundDestroy(bg);
    if ((bg = RemoveItem("STARTUP_BACKGROUND", 0,
                        LIST_FINDBY_NAME, LIST_TYPE_BACKGROUND)))
-      FreeDesktopBG(bg);
+      BackgroundDestroy(bg);
 
 #ifdef SIGCONT
    for (i = 0; i < child_count; i++)
@@ -365,9 +365,13 @@
    Mode.startup = 0;
 
    ThemeBadDialog();
+
+   BackgroundsInit();          /* Start the background accounting */
+
    /* The primary event loop */
    for (;;)
       WaitEvent();
+
    /* Of course, we should NEVER get to this point */
    EDBUG_RETURN(0);
 }
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/menus.c,v
retrieving revision 1.120
retrieving revision 1.121
diff -u -3 -r1.120 -r1.121
--- menus.c     9 Apr 2004 12:59:55 -0000       1.120
+++ menus.c     10 Apr 2004 19:36:49 -0000      1.121
@@ -1121,10 +1121,10 @@
                                      keep_asp = 1;
                                   }
                                 ESetColor(&xclr, 0, 0, 0);
-                                bg = CreateDesktopBG(s3, &xclr, ss, tile,
-                                                     keep_asp, justx, justy,
-                                                     scalex, scaley, NULL, 0,
-                                                     0, 0, 0, 0);
+                                bg = BackgroundCreate(s3, &xclr, ss, tile,
+                                                      keep_asp, justx, justy,
+                                                      scalex, scaley, NULL, 0,
+                                                      0, 0, 0, 0);
                                 AddItem(bg, bg->name, 0, LIST_TYPE_BACKGROUND);
                              }
                            else
@@ -1333,9 +1333,9 @@
                                 keep_asp = 1;
                              }
                            ESetColor(&xclr, 0, 0, 0);
-                           bg = CreateDesktopBG(s3, &xclr, ss, tile, keep_asp,
-                                                512, 512, scalex, scaley, NULL,
-                                                0, 0, 0, 0, 0);
+                           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
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/pager.c,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -3 -r1.82 -r1.83
--- pager.c     9 Apr 2004 12:59:55 -0000       1.82
+++ pager.c     10 Apr 2004 19:36:49 -0000      1.83
@@ -660,7 +660,8 @@
                       Imlib_Image        *im;
                       Pixmap              mask;
 
-                      uniq = GetUniqueBGString(desks.desk[p->desktop].bg);
+                      uniq =
+                         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),
@@ -683,8 +684,8 @@
                         }
                       else
                         {
-                           SetBackgroundTo(p->bgpmap,
-                                           desks.desk[p->desktop].bg, 0);
+                           BackgroundApply(desks.desk[p->desktop].bg,
+                                           p->bgpmap, 0);
                            imlib_context_set_drawable(p->bgpmap);
                            im =
                               imlib_create_image_from_drawable(0, 0, 0,
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/settings.c,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -3 -r1.104 -r1.105
--- settings.c  1 Apr 2004 22:41:22 -0000       1.104
+++ settings.c  10 Apr 2004 19:36:49 -0000      1.105
@@ -1074,7 +1074,7 @@
 
                  pmap = ECreatePixmap(disp, wins[i], 64, 48, root.depth);
                  ESetWindowBackgroundPixmap(disp, wins[i], pmap);
-                 SetBackgroundTo(pmap, desks.desk[i].bg, 0);
+                 BackgroundApply(desks.desk[i].bg, pmap, 0);
                  EFreePixmap(disp, pmap);
               }
          }
@@ -2466,7 +2466,7 @@
        tmp_bg->bg.xperc = tmp_bg_xperc;
        tmp_bg->bg.yperc = 1024 - tmp_bg_yperc;
        if (!tmp_bg_image)
-          RemoveImagesFromBG(tmp_bg);
+          BackgroundImagesRemove(tmp_bg);
        for (i = 0; i < ENLIGHTENMENT_CONF_NUM_DESKTOPS; i++)
          {
             if (desks.desk[i].bg == tmp_bg)
@@ -2490,7 +2490,7 @@
           Esnprintf(s, sizeof(s), "%s/cached/bgsel/%s", EDirUserCache(),
                     tmp_bg->name);
           p2 = ECreatePixmap(disp, root.win, 64, 48, root.depth);
-          SetBackgroundTo(p2, tmp_bg, 0);
+          BackgroundApply(tmp_bg, p2, 0);
           imlib_context_set_drawable(p2);
           im = imlib_create_image_from_drawable(0, 0, 0, 64, 48, 0);
           imlib_context_set_image(im);
@@ -2503,14 +2503,14 @@
      }
    if (val != 1)
      {
-       KeepBGimages(tmp_bg, 0);
+       BackgroundImagesKeep(tmp_bg, 0);
      }
    if (tbg)
      {
-       FreeDesktopBG(tbg);
+       BackgroundDestroy(tbg);
        tbg = NULL;
      }
-   DesktopAccounting();
+   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
@@ -2541,22 +2541,22 @@
      {
        if (!tmp_bg_image)
           tbg =
-             CreateDesktopBG("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);
+             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 =
-             CreateDesktopBG("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);
+             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
      {
@@ -2587,10 +2587,10 @@
        tbg->bg.xperc = tmp_bg_xperc;
        tbg->bg.yperc = 1024 - tmp_bg_yperc;
      }
-   KeepBGimages(tbg, 1);
+   BackgroundImagesKeep(tbg, 1);
    pmap = ECreatePixmap(disp, win, w, h, root.depth);
    ESetWindowBackgroundPixmap(disp, win, pmap);
-   SetBackgroundTo(pmap, tbg, 0);
+   BackgroundApply(tbg, pmap, 0);
    XClearWindow(disp, win);
    EFreePixmap(disp, pmap);
    val = 0;
@@ -2607,7 +2607,7 @@
    else
       tmp_bg_image = 0;
 
-   KeepBGimages(tmp_bg, 1);
+   BackgroundImagesKeep(tmp_bg, 1);
 
    if (tmp_bg->bg.file)
       stmp = fullfileof(tmp_bg->bg.file);
@@ -2639,7 +2639,7 @@
    DialogItemSliderSetVal(tmp_w[9], tmp_bg_xperc);
    if (tbg)
      {
-       FreeDesktopBG(tbg);
+       BackgroundDestroy(tbg);
        tbg = NULL;
      }
    CB_DesktopMiniDisplayRedraw(0, bg_mini_disp);
@@ -2655,12 +2655,12 @@
 
    Esnprintf(s, sizeof(s), "__NEWBG_%i\n", (unsigned)time(NULL));
    ESetColor(&xclr, tmp_bg_r, tmp_bg_g, tmp_bg_b);
-   bg = CreateDesktopBG(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);
+   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;
@@ -2708,7 +2708,7 @@
                     tmp_bg = bglist[i - 1];
                  i = num;
                  if (bg)
-                    FreeDesktopBG(bg);
+                    BackgroundDestroy(bg);
                  BG_DoDialog();
               }
          }
@@ -2781,7 +2781,7 @@
                                 Efree(f);
                              }
                         }
-                      FreeDesktopBG(bg);
+                      BackgroundDestroy(bg);
                    }
                  BG_DoDialog();
               }
@@ -2898,7 +2898,7 @@
                       Esnprintf(s, sizeof(s), "%s/cached/bgsel/%s",
                                 EDirUserCache(), bglist[i]->name);
                       p2 = ECreatePixmap(disp, pmap, 64, 48, root.depth);
-                      SetBackgroundTo(p2, bglist[i], 0);
+                      BackgroundApply(bglist[i], p2, 0);
                       XCopyArea(disp, p2, pmap, gc, 0, 0, 64, 48, x + 4, 4);
                       imlib_context_set_drawable(p2);
                       im =
@@ -2986,7 +2986,7 @@
        tmp_bg_selected = x;
        if ((tmp_bg_selected >= 0) && (tmp_bg_selected < num))
          {
-            KeepBGimages(tmp_bg, 0);
+            BackgroundImagesKeep(tmp_bg, 0);
             tmp_bg = bglist[tmp_bg_selected];
             BG_DoDialog();
             desks.desk[desks.current].bg = tmp_bg;
@@ -3050,7 +3050,7 @@
                                  99999);
                  DialogItemCallCallback(bg_sel_slider);
                  tmp_bg_selected = i;
-                 KeepBGimages(tmp_bg, 0);
+                 BackgroundImagesKeep(tmp_bg, 0);
                  tmp_bg = bglist[tmp_bg_selected];
                  BG_DoDialog();
                  BG_RedrawView(0);
@@ -3273,8 +3273,8 @@
    if ((!bg) || ((bg) && (!strcmp(bg->name, "NONE"))))
      {
        Esnprintf(s, sizeof(s), "__NEWBG_%i\n", (unsigned)time(NULL));
-       bg = CreateDesktopBG(s, NULL, NULL, 1, 1, 0, 0, 0, 0, NULL, 1, 512, 512,
-                            0, 0);
+       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;
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/startup.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -3 -r1.40 -r1.41
--- startup.c   9 Apr 2004 12:59:55 -0000       1.40
+++ startup.c   10 Apr 2004 19:36:49 -0000      1.41
@@ -216,8 +216,8 @@
        IclassApply(ic, b1, root.w, Conf.desks.dragbar_width, 0, 0, 0, 0);
        IclassApply(ic, b2, root.w, Conf.desks.dragbar_width, 0, 0, 0, 0);
        Mode.queue_up = pq;
-       SetBackgroundTo(win1, bg, 1);
-       SetBackgroundTo(win2, bg, 1);
+       BackgroundApply(bg, win1, 1);
+       BackgroundApply(bg, win2, 1);
        if (bg->pmap)
           imlib_free_pixmap_and_mask(bg->pmap);
        bg->pmap = 0;




-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to