Fastest and only macOS Dictation app with on-device STT and custom trained AI enhancement model. Windows, iOS testflight! Android, Linux waitlist open! A local Wispr Flow alternative. Follow https://x.com/fluidvoiceapp for more
Simplify mouse shortcut matching
George Pickett49e89f62f126
diff --git a/Sources/Fluid/Models/HotkeyShortcut.swift b/Sources/Fluid/Models/HotkeyShortcut.swiftindex 9ba689cb..41bdab2d 100644--- a/Sources/Fluid/Models/HotkeyShortcut.swift+++ b/Sources/Fluid/Models/HotkeyShortcut.swift@@ -212,7 +212,7 @@ extension HotkeyShortcut {}var isMouseShortcut: Bool {- self.kind == .mouse && self.mouseButton != nil+ self.kind == .mouse}var isUnmodifiedLeftOrRightClick: Bool {@@ -272,19 +272,21 @@ extension HotkeyShortcut {}static func == (lhs: HotkeyShortcut, rhs: HotkeyShortcut) -> Bool {- if lhs.isMouseShortcut || rhs.isMouseShortcut {- return lhs.kind == rhs.kind &&- lhs.mouseButton == rhs.mouseButton &&+ guard lhs.kind == rhs.kind else { return false }++ switch lhs.kind {+ case .mouse:+ return lhs.mouseButton == rhs.mouseButton &&lhs.relevantModifierFlags == rhs.relevantModifierFlags- }+ case .keyboard:+ let lhsModifierKeyCodes = lhs.normalizedModifierKeyCodes+ let rhsModifierKeyCodes = rhs.normalizedModifierKeyCodes+ if !lhsModifierKeyCodes.isEmpty, !rhsModifierKeyCodes.isEmpty {+ return lhsModifierKeyCodes == rhsModifierKeyCodes+ }- let lhsModifierKeyCodes = lhs.normalizedModifierKeyCodes- let rhsModifierKeyCodes = rhs.normalizedModifierKeyCodes- if !lhsModifierKeyCodes.isEmpty, !rhsModifierKeyCodes.isEmpty {- return lhsModifierKeyCodes == rhsModifierKeyCodes+ return lhs.keyCode == rhs.keyCode && lhs.relevantModifierFlags == rhs.relevantModifierFlags}-- return lhs.keyCode == rhs.keyCode && lhs.relevantModifierFlags == rhs.relevantModifierFlags}init(from decoder: Decoder) throws {diff --git a/Sources/Fluid/Services/GlobalHotkeyManager.swift b/Sources/Fluid/Services/GlobalHotkeyManager.swiftindex 8c12e648..0dd97d45 100644--- a/Sources/Fluid/Services/GlobalHotkeyManager.swift+++ b/Sources/Fluid/Services/GlobalHotkeyManager.swift@@ -623,7 +623,7 @@ final class GlobalHotkeyManager: NSObject {if self.handlePromptModeKeyDown(keyCode: keyCode, modifiers: eventModifiers) { return nil }// Check command mode hotkey first- if self.commandModeShortcutEnabled, self.matchesCommandModeShortcut(keyCode: keyCode, modifiers: eventModifiers) {+ if self.commandModeShortcutEnabled, self.commandModeShortcut.matches(keyCode: keyCode, modifiers: eventModifiers) {switch self.hotkeyMode {case .hold:// Press and hold: start on keyDown, stop on keyUp@@ -674,7 +674,7 @@ final class GlobalHotkeyManager: NSObject {// Check dedicated rewrite mode hotkeyif self.rewriteModeShortcutEnabled {- if self.matchesRewriteModeShortcut(keyCode: keyCode, modifiers: eventModifiers) {+ if self.rewriteModeShortcut.matches(keyCode: keyCode, modifiers: eventModifiers) {switch self.hotkeyMode {case .hold:// Press and hold: start on keyDown, stop on keyUp@@ -725,7 +725,7 @@ final class GlobalHotkeyManager: NSObject {}// Then check transcription hotkey- if self.matchesShortcut(keyCode: keyCode, modifiers: eventModifiers) {+ if self.shortcut.matches(keyCode: keyCode, modifiers: eventModifiers) {self.handlePrimaryDictationTriggerDown()return nil}@@ -1324,7 +1324,7 @@ final class GlobalHotkeyManager: NSObject {}private func handlePromptModeKeyDown(keyCode: UInt16, modifiers: NSEvent.ModifierFlags) -> Bool {- guard self.promptModeShortcutEnabled, self.matchesPromptModeShortcut(keyCode: keyCode, modifiers: modifiers) else { return false }+ guard self.promptModeShortcutEnabled, self.promptModeShortcut.matches(keyCode: keyCode, modifiers: modifiers) else { return false }switch self.hotkeyMode {case .hold:if !self.isPromptModeKeyPressed {@@ -1734,22 +1734,6 @@ final class GlobalHotkeyManager: NSObject {}}- private func matchesShortcut(keyCode: UInt16, modifiers: NSEvent.ModifierFlags) -> Bool {- self.shortcut.matches(keyCode: keyCode, modifiers: modifiers)- }-- private func matchesPromptModeShortcut(keyCode: UInt16, modifiers: NSEvent.ModifierFlags) -> Bool {- self.promptModeShortcut.matches(keyCode: keyCode, modifiers: modifiers)- }-- private func matchesCommandModeShortcut(keyCode: UInt16, modifiers: NSEvent.ModifierFlags) -> Bool {- self.commandModeShortcut.matches(keyCode: keyCode, modifiers: modifiers)- }-- private func matchesRewriteModeShortcut(keyCode: UInt16, modifiers: NSEvent.ModifierFlags) -> Bool {- self.rewriteModeShortcut.matches(keyCode: keyCode, modifiers: modifiers)- }-func isEventTapEnabled() -> Bool {guard let tap = eventTap else { return false }return CGEvent.tapIsEnabled(tap: tap)diff --git a/Sources/Fluid/UI/SettingsView.swift b/Sources/Fluid/UI/SettingsView.swiftindex bf33e76d..1b5de41d 100644--- a/Sources/Fluid/UI/SettingsView.swift+++ b/Sources/Fluid/UI/SettingsView.swift@@ -657,7 +657,7 @@ struct SettingsView: View {.font(.subheadline.weight(.medium)).foregroundStyle(.secondary)- Text("Primary dictation can use keys or an allowed mouse button. Changes usually apply immediately.")+ Text("Primary dictation can use a keyboard shortcut or allowed mouse button. Changes usually apply immediately.").font(.caption).foregroundStyle(.tertiary)@@ -666,7 +666,7 @@ struct SettingsView: View {icon: "mic.fill",iconColor: .secondary,title: "Primary Dictation Shortcut",- description: "Use a keyboard shortcut, side mouse button, or modified mouse click."+ description: "Use a keyboard shortcut, auxiliary mouse button, or modified click."),shortcut: self.hotkeyShortcut,isRecording: self.isRecording(.primaryDictation),