Skip to content

Commit

Permalink
Work on external display
Browse files Browse the repository at this point in the history
  • Loading branch information
yury committed Jul 23, 2019
1 parent 83075eb commit 8b21362
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 16 deletions.
4 changes: 2 additions & 2 deletions Blink/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
<true/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleExternalDisplay</key>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneDelegateClassName</key>
Expand All @@ -141,7 +141,7 @@
<string>main</string>
</dict>
</array>
<key>UIWindowSceneSessionRoleApplication</key>
<key>UIWindowSceneSessionRoleExternalDisplay</key>
<array>
<dict>
<key>UISceneDelegateClassName</key>
Expand Down
3 changes: 2 additions & 1 deletion Blink/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
let spaceCntrl = SpaceController()
spaceCntrl.restoreWith(stateRestorationActivity: session.stateRestorationActivity)
window?.rootViewController = spaceCntrl
window?.makeKeyAndVisible()
window?.isHidden = false
}

private func _tuneOverscanIfNeeded(session: UISceneSession) {
Expand Down Expand Up @@ -84,4 +84,5 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
private var _spaceController: SpaceController? {
window?.rootViewController as? SpaceController
}

}
30 changes: 30 additions & 0 deletions Blink/SpaceController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,37 @@ extension SpaceController {


@objc func _focusOtherScreenAction() {
let app = UIApplication.shared
let sessions = Array(app.openSessions)
.sorted(by: {(a, b) in
a.persistentIdentifier > b.persistentIdentifier
})
// view.window?.windowScene?.session.persistentIdentifier
guard
sessions.count > 1,
let session = view.window?.windowScene?.session,
let idx = sessions.firstIndex(of: session)?.advanced(by: 1)
else {
return
}

let nextSession: UISceneSession
if idx < sessions.endIndex {
nextSession = sessions[idx]
} else {
nextSession = sessions[0]
}

if let scene = nextSession.scene as? UIWindowScene,
scene.activationState == .foregroundActive || scene.activationState == .foregroundInactive,
let delegate = scene.delegate as? SceneDelegate,
let window = delegate.window,
let spaceCtrl = window.rootViewController as? SpaceController
{
window.makeKeyAndVisible()
} else {
app.requestSceneSessionActivation(nextSession, userActivity: nil, options: nil, errorHandler: nil)
}
}

@objc func _moveToOtherScreenAction() {
Expand Down
13 changes: 0 additions & 13 deletions Blink/TermInput.m
Original file line number Diff line number Diff line change
Expand Up @@ -411,19 +411,6 @@ - (BOOL)becomeFirstResponder
return res;
}

- (BOOL)canResignFirstResponder {
return UIApplication.sharedApplication.applicationState == UIApplicationStateActive;
}

- (BOOL)resignFirstResponder
{
if (UIApplication.sharedApplication.applicationState == UIApplicationStateInactive) {
return NO;
}
[_device blur];
return [super resignFirstResponder];
}

- (void)reset
{
_skipTextStorageDelete = YES;
Expand Down

0 comments on commit 8b21362

Please sign in to comment.