- UIWindow *saverWindow = [self window]; // not SaverRunner.window
- [listWindow setHidden:NO];
- [UIView animateWithDuration: 0.5
- animations:^{ fader.alpha = 0.0; }
- completion:^(BOOL finished) {
- [fader removeFromSuperview];
- fader.alpha = 1.0;
- [saverWindow setHidden:YES];
- [listWindow makeKeyAndVisible];
- [[[listWindow rootViewController] view] becomeFirstResponder];
- }];
- }
-}
-
-
-/* Whether the shape of the X11 Window should be changed to HxW when the
- device is in a landscape orientation. X11 hacks want this, but OpenGL
- hacks do not.
- */
-- (BOOL)reshapeRotatedWindow
-{
- return YES;
-}
-
-
-/* Called after the device's orientation has changed.
-
- Rotation is complicated: the UI, X11 and OpenGL work in 3 different ways.
-
- The UI (list of savers, preferences panels) is rotated by the system,
- because its UIWindow is under a UINavigationController that does
- automatic rotation, using Core Animation.
-
- The savers are under a different UIWindow and a UINavigationController
- that does not do automatic rotation.
-
- We have to do it this way for OpenGL savers because using Core Animation
- on an EAGLContext causes the OpenGL pipeline to fall back on software
- rendering and performance goes to hell.
-
- For X11-only savers, we could just use Core Animation and let the system
- handle it, but (maybe) it's simpler to do it the same way for X11 and GL.
-
- During and after rotation, the size/shape of the X11 window changes,
- and ConfigureNotify events are generated.
-
- X11 code (jwxyz) continues to draw into the (reshaped) backbuffer, which
- rotated at the last minute via a CGAffineTransformMakeRotation when it is
- copied to the display hardware.
-
- GL code always recieves a portrait-oriented X11 Window whose size never
- changes. The GL COLOR_BUFFER is displayed on the hardware directly and
- unrotated, so the GL hacks themselves are responsible for rotating the
- GL scene to match current_device_rotation().
-
- Touch events are converted to mouse clicks, and those XEvent coordinates
- are reported in the coordinate system currently in use by the X11 window.
- Again, GL must convert those.
- */
-- (void)didRotate:(NSNotification *)notification
-{
- UIDeviceOrientation current = [[UIDevice currentDevice] orientation];
-
- /* If the simulator starts up in the rotated position, sometimes
- the UIDevice says we're in Portrait when we're not -- but it
- turns out that the UINavigationController knows what's up!
- So get it from there.
- */
- if (current == UIDeviceOrientationUnknown) {
- switch ([[[self window] rootViewController] interfaceOrientation]) {
- case UIInterfaceOrientationPortrait:
- current = UIDeviceOrientationPortrait;
- break;
- case UIInterfaceOrientationPortraitUpsideDown:
- current = UIDeviceOrientationPortraitUpsideDown;
- break;
- /* It's opposite day, "because rotating the device to the left requires
- rotating the content to the right" */
- case UIInterfaceOrientationLandscapeLeft:
- current = UIDeviceOrientationLandscapeRight;
- break;
- case UIInterfaceOrientationLandscapeRight:
- current = UIDeviceOrientationLandscapeLeft;
- break;
- default:
- break;
- }
- }
-
- /* On the iPad (but not iPhone 3GS, or the simulator) sometimes we get
- an orientation change event with an unknown orientation. Those seem
- to always be immediately followed by another orientation change with
- a *real* orientation change, so let's try just ignoring those bogus
- ones and hoping that the real one comes in shortly...
- */
- if (current == UIDeviceOrientationUnknown)
- return;
-
- if (rotation_ratio >= 0) return; // in the midst of rotation animation
- if (orientation == current) return; // no change
-
- // When transitioning to FaceUp or FaceDown, pretend there was no change.
- if (current == UIDeviceOrientationFaceUp ||
- current == UIDeviceOrientationFaceDown)
- return;
-
- new_orientation = current; // current animation target
- rotation_ratio = 0; // start animating
- rot_start_time = double_time();
-
- switch (orientation) {
- case UIDeviceOrientationLandscapeLeft: angle_from = 90; break;
- case UIDeviceOrientationLandscapeRight: angle_from = 270; break;
- case UIDeviceOrientationPortraitUpsideDown: angle_from = 180; break;
- default: angle_from = 0; break;
- }
-
- switch (new_orientation) {
- case UIDeviceOrientationLandscapeLeft: angle_to = 90; break;
- case UIDeviceOrientationLandscapeRight: angle_to = 270; break;
- case UIDeviceOrientationPortraitUpsideDown: angle_to = 180; break;
- default: angle_to = 0; break;
- }
-
- switch (orientation) {
- case UIDeviceOrientationLandscapeRight: // from landscape
- case UIDeviceOrientationLandscapeLeft:
- rot_from.width = initial_bounds.height;
- rot_from.height = initial_bounds.width;
- break;
- default: // from portrait
- rot_from.width = initial_bounds.width;
- rot_from.height = initial_bounds.height;
- break;
- }
-
- switch (new_orientation) {
- case UIDeviceOrientationLandscapeRight: // to landscape
- case UIDeviceOrientationLandscapeLeft:
- rot_to.width = initial_bounds.height;
- rot_to.height = initial_bounds.width;
- break;
- default: // to portrait
- rot_to.width = initial_bounds.width;
- rot_to.height = initial_bounds.height;
- break;