Skip to content

Commit

Permalink
Catalyst
Browse files Browse the repository at this point in the history
  • Loading branch information
yury committed Feb 4, 2021
1 parent 8f6be64 commit 068a3a0
Show file tree
Hide file tree
Showing 17 changed files with 428 additions and 218 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "Frameworks/UICKeyChainStore"]
path = Frameworks/UICKeyChainStore
url = https://github.com/kishikawakatsumi/UICKeyChainStore.git
[submodule "Frameworks/ios_system"]
path = Frameworks/ios_system
url = https://github.com/holzschu/ios_system.git
Expand Down
41 changes: 41 additions & 0 deletions AppKitBridge/AppBridge.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//////////////////////////////////////////////////////////////////////////////////
//
// B L I N K
//
// Copyright (C) 2016-2019 Blink Mobile Shell Project
//
// This file is part of Blink.
//
// Blink is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Blink is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Blink. If not, see <http://www.gnu.org/licenses/>.
//
// In addition, Blink is also subject to certain additional terms under
// GNU GPL version 3 section 7.
//
// You should have received a copy of these additional terms immediately
// following the terms and conditions of the GNU General Public License
// which accompanied the Blink Source Code. If not, see
// <http://www.github.com/blinksh/blink>.
//
////////////////////////////////////////////////////////////////////////////////


#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface AppBridge : NSObject
+ (void)tuneStyle;
@end

NS_ASSUME_NONNULL_END
48 changes: 48 additions & 0 deletions AppKitBridge/AppBridge.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//////////////////////////////////////////////////////////////////////////////////
//
// B L I N K
//
// Copyright (C) 2016-2019 Blink Mobile Shell Project
//
// This file is part of Blink.
//
// Blink is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Blink is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Blink. If not, see <http://www.gnu.org/licenses/>.
//
// In addition, Blink is also subject to certain additional terms under
// GNU GPL version 3 section 7.
//
// You should have received a copy of these additional terms immediately
// following the terms and conditions of the GNU General Public License
// which accompanied the Blink Source Code. If not, see
// <http://www.github.com/blinksh/blink>.
//
////////////////////////////////////////////////////////////////////////////////


#import "AppBridge.h"
#import <AppKit/AppKit.h>

@implementation AppBridge

+ (void)tuneStyle {
NSApplication *app = [NSApplication sharedApplication];
// NSWindow * win = app.mainWindow;
for (NSWindow *win in app.windows) {
[[win standardWindowButton:NSWindowCloseButton] setHidden:YES];
[[win standardWindowButton:NSWindowMiniaturizeButton] setHidden:YES];
[[win standardWindowButton:NSWindowZoomButton] setHidden:YES];
}
}

@end
26 changes: 26 additions & 0 deletions AppKitBridge/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2021 Carlos Cabañero Projects SL. All rights reserved.</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
359 changes: 194 additions & 165 deletions Blink.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions Blink/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
// [nc addObserver:self selector:@selector(_active) name:@"UIApplicationSystemNavigationActionChangedNotification" object:nil];

[UIApplication sharedApplication].applicationSupportsShakeToEdit = NO;

//#ifdef TARGET_OS_MACCATALYST
// NSURL * bundleURL = [[[NSBundle mainBundle] builtInPlugInsURL] URLByAppendingPathComponent:@"AppKitBridge.bundle"];
// [[NSBundle bundleWithURL:bundleURL] load];
// NSObject *clas = (NSObject *)NSClassFromString(@"AppBridge");
//
// [clas performSelector:@selector(tuneStyle)];
//#endif

return YES;
}

Expand Down
8 changes: 8 additions & 0 deletions Blink/Blink.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@
</array>
<key>com.apple.developer.ubiquity-kvstore-identifier</key>
<string>$(TeamIdentifierPrefix)$(CFBundleIdentifier)</string>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.device.bluetooth</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.personal-information.location</key>
<true/>
<key>keychain-access-groups</key>
<array>
<string>$(AppIdentifierPrefix)Com.CarlosCabanero.Blink</string>
Expand Down
24 changes: 12 additions & 12 deletions Blink/Foundation/NSCoder+CodingKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
////////////////////////////////////////////////////////////////////////////////


import Foundation
//import Foundation
import UIKit

extension NSCoder {
extension UIKit.NSCoder {

func encode(_ value: Any?, for key: CodingKey) {
encode(value, forKey: key.stringValue)
Expand Down Expand Up @@ -99,29 +99,29 @@ extension NSCoder {

// MARK: - CGRect

func encode(_ value: CGRect, for key: CodingKey) {
encode(value, forKey: key.stringValue)
}
// func encode(_ value: CGRect, for key: CodingKey) {
// encode(value, forKey: key.stringValue)
// }

func decode(for key: CodingKey) -> CGRect {
decodeCGRect(forKey: key.stringValue)
}

// MARK: - CGSize

func encode(_ value: CGSize, for key: CodingKey) {
encode(value, forKey: key.stringValue)
}
// func encode(_ value: CGSize, for key: CodingKey) {
// encode(value, forKey: key.stringValue)
// }
//
func decode(for key: CodingKey) -> CGSize {
decodeCGSize(forKey: key.stringValue)
}

// MARK: - CGPoint

func encode(_ value: CGPoint, for key: CodingKey) {
encode(value, forKey: key.stringValue)
}
// func encode(_ value: CGPoint, for key: CodingKey) {
// encode(value, forKey: key.stringValue)
// }

func decode(for key: CodingKey) -> CGPoint {
decodeCGPoint(forKey: key.stringValue)
Expand Down
13 changes: 12 additions & 1 deletion Blink/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import Foundation
import SwiftUI



class ExternalWindow: UIWindow {
var shadowWindow: UIWindow? = nil
}
Expand Down Expand Up @@ -89,6 +91,8 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
// We need to move it
ShadowWindow.shared?.windowScene = UIApplication.shared.connectedScenes.activeAppScene(exclude: scene)
}

//
}

/**
Expand All @@ -114,6 +118,13 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
return
}

#if targetEnvironment(macCatalyst)
if let titlebar = windowScene.titlebar {
titlebar.titleVisibility = .hidden
titlebar.autoHidesToolbarInFullScreen = true
}
#endif

let conditions = scene.activationConditions

conditions.canActivateForTargetContentIdentifierPredicate = NSPredicate(value: true)
Expand Down Expand Up @@ -153,7 +164,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
self.window = window

window.rootViewController = _spCtrl
window.isHidden = false
window.isHidden = false
}

func sceneDidBecomeActive(_ scene: UIScene) {
Expand Down
25 changes: 25 additions & 0 deletions Blink/SpaceController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,31 @@ class SpaceController: UIViewController {
_commandsHUD.setNeedsLayout()
}

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)

#if targetEnvironment(macCatalyst)
guard let appBundleUrl = Bundle.main.builtInPlugInsURL else {
return
}

let helperBundleUrl = appBundleUrl.appendingPathComponent("AppKitBridge.bundle")

guard let bundle = Bundle(url: helperBundleUrl) else {
return
}

bundle.load()

guard let object = NSClassFromString("AppBridge") as? NSObjectProtocol else {
return
}

let selector = NSSelectorFromString("tuneStyle")
object.perform(selector)
#endif
}

@objc func _relayout() {
guard
let window = view.window,
Expand Down
17 changes: 17 additions & 0 deletions Blink/TermView.m
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,24 @@ - (void)_handleSelectionChange:(NSDictionary *)data

_selectionRect = CGRectFromString(data[@"rect"]);
[menu setMenuItems:items];
#ifndef TARGET_OS_MACCATALYST
[menu showMenuFromView:self rect:_selectionRect];
#else

// NSURL * bundleURL = [[[NSBundle mainBundle] builtInPlugInsURL] URLByAppendingPathComponent:@"AppKitBridge.bundle"];
// [[NSBundle bundleWithURL:bundleURL] load];
// NSObject *clas = (NSObject *)NSClassFromString(@"AppBridge");
//
// [clas performSelector:@selector(tuneStyle)];
// NSObject *app = [clas performSelector:@selector(sharedApplication)];
// [app performSelector:@selector(setPresentationOptions:) withObject:@((1 << 2) | (1 << 0)) ];
// NSObject *mainWin = [app performSelector:@selector(mainWindow)];

// [[mainWin performSelector:@selector(standardWindowButton:) withObject:nil] performSelector:@selector(setHidden:) withObject:@(YES)];
// [[self.window standardWindowButton:0] setHidden:YES];
// [[self.window standardWindowButton:1] setHidden:YES];
// [[self.window standardWindowButton:2] setHidden:YES];
#endif
}

- (void)modifySideOfSelection
Expand Down
1 change: 0 additions & 1 deletion Frameworks/UICKeyChainStore
Submodule UICKeyChainStore deleted from 37bcab
2 changes: 1 addition & 1 deletion Settings/Model/BKHosts.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

#import "BKHosts.h"
#import "BKiCloudSyncHandler.h"
#import "UICKeyChainStore/UICKeyChainStore.h"
#import "UICKeyChainStore.h"
#import "BlinkPaths.h"

NSMutableArray *Hosts;
Expand Down
2 changes: 1 addition & 1 deletion Settings/Model/BKPubKey.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@


#import "BKPubKey.h"
#import "UICKeyChainStore/UICKeyChainStore.h"
#import "UICKeyChainStore.h"

#import "BlinkPaths.h"
#import <openssl/rsa.h>
Expand Down
4 changes: 2 additions & 2 deletions xcfs/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"repositoryURL": "https://github.com/yury/FMake",
"state": {
"branch": null,
"revision": "1a19d51fc4f74f4c33e4540e395f98faee6e7c4d",
"version": "0.0.15"
"revision": "db46d80e35764c2367fb23ea01e1876d2c2fa9a6",
"version": "0.0.16"
}
},
{
Expand Down
Loading

0 comments on commit 068a3a0

Please sign in to comment.