- notification lifecycle fixes - replace some notifications with delegates

- fix osw profile switch issue
This commit is contained in:
TrueZhuanjia committed 2025-06-22 21:25:29 +08:00
1 parent cd6e08956c
commit 6bc142a07b
12 files changed
+89 -96

No files matched your search

@@ -34,7 +34,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
- (void) updateGuidelinesForOnScreenWidget:(OnScreenWidgetView* )widget;
- (void)updateGuidelinesForOnScreenWidget:(OnScreenWidgetView* )widget;
@end
NS_ASSUME_NONNULL_END
@@ -32,11 +32,6 @@
- (id) initWithView:(UIView*)view controllerSup:(ControllerSupport*)controllerSupport streamConfig:(StreamConfiguration*)streamConfig oscLevel:(int)oscLevel {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleMovingOnScreenWidgetNotification:)
name:@"OnScreenWidgetMovedByTouch"
object:nil];
_view = view;
_view.multipleTouchEnabled = false;
@@ -121,12 +116,7 @@
[self._view addSubview: verticalGuideline];
}
- (void) handleMovingOnScreenWidgetNotification: (NSNotification *)notification{
OnScreenWidgetView* widget = notification.object;
[self updateGuidelinesForOnScreenWidget:widget];
}
- (void) updateGuidelinesForOnScreenWidget: (OnScreenWidgetView* )widget{
- (void)updateGuidelinesForOnScreenWidget:(OnScreenWidgetView* )widget{
/* have guidelines follow wherever the user is touching on the screen */
horizontalGuideline.hidden = verticalGuideline.hidden = NO;
horizontalGuideline.center = verticalGuideline.center = CGPointMake(CGRectGetMidX(widget.frame), CGRectGetMidY(widget.frame));
@@ -349,5 +339,4 @@
}
@end
+7 -1
View File
@@ -19,6 +19,12 @@ import UIKit
}
}
@objc protocol OnScreenWidgetGuidelineUpdateDelegate: AnyObject {
func updateGuidelinesForOnScreenWidget(_ sender: Any)
}
@objc public weak var guidelineDelegate: OnScreenWidgetGuidelineUpdateDelegate?
enum WidgetTypeEnum: UInt8 {
case uninitialized = 0
case button = 1
@@ -1079,7 +1085,7 @@ import UIKit
// center = currentLocation;
//NSLog("x coord: %f, y coord: %f", self.frame.origin.x, self.frame.origin.y)
if OnScreenWidgetView.editMode {
NotificationCenter.default.post(name: Notification.Name("OnScreenWidgetMovedByTouch"), object:self) // inform the layoutOnScreenControl to update guideLines for this widget view
guidelineDelegate?.updateGuidelinesForOnScreenWidget(self)
}
}
+10 -6
View File
@@ -18,12 +18,12 @@
@protocol UserInteractionDelegate <NSObject>
- (void) userInteractionBegan;
- (void) userInteractionEnded;
- (void) streamExitRequested;
- (void) toggleStatsOverlay;
- (void) localMousePointerMode;
- (void) toggleMouseVisible;
- (void)userInteractionBegan;
- (void)userInteractionEnded;
- (void)streamExitRequested;
- (void)toggleStatsOverlay;
- (void)localMousePointerMode;
- (void)toggleMouseVisible;
@end
@@ -57,6 +57,10 @@
- (OnScreenControlsLevel) getCurrentOscState;
- (void)keyboardWillShow:(NSNotification *)notification;
- (void)keyboardWillHide;
#if !TARGET_OS_TV
- (void) updateCursorLocation:(CGPoint)location isMouse:(BOOL)isMouse;
#endif
+3 -12
View File
@@ -104,15 +104,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
keyboardToggleRecognizer.tapDownTimeThreshold = 0.2; // tap down time threshold in seconds.
keyboardToggleRecognizer.delaysTouchesBegan = NO;
keyboardToggleRecognizer.delaysTouchesEnded = NO;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillHide:)
name:UIKeyboardWillHideNotification
object:nil];
NSLog(@"setup streamView %f", CACurrentMediaTime());
// if(settings.touchMode.intValue == NativeTouchOnly) [self addGestureRecognizer:keyboardToggleRecognizer]; //keep legacy approach in pure native mode
// else [self->streamFrameTopLayerView addGestureRecognizer:keyboardToggleRecognizer]; //add to the superview in other modes
@@ -233,11 +225,11 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
self.frame = liftedStreamFrame;
isInputingText = true;
}
// NSLog(@"keyboard will show");
NSLog(@"keyboard will show %f", CACurrentMediaTime());
}
// this method also deals with recovering streamview when local keyboard is turned off
- (void)keyboardWillHide:(NSNotification *)notification{
- (void)keyboardWillHide{
if(isInputingText){
CGRect liftedStreamFrame = self.frame;
@@ -246,7 +238,6 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
self.frame = liftedStreamFrame;
isInputingText = false;
}
// NSLog(@"keyboard will hide");
}