Skip to content

Commit

Permalink
Fix dashboard cannot be dismiss
Browse files Browse the repository at this point in the history
  • Loading branch information
brian9206 committed Jul 8, 2018
1 parent fcd61b2 commit 0dc7c2f
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 20 deletions.
2 changes: 1 addition & 1 deletion control
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: pw.ssnull.homedockx
Name: HomeDockX
Depends: firmware (>= 11.0), mobilesubstrate, preferenceloader, applist
Version: 1.2.0
Version: 1.2.1
Architecture: iphoneos-arm
Description: iPhone X gesture with perfectly compatible iPad floating dock
Maintainer: Brian Choi <brian9206@hotmail.com>
Expand Down
15 changes: 13 additions & 2 deletions src/Dock.xm
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,19 @@ SBFloatingDockController *dock = NULL;
UIGestureRecognizer *edgePullGestureRecognizer = [[self.viewController grabberTongue] edgePullGestureRecognizer];
CGPoint location = [edgePullGestureRecognizer locationInView:edgePullGestureRecognizer.view];

// swipe up only for 1/3 left of the screen
if (location.x > edgePullGestureRecognizer.view.bounds.size.width / 2) {
bool stop = NO;

switch ([(SpringBoard*)[UIApplication sharedApplication] activeInterfaceOrientation]) {
case 1: // UIInterfaceOrientationPortrait
stop = location.x > edgePullGestureRecognizer.view.bounds.size.width / 2;
break;

case 2: // UIInterfaceOrientationPortraitUpsideDown
stop = location.x < edgePullGestureRecognizer.view.bounds.size.width / 2;
break;
}

if (stop) {
return NO;
}
}
Expand Down
63 changes: 48 additions & 15 deletions src/HomeGesture.xm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

// global variable
long _dismissalSlidingMode = 0;
BOOL _isDashboardActive = 0;

// Enable home gestures
%hook BSPlatform
Expand Down Expand Up @@ -79,27 +80,59 @@ long _dismissalSlidingMode = 0;
}

- (void)touchesBegan:(NSSet *)touches withEvent:(id)event {
UITouch *touch = [touches anyObject];

// do not do home gesture for 1/3 left of the screen if dock is enabled
if (!isSpringBoardAtFront &&
prefs.enableDock &&
[touch locationInView:touch.view].x <= touch.view.bounds.size.width / 2
) {
resetTouch(self, touches, event);
return;
}

// do not enable home gesture when using keyboard
if (prefs.noKeyboard && isKeyboardVisible) {
resetTouch(self, touches, event);
return;
if (!_isDashboardActive) {
UITouch *touch = [touches anyObject];

// do not do home gesture for 1/2 left of the screen if dock is enabled
if (!isSpringBoardAtFront &&
prefs.enableDock
) {
BOOL reset = NO;

switch ([(SpringBoard*)[UIApplication sharedApplication] activeInterfaceOrientation]) {
case 1: // UIInterfaceOrientationPortrait
reset = [touch locationInView:touch.view].x < touch.view.bounds.size.width / 2;
break;

case 2: // UIInterfaceOrientationPortraitUpsideDown
reset = [touch locationInView:touch.view].x > touch.view.bounds.size.width / 2;
break;

case 3: // UIInterfaceOrientationLandscapeRight
case 4: // UIInterfaceOrientationLandscapeLeft
reset = YES;
}

if (reset) {
resetTouch(self, touches, event);
return;
}
}

// do not enable home gesture when using keyboard
if (prefs.noKeyboard && isKeyboardVisible) {
resetTouch(self, touches, event);
return;
}
}

return %orig;
}
%end

// Listen for dashboard active state change
%hook SBDashBoardViewController
- (void)viewWillAppear:(_Bool)arg1 {
%orig;
_isDashboardActive = YES;
}

- (void)viewWillDisappear:(_Bool)arg1 {
%orig;
_isDashboardActive = NO;
}
%end

%end // end %group HomeGesture

%ctor {
Expand Down
7 changes: 5 additions & 2 deletions src/includes/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#import "includes/HomeDockXPreference.h"
#import "includes/KeyboardStateListener.h"

#import <SpringBoard/SpringBoard.h>

@interface FBApplicationInfo
@property (nonatomic,retain,readonly) NSURL *executableURL;
@end
Expand All @@ -20,6 +18,11 @@
-(BOOL)isClassic;
@end

@interface SpringBoard : UIApplication
- (SBApplication*)_accessibilityFrontMostApplication;
- (long long)activeInterfaceOrientation;
@end

#define isSpringBoardAtFront (![(SpringBoard*)[UIApplication sharedApplication] _accessibilityFrontMostApplication].bundleIdentifier)
#define isKeyboardVisible ([KeyboardStateListener sharedInstance].visible)
#define prefs [HomeDockXPreference sharedInstance]

0 comments on commit 0dc7c2f

Please sign in to comment.