Permalink
Browse files

Proper merge of theos-refactor

  • Loading branch information...
2 parents 6553849 + c3989ad commit cb7e67ed114273486a66dbb341acaa91babaa948 @rpetrich committed Aug 24, 2010
Showing with 109 additions and 101 deletions.
  1. +3 −3 PSWApplication.h
  2. +7 −7 PSWApplication.xm
  3. +44 −57 PSWApplicationController.xm
  4. +12 −13 PSWContainerView.xm
  5. +31 −9 PSWController.xm
  6. +8 −7 PSWResources.h
  7. +0 −1 PSWResources.xm
  8. +1 −1 PSWSurface.xm
  9. +1 −1 framework
  10. +2 −2 layout/DEBIAN/control
View
@@ -54,9 +54,9 @@ typedef enum {
@property (nonatomic, readonly) PSWCropInsets snapshotCropInsets;
@property (nonatomic, readonly) PSWSnapshotRotation snapshotRotation;
-- (void)loadSnapshotFromSurface:(IOSurfaceRef)surface;
-- (void)loadSnapshotFromSurface:(IOSurfaceRef)surface cropInsets:(PSWCropInsets)cropInsets;
-- (void)loadSnapshotFromSurface:(IOSurfaceRef)surface cropInsets:(PSWCropInsets)cropInsets rotation:(PSWSnapshotRotation)rotation;
+- (IOSurfaceRef)loadSnapshotFromSurface:(IOSurfaceRef)surface;
+- (IOSurfaceRef)loadSnapshotFromSurface:(IOSurfaceRef)surface cropInsets:(PSWCropInsets)cropInsets;
+- (IOSurfaceRef)loadSnapshotFromSurface:(IOSurfaceRef)surface cropInsets:(PSWCropInsets)cropInsets rotation:(PSWSnapshotRotation)rotation;
#endif
- (BOOL)writeSnapshotToDisk;
- (void)exit;
View
@@ -108,7 +108,7 @@ static NSUInteger defaultImagePassThrough;
}
#ifdef USE_IOSURFACE
-- (void)loadSnapshotFromSurface:(IOSurfaceRef)surface cropInsets:(PSWCropInsets)cropInsets rotation:(PSWSnapshotRotation)rotation
+- (IOSurfaceRef)loadSnapshotFromSurface:(IOSurfaceRef)surface cropInsets:(PSWCropInsets)cropInsets rotation:(PSWSnapshotRotation)rotation
{
if (surface != _surface) {
CGImageRelease(_snapshotImage);
@@ -128,29 +128,29 @@ static NSUInteger defaultImagePassThrough;
_cropInsets.right = 0;
if (surface) {
- CFRetain(surface);
- _surface = surface;
+ _surface = PSWSurfaceCopyToMainMemory(surface, 'L565', 2);
_cropInsets = cropInsets;
_snapshotRotation = rotation;
}
if ([_delegate respondsToSelector:@selector(applicationSnapshotDidChange:)])
[_delegate applicationSnapshotDidChange:self];
}
+ return _surface;
}
-- (void)loadSnapshotFromSurface:(IOSurfaceRef)surface cropInsets:(PSWCropInsets)cropInsets
+- (IOSurfaceRef)loadSnapshotFromSurface:(IOSurfaceRef)surface cropInsets:(PSWCropInsets)cropInsets
{
- [self loadSnapshotFromSurface:surface cropInsets:cropInsets rotation:PSWSnapshotRotationNone];
+ return [self loadSnapshotFromSurface:surface cropInsets:cropInsets rotation:PSWSnapshotRotationNone];
}
-- (void)loadSnapshotFromSurface:(IOSurfaceRef)surface
+- (IOSurfaceRef)loadSnapshotFromSurface:(IOSurfaceRef)surface
{
PSWCropInsets insets;
insets.top = 0;
insets.left = 0;
insets.bottom = 0;
insets.right = 0;
- [self loadSnapshotFromSurface:surface cropInsets:insets rotation:PSWSnapshotRotationNone];
+ return [self loadSnapshotFromSurface:surface cropInsets:insets rotation:PSWSnapshotRotationNone];
}
#endif
View
@@ -1,6 +1,5 @@
#import "PSWApplicationController.h"
-#import <CaptainHook/CaptainHook.h>
#import <SpringBoard/SpringBoard.h>
#import "PSWApplication.h"
@@ -121,6 +120,7 @@ static SBApplication *currentZoomApp;
static UIWindow *currentZoomStatusWindow;
%hook SBUIController
+
- (void)showZoomLayerWithIOSurfaceSnapshotOfApp:(SBApplication *)application includeStatusWindow:(UIWindow *)statusWindow
{
currentZoomApp = application;
@@ -129,78 +129,65 @@ static UIWindow *currentZoomStatusWindow;
currentZoomStatusWindow = nil;
currentZoomApp = nil;
}
+
%end
%hook SBZoomView
// 3.0-3.1
- (id)initWithSnapshotFrame:(CGRect)snapshotFrame ioSurface:(IOSurfaceRef)surface
{
- surface = PSWSurfaceCopyToMainMemory(surface, 'L565', 2);
- if ((self = %orig)) {
- PSWApplication *application = [[PSWApplicationController sharedInstance] applicationWithDisplayIdentifier:[currentZoomApp displayIdentifier]];
- PSWCropInsets insets;
- insets.top = 0;
- insets.left = 0;
- insets.bottom = 0;
- insets.right = 0;
- if (currentZoomStatusWindow) {
- CGRect frame = [currentZoomStatusWindow frame];
- CGSize screenSize = [[UIScreen mainScreen] bounds].size;
- if (frame.origin.y + frame.size.height < screenSize.height / 2.0f)
- insets.top = frame.size.height;
- else if (frame.origin.x + frame.size.width < screenSize.width / 2.0f)
- insets.left = frame.size.width;
- else if (frame.size.width > frame.size.height)
- insets.bottom = frame.size.height;
- else
- insets.right = frame.size.width;
- }
- [application loadSnapshotFromSurface:surface cropInsets:insets];
+ PSWApplication *application = [[PSWApplicationController sharedInstance] applicationWithDisplayIdentifier:[currentZoomApp displayIdentifier]];
+ PSWCropInsets insets;
+ insets.top = 0;
+ insets.left = 0;
+ insets.bottom = 0;
+ insets.right = 0;
+ if (currentZoomStatusWindow) {
+ CGRect frame = [currentZoomStatusWindow frame];
+ CGSize screenSize = [[UIScreen mainScreen] bounds].size;
+ if (frame.origin.y + frame.size.height < screenSize.height / 2.0f)
+ insets.top = frame.size.height;
+ else if (frame.origin.x + frame.size.width < screenSize.width / 2.0f)
+ insets.left = frame.size.width;
+ else if (frame.size.width > frame.size.height)
+ insets.bottom = frame.size.height;
+ else
+ insets.right = frame.size.width;
}
- if (surface)
- CFRelease(surface);
- return self;
+ surface = [application loadSnapshotFromSurface:surface cropInsets:insets];
+ return %orig;
}
// 3.2
- (id)initWithSnapshotFrame:(CGRect)snapshotFrame ioSurface:(IOSurfaceRef)surface transform:(CGAffineTransform)transform
{
- surface = PSWSurfaceCopyToMainMemory(surface, 'L565', 2);
- if ((self = %orig)) {
- PSWApplication *application = [[PSWApplicationController sharedInstance] applicationWithDisplayIdentifier:[currentZoomApp displayIdentifier]];
- PSWCropInsets insets;
- insets.top = 0;
- insets.left = 0;
- insets.bottom = 0;
- insets.right = 0;
- PSWSnapshotRotation rotation;
- switch (MSHookIvar<UIInterfaceOrientation>([$SBUIController sharedInstance], "_orientation")) {
- case UIInterfaceOrientationPortrait:
- rotation = PSWSnapshotRotation90Left;
- break;
- case UIInterfaceOrientationPortraitUpsideDown:
- rotation = PSWSnapshotRotation90Right;
- break;
- case UIInterfaceOrientationLandscapeLeft:
- rotation = PSWSnapshotRotation180;
- break;
- case UIInterfaceOrientationLandscapeRight:
- default:
- rotation = PSWSnapshotRotationNone;
- break;
- }
- [application loadSnapshotFromSurface:surface cropInsets:insets rotation:rotation];
+ PSWApplication *application = [[PSWApplicationController sharedInstance] applicationWithDisplayIdentifier:[currentZoomApp displayIdentifier]];
+ PSWCropInsets insets;
+ insets.top = 0;
+ insets.left = 0;
+ insets.bottom = 0;
+ insets.right = 0;
+ PSWSnapshotRotation rotation;
+ switch (MSHookIvar<UIInterfaceOrientation>([$SBUIController sharedInstance], "_orientation")) {
+ case UIInterfaceOrientationPortrait:
+ rotation = PSWSnapshotRotation90Left;
+ break;
+ case UIInterfaceOrientationPortraitUpsideDown:
+ rotation = PSWSnapshotRotation90Right;
+ break;
+ case UIInterfaceOrientationLandscapeLeft:
+ rotation = PSWSnapshotRotation180;
+ break;
+ case UIInterfaceOrientationLandscapeRight:
+ default:
+ rotation = PSWSnapshotRotationNone;
+ break;
}
- if (surface)
- CFRelease(surface);
- return self;
+ surface = [application loadSnapshotFromSurface:surface cropInsets:insets rotation:rotation];
+ return %orig;
}
%end
#endif
-
-
-
-
View
@@ -85,7 +85,7 @@ CGRect PSWProportionalInsetsInsetRect(CGRect rect, PSWProportionalInsets insets)
- (void)shouldExit
{
- [self.pageView shouldExit];
+ [_pageView shouldExit];
}
- (void)_applyInsets
@@ -157,19 +157,19 @@ CGRect PSWProportionalInsetsInsetRect(CGRect rect, PSWProportionalInsets insets)
- (void)setPageControlCount:(NSInteger)count
{
- [self.pageControl setNumberOfPages:count];
+ [_pageControl setNumberOfPages:count];
[self setIsEmpty:!count];
}
- (NSInteger)pageControlPage
{
- return [self.pageControl currentPage];
+ return [_pageControl currentPage];
}
- (void)setPageControlPage:(NSInteger)page
{
- [self.pageControl setCurrentPage:page];
+ [_pageControl setCurrentPage:page];
}
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
@@ -182,27 +182,27 @@ CGRect PSWProportionalInsetsInsetRect(CGRect rect, PSWProportionalInsets insets)
- (void)tapPreviousAndContinue
{
- [self.pageView movePrevious];
+ [_pageView movePrevious];
_shouldScrollOnUp = NO;
}
- (void)tapNextAndContinue
{
- [self.pageView moveNext];
+ [_pageView moveNext];
_shouldScrollOnUp = NO;
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint point = [touch locationInView:self];
- CGPoint offset = [self.pageView frame].origin;
+ CGPoint offset = [_pageView frame].origin;
point.x -= offset.x;
if (point.x <= 0.0f) {
[self performSelector:@selector(tapPreviousAndContinue) withObject:nil afterDelay:0.1f];
- } else if (point.x > [self.pageView bounds].size.width) {
+ } else if (point.x > [_pageView bounds].size.width) {
[self performSelector:@selector(tapNextAndContinue) withObject:nil afterDelay:0.1f];
}
@@ -225,7 +225,7 @@ CGRect PSWProportionalInsetsInsetRect(CGRect rect, PSWProportionalInsets insets)
UITouch *touch = [touches anyObject];
NSInteger tapCount = [touch tapCount];
CGPoint point = [touch locationInView:self];
- CGPoint offset = [self.pageView frame].origin;
+ CGPoint offset = [_pageView frame].origin;
point.x -= offset.x;
@@ -234,14 +234,14 @@ CGRect PSWProportionalInsetsInsetRect(CGRect rect, PSWProportionalInsets insets)
_doubleTapped = YES;
if (point.x <= 0.0f) {
- [self.pageView moveToStart];
+ [_pageView moveToStart];
} else {
- [self.pageView moveToEnd];
+ [_pageView moveToEnd];
}
} else if (_shouldScrollOnUp) {
if (point.x <= 0.0f) {
[self tapPreviousAndContinue];
- } else if (point.x > [self.pageView bounds].size.width) {
+ } else if (point.x > [_pageView bounds].size.width) {
[self tapNextAndContinue];
}
}
@@ -258,4 +258,3 @@ CGRect PSWProportionalInsetsInsetRect(CGRect rect, PSWProportionalInsets insets)
}
@end
-
View
@@ -116,9 +116,8 @@ static PSWController *sharedController;
[containerView setPageView:snapshotPageView];
[snapshotPageView setPageViewDelegate:self];
-
[containerView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
-
+
LAActivator *la = [$LAActivator sharedInstance];
if ([la respondsToSelector:@selector(hasSeenListenerWithName:)] && [la respondsToSelector:@selector(assignEvent:toListenerWithName:)])
if (![la hasSeenListenerWithName:@"com.collab.proswitcher"])
@@ -276,7 +275,8 @@ static PSWController *sharedController;
- (void)didFinishActivate
{
isAnimating = NO;
- [snapshotPageView layoutSubviews];
+ [containerView layoutSubviews];
+ [containerView setTransform:CGAffineTransformIdentity];
}
- (void)activateWithAnimation:(BOOL)animated
@@ -318,10 +318,10 @@ static PSWController *sharedController;
if (animated) {
[containerView setAlpha:0.0f];
- [snapshotPageView.layer setTransform:CATransform3DMakeScale(2.0f, 2.0f, 1.0f)];
+ [containerView setTransform:CGAffineTransformMakeScale(2.0f, 2.0f)];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5f];
- [snapshotPageView.layer setTransform:CATransform3DIdentity];
+ [containerView setTransform:CGAffineTransformIdentity];
}
if (GetPreference(PSWShowPageControl, BOOL))
@@ -346,7 +346,7 @@ static PSWController *sharedController;
{
[containerView removeFromSuperview];
[containerView setHidden:YES];
- [snapshotPageView.layer setTransform:CATransform3DIdentity];
+ [containerView setTransform:CGAffineTransformIdentity];
isAnimating = NO;
}
@@ -362,10 +362,10 @@ static PSWController *sharedController;
focusedApplication = [[snapshotPageView focusedApplication] retain];
if (animated) {
- [snapshotPageView.layer setTransform:CATransform3DIdentity];
+ [containerView setTransform:CGAffineTransformIdentity];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5f];
- [snapshotPageView.layer setTransform:CATransform3DMakeScale(2.0f, 2.0f, 1.0f)];
+ [containerView setTransform:CGAffineTransformMakeScale(2.0f, 2.0f)];
}
// Show SpringBoard's page control
@@ -504,6 +504,27 @@ static PSWController *sharedController;
@end
+@interface PSWController (Beta) <UIAlertViewDelegate>
+- (void)showBetaAlert;
+@end
+
+@implementation PSWController (Beta)
+
+- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
+{
+ if (buttonIndex != [alertView cancelButtonIndex])
+ [SBSharedInstance applicationOpenURL:[NSURL URLWithString:@"http://github.com/rpetrich/ProSwitcher/issues"]];
+}
+
+- (void)showBetaAlert
+{
+ UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"ProSwitcher Alpha" message:@"\"If debugging is the process of removing software bugs, then programming must be the process of putting them in.\" -- Edsger Dijkstra\n\nPlease help us get the bugs out :)" delegate:self cancelButtonTitle:@"Continue" otherButtonTitles:@"Report Bug", nil];
+ [av show];
+ [av release];
+}
+
+@end
+
#pragma mark Preference Changed Notification
static void PreferenceChangedCallback(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo)
{
@@ -565,10 +586,11 @@ static void PreferenceChangedCallback(CFNotificationCenterRef center, void *obse
PSWWriteBinaryPropertyList(plistDict, PSWPreferencesFilePath);
}
[plistDict release];
-
+
%orig;
sharedController = [[PSWController alloc] init];
+ [sharedController showBetaAlert];
if (GetPreference(PSWBecomeHomeScreen, NSInteger) != PSWBecomeHomeScreenDisabled)
[sharedController setActive:YES animated:NO];
Oops, something went wrong.

0 comments on commit cb7e67e

Please sign in to comment.