From http://www.jwz.org/xscreensaver/xscreensaver-5.19.tar.gz
[xscreensaver] / OSX / SaverRunner.m
index 60233a087b6b7c5028b54357b2d99b7ad76d4e7b..526f62eb0dc4071b3a0a8e19c1282a154cf7f207 100644 (file)
    of bundles that have executable code in them.  Bleh.
  */
 
+#import <TargetConditionals.h>
 #import "SaverRunner.h"
 #import "SaverListController.h"
 #import "XScreenSaverGLView.h"
-#import <TargetConditionals.h>
+#import "yarandom.h"
 
 #ifdef USE_IPHONE
 
@@ -417,19 +418,28 @@ relabel_menus (NSObject *v, NSString *old_str, NSString *new_str)
   [prefs synchronize];
 
   if (saverName && [saverName isEqualToString: name]) {
-    if (launch && ![saverView isAnimating]) {
-      [window addSubview: saverView];
-      [saverView startAnimation];
-    }
-    return;
+    if ([saverView isAnimating])
+      return;
+    else
+      goto LAUNCH;
   }
 
   saverName = name;
 
+  if (! backgroundView) {
+    // This view is the parent of the XScreenSaverView, and exists only
+    // so that there is a black background behind it.  Without this, when
+    // rotation is in progresss, the scrolling-list window's corners show
+    // through in the corners.
+    backgroundView = [[[NSView class] alloc] initWithFrame:[window frame]];
+    [backgroundView setBackgroundColor:[NSColor blackColor]];
+  }
+
   if (saverView) {
     if ([saverView isAnimating])
       [saverView stopAnimation];
     [saverView removeFromSuperview];
+    [backgroundView removeFromSuperview];
   }
 
   NSSize size = [window frame].size;
@@ -452,8 +462,12 @@ relabel_menus (NSObject *v, NSString *old_str, NSString *new_str)
     selector:@selector(didRotate:)
     name:UIDeviceOrientationDidChangeNotification object:nil];
 
+ LAUNCH:
   if (launch) {
-    [window addSubview: saverView];
+    [self saveScreenshot];
+    [window addSubview: backgroundView];
+    [backgroundView addSubview: saverView];
+    [saverView becomeFirstResponder];
     [saverView startAnimation];
   }
 # endif // USE_IPHONE
@@ -466,9 +480,10 @@ relabel_menus (NSObject *v, NSString *old_str, NSString *new_str)
 }
 
 
+# ifndef USE_IPHONE
+
 - (void)aboutPanel:(id)sender
 {
-# ifndef USE_IPHONE
   NSDictionary *bd = [saverBundle infoDictionary];
   NSMutableDictionary *d = [NSMutableDictionary dictionaryWithCapacity:20];
 
@@ -484,28 +499,9 @@ relabel_menus (NSObject *v, NSString *old_str, NSString *new_str)
 
   [[NSApplication sharedApplication]
     orderFrontStandardAboutPanelWithOptions:d];
-
-# else  // USE_IPHONE
-
-  NSDictionary *bd = [[NSBundle mainBundle] infoDictionary];
-  NSString *body = [bd objectForKey:@"CFBundleGetInfoString"];
-
-  body = [body stringByReplacingOccurrencesOfString:@", " withString:@",\n"];
-  body = [body stringByAppendingString:
-               @"\n\n"
-               "Double-tap to run.\n\n"
-               "Double-tap again to\n"
-               "return to this list."];
-
-  [[[UIAlertView alloc] initWithTitle: @""
-                        message: body
-                        delegate: nil
-                        cancelButtonTitle: @"OK"
-                        otherButtonTitles: nil]
-    show];
+}
 
 # endif // USE_IPHONE
-}
 
 
 
@@ -916,6 +912,7 @@ relabel_menus (NSObject *v, NSString *old_str, NSString *new_str)
                                 initWithNames:saverNames
                                 descriptions:[self makeDescTable]];
   [rootViewController pushViewController:menu animated:YES];
+  [menu becomeFirstResponder];
 
   [window makeKeyAndVisible];
   [window setAutoresizesSubviews:YES];
@@ -923,8 +920,7 @@ relabel_menus (NSObject *v, NSString *old_str, NSString *new_str)
             (UIViewAutoresizingFlexibleWidth | 
              UIViewAutoresizingFlexibleHeight)];
 
-  // Has to be after the list window is up, or we get black.
-  [self saveScreenshot];
+  application.applicationSupportsShakeToEdit = YES;
 
 # endif // USE_IPHONE