static_cast<type>(~type())
static bool menu_;
-static unsigned lock_;
static _H<NSArray> settings_;
static _H<NSArray> cydgets_;
@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) {