Skip to content
Permalink
Browse files
Added AppKit framework & initial window hiding test
  • Loading branch information
steventroughtonsmith committed Jan 30, 2021
1 parent d2335cf commit 38599c5ca14963098eb648d2c0bc2729b3d31587
Show file tree
Hide file tree
Showing 9 changed files with 342 additions and 15 deletions.
@@ -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
}
}
}
@@ -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>


@@ -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>

0 comments on commit 38599c5

Please sign in to comment.