Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Added AppKit framework & initial window hiding test
- Loading branch information
1 parent
d2335cf
commit 38599c5ca14963098eb648d2c0bc2729b3d31587
Showing
9 changed files
with
342 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| // | ||
| // AppKitController.swift | ||
| // AppKitIntegration | ||
| // | ||
| // Created by Steven Troughton-Smith on 30/01/2021. | ||
| // | ||
| import AppKit | ||
|
|
||
| extension NSObject { | ||
| @objc func hostWindowForSceneIdentifier(_ identifier:String) -> NSWindow? { | ||
| return nil | ||
| } | ||
| } | ||
|
|
||
| class AppKitController : NSObject { | ||
| @objc public func _marzipan_setupWindow(_ note:Notification) { | ||
|
|
||
| NSLog("_marzipan_setupWindow: \(note.userInfo)") | ||
|
|
||
| guard let userInfo = note.userInfo, let sceneIdentifier = userInfo["SceneIdentifier"] as? String else { return } | ||
|
|
||
| hideWindowForSceneIdentifier(sceneIdentifier) | ||
| } | ||
|
|
||
| @objc public func hideWindowForSceneIdentifier(_ sceneIdentifier:String) { | ||
| guard let appDelegate = NSApp.delegate as? NSObject else { return } | ||
|
|
||
| if appDelegate.responds(to: #selector(hostWindowForSceneIdentifier(_:))) { | ||
| guard let hostWindow = appDelegate.hostWindowForSceneIdentifier(sceneIdentifier) else { return } | ||
|
|
||
| hostWindow.alphaValue = 0 | ||
| } | ||
| } | ||
|
|
||
| @objc public func showWindowForSceneIdentifier(_ sceneIdentifier:String) { | ||
| guard let appDelegate = NSApp.delegate as? NSObject else { return } | ||
|
|
||
| if appDelegate.responds(to: #selector(hostWindowForSceneIdentifier(_:))) { | ||
| guard let hostWindow = appDelegate.hostWindowForSceneIdentifier(sceneIdentifier) else { return } | ||
|
|
||
| hostWindow.alphaValue = 1 | ||
| } | ||
| } | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| // | ||
| // AppKitIntegration.h | ||
| // AppKitIntegration | ||
| // | ||
| // Created by Steven Troughton-Smith on 30/01/2021. | ||
| // | ||
|
|
||
| #import <Foundation/Foundation.h> | ||
|
|
||
| //! Project version number for AppKitIntegration. | ||
| FOUNDATION_EXPORT double AppKitIntegrationVersionNumber; | ||
|
|
||
| //! Project version string for AppKitIntegration. | ||
| FOUNDATION_EXPORT const unsigned char AppKitIntegrationVersionString[]; | ||
|
|
||
| // In this header, you should import all the public headers of your framework using statements like #import <AppKitIntegration/PublicHeader.h> | ||
|
|
||
|
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| <?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>$(CURRENT_PROJECT_VERSION)</string> | ||
| </dict> | ||
| </plist> |
Oops, something went wrong.