-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathTweak.xm
110 lines (96 loc) · 3.32 KB
/
Tweak.xm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#import <dlfcn.h>
#import <substrate.h>
#import <FrontBoard/FBSMutableSceneSettings.h>
#import <FrontBoard/FBScene.h>
#import <FrontBoard/FBSceneManager.h>
#import <mach-o/dyld.h>
#import "MilkyWay2.h"
static AXPassthroughWindow *keyboardWindow;
@interface FBScene ()
- (void)updateSettings:(id)arg1 withTransitionContext:(id)arg2 ;
@end
@interface FBSMutableSceneSettings ()
@property (assign,getter=isForeground,nonatomic) BOOL foreground;
@end
@interface SBAppLayout : NSObject
+(id)homeScreenAppLayout;
@end
@interface SBMainSwitcherViewController : UIViewController
+(id)sharedInstance;
-(BOOL)_dismissSwitcherNoninteractivelyToAppLayout:(SBAppLayout*)arg1 dismissFloatingSwitcher:(BOOL)arg2 animated:(BOOL)arg3 ;
@end
%group iOS14
%hook SBAppLayout
%new
-(id)rolesToLayoutItemsMap{
return MSHookIvar<id>(self,"_rolesToLayoutItemsMap");
}
%end //SBApplayout
%hook AXWindowView
-(void)updateLayers{
%orig;
for(UIView *hostView in [[self contentView] subviews]){
if([hostView isKindOfClass:%c(_UIKeyboardLayerHostView)]){
if(!keyboardWindow){
keyboardWindow = [[%c(AXPassthroughWindow) alloc] initWithNoRotation];
[keyboardWindow setBackgroundColor:[UIColor clearColor]];
[keyboardWindow setWindowLevel:10000];
[keyboardWindow makeKeyAndVisible];
}
for(UIView *subview in [keyboardWindow subviews]){
[subview removeFromSuperview];
}
[keyboardWindow addSubview:hostView];
[hostView setClipsToBounds:NO];
}
}
}
%end //AXWindowView
%hook SBAppSwitcherPageView
-(void)AXlongPressAction:(UIGestureRecognizer*)gestureRecognizer{
%orig;
[[%c(SBMainSwitcherViewController) sharedInstance] _dismissSwitcherNoninteractivelyToAppLayout:[%c(SBAppLayout) homeScreenAppLayout] dismissFloatingSwitcher:YES animated:YES];
}
%end //SBAppSwitcherPageView
%end //iOS14
%group iOS15
%hook AXFlexHelper
+(FBScene*)getFBScene:(NSString*)identifier{
FBSceneManager *manager = [%c(FBSceneManager) sharedInstance];
id workspace = MSHookIvar<id>(manager, "_workspace");
NSDictionary *_allScenesByID = MSHookIvar<NSDictionary*>(workspace, "_allScenesByID");
for(NSString *key in [_allScenesByID allKeys]){
if([key containsString:identifier]){
return _allScenesByID[key];
}
}
return nil;
}
+(void)wakeUpScene:(NSString*)identifier{
FBScene *scene = [%c(AXFlexHelper) getFBScene:identifier];
FBSMutableSceneSettings *mutableSetting = [[scene settings] mutableCopy];
[mutableSetting setForeground:YES];
[scene updateSettings:mutableSetting withTransitionContext:nil];
}
+(void)sleepScene:(NSString*)identifier{
FBScene *scene = [%c(AXFlexHelper) getFBScene:identifier];
FBSMutableSceneSettings *mutableSetting = [[scene settings] mutableCopy];
[mutableSetting setForeground:NO];
[scene updateSettings:mutableSetting withTransitionContext:nil];
}
%end //AXFlexHelper
%end //iOS 15
%ctor{
NSLog(@"ctor: MilkyWay2iOS14Fix");
#if TARGET_OS_SIMULATOR
dlopen("/opt/simject/MilkyWay2.dylib", RTLD_NOW);
#else
dlopen("/Library/MobileSubstrate/DynamicLibraries/MilkyWay2.dylib", RTLD_NOW);
#endif
if(@available(iOS 15, *)){
%init(iOS15);
}
if(@available(iOS 14, *)){
%init(iOS14);
}
}