diff --git a/MochaUI/NSAppearance+Extensions.swift b/MochaUI/NSAppearance+Extensions.swift index 45d4cb0..78235d7 100644 --- a/MochaUI/NSAppearance+Extensions.swift +++ b/MochaUI/NSAppearance+Extensions.swift @@ -30,3 +30,19 @@ public class NSAntiVisualEffectView: NSVisualEffectView { // } } + +public extension CALayer { + + /// Creates a `CALayer` that mirrors the given window ID (can either be within the same + /// app, or from another app entirely) into its contents. Note: this will only work if + /// the containing window hosts its layers in windowserver (`layerUsesCoreImageFilters=NO`). + public class func mirroring(windowID: CGWindowID, includesShadow: Bool = true, contentsGravity: String = kCAGravityResizeAspect) -> CALayer { + let clz = NSClassFromString("CAPluginLayer") as! CALayer.Type + let layer = clz.init() + layer.setValue("com.apple.WindowServer.CGSWindow", forKey: "pluginType") + layer.setValue(windowID, forKey: "pluginId") + layer.setValue(contentsGravity, forKey: "pluginGravity") + layer.setValue(includesShadow ? 0x0 : 0x4, forKey: "pluginFlags") + return layer + } +} diff --git a/MochaUI/NSWindow+Transforms.swift b/MochaUI/NSWindow+Transforms.swift index 8c23b2a..9cb11cf 100644 --- a/MochaUI/NSWindow+Transforms.swift +++ b/MochaUI/NSWindow+Transforms.swift @@ -1,12 +1,10 @@ import AppKit import Mocha -/* TODO: Works in another sample project, but fails within Parrot? */ - /* DispatchQueue.main.async { var perspective = CATransform3DIdentity - perspective.m34 = 1 / 70 + perspective.m34 = 1 / 500 perspective = CATransform3DRotate(perspective, .pi * 0.4, 1, 0, 0) window.transform = perspective } @@ -15,7 +13,7 @@ public extension NSWindow { public var transform: CATransform3D { get { return CATransform3DIdentity } set { - let t = CATransform3DConcat(newValue, CATransform3DMakeScale(1, -1, 1)) + let t = newValue//CATransform3DConcat(newValue, CATransform3DMakeScale(1, -1, 1)) let f = self.frame let p = CGPoint(x: self.frame.minX, y: self.screen!.frame.height - self.frame.maxY) let w = Float(f.width), h = Float(f.height) @@ -30,6 +28,7 @@ public extension NSWindow { global: CAMesh(CGSMeshPoint(x: w, y: h), f, p, t)) let warps = [bl, br, tl, tr] + print("\n\nSETTING WARPS \(warps)\n\n") let ptr: UnsafeMutablePointer = UnsafeMutablePointer(mutating: warps) _ = ptr.withMemoryRebound(to: CGSWarpPoint.self, capacity: 4) { CGSSetWindowWarp(NSApp.value(forKey: "contextID") as! Int32, diff --git a/Parrot/MessageCell.swift b/Parrot/MessageCell.swift index 76e08c0..74a2906 100755 --- a/Parrot/MessageCell.swift +++ b/Parrot/MessageCell.swift @@ -21,8 +21,8 @@ public class MessageCell: NSCollectionViewItem, NSTextViewDelegate { v.isEditable = false v.isSelectable = true v.drawsBackground = false - v.backgroundColor = NSColor.clear - v.textColor = NSColor.labelColor + v.backgroundColor = .clear + v.textColor = .labelColor v.textContainerInset = NSSize(width: 4, height: 4) //v.setContentCompressionResistancePriority(1000, for: .vertical) @@ -88,14 +88,15 @@ public class MessageCell: NSCollectionViewItem, NSTextViewDelegate { //self.textLabel.alignment = (o.sender.me ?? false) ? .right : .left // Enable automatic links and data detectors. + self.updateTextStyles() self.textLabel.isEditable = true self.textLabel.checkTextInDocument(nil) self.textLabel.isEditable = false let text = self.textLabel let appearance: NSAppearance = self.view.appearance ?? NSAppearance.current - text.textColor = NSColor.labelColor - //self.setColors() + text.textColor = .labelColor + self.setColors() // NSTextView doesn't automatically change its text color when the // backing view's appearance changes, so we need to set it each time. @@ -123,7 +124,6 @@ public class MessageCell: NSCollectionViewItem, NSTextViewDelegate { NSAttributedStringKey.foregroundColor: NSColor.labelColor, NSAttributedStringKey.underlineStyle: 0, ] - self.updateTextStyles() } } @@ -179,7 +179,7 @@ public class MessageCell: NSCollectionViewItem, NSTextViewDelegate { } public override func viewWillAppear() { - self.setColors() + //self.setColors() } /// Allows the circle crop and masking to dynamically change. diff --git a/Parrot/MessageInputViewController.swift b/Parrot/MessageInputViewController.swift index c2d3bb8..4a2696a 100644 --- a/Parrot/MessageInputViewController.swift +++ b/Parrot/MessageInputViewController.swift @@ -231,7 +231,6 @@ public class MessageInputViewController: NSViewController, NSTextViewExtendedDel } else { text.appearance = self.view.effectiveAppearance//self.appearance } - text.appearance = self.view.effectiveAppearance text.layer?.backgroundColor = color.cgColor }