streamview bug fixes

This commit is contained in:
True Zhuanjia committed 2026-05-11 12:43:45 +08:00
1 parent 94f61ebf0c
commit 237f03a501
4 files changed
+73 -11

No files matched your search

-1
View File
@@ -42,7 +42,6 @@
@property (assign, nonatomic) bool widgetToolOpened; @property (assign, nonatomic) bool widgetToolOpened;
@property (strong, nonatomic) OnScreenControls* onScreenControls; @property (strong, nonatomic) OnScreenControls* onScreenControls;
@property (weak, nonatomic) PencilHandler* pencilHandler; @property (weak, nonatomic) PencilHandler* pencilHandler;
@property (weak, nonatomic) UIViewController* streamFrameVC;
- (void) setupStreamViewWithControllerSupport:(ControllerSupport*)controllerSupport - (void) setupStreamViewWithControllerSupport:(ControllerSupport*)controllerSupport
interactionDelegate:(id<UserInteractionDelegate>)interactionDelegate interactionDelegate:(id<UserInteractionDelegate>)interactionDelegate
+54 -8
View File
@@ -29,9 +29,13 @@
#import "StreamFrameViewController.h" #import "StreamFrameViewController.h"
static const double X1_MOUSE_SPEED_DIVISOR = 2.5; @interface StreamView()
@property (weak, nonatomic) StreamFrameViewController* streamFrameVC;
@end
static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
/* /*
Stream Video has been moved out of this class to _renderView in StreamFrameViewController. Stream Video has been moved out of this class to _renderView in StreamFrameViewController.
*/ */
@@ -664,14 +668,12 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
} }
} }
StreamFrameViewController* streamFrameVC = (StreamFrameViewController*)_streamFrameVC;
newProfile.unfoldedExclusiveFolderSequence = OnScreenWidgetView.unfoldedExclusiveFolderSequence; newProfile.unfoldedExclusiveFolderSequence = OnScreenWidgetView.unfoldedExclusiveFolderSequence;
newProfile.postExclusiveUnfoldedSequences = OnScreenWidgetView.postExclusiveUnfoldedSequences; newProfile.postExclusiveUnfoldedSequences = OnScreenWidgetView.postExclusiveUnfoldedSequences;
newProfile.gamepadOverlayEnabled = streamFrameVC.virtualGamepadOverlay != nil; newProfile.gamepadOverlayEnabled = _streamFrameVC.virtualGamepadOverlay != nil;
newProfile.normalizedStreamViewOffset = CGPointMake(streamFrameVC.streamViewMagnifierContentOffset.x/self.bounds.size.width, streamFrameVC.streamViewMagnifierContentOffset.y/self.bounds.size.height); newProfile.normalizedStreamViewOffset = CGPointMake(_streamFrameVC.streamViewMagnifierContentOffset.x/self.bounds.size.width, _streamFrameVC.streamViewMagnifierContentOffset.y/self.bounds.size.height);
newProfile.streamViewScale = streamFrameVC.streamViewMagnifierZoomScale; newProfile.streamViewScale = _streamFrameVC.streamViewMagnifierZoomScale;
[oscProfileMan replaceSelectedProfileWith:newProfile overwriteDefault:YES]; [oscProfileMan replaceSelectedProfileWith:newProfile overwriteDefault:YES];
} }
@@ -689,7 +691,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
MotionHandler* motionHandler = [MotionHandler sharedWithProfile:profile]; MotionHandler* motionHandler = [MotionHandler sharedWithProfile:profile];
// get streamFrameVC // get streamFrameVC
if(!self->_streamFrameVC) self->_streamFrameVC = [GenericUtils parentViewControllerForView:self]; if(!self.streamFrameVC) self.streamFrameVC = (StreamFrameViewController* )[GenericUtils parentViewControllerForView:self];
/* /*
if (@available(iOS 13.0, *)) { if (@available(iOS 13.0, *)) {
@@ -843,7 +845,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
[PencilHandler.shared setupPressureLUTWithProfile:profile]; [PencilHandler.shared setupPressureLUTWithProfile:profile];
} }
[(StreamFrameViewController* )self->_streamFrameVC restorePersistedStreamViewOffsetAndScaleWithProfile:profile]; [self.streamFrameVC restorePersistedStreamViewOffsetAndScaleWithProfile:profile];
[self updateTouchHandlerWithProfile:profile]; [self updateTouchHandlerWithProfile:profile];
}); });
} }
@@ -1280,7 +1282,36 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
} }
} }
- (BOOL)isOptionVerticalArrowPress:(UIPress *)press {
if (@available(iOS 13.4, tvOS 13.4, *)) {
UIKey *key = press.key;
if (key == nil) {
return NO;
}
return key.modifierFlags == UIKeyModifierAlternate &&
(key.keyCode == UIKeyboardHIDUsageKeyboardUpArrow ||
key.keyCode == UIKeyboardHIDUsageKeyboardDownArrow);
}
return NO;
}
- (void)pressesBegan:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event { - (void)pressesBegan:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event {
if (@available(iOS 17.0, *)) nil;
else {
BOOL shouldBypassMagnifierInset = NO;
for (UIPress *press in presses) {
if ([self isOptionVerticalArrowPress:press]) {
shouldBypassMagnifierInset = YES;
break;
}
}
if (shouldBypassMagnifierInset) {
_streamFrameVC.scrollView.contentInset = UIEdgeInsetsZero;
}
}
BOOL handled = NO; BOOL handled = NO;
if (@available(iOS 13.4, tvOS 13.4, *)) { if (@available(iOS 13.4, tvOS 13.4, *)) {
@@ -1301,6 +1332,21 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
} }
- (void)pressesEnded:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event { - (void)pressesEnded:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event {
if (@available(iOS 17.0, *)) nil;
else {
BOOL shouldRestoreMagnifierMetrics = NO;
for (UIPress *press in presses) {
if ([self isOptionVerticalArrowPress:press]) {
shouldRestoreMagnifierMetrics = YES;
break;
}
}
if (shouldRestoreMagnifierMetrics) {
[_streamFrameVC updateMagnifierViewportMetrics];
[_streamFrameVC resetMagnifierStreamViewWithAnimated:NO];
}
}
BOOL handled = NO; BOOL handled = NO;
if (@available(iOS 13.4, tvOS 13.4, *)) { if (@available(iOS 13.4, tvOS 13.4, *)) {
@@ -42,6 +42,7 @@
@property (nonatomic, strong) MetalViewController *metalViewController; @property (nonatomic, strong) MetalViewController *metalViewController;
@property (nonatomic, strong) ImGuiRenderer *imguiView; @property (nonatomic, strong) ImGuiRenderer *imguiView;
@property (nonatomic, strong) UIView* virtualGamepadOverlay; @property (nonatomic, strong) UIView* virtualGamepadOverlay;
@property (nonatomic, strong) UIScrollView* scrollView;
@property (nonatomic, assign) CGPoint streamViewMagnifierContentOffset; @property (nonatomic, assign) CGPoint streamViewMagnifierContentOffset;
@property (nonatomic, assign) CGFloat streamViewMagnifierZoomScale; @property (nonatomic, assign) CGFloat streamViewMagnifierZoomScale;
@@ -55,5 +56,6 @@
- (void)toggleGamepadOverlayWithOverlayEnabled:(BOOL)overlayEnabled API_AVAILABLE(ios(13.0)); - (void)toggleGamepadOverlayWithOverlayEnabled:(BOOL)overlayEnabled API_AVAILABLE(ios(13.0));
- (void)loadAbstractGamepadOverlayIfNeeded API_AVAILABLE(ios(13.0)); - (void)loadAbstractGamepadOverlayIfNeeded API_AVAILABLE(ios(13.0));
- (void)restorePersistedStreamViewOffsetAndScaleWithProfile:(OSCProfile* )profile; - (void)restorePersistedStreamViewOffsetAndScaleWithProfile:(OSCProfile* )profile;
- (void)updateMagnifierViewportMetrics;
@end @end
@@ -61,7 +61,6 @@
UILabel *_tipLabel; UILabel *_tipLabel;
UIActivityIndicatorView *_spinner; UIActivityIndicatorView *_spinner;
StreamView *_streamView; StreamView *_streamView;
UIScrollView *_scrollView;
BOOL _magnifierViewportInteractionActive; BOOL _magnifierViewportInteractionActive;
BOOL _userIsInteracting; BOOL _userIsInteracting;
bool viewIsBeingResized; bool viewIsBeingResized;
@@ -391,6 +390,9 @@
} }
BOOL interactionEnabled = _magnifierViewportInteractionActive; BOOL interactionEnabled = _magnifierViewportInteractionActive;
if (@available(iOS 17.0, *)) {
_scrollView.allowsKeyboardScrolling = false;
}
_scrollView.scrollEnabled = interactionEnabled; _scrollView.scrollEnabled = interactionEnabled;
_scrollView.panGestureRecognizer.enabled = interactionEnabled; _scrollView.panGestureRecognizer.enabled = interactionEnabled;
_scrollView.pinchGestureRecognizer.enabled = interactionEnabled; _scrollView.pinchGestureRecognizer.enabled = interactionEnabled;
@@ -441,16 +443,29 @@
[self syncMagnifierStateFromScrollView]; [self syncMagnifierStateFromScrollView];
} }
- (void)handleScrollPan:(UIPanGestureRecognizer *)gesture {
switch (gesture.state){
case UIGestureRecognizerStateEnded:
if(_settings.touchMode.intValue == AbsoluteTouch && _scrollView.zoomScale < 1.0) [self resetMagnifierStreamViewWithAnimated:true];
break;
default:
break;
}
}
- (void)configZoomGestureAndAddStreamView{ - (void)configZoomGestureAndAddStreamView{
BOOL shouldWrapInScrollView = [self shouldWrapStreamViewInScrollView]; BOOL shouldWrapInScrollView = [self shouldWrapStreamViewInScrollView];
if (shouldWrapInScrollView) { if (shouldWrapInScrollView) {
if(!_scrollView) _scrollView = [[UIScrollView alloc] initWithFrame:self.view.frame]; if(!_scrollView) _scrollView = [[UIScrollView alloc] initWithFrame:self.view.frame];
_scrollView.scrollsToTop = false;
_scrollView.frame = self.view.bounds; _scrollView.frame = self.view.bounds;
_scrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; _scrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
#if !TARGET_OS_TV #if !TARGET_OS_TV
[_scrollView.panGestureRecognizer setMinimumNumberOfTouches:2]; [_scrollView.panGestureRecognizer setMinimumNumberOfTouches:2];
[_scrollView.panGestureRecognizer setMaximumNumberOfTouches:2]; // reduce competing with keyboardToggleRecognizer in StreamView. [_scrollView.panGestureRecognizer setMaximumNumberOfTouches:2]; // reduce competing with keyboardToggleRecognizer in StreamView.
[_scrollView.panGestureRecognizer addTarget:self
action:@selector(handleScrollPan:)];
#endif #endif
[_scrollView setShowsHorizontalScrollIndicator:NO]; [_scrollView setShowsHorizontalScrollIndicator:NO];
[_scrollView setShowsVerticalScrollIndicator:NO]; [_scrollView setShowsVerticalScrollIndicator:NO];
@@ -1004,7 +1019,7 @@
} }
- (void)setMagnifierViewportInteractionEnabled:(BOOL)enabled { - (void)setMagnifierViewportInteractionEnabled:(BOOL)enabled {
_magnifierViewportInteractionActive = enabled; _magnifierViewportInteractionActive = enabled || _settings.touchMode.intValue == AbsoluteTouch;
[self updateScrollViewInteractionState]; [self updateScrollViewInteractionState];
} }