1 /* xscreensaver, Copyright (c) 2006-2013 Jamie Zawinski <jwz@jwz.org>
3 * Permission to use, copy, modify, distribute, and sell this software and its
4 * documentation for any purpose is hereby granted without fee, provided that
5 * the above copyright notice appear in all copies and that both that
6 * copyright notice and this permission notice appear in supporting
7 * documentation. No representations are made about the suitability of this
8 * software for any purpose. It is provided "as is" without express or
12 /* This is a subclass of Apple's ScreenSaverView that knows how to run
13 xscreensaver programs without X11 via the dark magic of the "jwxyz"
14 library. In xscreensaver terminology, this is the replacement for
15 the "screenhack.c" module.
19 # import <Foundation/Foundation.h>
20 # import <UIKit/UIKit.h>
21 # define NSView UIView
22 # define NSRect CGRect
23 # define NSSize CGSize
24 # define NSColor UIColor
25 # define NSImage UIImage
26 # define NSEvent UIEvent
27 # define NSWindow UIWindow
29 # import <Cocoa/Cocoa.h>
30 # import <ScreenSaver/ScreenSaver.h>
34 #import "screenhackI.h"
35 #import "PrefsReader.h"
38 @interface ScreenSaverView : NSView
39 - (id)initWithFrame:(NSRect)frame isPreview:(BOOL)isPreview;
40 - (NSTimeInterval)animationTimeInterval;
41 - (void)setAnimationTimeInterval:(NSTimeInterval)timeInterval;
42 - (void)startAnimation;
43 - (void)stopAnimation;
45 - (void)animateOneFrame;
46 - (BOOL)hasConfigureSheet;
47 //- (NSWindow*)configureSheet;
48 - (UIViewController*)configureView;
55 #define USE_BACKBUFFER // must be in sync with jwxyz.m
56 #define USE_CALAYER // requires USE_BACKBUFFER; required by iOS.
58 @interface XScreenSaverView : ScreenSaverView
63 struct xscreensaver_function_table *xsft;
64 PrefsReader *prefsReader;
66 BOOL setup_p; // whether xsft->setup_cb() has been run
67 BOOL initted_p; // whether xsft->init_cb() has been run
68 BOOL resized_p; // whether to run the xsft->reshape_cb() soon
69 double next_frame_time; // time_t in milliseconds of when to tick the frame
71 // Data used by the Xlib-flavored screensaver
78 UIDeviceOrientation orientation, new_orientation;
83 CGSize initial_bounds;
85 GLfloat rotation_ratio; // ratio thru rotation anim, or -1
86 NSSize rot_from, rot_to; // start size rect, end size rect
87 GLfloat angle_from, angle_to; // start angle, end angle
88 double rot_start_time;
89 BOOL ignore_rotation_p;
91 NSSize rot_current_size;
92 GLfloat rot_current_angle;
96 NSDictionary *function_tables;
100 # ifdef USE_BACKBUFFER
101 CGContextRef backbuffer;
102 CGSize backbuffer_size;
103 CGColorSpaceRef colorspace;
106 CGContextRef window_ctx;
109 # endif // USE_BACKBUFFER
112 - (id)initWithFrame:(NSRect)frame saverName:(NSString*)n isPreview:(BOOL)p;
115 - (void) prepareContext;
116 - (void) resizeContext;
117 - (NSUserDefaultsController *) userDefaultsController;
118 + (NSString *) decompressXML:(NSData *)xml;
121 - (void)didRotate:(NSNotification *)notification;
122 - (void)setScreenLocked:(BOOL)locked;
125 #ifdef USE_BACKBUFFER
127 - (void)createBackbuffer;
128 #endif // USE_BACKBUFFER