Enlightenment CVS committal

Author  : kwo
Project : e16
Module  : e

Dir     : e16/e/src


Modified Files:
        backgrounds.c backgrounds.h iclass.c 


Log Message:
More background pixmap handling stuff.
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/backgrounds.c,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -3 -r1.51 -r1.52
--- backgrounds.c       21 Nov 2005 17:48:44 -0000      1.51
+++ backgrounds.c       22 Nov 2005 23:21:47 -0000      1.52
@@ -535,9 +535,10 @@
    return pmap;
 }
 
-Pixmap
-BackgroundApply(Background * bg, Drawable draw,
-               unsigned int rw, unsigned int rh, int is_win)
+void
+BackgroundRealize(Background * bg, Drawable draw, unsigned int rw,
+                 unsigned int rh, int is_win, Pixmap * ppmap,
+                 unsigned long *ppixel)
 {
    Pixmap              pmap;
    GC                  gc;
@@ -604,11 +605,7 @@
        /* Solid color only */
        EAllocColor(&bg->bg_solid);
 
-       if (is_win)
-         {
-            ESetWindowBackground(draw, bg->bg_solid.pixel);
-         }
-       else
+       if (!is_win)
          {
             gc = ECreateGC(draw, 0, NULL);
             XSetClipMask(disp, gc, 0);
@@ -617,7 +614,11 @@
             XFillRectangle(disp, draw, gc, 0, 0, rw, rh);
             EFreeGC(gc);
          }
-       return None;
+       if (ppmap)
+          *ppmap = None;
+       if (ppixel)
+          *ppixel = bg->bg_solid.pixel;
+       return;
      }
 
    /* Has either bg or fg image */
@@ -650,6 +651,7 @@
        imlib_context_set_drawable(pmap);
        imlib_render_image_on_drawable_at_size(0, 0, w, h);
 
+#if 0                          /* FIXME - Remove? */
        if (x == 0 && y == 0)   /* Hmmm. Always true. */
          {
             ESetWindowBackgroundPixmap(draw, pmap);
@@ -663,6 +665,7 @@
             XFillRectangle(disp, draw, gc, 0, 0, rw, rh);
             EFreeGC(gc);
          }
+#endif
        goto done;
      }
 
@@ -735,51 +738,60 @@
 
    imlib_context_set_dither(rt);
 
-   return pmap;
+   if (ppmap)
+      *ppmap = pmap;
+   if (ppixel)
+      *ppixel = 0;
 }
 
 void
 BackgroundApplyPmap(Background * bg, Drawable draw,
                    unsigned int w, unsigned int h)
 {
-   BackgroundApply(bg, draw, w, h, 0);
+   BackgroundRealize(bg, draw, w, h, 0, NULL, NULL);
+}
+
+static void
+BackgroundApplyWin(Background * bg, Window win)
+{
+   int                 w, h;
+   Pixmap              pmap;
+   unsigned long       pixel;
+
+   if (!EGetGeometry(win, NULL, NULL, NULL, &w, &h, NULL, NULL))
+      return;
+
+   BackgroundRealize(bg, win, w, h, 1, &pmap, &pixel);
+   if (pmap != None)
+      ESetWindowBackgroundPixmap(win, pmap);
+   else
+      ESetWindowBackground(win, pixel);
+   EClearWindow(win);
 }
 
 /*
- * Apply a background to window/pixmap.
+ * Apply a background to window.
  * The (scaled) BG pixmap is stored in bg->pmap.
  */
 void
 BackgroundSet(Background * bg, Window win, unsigned int w, unsigned int h)
 {
    Pixmap              pmap;
+   unsigned long       pixel;
 
    if (bg->pmap)
       pmap = bg->pmap;
    else
-      pmap = BackgroundApply(bg, win, w, h, 1);
+      BackgroundRealize(bg, win, w, h, 1, &pmap, &pixel);
 
    bg->pmap = pmap;
    if (pmap != None)
       ESetWindowBackgroundPixmap(win, pmap);
    else
-      ESetWindowBackground(win, bg->bg_solid.pixel);
+      ESetWindowBackground(win, pixel);
    EClearWindow(win);
 }
 
-static void
-BackgroundApply2(Background * bg, Window win)
-{
-   Window              rr;
-   int                 x, y;
-   unsigned int        w, h, bw, depth;
-
-   if (!XGetGeometry(disp, win, &rr, &x, &y, &w, &h, &bw, &depth))
-      return;
-
-   BackgroundApply(bg, win, w, h, 1);
-}
-
 Background         *
 BrackgroundCreateFromImage(const char *bgid, const char *file,
                           char *thumb, int thlen)
@@ -1043,6 +1055,21 @@
             bg->top.xperc, bg->top.yperc);
 }
 
+void
+BackgroundsInvalidate(void)
+{
+   int                 i, num;
+   Desk               *dsk;
+
+   num = DesksGetNumber();
+   for (i = 0; i < num; i++)
+     {
+       dsk = DeskGet(i);
+       BackgroundPixmapFree(DeskBackgroundGet(dsk));
+       DeskRefresh(dsk);
+     }
+}
+
 /*
  * Config load/save
  */
@@ -2561,7 +2588,7 @@
             win = None;
             sscanf(p, "%lx", &win);
             if (win)
-               BackgroundApply2(bg, win);
+               BackgroundApplyWin(bg, win);
          }
      }
    else if (!strncmp(cmd, "cfg", 2))
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/backgrounds.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- backgrounds.h       21 Nov 2005 17:48:44 -0000      1.2
+++ backgrounds.h       22 Nov 2005 23:21:47 -0000      1.3
@@ -30,9 +30,10 @@
 void                BackgroundPixmapFree(Background * bg);
 void                BackgroundImagesFree(Background * bg, int free_pmap);
 void                BackgroundDestroyByName(const char *name);
-Pixmap              BackgroundApply(Background * bg, Drawable draw,
-                                   unsigned int rw, unsigned int rh,
-                                   int is_win);
+void                BackgroundRealize(Background * bg, Drawable draw,
+                                     unsigned int rw, unsigned int rh,
+                                     int is_win, Pixmap * ppmap,
+                                     unsigned long *ppixel);
 void                BackgroundApplyPmap(Background * bg, Drawable draw,
                                        unsigned int rw, unsigned int rh);
 void                BackgroundSet(Background * bg, Window win, unsigned int rw,
@@ -48,6 +49,7 @@
                                               const char *file, char *thumb,
                                               int thlen);
 
+void                BackgroundsInvalidate(void);
 int                 BackgroundsConfigLoad(FILE * fs);
 
 #endif /* _BACKGROUNDS_H_ */
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/iclass.c,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -3 -r1.83 -r1.84
--- iclass.c    21 Nov 2005 17:48:44 -0000      1.83
+++ iclass.c    22 Nov 2005 23:21:47 -0000      1.84
@@ -163,16 +163,7 @@
    if (prev_alpha == 0)
      {
        /* Hack to get tiled backgrounds regenerated at full size */
-       int                 i, num;
-       Desk               *dsk;
-
-       num = DesksGetNumber();
-       for (i = 0; i < num; i++)
-         {
-            dsk = DeskGet(i);
-            BackgroundPixmapFree(DeskBackgroundGet(dsk));
-            DeskRefresh(dsk);
-         }
+       BackgroundsInvalidate();
      }
    ModulesSignal(ESIGNAL_THEME_TRANS_CHANGE, NULL);
 }




-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.  Get Certified Today
Register for a JBoss Training Course.  Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to