Repository navigation
Expand file tree
/
Copy pathTweak.x
More file actions
110 lines (85 loc) · 2.98 KB
/
Copy pathTweak.x
File metadata and controls
110 lines (85 loc) · 2.98 KB
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 <UIKit/UIKit.h>
#import <objc/runtime.h>
#import <string.h>
#import <dlfcn.h>
// --- State ---
static BOOL isUnlimited = YES;
// --- Interfaces ---
@interface PGPictureInPictureViewController : UIViewController
@property (nonatomic, assign) CGFloat preferredMinimumWidth;
@end
@interface SBPIPInteractionController : NSObject
@end
// ============================================================================
// GROUP 1: Pegasus Hooks (YouTube, Safari, etc.)
// ============================================================================
%group PegasusHooks
// 1. Hook the Controller
%hook PGPictureInPictureViewController
- (CGFloat)preferredMinimumWidth {
return isUnlimited ? 20.0 : %orig;
}
- (CGSize)minimumStashTabSize {
return isUnlimited ? CGSizeMake(10, 10) : %orig;
}
- (CGSize)microPIPSize {
return isUnlimited ? CGSizeMake(20, 20) : %orig;
}
%end // End PGPictureInPictureViewController
// 2. Hook the Settings Object
%hook PGMobilePIPSettings
- (double)minimumScale {
return isUnlimited ? 0.01 : %orig;
}
- (double)maximumScale {
return isUnlimited ? 10.0 : %orig;
}
%end // End PGMobilePIPSettings
%end // End Group PegasusHooks
// ============================================================================
// GROUP 2: SpringBoard Hooks (System Physics)
// ============================================================================
%group SpringBoardHooks
%hook SBPIPInteractionController
- (double)minimumScale {
return isUnlimited ? 0.01 : %orig;
}
- (double)maximumScale {
return isUnlimited ? 10.0 : %orig;
}
// iOS 17 fallback: force values if system tries to recalculate them
- (void)_updateScaleLimits {
%orig;
if (isUnlimited) {
@try {
[self setValue:@(0.01) forKey:@"minimumScale"];
[self setValue:@(10.0) forKey:@"maximumScale"];
} @catch (NSException *e) {}
}
}
%end
%end // End Group SpringBoardHooks
// ============================================================================
// INITIALIZATION
// ============================================================================
%ctor {
@autoreleasepool {
const char *bundleID = [[[NSBundle mainBundle] bundleIdentifier] UTF8String];
if (bundleID) {
// 1. SpringBoard: Init immediately
if (strcmp(bundleID, "com.apple.springboard") == 0) {
%init(SpringBoardHooks);
}
// 2. Apps (YouTube, etc.): Force load framework, then init
else {
// Force load Pegasus so we can hook it even if the app hasn't started a video yet
// We call dlopen but don't store the result to avoid "unused variable" warnings
dlopen("/System/Library/PrivateFrameworks/Pegasus.framework/Pegasus", RTLD_NOW);
// Only init if the class exists
if (objc_getClass("PGPictureInPictureViewController")) {
%init(PegasusHooks);
}
}
}
}
}