Skip to content

Commit d892039

Browse files
committed
SecureInputPanel: Avoid calling view adding logic on refresh if already visible. Remove the panel when AeroSpace is disabled. Fix caption to mention AeroSpace, so the user knows where the message comes from. Also use default system font.
1 parent 480eed8 commit d892039

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

Sources/AppBundle/ui/SecureInputView.swift

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Carbon
33
import SwiftUI
44

55
private let iconSize = CGSize(width: 50, height: 50)
6-
private let textSize = CGSize(width: 440, height: 100)
6+
private let textSize = CGSize(width: 440, height: 110)
77

88
public class SecureInputPanel: NSPanelHud {
99
@MainActor public static var shared: SecureInputPanel = SecureInputPanel()
@@ -13,9 +13,13 @@ public class SecureInputPanel: NSPanelHud {
1313
super.init()
1414
}
1515

16+
@MainActor
1617
public func refresh() {
17-
self.contentView?.subviews.removeAll()
18-
if IsSecureEventInputEnabled() {
18+
if isVisible && !TrayMenuModel.shared.isEnabled {
19+
close()
20+
} else if IsSecureEventInputEnabled() {
21+
if isVisible { return }
22+
self.contentView?.subviews.removeAll()
1923
hostingView = NSHostingView(rootView: SecureInputView())
2024
hostingView.frame = NSRect(x: 0, y: 0, width: iconSize.width, height: iconSize.height)
2125
self.contentView?.addSubview(hostingView)
@@ -24,7 +28,7 @@ public class SecureInputPanel: NSPanelHud {
2428
self.setFrame(panelFrame, display: true)
2529
self.orderFrontRegardless()
2630
} else {
27-
close()
31+
if isVisible { close() }
2832
}
2933
}
3034

@@ -56,8 +60,8 @@ struct SecureInputView: View {
5660
.aspectRatio(contentMode: .fit)
5761
.padding(6)
5862
} else {
59-
Text("**Secure Input** is active. **Secure Input** is a macOS security feature that prevents applications from reading keyboard events.")
60-
.font(.system(.title3, design: .monospaced))
63+
Text("AeroSpace cannot respond to keyboard shortcuts while **Secure Input** is active. **Secure Input** is a macOS security feature that prevents applications from reading keyboard events.")
64+
.font(.title3)
6165
.padding(10)
6266
}
6367
}

0 commit comments

Comments
 (0)