-
Notifications
You must be signed in to change notification settings - Fork 17
/
Hooks.xm
1339 lines (933 loc) · 35.9 KB
/
Hooks.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#import "include.h"
#import "OSViewController.h"
#import "OSAppPane.h"
#import <dispatch/dispatch.h>
#import <GraphicsServices/GraphicsServices.h>
#import <UIKit/UIKit.h>
#import <mach/mach_time.h>
#import <IOKit/hid/IOHIDEventSystem.h>
#import <substrate.h>
#import "explorer/OSExplorerWindow.h"
#import <rocketbootstrap.h>
#import "OSPreferences.h"
#import "tutorial/OSTutorialController.h"
extern "C" void BKSTerminateApplicationForReasonAndReportWithDescription(NSString *app, int a, int b, NSString *description);
extern "C" void BKSHIDServicesSystemGestureIsStealingEvents(BOOL stealing);
extern "C" CFTypeRef SecTaskCopyValueForEntitlement(/*SecTaskRef*/void* task, CFStringRef entitlement, CFErrorRef *error);//In Security.framework
#define notificationCenterID @"com.eswick.osexperience.notificationCenter"
#define explorerIconDisplayName @"OS Explorer"
#define explorerIconIdentifier @"com.eswick.osexperience.osexplorer"
%group SpringBoard //Springboard hooks
/* ------------------------------ */
%hook SBBulletinWindowController
- (BOOL)isBusy{
return false;
}
%end
%hook SBSearchViewController
- (void)_fadeForLaunchWithDuration:(double)arg1 completion:(id)arg2{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, arg1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[[OSViewController sharedInstance] setLaunchpadActive:false animated:true];
});
%orig;
}
%end
%hook SBWallpaperView
- (BOOL)_shouldShowGradientOverWallpaper{
return false;
}
%end
%hook SBPanGestureRecognizer
- (id)initForHorizontalPanning{
self = %orig;
[[OSSlider sharedInstance] setSwipeGestureRecognizer:self];
return self;
}
%end
%hook SBScaleGestureRecognizer
- (void)setRequiredDirectionality:(int)directionality{
%orig(0);
}
%end
%hook SBUIController
%property (assign) BOOL switchAppGestureInProgress;
%property (assign) BOOL switcherGestureInProgress;
%property (assign) BOOL scaleGestureInProgress;
- (void)_deviceLockStateChanged:(id)arg1{
if([[[arg1 userInfo] objectForKey:@"kSBNotificationKeyState"] boolValue]){
[[OSViewController sharedInstance] setLaunchpadActive:false animated:false];
[[(SpringBoard*)UIApp statusBarWindow] setAlpha:1.0];
}else{
[UIView animateWithDuration:0.25 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
[[(SpringBoard*)UIApp statusBarWindow] setAlpha:0.0];
}completion:^(BOOL finished){
}];
}
%orig;
}
- (UIView*)contentView{
return [[OSViewController sharedInstance] iconContentView];
}
- (BOOL)allowSystemGestureType:(SBSystemGestureType)type atLocation:(struct CGPoint)arg2{
if([[OSTutorialController sharedInstance] inProgress])
return [[OSTutorialController sharedInstance] allowSystemGestureType:type atLocation:arg2];
if(type & SBSystemGestureTypeSuspendApp){
if(self.switchAppGestureInProgress || self.switcherGestureInProgress || [[OSViewController sharedInstance] missionControlIsActive])
return false;
}
if(type & SBSystemGestureTypeSwitcher){
if(self.switchAppGestureInProgress || self.scaleGestureInProgress)
return false;
}
if(type & SBSystemGestureTypeSwitchApp){
if(self.scaleGestureInProgress || self.switcherGestureInProgress || [[OSViewController sharedInstance] missionControlIsActive])
return false;
}
return %orig;
}
- (void)handleFluidVerticalSystemGesture:(SBPanGestureRecognizer*)arg1{
static BOOL upGestureWasRecognized = false;
static BOOL downGestureWasRecognized = false;
if([arg1 state] == UIGestureRecognizerStateBegan)
self.switcherGestureInProgress = true;
if([arg1 state] == UIGestureRecognizerStateEnded || [arg1 state] == UIGestureRecognizerStateCancelled){
upGestureWasRecognized = false;
downGestureWasRecognized = false;
self.switcherGestureInProgress = false;
BKSHIDServicesSystemGestureIsStealingEvents(false);
return;
}
if([arg1 cumulativeMotion] == [arg1 animationDistance]){
upGestureWasRecognized = false;
if(!downGestureWasRecognized){
[[OSViewController sharedInstance] handleDownGesture];
downGestureWasRecognized = true;
}
}else if([arg1 cumulativeMotion] == -[arg1 animationDistance]){
downGestureWasRecognized = false;
if(!upGestureWasRecognized){
[[OSViewController sharedInstance] handleUpGesture];
upGestureWasRecognized = true;
}
}
}
- (void)handleFluidScaleSystemGesture:(SBScaleGestureRecognizer*)arg1{
static BOOL launchpadClosing = false;
if([arg1 animationDistance] == 0)
return;
float percentage = [arg1 cumulativeMotion] / [arg1 animationDistance];
if([arg1 state] == UIGestureRecognizerStateBegan){
self.scaleGestureInProgress = true;
launchpadClosing = [[OSViewController sharedInstance] launchpadIsActive];
if(![[OSViewController sharedInstance] launchpadIsActive]){
[[[OSViewController sharedInstance] iconContentView] prepareForDisplay];
}
[[OSViewController sharedInstance] setLaunchpadAnimating:true];
}else if([arg1 state] == UIGestureRecognizerStateChanged){
if(!launchpadClosing){
[[OSViewController sharedInstance] setLaunchpadVisiblePercentage:-percentage];
if(![[[OSSlider sharedInstance] currentPane] showsDock])
[[OSViewController sharedInstance] setDockPercentage:1 - (-percentage)];
}else{
[[OSViewController sharedInstance] setLaunchpadVisiblePercentage:1 - (percentage)];
if(![[[OSSlider sharedInstance] currentPane] showsDock])
[[OSViewController sharedInstance] setDockPercentage:percentage];
}
}else if([arg1 state] == UIGestureRecognizerStateEnded){
BKSHIDServicesSystemGestureIsStealingEvents(false);
[[OSViewController sharedInstance] setLaunchpadAnimating:true];
if([arg1 completionTypeProjectingMomentumForInterval:3.0] != -1){
if(!launchpadClosing){
[UIView animateWithDuration:0.25
delay:0
options: UIViewAnimationOptionCurveEaseOut
animations:^{
[[OSViewController sharedInstance] setLaunchpadVisiblePercentage:1];
[[OSViewController sharedInstance] setDockPercentage:0.0];
}completion:^(BOOL completed){
self.scaleGestureInProgress = false;
[[OSViewController sharedInstance] setLaunchpadActive:true];
[[OSViewController sharedInstance] setLaunchpadAnimating:false];
}];
}else{
[UIView animateWithDuration:0.25
delay:0
options: UIViewAnimationOptionCurveEaseOut
animations:^{
self.scaleGestureInProgress = false;
[[OSViewController sharedInstance] setLaunchpadVisiblePercentage:0];
[[OSViewController sharedInstance] setLaunchpadActive:false];
[[OSSlider sharedInstance] updateDockPosition];
}completion:^(BOOL completed){
[[OSViewController sharedInstance] setLaunchpadAnimating:false];
}];
}
}else{
[UIView animateWithDuration:0.25
delay:0
options: UIViewAnimationOptionCurveEaseOut
animations:^{
self.scaleGestureInProgress = false;
[[OSSlider sharedInstance] updateDockPosition];
[[OSViewController sharedInstance] setLaunchpadVisiblePercentage:0];
}completion:^(BOOL completed){
[[OSViewController sharedInstance] setLaunchpadActive:false];
[[OSViewController sharedInstance] setLaunchpadAnimating:false];
}];
}
}else if([arg1 state] == UIGestureRecognizerStateCancelled){
self.scaleGestureInProgress = false;
}
}
- (void)_switchAppGestureBegan:(double)arg1{
for(UIGestureRecognizer *recognizer in [[OSSlider sharedInstance] gestureRecognizers]){
if([recognizer isKindOfClass:objc_getClass("UIScrollViewPagingSwipeGestureRecognizer")]){
recognizer.enabled = false;
}
}
self.switchAppGestureInProgress = true;
if(![[OSViewController sharedInstance] launchpadIsAnimating] && ![[OSViewController sharedInstance] launchpadIsActive])
[[OSSlider sharedInstance] beginPaging];
}
- (void)_switchAppGestureChanged:(double)arg1{
if(![[OSViewController sharedInstance] launchpadIsAnimating] && ![[OSViewController sharedInstance] launchpadIsActive])
[[OSSlider sharedInstance] updatePaging:arg1];
}
- (void)_switchAppGestureCancelled{
[[OSSlider sharedInstance] swipeGestureEndedWithCompletionType:0 cumulativePercentage:0];
}
- (void)_switchAppGestureEndedWithCompletionType:(long long)arg1 cumulativePercentage:(double)arg2{
self.switchAppGestureInProgress = false;
if(![[OSViewController sharedInstance] launchpadIsAnimating] && ![[OSViewController sharedInstance] launchpadIsActive])
[[OSSlider sharedInstance] swipeGestureEndedWithCompletionType:arg1 cumulativePercentage:arg2];
}
- (void)_setToggleSwitcherAfterLaunchApp:(id)arg1{
}
- (BOOL)isAppSwitcherShowing{
return [[OSViewController sharedInstance] missionControlIsActive];
}
- (BOOL)_activateAppSwitcherFromSide:(int)arg1{
[[OSViewController sharedInstance] setMissionControlActive:true animated:true];
return true;
}
static BOOL preventSwitcherDismiss = false;
- (void)dismissSwitcherAnimated:(BOOL)arg1{
if(!preventSwitcherDismiss)
[[OSViewController sharedInstance] setMissionControlActive:false animated:arg1];
}
- (void)activateApplicationAnimated:(id)arg1{
preventSwitcherDismiss = true;
%orig;
preventSwitcherDismiss = false;
}
- (void)_toggleSwitcher{
if([[OSViewController sharedInstance] missionControlIsActive])
[[OSViewController sharedInstance] setMissionControlActive:false animated:true];
else
[[OSViewController sharedInstance] setMissionControlActive:true animated:true];
}
- (id)init{
self = %orig;
[MSHookIvar<UIView*>(self, "_contentView") removeFromSuperview];
OSViewController *viewController = [OSViewController sharedInstance];
[[UIApp keyWindow] setRootViewController:viewController];
[viewController.view setFrame:[[UIScreen mainScreen] bounds]];
CPDistributedMessagingCenter *messagingCenter;
messagingCenter = [CPDistributedMessagingCenter centerNamed:@"com.eswick.osexperience.backboardserver"];
NSArray *keys = [NSArray arrayWithObjects:@"context", nil];
NSArray *objects = [NSArray arrayWithObjects:[NSNumber numberWithInt:[[UIApp keyWindow] _contextId]], nil];
NSDictionary *dictionary = [NSDictionary dictionaryWithObjects:objects forKeys:keys];
[messagingCenter sendMessageAndReceiveReplyName:@"setKeyWindowContext" userInfo:dictionary];
return self;
}
- (void)window:(id)arg1 willAnimateRotationToInterfaceOrientation:(int)arg2 duration:(double)arg3{
int degrees;
switch(arg2){
case UIInterfaceOrientationPortrait:
degrees = 0;
break;
case UIInterfaceOrientationPortraitUpsideDown:
degrees = 180;
break;
case UIInterfaceOrientationLandscapeLeft:
degrees = 270;
break;
case UIInterfaceOrientationLandscapeRight:
degrees = 90;
break;
}
[[OSSlider sharedInstance] setPageIndexPlaceholder:[[OSSlider sharedInstance] currentPageIndex]];
[UIView animateWithDuration:arg3 delay:0.0 options: UIViewAnimationCurveEaseOut animations:^{
UIView *osView = [[OSViewController sharedInstance] view];
osView.transform = CGAffineTransformMakeRotation(DegreesToRadians(degrees));
[osView setFrame:[[UIScreen mainScreen] bounds]];
}completion:^(BOOL finished){
}];
[[OSSlider sharedInstance] willRotateToInterfaceOrientation:arg2 duration:arg3];
[[OSThumbnailView sharedInstance] willRotateToInterfaceOrientation:arg2 duration:arg3];
[[OSTutorialController sharedInstance] willRotateToInterfaceOrientation:arg2 duration:arg3];
%orig;
[[OSSlider sharedInstance] updateDockPosition];
}
- (BOOL)hasPendingAppActivatedByGesture{
return true;
}
%end
%hook SBBacklightController
- (void)_lockScreenDimTimerFired{
if([[OSTutorialController sharedInstance] inProgress])
return;
%orig;
}
%end
%hook SBIconListView
- (void)prepareToRotateToInterfaceOrientation:(UIInterfaceOrientation)arg1{
self.transform = CGAffineTransformIdentity;
%orig;
}
%end
%hook SBLockScreenViewController
static dispatch_once_t onceToken;
- (void)finishUIUnlockFromSource:(int)arg1{
%orig;
if(![[NSUserDefaults standardUserDefaults] boolForKey:@"SBUseSystemGestures"] && [prefs SHOW_MG_POPUP]){
dispatch_once (&onceToken, ^{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Multitasking Gestures not enabled." message:@"Multitasking gestures are not enabled. Some features of OS Experience may be unavailable. Turn them on now?" delegate:self cancelButtonTitle:@"Don't ask again." otherButtonTitles:@"Yes", @"No", nil];
[alert show];
[alert release];
});
}
[[OSSlider sharedInstance] updateDockPosition];
}
%new
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(int)buttonIndex {
if(buttonIndex == 0){
//Don't ask again
[prefs setSHOW_MG_POPUP:false];
}else if(buttonIndex == 1){
//Yes
[[NSUserDefaults standardUserDefaults] setBool:true forKey:@"SBUseSystemGestures"];
[UIApp userDefaultsDidChange:@"SBUseSystemGestures"];
}
}
%end
%hook SpringBoard
- (void)_lockButtonDownFromSource:(int)arg1{
if([[OSTutorialController sharedInstance] inProgress]){
return;
}
%orig;
}
- (void)_lockButtonUpFromSource:(int)arg1{
if([[OSTutorialController sharedInstance] inProgress]){
return;
}
%orig;
}
- (id)_accessibilityFrontMostApplication{
return nil;
}
- (void)sendEvent:(id)arg1{
GSEventRef event = [arg1 _gsEvent];
if(event == NULL){
%orig; return;
}
if(GSEventGetType(event) == kGSEventDeviceOrientationChanged){
for(OSAppPane *appPane in [[OSPaneModel sharedInstance] panes]){
if(![appPane isKindOfClass:[OSAppPane class]])
continue;
[[appPane application] rotateToInterfaceOrientation:GSEventDeviceOrientation(event)];
}
}
%orig;
}
- (void)_handleMenuButtonEvent{
if([[%c(SBNotificationCenterController) sharedInstance] isVisible]){
[[%c(SBNotificationCenterController) sharedInstance] dismissAnimated:true];
return;
}
if([%c(SBAssistantController) isAssistantVisible]){
SBAssistantController *controller = [%c(SBAssistantController) sharedInstanceIfExists];
[controller _dismissForMainScreenAnimated:true duration:[controller _defaultAnimatedDismissDurationForMainScreen] completion:nil];
return;
}
if([UIApp isLocked])
return;
if([[OSViewController sharedInstance] launchpadIsActive])
[[OSViewController sharedInstance] setLaunchpadActive:false animated:true];
else
[[OSViewController sharedInstance] setLaunchpadActive:true animated:true];
}
- (void)applicationDidFinishLaunching:(id)arg1{
%orig;
CPDistributedMessagingCenter *messagingCenter = [CPDistributedMessagingCenter centerNamed:@"com.eswick.osexperience.springboardserver"];
rocketbootstrap_distributedmessagingcenter_apply(messagingCenter);
[messagingCenter runServerOnCurrentThread];
[messagingCenter registerForMessageName:@"forceClassic" target:self selector:@selector(handleMessageNamed:withUserInfo:)];
[messagingCenter registerForMessageName:@"checkin" target:self selector:@selector(handleMessageNamed:withUserInfo:)];
[messagingCenter registerForMessageName:@"frontmostApp" target:self selector:@selector(handleFrontmostAppRequest:withUserInfo:)];
[messagingCenter registerForMessageName:@"shortcut" target:self selector:@selector(handleShortcut:withUserInfo:)];
if(![[OSPreferences sharedInstance] TUTORIAL_SHOWN])
[[OSTutorialController sharedInstance] beginTutorial];
}
%new
- (NSDictionary *)handleShortcut:(NSString *)name withUserInfo:(NSDictionary *)userinfo {
if([[userinfo objectForKey:@"key"] intValue] == ARROW_LEFT_KEY){
if([[OSSlider sharedInstance] currentPageIndex] > 0){
[[OSSlider sharedInstance] scrollToPane:[[OSPaneModel sharedInstance] paneAtIndex:[[OSSlider sharedInstance] currentPageIndex] - 1] animated:true];
}
}else if([[userinfo objectForKey:@"key"] intValue] == ARROW_RIGHT_KEY){
if([[OSSlider sharedInstance] currentPageIndex] < [[OSPaneModel sharedInstance] count] - 1){
[[OSSlider sharedInstance] scrollToPane:[[OSPaneModel sharedInstance] paneAtIndex:[[OSSlider sharedInstance] currentPageIndex] + 1] animated:true];
}
}
return nil;
}
%new
- (NSDictionary *)handleFrontmostAppRequest:(NSString *)name withUserInfo:(NSDictionary *)userinfo {
NSString *bundleID = [self frontmostApp] ? [[self frontmostApp] displayIdentifier] : @"com.apple.springboard";
return @{ @"bundleID" : bundleID };
}
%new
- (SBApplication*)frontmostApp{
if([[[OSSlider sharedInstance] currentPane] isKindOfClass:[OSAppPane class]] && ![[OSViewController sharedInstance] launchpadIsActive]){
return [(OSAppPane*)[[OSSlider sharedInstance] currentPane] application];
}else if([[[OSSlider sharedInstance] currentPane] isKindOfClass:[OSDesktopPane class]] && ![[OSViewController sharedInstance] launchpadIsActive]){
OSDesktopPane *pane = (OSDesktopPane*)[[OSSlider sharedInstance] currentPane];
if([pane activeWindow]){
if([[pane activeWindow] isKindOfClass:[OSAppWindow class]]){
return [(OSAppWindow*)[pane activeWindow] application];
}
}
}
return nil;
}
%new
- (NSDictionary *)handleMessageNamed:(NSString *)name withUserInfo:(NSDictionary *)userinfo {
if([name isEqualToString:@"checkin"])
return @{};
SBApplication *app = [[%c(SBApplicationController) sharedInstance] applicationWithDisplayIdentifier:[userinfo objectForKey:@"bundleID"]];
if([app forceClassic]){
return @{@"forceClassic" : @(true)};
}else{
return @{@"forceClassic" : @(false)};
}
}
%end
%hook SBHandMotionExtractor
- (void)extractHandMotionForActiveTouches:(SBGestureRecognizerTouchData *)arg1 count:(unsigned int)arg2 centroid:(struct CGPoint)arg3{
if(arg2 < 4 && arg1[0].type == 0){
for(OSDesktopPane *pane in [[OSPaneModel sharedInstance] panes]){
if(![pane isKindOfClass:[OSDesktopPane class]])
continue;
for(int i = [pane.subviews count] - 1; i > 0; i--){
OSWindow *window = [pane.subviews objectAtIndex:i];
if(![window isKindOfClass:[OSWindow class]])
continue;
CGPoint point = [[[OSViewController sharedInstance] view] convertPoint:arg1[0].location toView:window];
if([window pointInside:point withEvent:nil]){
dispatch_async(dispatch_get_main_queue(), ^{
[pane bringSubviewToFront:window];
[pane setActiveWindow:window];
});
return;
}
}
}
}
%orig;
}
%end
%hook SBWindowContextHostManager
- (id)hostViewForRequester:(id)arg1 enableAndOrderFront:(_Bool)arg2{
if([arg1 isEqualToString:@"com.apple.springboard.launchwithzoomanimation"] || [arg1 isEqualToString:@"SBUIAnimationLockScreenToAppZoomIn"])
return nil;
return %orig;
}
%end
%hook SBApplication
%property (assign) BOOL forceClassic;
%property (assign, getter=isRelaunching) BOOL relaunching;
- (void)setDisplaySetting:(unsigned int)arg1 value:(id)arg2{
%orig;
if(arg1 == 4){//Rotation changed
for(OSPane *pane in [[OSPaneModel sharedInstance] panes]){
if([pane isKindOfClass:[OSDesktopPane class]]){
for(OSAppWindow *window in pane.subviews){
if(![window isKindOfClass:[OSAppWindow class]])
continue;
if(window.application == self){
[window applicationDidRotate];
return;
}
}
continue;
}else if(![pane isKindOfClass:[OSAppPane class]])
continue;
if([(OSAppPane*)pane application] == self){
}
}
for(OSPaneThumbnail *thumbnail in [[[OSThumbnailView sharedInstance] wrapperView] subviews]){
[thumbnail layoutSubviews];
}
}
}
-(void)didExitWithInfo:(id)arg1 type:(int)arg2{
if([self isRelaunching]){
%orig;
[self performSelector:@selector(launch) withObject:nil afterDelay:1];
return;
}
OSAppPane *appPane = nil;
for(OSAppPane *pane in [[OSPaneModel sharedInstance] panes]){
if(![pane isKindOfClass:[OSAppPane class]])
continue;
if(pane.application == self)
appPane = pane;
}
OSAppWindow *foundWindow = nil;
OSDesktopPane *foundDesktop = nil;
if(appPane){
[[OSPaneModel sharedInstance] removePane:appPane];
}else{
for(OSDesktopPane *desktop in [[OSPaneModel sharedInstance] panes]){
if(![desktop isKindOfClass:[OSDesktopPane class]])
continue;
for(OSAppWindow *window in desktop.windows){
if(![window isKindOfClass:[OSAppWindow class]])
continue;
if(window.application == self){
foundDesktop = desktop;
foundWindow = window;
}
}
}
}
[foundDesktop.windows removeObject:foundWindow];
[foundWindow removeFromSuperview];
%orig;
}
-(void)didSuspend{
return;
OSAppPane *appPane = nil;
for(OSAppPane *pane in [[OSPaneModel sharedInstance] panes]){
if(![pane isKindOfClass:[OSAppPane class]])
continue;
if(pane.application == self)
appPane = pane;
}
if(appPane){
[[OSPaneModel sharedInstance] removePane:appPane];
}
CPDistributedMessagingCenter *messagingCenter;
messagingCenter = [CPDistributedMessagingCenter centerNamed:@"com.eswick.osexperience.backboardserver"];
NSArray *keys = [NSArray arrayWithObjects:@"bundleIdentifier", @"performOriginals", nil];
NSArray *objects = [NSArray arrayWithObjects:[self displayIdentifier], [NSNumber numberWithBool:false], nil];
NSDictionary *dictionary = [NSDictionary dictionaryWithObjects:objects forKeys:keys];
[messagingCenter sendMessageAndReceiveReplyName:@"setApplicationPerformOriginals" userInfo:dictionary];
%orig;
}
%new
- (BOOL)rotateToInterfaceOrientation:(int)orientation{
struct GSOrientationEvent {
GSEventRecord record;
GSDeviceOrientationInfo orientationInfo;
} event;
bzero(&event, sizeof(event));
event.record.type = kGSEventDeviceOrientationChanged;
event.record.flags = (GSEventFlags)0;
event.record.infoSize = 4;
event.orientationInfo.orientation = orientation;
int success = GSSendEvent((GSEventRecord*)&event, (mach_port_t)[self eventPort]);
return (success == 0);
}
-(void)willActivate{
%orig;
[self addToSlider];
}
- (void)didLaunch:(BKSApplicationProcessInfo*)arg1{
if([self isRelaunching])
[self setRelaunching:false];
%orig;
if([arg1 suspended]){
return;
}
[self addToSlider];
}
%new
-(void)addToSlider{
BOOL found = false;
OSAppPane *foundPane = nil;
OSAppWindow *foundWindow = nil;
for(OSAppPane *pane in [[OSPaneModel sharedInstance] panes]){
if(![pane isKindOfClass:[OSAppPane class]]){
continue;
}
if(pane.application == self){
found = true;
foundPane = pane;
}
}
for(OSDesktopPane *desktopPane in [[OSPaneModel sharedInstance] panes]){
if(![desktopPane isKindOfClass:[OSDesktopPane class]])
continue;
for(OSAppWindow *window in desktopPane.windows){
if(![window isKindOfClass:[OSAppWindow class]])
continue;
if(window.application == self){
found = true;
foundWindow = window;
}
}
}
if(!found){
OSAppPane *appPane = [[OSAppPane alloc] initWithDisplayIdentifier:[self bundleIdentifier]];
int appViewDegrees;
switch([UIApp statusBarOrientation]){
case UIInterfaceOrientationPortrait:
appViewDegrees = 0;
break;
case UIInterfaceOrientationPortraitUpsideDown:
appViewDegrees = 180;
break;
case UIInterfaceOrientationLandscapeLeft:
appViewDegrees = 90;
break;
case UIInterfaceOrientationLandscapeRight:
appViewDegrees = 270;
break;
}
UIView *appView = [appPane appView];
appView.transform = CGAffineTransformMakeRotation(DegreesToRadians(appViewDegrees));
CGRect frame = [appView frame];
frame.origin = CGPointMake(0, 0);
[appView setFrame:frame];
[[OSPaneModel sharedInstance] addPaneToBack:appPane];
[self activate];
[[OSSlider sharedInstance] scrollToPane:appPane animated:true];
[appPane release];
}
if(found){
if(foundPane){
[[OSSlider sharedInstance] scrollToPane:foundPane animated:true];
}
if(foundWindow){
[foundWindow resetHostView];
[[OSSlider sharedInstance] scrollToPane:[[OSPaneModel sharedInstance] desktopPaneContainingWindow:foundWindow] animated:true];
}
}
}
- (void)activate{
CPDistributedMessagingCenter *messagingCenter = [CPDistributedMessagingCenter centerNamed:@"com.eswick.osexperience.backboardserver"];
rocketbootstrap_distributedmessagingcenter_apply(messagingCenter);
NSArray *keys = [NSArray arrayWithObjects:@"bundleIdentifier", nil];
NSArray *objects = [NSArray arrayWithObjects:[self displayIdentifier], nil];
NSDictionary *dictionary = [NSDictionary dictionaryWithObjects:objects forKeys:keys];
[messagingCenter sendMessageName:@"activate" userInfo:dictionary];
}
%new
- (void)suspend{
CPDistributedMessagingCenter *messagingCenter = [CPDistributedMessagingCenter centerNamed:@"com.eswick.osexperience.backboardserver"];
rocketbootstrap_distributedmessagingcenter_apply(messagingCenter);
NSArray *keys = [NSArray arrayWithObjects:@"bundleIdentifier", @"performOriginals", nil];
NSArray *objects = [NSArray arrayWithObjects:[self displayIdentifier], [NSNumber numberWithBool:true], nil];
NSDictionary *dictionary = [NSDictionary dictionaryWithObjects:objects forKeys:keys];
[messagingCenter sendMessageAndReceiveReplyName:@"setApplicationPerformOriginals" userInfo:dictionary];
BKSTerminateApplicationForReasonAndReportWithDescription([self bundleIdentifier], 3, 0, 0);
}
%new
- (void)relaunch{
[self setRelaunching:true];
[self suspend];
}
%new
- (void)launch{
SBIconModel *iconModel = MSHookIvar<SBIconModel*>([%c(SBIconController) sharedInstance], "_iconModel");
SBIcon *icon = [iconModel applicationIconForDisplayIdentifier:[self bundleIdentifier]];
[self icon:icon launchFromLocation:0];
}
%end
%hook SBToAppWorkspaceTransaction
- (void)performToAppStateCleanup{
preventSwitcherDismiss = true;
%orig;
preventSwitcherDismiss = false;
}
%end
%hook SBIconController
-(void)iconWasTapped:(SBApplicationIcon*)arg1{
if(![[arg1 application] isRunning]){
[[arg1 application] icon:arg1 launchFromLocation:0];
}else{
[[arg1 application] addToSlider];
}
}
-(void)iconTapped:(SBIconView*)arg1{
[arg1 setHighlighted:false];
if(![[OSViewController sharedInstance] launchpadIsActive]){
%orig;
return;
}
if([[arg1 icon] isFolderIcon] || [[arg1 icon] isNewsstandIcon]){
[[arg1 icon] launchFromLocation:0];
}else{
[[OSViewController sharedInstance] deactivateLaunchpadWithIconView:arg1];
%orig;
}
}
- (void)_resetRootIconLists{
%orig;
[[[OSViewController sharedInstance] dock] removeFromSuperview];
[[OSViewController sharedInstance] setDock:[[[[objc_getClass("SBIconController") sharedInstance] _rootFolderController] contentView] dockView]];
CGRect dockFrame = [[[OSViewController sharedInstance] dock] frame];
dockFrame.origin.y = [[UIScreen mainScreen] bounds].size.height - dockFrame.size.height;
[[[OSViewController sharedInstance] dock] setFrame:dockFrame];
[[[OSViewController sharedInstance] view] addSubview:[[OSViewController sharedInstance] dock]];
}
- (void)willRotateToInterfaceOrientation:(long long)arg1 duration:(double)arg2{
[[[OSViewController sharedInstance] iconContentView] contentView].transform = CGAffineTransformIdentity;
%orig;
}
%end
/* Block app launch animation */
%hook SBUIAnimationZoomUpAppFromHome
- (void)prepareZoom{
}
%end
%hook SBUIAnimationController
- (void)__cleanupAnimation{
[self _setAnimationState:3];
[self _releaseActivationAssertion];
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"SBApplicationActivationStateDidChange" object:nil];
[[%c(SBAlertItemsController) sharedInstance] setForceAlertsToPend:false forReason:[self _animationIdentifier]];
[UIWindow _synchronizeDrawing];
}
- (void)dealloc{
[self _setAnimationState:4];
%orig;
}
%end
%hook SBUIMainScreenAnimationController