From 1b616711f37f1c9dd41b99d15f7fe7682250dab4 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sun, 24 Oct 2010 10:41:50 +0000 Subject: [PATCH] Simplified 4.x-compatible menu state-machine. --- Tweak.mm | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/Tweak.mm b/Tweak.mm index d0f12d9..5b8e843 100644 --- a/Tweak.mm +++ b/Tweak.mm @@ -57,7 +57,6 @@ MSClassHook(SBAwayWindow) static_cast(~type()) static bool menu_; -static unsigned lock_; static _H settings_; static _H cydgets_; @@ -104,54 +103,34 @@ static unsigned online_; @end MSInstanceMessageHook0(BOOL, SBAwayController, handleMenuButtonTap) { - unsigned lock(lock_); - - if (!MSOldCall() && lock != 2) { + if (!MSOldCall() && menu_) { [[cydgets_ objectAtIndex:active_] disableCydget:self]; active_ = (active_ + 1) % [cydgets_ count]; [[cydgets_ objectAtIndex:active_] enableCydget:self]; - } else if (lock == 2) - lock_ = 0; + } return YES; } MSInstanceMessageHook0(void, SBAwayController, _undimScreen) { - if (lock_ == 1) - lock_ = 2; + menu_ = false; [[cydgets_ objectAtIndex:active_] enableCydget:[$SBAwayController sharedAwayController]]; MSOldCall(); } -MSInstanceMessageHook0(void, SBAwayController, undimScreen) { - if (lock_ != 2) - lock_ = menu_ ? 1 : 0; - MSOldCall(); -} - static void Deactivate_(SBAwayController *self) { [[cydgets_ objectAtIndex:active_] disableCydget:self]; active_ = 0; } -#define MSNotificationHook(notification) \ - static void N_mas(); \ - static void burple(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef info) { \ - N_mas(); \ - } \ - static class N_MSq { public: _finline N_MSq() { \ - CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, &burple, CFSTR(notification), NULL, 0); \ - } } n_msq; \ - static void N_mas() - -MSNotificationHook("SBDidTurnOffDisplayNotification") { +MSInstanceMessageHook1(void, SBAwayController, dimScreen, BOOL, dim) { Deactivate_([$SBAwayController sharedAwayController]); + MSOldCall(dim); } MSInstanceMessageHook1(void, SpringBoard, menuButtonUp, GSEventRef, event) { menu_ = true; MSOldCall(event); - menu_ = false; } MSInstanceMessageHook1(void, SBAwayView, addGestureRecognizer, id, recognizer) { -- 2.7.4