From eb4153674957e4f42d5bf9afd17093095182940f Mon Sep 17 00:00:00 2001 From: TrueZhuanjia Date: Mon, 21 Jul 2025 13:01:19 +0800 Subject: [PATCH] disable background hostCard update while streaming --- VoidLink/HostCardView.h | 1 + VoidLink/HostCardView.m | 4 +++- .../ViewControllers/MainFrameViewController.m | 17 ++++++++++++----- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/VoidLink/HostCardView.h b/VoidLink/HostCardView.h index b78f2e07..a7c903a2 100644 --- a/VoidLink/HostCardView.h +++ b/VoidLink/HostCardView.h @@ -16,6 +16,7 @@ - (void)wakeupButtonTappedForHost:(TemporaryHost *)host; - (void)pairButtonTappedForHost:(TemporaryHost *)host; - (void)hostCardLongPressed:(TemporaryHost *)host view:(UIView *)view; +- (bool)isStreaming; @end diff --git a/VoidLink/HostCardView.m b/VoidLink/HostCardView.m index 3a1b1d0e..85ed5a21 100644 --- a/VoidLink/HostCardView.m +++ b/VoidLink/HostCardView.m @@ -509,10 +509,12 @@ static const float REFRESH_CYCLE = 2.0f; return; } + NSLog(@"hostCard update loop %f", CACurrentMediaTime()); + [self updateContentsForHost:_host]; // Queue the next refresh cycle - [self performSelector:@selector(updateLoop) withObject:self afterDelay:REFRESH_CYCLE]; + if(![self.delegate isStreaming]) [self performSelector:@selector(updateLoop) withObject:self afterDelay:REFRESH_CYCLE]; } - (void) updateContentsForHost:(TemporaryHost*)host { diff --git a/VoidLink/ViewControllers/MainFrameViewController.m b/VoidLink/ViewControllers/MainFrameViewController.m index 711af1a0..46f7f0b9 100644 --- a/VoidLink/ViewControllers/MainFrameViewController.m +++ b/VoidLink/ViewControllers/MainFrameViewController.m @@ -69,6 +69,7 @@ NSCache* _boxArtCache; bool _background; bool _enteredAppView; + bool _settingsViewExpanded; UIView* menuSeparator; UIView* snapshot; SettingsViewController* settingsViewController; @@ -1119,6 +1120,7 @@ static NSMutableSet* hostList; - (void)revealController:(SWRevealViewController *)revealController willMoveToPosition:(FrontViewPosition)position { settingsViewController = (SettingsViewController*)[revealController rearViewController]; revealController.navBarMenuDelegate = settingsViewController; + _settingsViewExpanded = position != FrontViewPositionLeft; if (position == FrontViewPositionLeft) { self.navigationItem.leftBarButtonItems = @[_settingsButton]; } @@ -1788,11 +1790,12 @@ static NSMutableSet* hostList; [super viewWillAppear:NO]; /* this makes background color works*/ - /* - for (UIView *subview in self.view.subviews) { - [subview removeFromSuperview]; // 暂时移除所有子视图 - }*/ - + + if(!_settingsViewExpanded){ + for (UIView *subview in self.view.subviews) { + [subview removeFromSuperview]; // 暂时移除所有子视图 + } + } // We can get here on home press while streaming // since the stream view segues to us just before @@ -2008,6 +2011,10 @@ static NSMutableSet* hostList; return !self.revealViewController.isStreaming && _enteredAppView; } +- (bool)isStreaming{ + return self.revealViewController.isStreaming; +} + - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { UICollectionViewCell* cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"AppCell" forIndexPath:indexPath];