]> git.saurik.com Git - cydget.git/commitdiff
Reorganize state machine (again).
authorJay Freeman (saurik) <saurik@saurik.com>
Tue, 29 Mar 2011 08:10:54 +0000 (08:10 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Tue, 29 Mar 2011 08:10:54 +0000 (08:10 +0000)
LockScreen.mm
Tweak.mm

index f82f7e71a9f294caf56b97da0737ffca96283671..3d1f4618db9b5e9851c6e52a1607b96cc74d19a7 100644 (file)
@@ -113,7 +113,6 @@ while (false)
 static Class $CydgetController(objc_getClass("CydgetController"));
 
 MSClassHook(UIWebBrowserView)
-MSClassHook(SBAwayView)
 
 static bool Wildcat_, iOS4;
 
@@ -239,10 +238,6 @@ static float CYScrollViewDecelerationRateNormal;
 
 @end
 
-MSInstanceMessageHook0(UIView *, SBAwayView, inputView) {
-    return [[[UIView alloc] init] autorelease];
-}
-
 @interface WebCydgetLockScreenView : UIView {
     CydgetWebView *webview_;
     UIScrollView *scroller_;
index be0da285ea129255c2a52f6e2d4f277376c770c3..361223f1cde0985a9f311117555eec12ff4fc92c 100644 (file)
--- a/Tweak.mm
+++ b/Tweak.mm
 #import <SpringBoard/SpringBoard.h>
 
 MSClassHook(SpringBoard)
+
 MSClassHook(SBAwayController)
 MSClassHook(SBAwayView)
+MSClassHook(SBAwayViewController)
 MSClassHook(SBAwayWindow)
 
 #define _trace() \
@@ -100,29 +102,43 @@ MSClassHook(UIPeripheralHost)
 
 - (void) enableCydget:(SBAwayController *)away {
     if (NSString *plugin = [self objectForKey:@"CYPlugin"] ?: [self objectForKey:@"Plugin"]) {
+        ++online_;
         UIKeyboardEnableAutomaticAppearance();
+
         [[$UIPeripheralHost sharedInstance] createAutomaticKeyboardIfNeeded];
         [[UITextEffectsWindow sharedTextEffectsWindow] setWindowLevel:1000];
 
         [away enableLockScreenBundleWithName:plugin];
-        ++online_;
     }
 }
 
 - (void) disableCydget:(SBAwayController *)away {
     if (NSString *plugin = [self objectForKey:@"CYPlugin"] ?: [self objectForKey:@"Plugin"]) {
-        --online_;
         [away disableLockScreenBundleWithName:plugin];
 
         [$UIPeripheralHost _releaseSharedInstance];
+
         UIKeyboardDisableAutomaticAppearance();
+        --online_;
     }
 }
 
 @end
 
+// avoid rendering a keyboard onto the default SBAwayView while automatic keyboard is online
+MSInstanceMessageHook0(UIView *, SBAwayView, inputView) {
+    if (online_ == 0)
+        return MSOldCall();
+
+    return [[[UIView alloc] init] autorelease];
+}
+
+// by default, keyboard actions are redirected to SBAwayController and press menu button
 MSInstanceMessageHook1(void, SpringBoard, handleKeyEvent, GSEventRef, event) {
-    MSSuperCall(event);
+    if (online_ == 0)
+        return MSOldCall(event);
+
+    return MSSuperCall(event);
 }
 
 MSInstanceMessageHook0(BOOL, SBAwayController, handleMenuButtonTap) {
@@ -137,8 +153,9 @@ MSInstanceMessageHook0(BOOL, SBAwayController, handleMenuButtonTap) {
 
 MSInstanceMessageHook0(void, SBAwayController, _undimScreen) {
     menu_ = false;
-    [[cydgets_ objectAtIndex:active_] enableCydget:[$SBAwayController sharedAwayController]];
-    MSOldCall();
+    [[cydgets_ objectAtIndex:active_] enableCydget:self];
+    [[[self awayView] window] makeKeyWindow];
+    return MSOldCall();
 }
 
 static void Deactivate_(SBAwayController *self) {
@@ -157,14 +174,16 @@ MSInstanceMessageHook1(void, SpringBoard, menuButtonUp, GSEventRef, event) {
 }
 
 MSInstanceMessageHook1(void, SBAwayView, addGestureRecognizer, id, recognizer) {
-    // MSOldCall(recognizer);
+    if (online_ == 0)
+        return MSOldCall(recognizer);
 }
 
 MSInstanceMessageHook1(void, SBAwayWindow, sendGSEvent, GSEventRef, event) {
-    if (online_ != 0)
-        MSSuperCall(event);
-    else
-        MSOldCall(event);
+    NSLog(@"sendGSEvent");
+    if (online_ == 0)
+        return MSOldCall(event);
+
+    return MSSuperCall(event);
 }
 
 #define Cydgets_ @"/System/Library/LockCydgets"