Improve clipboard handling and reorder paste operations
This commit is contained in:
parent
67d55876c2
commit
413d11b00b
@ -35,13 +35,17 @@ class CursorPaster {
|
||||
vUp?.post(tap: .cghidEventTap)
|
||||
cmdUp?.post(tap: .cghidEventTap)
|
||||
|
||||
// Restore the original pasteboard contents after a delay
|
||||
// Use a background queue to not block the main thread
|
||||
DispatchQueue.global(qos: .userInitiated).asyncAfter(deadline: .now() + pasteCompletionDelay) {
|
||||
if let oldContents = oldContents {
|
||||
pasteboard.clearContents()
|
||||
pasteboard.setString(oldContents, forType: .string)
|
||||
// First clear the clipboard of our pasted content
|
||||
DispatchQueue.global(qos: .userInitiated).asyncAfter(deadline: .now() + 0.1) {
|
||||
pasteboard.clearContents()
|
||||
|
||||
// Then restore the original content after a short delay
|
||||
DispatchQueue.global(qos: .userInitiated).asyncAfter(deadline: .now() + 0.2) {
|
||||
if let oldContents = oldContents {
|
||||
pasteboard.clearContents()
|
||||
pasteboard.setString(oldContents, forType: .string)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -26,7 +26,7 @@ class MediaController: ObservableObject {
|
||||
// Additional function pointers for direct control
|
||||
private var mrSendCommand: (@convention(c) (Int, [String: Any]?) -> Bool)?
|
||||
|
||||
// MediaRemote command constants
|
||||
// MediaRemote command constantst
|
||||
private let kMRPlay = 0
|
||||
private let kMRPause = 1
|
||||
private let kMRTogglePlayPause = 2
|
||||
|
||||
@ -552,6 +552,17 @@ class WhisperState: NSObject, ObservableObject, AVAudioRecorderDelegate {
|
||||
// Play stop sound when transcription is complete
|
||||
SoundManager.shared.playStopSound()
|
||||
|
||||
// First try to paste if accessibility permissions are granted
|
||||
if AXIsProcessTrusted() {
|
||||
// For notch recorder, paste right after animation starts (animation takes 0.3s)
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
CursorPaster.pasteAtCursor(text)
|
||||
}
|
||||
} else {
|
||||
messageLog += "Accessibility permissions not granted. Transcription not pasted automatically.\n"
|
||||
}
|
||||
|
||||
// Then copy to clipboard if enabled (as a backup)
|
||||
if isAutoCopyEnabled {
|
||||
let success = ClipboardManager.copyToClipboard(text)
|
||||
if success {
|
||||
@ -562,15 +573,6 @@ class WhisperState: NSObject, ObservableObject, AVAudioRecorderDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
if AXIsProcessTrusted() {
|
||||
// For notch recorder, paste right after animation starts (animation takes 0.3s)
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
CursorPaster.pasteAtCursor(text)
|
||||
}
|
||||
} else {
|
||||
messageLog += "Accessibility permissions not granted. Transcription not pasted automatically.\n"
|
||||
}
|
||||
|
||||
await cleanupResources()
|
||||
|
||||
// Don't set processing states to false here
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user