stringByReplacingOccurrencesOfString:@" "
withString:@""]
stringByAppendingPathExtension:@"xml"]];
- NSString *xml = [NSString stringWithContentsOfFile:path
- encoding:NSISOLatin1StringEncoding
- error:nil];
- NSAssert (xml, @"no XML: %@", path);
+ NSData *xmld = [NSData dataWithContentsOfFile:path];
+ NSAssert (xmld, @"no XML: %@", path);
+ NSString *xml = [XScreenSaverView decompressXML:xmld];
Bool gl_p = (xml && [xml rangeOfString:@"gl=\"yes\""].length > 0);
new_class = (gl_p
orderFrontStandardAboutPanelWithOptions:d];
# else // USE_IPHONE
+ if ([saverNames count] == 1)
+ return;
+
NSString *name = saverName;
NSString *year = [self makeDesc:saverName yearOnly:YES];
if ([[p pathExtension] caseInsensitiveCompare: ext])
continue;
-# ifndef USE_IPHONE
NSString *name = [[p lastPathComponent] stringByDeletingPathExtension];
-# else // !USE_IPHONE
+# ifdef USE_IPHONE
// Get the saver name's capitalization right by reading the XML file.
p = [dir stringByAppendingPathComponent: p];
- NSString *name = [NSString stringWithContentsOfFile:p
- encoding:NSISOLatin1StringEncoding
- error:nil];
- NSRange r = [name rangeOfString:@"_label=\"" options:0];
- name = [name substringFromIndex: r.location + r.length];
- r = [name rangeOfString:@"\"" options:0];
- name = [name substringToIndex: r.location];
-
- NSAssert1 (name, @"no name in %@", p);
+ NSData *xmld = [NSData dataWithContentsOfFile:p];
+ NSAssert (xmld, @"no XML: %@", p);
+ NSString *xml = [XScreenSaverView decompressXML:xmld];
+ NSRange r = [xml rangeOfString:@"_label=\"" options:0];
+ NSAssert1 (r.length, @"no name in %@", p);
+ if (r.length) {
+ xml = [xml substringFromIndex: r.location + r.length];
+ r = [xml rangeOfString:@"\"" options:0];
+ if (r.length) name = [xml substringToIndex: r.location];
+ }
-# endif // !USE_IPHONE
+# endif // USE_IPHONE
- [result addObject: name];
+ NSAssert1 (name, @"no name in %@", p);
+ if (name) [result addObject: name];
}
if (! [result count])
NSRange r;
path = [path stringByAppendingPathExtension:@"xml"];
- desc = [NSString stringWithContentsOfFile:path
- encoding:NSISOLatin1StringEncoding
- error:nil];
+ NSData *xmld = [NSData dataWithContentsOfFile:path];
+ if (! xmld) goto FAIL;
+ desc = [XScreenSaverView decompressXML:xmld];
if (! desc) goto FAIL;
r = [desc rangeOfString:@"<_description>"
FAIL:
if (! desc) {
- desc = @"Oops, this module appears to be incomplete.";
- // NSLog(@"broken saver: %@", path);
+ if ([saverNames count] > 1)
+ desc = @"Oops, this module appears to be incomplete.";
+ else
+ desc = @"";
}
return desc;
return win;
}
+
+- (void) animTimer
+{
+ for (NSWindow *win in windows) {
+ ScreenSaverView *sv = find_saverView ([win contentView]);
+ if ([sv isAnimating])
+ [sv animateOneFrame];
+ }
+}
+
# endif // !USE_IPHONE
[NSString stringWithFormat:@"XScreenSaverWindow%d", i]];
[win setFrameUsingName:[win frameAutosaveName]];
[a addObject: win];
+ // This prevents clicks from being seen by savers.
+ // [win setMovableByWindowBackground:YES];
}
# else // USE_IPHONE
# endif
[self selectedSaverDidChange:nil];
+
+
+# ifndef USE_IPHONE
+ /* On 10.8 and earlier, [ScreenSaverView startAnimation] causes the
+ ScreenSaverView to run its own timer calling animateOneFrame.
+ On 10.9, that fails because the private class ScreenSaverModule
+ is only initialized properly by ScreenSaverEngine, and in the
+ context of SaverRunner, the null ScreenSaverEngine instance
+ behaves as if [ScreenSaverEngine needsAnimationTimer] returned false.
+ So, if it looks like this is the 10.9 version of ScreenSaverModule
+ instead of the 10.8 version, we run our own timer here. This sucks.
+ */
+ if (!anim_timer) {
+ Class ssm = NSClassFromString (@"ScreenSaverModule");
+ if (ssm && [ssm instancesRespondToSelector:
+ @selector(needsAnimationTimer)]) {
+ NSWindow *win = [windows objectAtIndex:0];
+ ScreenSaverView *sv = find_saverView ([win contentView]);
+ anim_timer = [NSTimer scheduledTimerWithTimeInterval:
+ [sv animationTimeInterval]
+ target:self
+ selector:@selector(animTimer)
+ userInfo:nil
+ repeats:YES];
+ }
+ }
+# endif // !USE_IPHONE
}
#ifndef USE_IPHONE
/* When the window closes, exit (even if prefs still open.)
-*/
+ */
- (BOOL) applicationShouldTerminateAfterLastWindowClosed: (NSApplication *) n
{
return YES;