Enlightenment CVS committal

Author  : kwo
Project : e16
Module  : e

Dir     : e16/e/src


Modified Files:
        cursors.c 


Log Message:
Add some sanity checking for pixmap cursors.

===================================================================
RCS file: /cvs/e/e16/e/src/cursors.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -3 -r1.34 -r1.35
--- cursors.c   14 May 2006 16:01:17 -0000      1.34
+++ cursors.c   28 May 2006 09:12:33 -0000      1.35
@@ -69,22 +69,30 @@
        XReadBitmapFile(disp, VRoot.xwin, msk, &w, &h, &mask, &xh, &yh);
        XReadBitmapFile(disp, VRoot.xwin, img, &w, &h, &pmap, &xh, &yh);
        XQueryBestCursor(disp, VRoot.xwin, w, h, &ww, &hh);
-       if ((w > ww) || (h > hh))
+       curs = None;
+       if ((w <= ww) && (h <= hh) && (pmap))
          {
-            EFreePixmap(pmap);
-            EFreePixmap(mask);
-            Efree(img);
-            return NULL;
+            EAllocColor(VRoot.cmap, fg);
+            EAllocColor(VRoot.cmap, bg);
+            if (xh < 0 || xh >= (int)w)
+               xh = (int)w / 2;
+            if (yh < 0 || yh >= (int)h)
+               yh = (int)h / 2;
+            curs = XCreatePixmapCursor(disp, pmap, mask, fg, bg, xh, yh);
          }
 
-       EAllocColor(VRoot.cmap, fg);
-       EAllocColor(VRoot.cmap, bg);
+       if (!curs)
+          Eprintf("*** Failed to create cursor \"%s\" from %s,%s\n",
+                  name, img, msk);
 
-       curs = 0;
-       curs = XCreatePixmapCursor(disp, pmap, mask, fg, bg, xh, yh);
-       EFreePixmap(pmap);
-       EFreePixmap(mask);
+       if (pmap)
+          EFreePixmap(pmap);
+       if (mask)
+          EFreePixmap(mask);
        Efree(img);
+
+       if (!curs)
+          return NULL;
      }
    else
      {




-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to