Enlightenment CVS committal

Author  : kwo
Project : e16
Module  : e

Dir     : e16/e/src


Modified Files:
        draw.c 


Log Message:
Limit shape to window extents.
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/draw.c,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -3 -r1.70 -r1.71
--- draw.c      14 May 2005 19:40:33 -0000      1.70
+++ draw.c      15 May 2005 18:26:32 -0000      1.71
@@ -1118,95 +1118,107 @@
 PropagateShapes(Window win)
 {
    Window              rt, par, *list = NULL;
-   int                 k, i, num = 0, num_rects = 0, rn = 0, ord;
-   int                 x, y, ww, hh, w, h, d;
-   XRectangle         *rects = NULL, *rl = NULL;
+   unsigned int        i, num, num_rects;
+   int                 k, rn, ord;
+   int                 x, y, xx, yy, ww, hh, d;
+   XRectangle         *rects, *rl;
    XWindowAttributes   att;
 
+   if (!EGetGeometry(win, &rt, &xx, &yy, &ww, &hh, &d, &d))
+      return;
+   if ((ww <= 0) || (hh <= 0))
+      return;
+
 #if 0
-   Eprintf("PropagateShapes: %#lx\n", win);
+   Eprintf("PropagateShapes %#lx %d,%d %dx%d\n", win, xx, yy, ww, hh);
 #endif
 
-   if (!EGetGeometry(win, &rt, &x, &y, &w, &h, &d, &d))
-      return;
-   if ((w <= 0) || (h <= 0))
+   XQueryTree(disp, win, &rt, &par, &list, &num);
+   if (!list)
       return;
 
-   ww = w;
-   hh = h;
+   num_rects = 0;
+   rects = NULL;
 
-   XQueryTree(disp, win, &rt, &par, &list, (unsigned int *)&num);
-   if (list)
+   /* go through all child windows and create/inset spans */
+   for (i = 0; i < num; i++)
      {
-       /* go through all child windows and create/inset spans */
-       for (i = 0; i < num; i++)
+       XGetWindowAttributes(disp, list[i], &att);
+       x = att.x;
+       y = att.y;
+       if ((att.class == InputOutput) && (att.map_state != IsUnmapped))
          {
-            XGetWindowAttributes(disp, list[i], &att);
-            x = att.x;
-            y = att.y;
-            w = att.width;
-            h = att.height;
-            if ((att.class == InputOutput) && (att.map_state != IsUnmapped))
+            rl = EShapeGetRectangles(list[i], ShapeBounding, &rn, &ord);
+            if (rl)
               {
-                 rl = NULL;
-                 rl = EShapeGetRectangles(list[i], ShapeBounding, &rn, &ord);
-                 if (rl)
+                 if (rn > 0)
                    {
-                      num_rects += rn;
-                      if (rn > 0)
+                      rects = Erealloc(rects,
+                                       (num_rects + rn) * sizeof(XRectangle));
+                      /* go through all clip rects in thsi window's shape */
+                      for (k = 0; k < rn; k++)
                         {
-                           rects =
-                              Erealloc(rects, num_rects * sizeof(XRectangle));
-                           /* go through all clip rects in thsi window's shape 
*/
-                           for (k = 0; k < rn; k++)
-                             {
-                                /* for each clip rect, add it to the rect list 
*/
-                                rects[num_rects - rn + k].x = x + rl[k].x;
-                                rects[num_rects - rn + k].y = y + rl[k].y;
-                                rects[num_rects - rn + k].width = rl[k].width;
-                                rects[num_rects - rn + k].height =
-                                   rl[k].height;
-                             }
+                           /* for each clip rect, add it to the rect list */
+                           rects[num_rects + k].x = x + rl[k].x;
+                           rects[num_rects + k].y = y + rl[k].y;
+                           rects[num_rects + k].width = rl[k].width;
+                           rects[num_rects + k].height = rl[k].height;
                         }
-                      Efree(rl);
+                      num_rects += rn;
                    }
-                 else
-                   {
-                      num_rects++;
-                      rects = Erealloc(rects, num_rects * sizeof(XRectangle));
+                 Efree(rl);
+              }
+            else
+              {
+                 rects = Erealloc(rects, (num_rects + 1) * sizeof(XRectangle));
 
-                      rects[num_rects - 1].x = x;
-                      rects[num_rects - 1].y = y;
-                      rects[num_rects - 1].width = w;
-                      rects[num_rects - 1].height = h;
-                   }
+                 rects[num_rects].x = x;
+                 rects[num_rects].y = y;
+                 rects[num_rects].width = att.width;
+                 rects[num_rects].height = att.height;
+                 num_rects++;
               }
          }
-       /* set the rects as the shape mask */
-       if (rects)
+     }
+
+#if 0
+   for (i = 0; i < num_rects; i++)
+      Eprintf("%3d %4d,%4d %4dx%4d\n", i, rects[i].x, rects[i].y,
+             rects[i].width, rects[i].height);
+#endif
+
+   /* set the rects as the shape mask */
+   if (rects)
+     {
+       EShapeCombineRectangles(win, ShapeBounding, 0, 0, rects,
+                               num_rects, ShapeSet, Unsorted);
+
+       /* Limit shape to window extents */
+       rects[0].x = 0;
+       rects[0].y = 0;
+       rects[0].width = ww;
+       rects[0].height = hh;
+       XShapeCombineRectangles(disp, win, ShapeBounding, 0, 0, rects,
+                               1, ShapeIntersect, Unsorted);
+
+       Efree(rects);
+       rl = NULL;
+       rl = EShapeGetRectangles(win, ShapeBounding, &rn, &ord);
+       if (rl)
          {
-            EShapeCombineRectangles(win, ShapeBounding, 0, 0, rects,
-                                    num_rects, ShapeSet, Unsorted);
-            Efree(rects);
-            rl = NULL;
-            rl = EShapeGetRectangles(win, ShapeBounding, &rn, &ord);
-            if (rl)
+            if (rn < 1)
+               EShapeCombineMask(win, ShapeBounding, 0, 0, None, ShapeSet);
+            else if (rn == 1)
               {
-                 if (rn < 1)
-                    EShapeCombineMask(win, ShapeBounding, 0, 0, None,
-                                      ShapeSet);
-                 else if (rn == 1)
-                   {
-                      if ((rl[0].x == 0) && (rl[0].y == 0)
-                          && (rl[0].width == ww) && (rl[0].height == hh))
-                         EShapeCombineMask(win, ShapeBounding, 0, 0,
-                                           None, ShapeSet);
-                   }
-                 Efree(rl);
+                 if ((rl[0].x == 0) && (rl[0].y == 0)
+                     && (rl[0].width == ww) && (rl[0].height == hh))
+                    EShapeCombineMask(win, ShapeBounding, 0, 0,
+                                      None, ShapeSet);
               }
-            else
-               EShapeCombineMask(win, ShapeBounding, 0, 0, None, ShapeSet);
+            Efree(rl);
          }
-       XFree(list);
+       else
+          EShapeCombineMask(win, ShapeBounding, 0, 0, None, ShapeSet);
      }
+   XFree(list);
 }




-------------------------------------------------------
This SF.Net email is sponsored by Oracle Space Sweepstakes
Want to be the first software developer in space?
Enter now for the Oracle Space Sweepstakes!
http://ads.osdn.com/?ad_id=7393&alloc_id=16281&op=click
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to