From http://www.jwz.org/xscreensaver/xscreensaver-5.27.tar.gz
[xscreensaver] / OSX / jwxyz.m
index 15d82135ade30bf2d4a10395924854db03ba365d..2703bdca23076d20219e59fca6d815c7b0ea3378 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1991-2013 Jamie Zawinski <jwz@jwz.org>
+/* xscreensaver, Copyright (c) 1991-2014 Jamie Zawinski <jwz@jwz.org>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -189,6 +189,7 @@ jwxyz_free_display (Display *dpy)
   
   free (dpy->screen->visual);
   free (dpy->screen);
+  CFRelease (dpy->main_window->window.view);
   free (dpy->main_window);
   free (dpy);
 }
@@ -523,7 +524,7 @@ XDrawPoints (Display *dpy, Drawable d, GC gc,
 
     Assert (data, "no bitmap data in Drawable");
 
-    unsigned int argb = gc->gcv.foreground;
+    unsigned long argb = gc->gcv.foreground;
     validate_pixel (argb, gc->depth, gc->gcv.alpha_allowed_p);
     if (gc->depth == 1)
       argb = (gc->gcv.foreground ? WhitePixel(0,0) : BlackPixel(0,0));
@@ -541,7 +542,7 @@ XDrawPoints (Display *dpy, Drawable d, GC gc,
         if (x >= 0 && x < w && y >= 0 && y < h) {
           unsigned int *p = (unsigned int *)
             ((char *) data + (size_t) y * bpr + (size_t) x * 4);
-          *p = argb;
+          *p = (unsigned int) argb;
         }
       }
     } else {
@@ -552,7 +553,7 @@ XDrawPoints (Display *dpy, Drawable d, GC gc,
         if (x >= 0 && x < w && y >= 0 && y < h) {
           unsigned int *p = (unsigned int *)
             ((char *) data + (size_t) y * bpr + (size_t) x * 4);
-          *p = argb;
+          *p = (unsigned int) argb;
         }
       }
     }
@@ -876,7 +877,7 @@ XCopyArea (Display *dpy, Drawable src, Drawable dst, GC gc,
         if (orig_dst_y < dst_y0) {
           fill_rect_memset (seek_xy (dst_data, dst_pitch,
                                      orig_dst_x, orig_dst_y), dst_pitch,
-                            gc->gcv.background, orig_width,
+                            (uint32_t) gc->gcv.background, orig_width,
                             dst_y0 - orig_dst_y);
         }
 
@@ -884,20 +885,20 @@ XCopyArea (Display *dpy, Drawable src, Drawable dst, GC gc,
           fill_rect_memset (seek_xy (dst_data, dst_pitch, orig_dst_x,
                                      dst_y0 + height0),
                             dst_pitch,
-                            gc->gcv.background, orig_width,
+                            (uint32_t) gc->gcv.background, orig_width,
                             orig_dst_y + orig_height - dst_y0 - height0);
         }
 
         if (orig_dst_x < dst_x0) {
           fill_rect_memset (seek_xy (dst_data, dst_pitch, orig_dst_x, dst_y0),
-                            dst_pitch, gc->gcv.background,
+                            dst_pitch, (uint32_t) gc->gcv.background,
                             dst_x0 - orig_dst_x, height0);
         }
 
         if (dst_x0 + width0 < orig_dst_x + orig_width) {
           fill_rect_memset (seek_xy (dst_data, dst_pitch, dst_x0 + width0,
                                      dst_y0),
-                            dst_pitch, gc->gcv.background,
+                            dst_pitch, (uint32_t) gc->gcv.background,
                             orig_dst_x + orig_width - dst_x0 - width0,
                             height0);
         }
@@ -1738,7 +1739,7 @@ XCreateImage (Display *dpy, Visual *visual, unsigned int depth,
   ximage->format = format;
   ximage->data = data;
   ximage->bitmap_unit = 8;
-  ximage->byte_order = MSBFirst;
+  ximage->byte_order = LSBFirst;
   ximage->bitmap_bit_order = ximage->byte_order;
   ximage->bitmap_pad = bitmap_pad;
   ximage->depth = depth;
@@ -2001,7 +2002,7 @@ XGetImage (Display *dpy, Drawable d, int x, int y,
            unsigned long plane_mask, int format)
 {
   const unsigned char *data = 0;
-  int depth, ibpp, ibpl;
+  size_t depth, ibpp, ibpl;
   enum { RGBA, ARGB, BGRA } src_format; // As bytes.
 # ifndef USE_BACKBUFFER
   NSBitmapImageRep *bm = 0;
@@ -2053,8 +2054,8 @@ XGetImage (Display *dpy, Drawable d, int x, int y,
   data += (y * ibpl) + (x * (ibpp/8));
   
   format = (depth == 1 ? XYPixmap : ZPixmap);
-  XImage *image = XCreateImage (dpy, 0, depth, format, 0, 0, width, height,
-                                0, 0);
+  XImage *image = XCreateImage (dpy, 0, (unsigned int) depth,
+                                format, 0, 0, width, height, 0, 0);
   image->data = (char *) malloc (height * image->bytes_per_line);
   
   int obpl = image->bytes_per_line;
@@ -2876,7 +2877,7 @@ try_xlfd_font (const char *name, float scale,
     while (*s2 && (*s2 != '*' && *s2 != '-'))
       s2++;
     
-    int L = s2-s;
+    unsigned long L = s2-s;
     if (s == s2)
       ;
 # define CMP(STR) (L == strlen(STR) && !strncasecmp (s, (STR), L))
@@ -3498,6 +3499,13 @@ visual_class (Screen *s, Visual *v)
   return TrueColor;
 }
 
+int
+get_bits_per_pixel (Display *dpy, int depth)
+{
+  Assert (depth == 32 || depth == 1, "unexpected depth");
+  return depth;
+}
+
 // declared in utils/grabclient.h
 Bool
 use_subwindow_mode_p (Screen *screen, Window window)