X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=OSX%2Fjwxyz.m;h=2703bdca23076d20219e59fca6d815c7b0ea3378;hb=8afc01a67be4fbf3f1cc0fce9adf01b5289a21c6;hp=06db22436a21bfb8d3362ace7b0067b8d9675894;hpb=2762a7d7cf8d83e68b8f635941f6609119d630ae;p=xscreensaver diff --git a/OSX/jwxyz.m b/OSX/jwxyz.m index 06db2243..2703bdca 100644 --- a/OSX/jwxyz.m +++ b/OSX/jwxyz.m @@ -1,4 +1,4 @@ -/* xscreensaver, Copyright (c) 1991-2013 Jamie Zawinski +/* xscreensaver, Copyright (c) 1991-2014 Jamie Zawinski * * 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); } @@ -244,6 +245,11 @@ jwxyz_window_resized (Display *dpy, Window w, CGDisplayCount n; dpy->cgdpy = 0; CGGetDisplaysWithPoint (p, 1, &dpy->cgdpy, &n); + // Auuugh! + if (! dpy->cgdpy) { + p.x = p.y = 0; + CGGetDisplaysWithPoint (p, 1, &dpy->cgdpy, &n); + } Assert (dpy->cgdpy, "unable to find CGDisplay"); } # endif // USE_IPHONE @@ -518,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)); @@ -536,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 { @@ -547,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; } } } @@ -775,8 +781,15 @@ XCopyArea (Display *dpy, Drawable src, Drawable dst, GC gc, // Sort-of-special case where no pixels can be grabbed from the source, // and the whole destination is filled with the background color. if (src_rect.size.width < 0 || src_rect.size.height < 0) { + + Assert((int)src_rect.size.width == (int)dst_rect.size.width || + (int)src_rect.size.height == (int)dst_rect.size.height, + "size mismatch"); + src_rect.size.width = 0; src_rect.size.height = 0; + dst_rect.size.width = 0; + dst_rect.size.height = 0; } NSObject *releaseme = 0; @@ -864,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); } @@ -872,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); } @@ -1726,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; @@ -1989,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; @@ -2041,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; @@ -2864,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)) @@ -3486,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)