]> git.r.bdr.sh - rbdr/captura/blobdiff - Captura/CapturaApp.swift
Add multimonitor support
[rbdr/captura] / Captura / CapturaApp.swift
index 2136d72f9be0ed6d699d6b9629cf3f6814e57697..00c5cc422f0e3728f24951a411c24c67ca1b9be5 100644 (file)
@@ -1,5 +1,4 @@
 import SwiftUI
 import SwiftUI
-import SwiftData
 import Cocoa
 import Combine
 import AVFoundation
 import Cocoa
 import Combine
 import AVFoundation
@@ -133,9 +132,14 @@ struct CapturaApp: App {
   
   func menuWillOpen(_ menu: NSMenu) {
     if captureState != .idle {
   
   func menuWillOpen(_ menu: NSMenu) {
     if captureState != .idle {
-      menu.cancelTracking()
+      menu.cancelTrackingWithoutAnimation()
+      if captureState == .selectingArea {
+        NotificationCenter.default.post(name: .startRecording, object: nil, userInfo: nil)
+        return
+      }
       if captureState == .recording {
         NotificationCenter.default.post(name: .stopRecording, object: nil, userInfo: nil)
       if captureState == .recording {
         NotificationCenter.default.post(name: .stopRecording, object: nil, userInfo: nil)
+        return
       }
     }
   }
       }
     }
   }
@@ -327,7 +331,10 @@ struct CapturaApp: App {
     if now - gifCallbackTimer > .nanoseconds(1_000_000_000 / UInt64(captureSessionConfiguration.frameRate)) {
       gifCallbackTimer = now
       DispatchQueue.main.async {
     if now - gifCallbackTimer > .nanoseconds(1_000_000_000 / UInt64(captureSessionConfiguration.frameRate)) {
       gifCallbackTimer = now
       DispatchQueue.main.async {
-        if let cgImage = frame.cgImage?.resize(by: self.pixelDensity) {
+        if var cgImage = frame.cgImage {
+          if self.pixelDensity > 1 {
+            cgImage = cgImage.resize(by: self.pixelDensity) ?? cgImage
+          }
           self.images.append(cgImage)
         }
       }
           self.images.append(cgImage)
         }
       }