From a143e10b699d5453da1a6d6b8feadc370846acc0 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Fri, 24 Jan 2014 15:37:31 -0800 Subject: [PATCH] Separate logic from @media evaluator for reuse. --- LockScreen.mm | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/LockScreen.mm b/LockScreen.mm index 42d8f1e..5429de0 100644 --- a/LockScreen.mm +++ b/LockScreen.mm @@ -1028,16 +1028,24 @@ struct MediaQueryExp { String cache_; }; } +bool CYHaveMediaControls() { + SBLockScreenView *view([[[$SBLockScreenManager sharedInstance] lockScreenViewController] lockScreenView]); + return view != nil && ![view mediaControlsHidden]; + //return [[[$SBLockScreenManager sharedInstance] lockScreenViewController] isShowingMediaControls]; +} + +bool CYHaveNotificationList() { + SBLockScreenNotificationListController *controller([[[$SBLockScreenManager sharedInstance] lockScreenViewController] _notificationController]); + return controller != nil && [controller hasAnyContent]; +} + MSHook(bool, _ZNK7WebCore19MediaQueryEvaluator4evalEPKNS_13MediaQueryExpE, WebCore::MediaQueryEvaluator *_this, WebCore::String &query) { - Log(query); if (false) { - } else if (kCFCoreFoundationVersionNumber >= 800 && StringEquals(query, "cydget-media-controls")) { - SBLockScreenView *view([[[$SBLockScreenManager sharedInstance] lockScreenViewController] lockScreenView]); - return view != nil && ![view mediaControlsHidden]; - //return [[[$SBLockScreenManager sharedInstance] lockScreenViewController] isShowingMediaControls]; - } else if (kCFCoreFoundationVersionNumber >= 800 && StringEquals(query, "cydget-notification-list")) { - SBLockScreenNotificationListController *controller([[[$SBLockScreenManager sharedInstance] lockScreenViewController] _notificationController]); - return controller != nil && [controller hasAnyContent]; - } else + Log(query); if (false); + else if (kCFCoreFoundationVersionNumber >= 800 && StringEquals(query, "cydget-media-controls")) + return CYHaveMediaControls(); + else if (kCFCoreFoundationVersionNumber >= 800 && StringEquals(query, "cydget-notification-list")) + return CYHaveNotificationList(); + else return __ZNK7WebCore19MediaQueryEvaluator4evalEPKNS_13MediaQueryExpE(_this, query); } -- 2.45.2