#ifndef USE_IPHONE
# import <Cocoa/Cocoa.h>
#else
-# import <SaverRunner.h>
+# import "SaverRunner.h"
#endif
#import "jwxyz.h"
#import "grabscreen.h"
/* 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.
*/
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;
{
# ifndef USE_IPHONE
+ if (!filename || !*filename) return False;
+
NSImage *img = [[NSImage alloc] initWithContentsOfFile:
[NSString stringWithCString:filename
encoding:NSUTF8StringEncoding]];
# 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 */