+- (void) stopAndClose
+{
+ if ([self isAnimating])
+ [self stopAnimation];
+
+ /* Need to make the SaverListController be the firstResponder again
+ so that it can continue to receive its own shake events. I
+ suppose that this abstraction-breakage means that I'm adding
+ XScreenSaverView to the UINavigationController wrong...
+ */
+ UIViewController *v = [[self window] rootViewController];
+ if ([v isKindOfClass: [UINavigationController class]]) {
+ UINavigationController *n = (UINavigationController *) v;
+ [[n topViewController] becomeFirstResponder];
+ }
+
+ // [self removeFromSuperview];
+ [UIView animateWithDuration: 0.5
+ animations:^{ self.alpha = 0.0; }
+ completion:^(BOOL finished) {
+ [self removeFromSuperview];
+ self.alpha = 1.0;
+ }];
+}
+
+
+- (void) stopAndClose:(Bool)relaunch_p
+{
+ [self stopAndClose];
+
+ if (relaunch_p) { // Fake a shake on the SaverListController.
+ UIViewController *v = [[self window] rootViewController];
+ if ([v isKindOfClass: [UINavigationController class]]) {
+ UINavigationController *n = (UINavigationController *) v;
+ [[n topViewController] motionEnded: UIEventSubtypeMotionShake
+ withEvent: nil];
+ }
+ }
+}
+
+