widget layering fixes

This commit is contained in:
True Zhuanjia committed 2026-05-21 19:44:28 +08:00
1 parent 843570dbca
commit 5f4fe6a040
3 files changed
+31 -17

No files matched your search

+19 -2
View File
@@ -453,7 +453,7 @@ import ObjectiveC.runtime
if !self.cmdString.contains("+"){ if !self.cmdString.contains("+"){
// 安全解包并处理 `comboKeyStrings` // 安全解包并处理 `comboKeyStrings`
if var comboStrings = CommandManager.shared.extractCmdStrings(from: self.cmdString) { if let comboStrings = CommandManager.shared.extractCmdStrings(from: self.cmdString) {
if CommandManager.touchPadCmds.contains(comboStrings.first ?? "") {self.widgetType = WidgetTypeEnum.touchPad} if CommandManager.touchPadCmds.contains(comboStrings.first ?? "") {self.widgetType = WidgetTypeEnum.touchPad}
else {self.widgetType = WidgetTypeEnum.button} else {self.widgetType = WidgetTypeEnum.button}
@@ -3932,6 +3932,23 @@ import ObjectiveC.runtime
isRestoringFolderStates = false isRestoringFolderStates = false
} }
@objc static func getDeepestButton() -> OnScreenWidgetView?{
var maxIndex: Int = Int.max
var deepestButton: OnScreenWidgetView?
for widget in OnScreenWidgetView.mapping.values.filter({ $0.widgetType == .button}){
let currentIndex = widget.superview?.subviews.firstIndex(of: widget)
if let currentIndex = currentIndex {
if currentIndex < maxIndex {
maxIndex = currentIndex
deepestButton = widget
}
}
else {continue}
}
OnScreenWidgetView.deepestButton = deepestButton
return deepestButton
}
@objc static func getMaxSequence() -> Int16{ @objc static func getMaxSequence() -> Int16{
return OnScreenWidgetView.mapping.keys.max() ?? -1 return OnScreenWidgetView.mapping.keys.max() ?? -1
} }
@@ -4052,7 +4069,7 @@ import ObjectiveC.runtime
} }
deinit { deinit {
print("onScreenWidgetView deinit \(self.widgetLabel) \(CACurrentMediaTime())") print("onScreenWidgetView deinit \(self.widgetLabel))")
} }
} }
+2 -15
View File
@@ -805,21 +805,8 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
[self->oscProfileMan replaceSelectedProfileWith:profile overwriteDefault:YES]; [self->oscProfileMan replaceSelectedProfileWith:profile overwriteDefault:YES];
} }
uint64_t buttonIndex = 9999999; OnScreenWidgetView.deepestButton = nil;
UIView* deepestButton; UIView* deepestButton = [OnScreenWidgetView getDeepestButton];
for (UIView *subview in self->_streamFrameTopLayerView.subviews) {
if ([subview isKindOfClass:[OnScreenWidgetView class]]) {
OnScreenWidgetView* widget = (OnScreenWidgetView* ) subview;
if(widget.widgetType == WidgetTypeEnumButton){
uint64_t index = [self->_streamFrameTopLayerView.subviews indexOfObject:subview];
if (index<buttonIndex){
buttonIndex = index;
deepestButton = subview;
OnScreenWidgetView.deepestButton = (OnScreenWidgetView* )deepestButton;
}
}
}
}
if(deepestButton){ if(deepestButton){
for (UIView *subview in self->_streamFrameTopLayerView.subviews) { for (UIView *subview in self->_streamFrameTopLayerView.subviews) {
if ([subview isKindOfClass:[OnScreenWidgetView class]]) { if ([subview isKindOfClass:[OnScreenWidgetView class]]) {
@@ -492,6 +492,16 @@ final class LayoutOnScreenControlsViewController: UIViewController, OnScreenWidg
self.layoutOSC.oscButtonLayerPool.removeAllObjects() self.layoutOSC.oscButtonLayerPool.removeAllObjects()
} }
OnScreenWidgetView.deepestButton = nil;
_ = OnScreenWidgetView.getDeepestButton()
if let deepestButton = OnScreenWidgetView.deepestButton {
for widget in OnScreenWidgetView.mapping.values {
if widget.widgetType == .touchPad {
widget.superview?.insertSubview(widget, belowSubview: deepestButton)
}
}
}
view.bringSubviewToFront(toolbarRootView) view.bringSubviewToFront(toolbarRootView)
} }