diff --git a/PinStickApp.swift b/PinStickApp.swift index 4d23686..18700b4 100644 --- a/PinStickApp.swift +++ b/PinStickApp.swift @@ -25,6 +25,16 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { } } + func windowWillMiniaturize(_ notification: Notification) { + guard + let miniaturizingWindow = notification.object as? NSWindow, + let image = miniaturizingWindow.contentView?.snapshotImage() + else { + return + } + miniaturizingWindow.miniwindowImage = image + } + func windowShouldClose(_ sender: NSWindow) -> Bool { if sender.isDocumentEdited { let alert = NSAlert() @@ -50,6 +60,21 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { } } +private extension NSView { + func snapshotImage() -> NSImage? { + guard bounds.width > 0, bounds.height > 0 else { + return nil + } + guard let bitmap = bitmapImageRepForCachingDisplay(in: bounds) else { + return nil + } + cacheDisplay(in: bounds, to: bitmap) + let image = NSImage(size: bounds.size) + image.addRepresentation(bitmap) + return image + } +} + struct ContentViewWrapper: NSViewControllerRepresentable { func makeNSViewController(context: Context) -> NSHostingController { let view = ContentView() diff --git a/cross-platform/package-lock.json b/cross-platform/package-lock.json index 6e009a6..468e984 100644 --- a/cross-platform/package-lock.json +++ b/cross-platform/package-lock.json @@ -1,12 +1,12 @@ { "name": "pinstick-cross", - "version": "2.8.1", + "version": "2.8.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "pinstick-cross", - "version": "2.8.1", + "version": "2.8.2", "devDependencies": { "@tauri-apps/cli": "1.5.10" } diff --git a/cross-platform/package.json b/cross-platform/package.json index 0cd65f8..45ab74a 100644 --- a/cross-platform/package.json +++ b/cross-platform/package.json @@ -1,6 +1,6 @@ { "name": "pinstick-cross", - "version": "2.8.1", + "version": "2.8.2", "private": true, "type": "module", "scripts": { diff --git a/cross-platform/src-tauri/Cargo.toml b/cross-platform/src-tauri/Cargo.toml index 4575f35..08afcb6 100644 --- a/cross-platform/src-tauri/Cargo.toml +++ b/cross-platform/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pinstick" -version = "2.8.1" +version = "2.8.2" description = "PinStick cross-platform note pinning app" authors = ["SillyLittleTech"] edition = "2021" diff --git a/cross-platform/src-tauri/tauri.conf.json b/cross-platform/src-tauri/tauri.conf.json index 7e03c10..4504691 100644 --- a/cross-platform/src-tauri/tauri.conf.json +++ b/cross-platform/src-tauri/tauri.conf.json @@ -8,7 +8,7 @@ }, "package": { "productName": "PinStick", - "version": "2.8.1" + "version": "2.8.2" }, "tauri": { "macOSPrivateApi": true,