From http://www.jwz.org/xscreensaver/xscreensaver-5.35.tar.gz
[xscreensaver] / OSX / osxgrabscreen.m
index 9dc5001cd6169e26afe91f168d05e62004115767..c7f4f15b686902b3185744abf1f3f06eef74c001 100644 (file)
@@ -24,7 +24,7 @@
 #else
 # import "SaverRunner.h"
 #endif
-#import "jwxyz.h"
+#import "jwxyz-cocoa.h"
 #import "grabscreen.h"
 #import "colorbars.h"
 #import "resources.h"
@@ -253,7 +253,7 @@ osx_grab_desktop_image (Screen *screen, Window xwindow, Drawable drawable,
        /* What a hack!
 
            On iOS, our application delegate, SaverRunner, grabs an image
-           of itself as a UIImage before creating the XScreenSaverView.
+           of itself as a UIImage before mapping the XScreenSaverView.
            In this code, we ask SaverRunner for that UIImage, then copy
            it to the root window.
          */
@@ -262,18 +262,12 @@ Bool
 osx_grab_desktop_image (Screen *screen, Window xwindow, Drawable drawable,
                         XRectangle *geom_ret)
 {
-
-  /* Just for a little variety, let's return colorbars every other time. */
-  static int counter = 0;
-  if (counter++ & 1)
-    return False;
-
   SaverRunner *s = 
     (SaverRunner *) [[UIApplication sharedApplication] delegate];
   if (! s)
     return False;
   if (! [s isKindOfClass:[SaverRunner class]])
-    abort();
+    return False;
   UIImage *img = [s screenshot];
   if (! img)
     return False;
@@ -430,6 +424,8 @@ osx_load_image_file (Screen *screen, Window xwindow, Drawable drawable,
 {
 # ifndef USE_IPHONE
 
+  if (!filename || !*filename) return False;
+
   NSImage *img = [[NSImage alloc] initWithContentsOfFile:
                                     [NSString stringWithCString:filename
                                               encoding:NSUTF8StringEncoding]];
@@ -444,16 +440,7 @@ osx_load_image_file (Screen *screen, Window xwindow, Drawable drawable,
 
 # else  /* USE_IPHONE */
 
-  /* It would be nice to select a random image from the Photo Album and
-     load that, but that looks like a gigantic pain in the ass, because
-     it's an asynchronous API, and might require manual authorization
-     by the user.  (ALAssetsLibrary, enumerateGroupsWithTypes.)
-
-     Possibly useful sample code to check out:
-       http://www.fiveminutes.eu/accessing-photo-library-using-assets-library-framework-on-iphone/
-
-     So, in the meantime, return False, acquire colorbars.
-   */
+  /* This is handled differently: see grabclient.c and iosgrabimage.m. */
   return False;
 
 # endif /* USE_IPHONE */